@aeternity/aepp-sdk 13.0.0 → 13.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/README.md +4 -2
  2. package/bin/aesophia_cli +0 -0
  3. package/dist/aepp-sdk.browser-script.js +1 -1
  4. package/dist/aepp-sdk.browser-script.js.map +1 -1
  5. package/dist/aepp-sdk.browser.js +1 -1
  6. package/dist/aepp-sdk.browser.js.map +1 -1
  7. package/dist/aepp-sdk.js +27068 -16862
  8. package/dist/aepp-sdk.js.map +1 -1
  9. package/es/AeSdkBase.d.ts +11 -3
  10. package/es/AeSdkBase.mjs +24 -3
  11. package/es/AeSdkBase.mjs.map +1 -1
  12. package/es/AeSdkMethods.d.ts +9 -14
  13. package/es/AeSdkMethods.mjs +20 -49
  14. package/es/AeSdkMethods.mjs.map +1 -1
  15. package/es/AeSdkWallet.mjs +28 -5
  16. package/es/AeSdkWallet.mjs.map +1 -1
  17. package/es/Middleware.d.ts +38 -0
  18. package/es/Middleware.mjs +90 -0
  19. package/es/Middleware.mjs.map +1 -0
  20. package/es/MiddlewareSubscriber.d.ts +30 -0
  21. package/es/MiddlewareSubscriber.mjs +198 -0
  22. package/es/MiddlewareSubscriber.mjs.map +1 -0
  23. package/es/Node.d.ts +1 -1
  24. package/es/Node.mjs.map +1 -1
  25. package/es/account/Base.d.ts +14 -2
  26. package/es/account/Base.mjs.map +1 -1
  27. package/es/account/Generalized.d.ts +1 -0
  28. package/es/account/Generalized.mjs +5 -0
  29. package/es/account/Generalized.mjs.map +1 -1
  30. package/es/account/Ledger.d.ts +1 -0
  31. package/es/account/Ledger.mjs +5 -0
  32. package/es/account/Ledger.mjs.map +1 -1
  33. package/es/account/Memory.d.ts +2 -0
  34. package/es/account/Memory.mjs +18 -0
  35. package/es/account/Memory.mjs.map +1 -1
  36. package/es/account/Rpc.d.ts +1 -6
  37. package/es/account/Rpc.mjs +24 -10
  38. package/es/account/Rpc.mjs.map +1 -1
  39. package/es/aens.d.ts +1 -1
  40. package/es/aens.mjs +1 -1
  41. package/es/aens.mjs.map +1 -1
  42. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -2
  43. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  44. package/es/aepp-wallet-communication/rpc/types.d.ts +10 -0
  45. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  46. package/es/aepp-wallet-communication/schema.d.ts +1 -8
  47. package/es/aepp-wallet-communication/schema.mjs +1 -14
  48. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  49. package/es/aepp-wallet-communication/wallet-detector.d.ts +1 -1
  50. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
  51. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  52. package/es/apis/compiler/compiler.mjs +15 -1
  53. package/es/apis/compiler/compiler.mjs.map +1 -1
  54. package/es/apis/compiler/models/index.d.ts +1 -7
  55. package/es/apis/compiler/models/index.mjs.map +1 -1
  56. package/es/apis/compiler/models/mappers.d.ts +0 -1
  57. package/es/apis/compiler/models/mappers.mjs +0 -43
  58. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  59. package/es/apis/middleware/index.d.ts +2 -0
  60. package/es/apis/middleware/index.mjs +3 -0
  61. package/es/apis/middleware/index.mjs.map +1 -0
  62. package/es/apis/middleware/middleware.d.ts +309 -0
  63. package/es/apis/middleware/middleware.mjs +1527 -0
  64. package/es/apis/middleware/middleware.mjs.map +1 -0
  65. package/es/apis/middleware/models/index.d.ts +1496 -0
  66. package/es/apis/middleware/models/index.mjs +364 -0
  67. package/es/apis/middleware/models/index.mjs.map +1 -0
  68. package/es/apis/middleware/models/mappers.d.ts +102 -0
  69. package/es/apis/middleware/models/mappers.mjs +3334 -0
  70. package/es/apis/middleware/models/mappers.mjs.map +1 -0
  71. package/es/apis/middleware/models/parameters.d.ts +43 -0
  72. package/es/apis/middleware/models/parameters.mjs +417 -0
  73. package/es/apis/middleware/models/parameters.mjs.map +1 -0
  74. package/es/chain.d.ts +2 -1
  75. package/es/chain.mjs +4 -2
  76. package/es/chain.mjs.map +1 -1
  77. package/es/channel/Base.d.ts +1 -1
  78. package/es/channel/Base.mjs +1 -4
  79. package/es/channel/Base.mjs.map +1 -1
  80. package/es/channel/internal.mjs +2 -0
  81. package/es/channel/internal.mjs.map +1 -1
  82. package/es/contract/Contract.d.ts +1 -2
  83. package/es/contract/Contract.mjs +1 -1
  84. package/es/contract/Contract.mjs.map +1 -1
  85. package/es/contract/compiler/Base.d.ts +21 -0
  86. package/es/contract/compiler/Base.mjs.map +1 -1
  87. package/es/contract/compiler/Cli.d.ts +2 -0
  88. package/es/contract/compiler/Cli.mjs +24 -3
  89. package/es/contract/compiler/Cli.mjs.map +1 -1
  90. package/es/contract/compiler/Http.d.ts +2 -0
  91. package/es/contract/compiler/Http.mjs +22 -2
  92. package/es/contract/compiler/Http.mjs.map +1 -1
  93. package/es/contract/compiler/HttpNode.d.ts +1 -0
  94. package/es/contract/compiler/HttpNode.mjs +5 -0
  95. package/es/contract/compiler/HttpNode.mjs.map +1 -1
  96. package/es/deprecated.d.ts +14 -0
  97. package/es/deprecated.mjs +22 -0
  98. package/es/deprecated.mjs.map +1 -0
  99. package/es/index-browser.d.ts +20 -14
  100. package/es/index-browser.mjs +19 -15
  101. package/es/index-browser.mjs.map +1 -1
  102. package/es/tx/builder/constants.d.ts +0 -1
  103. package/es/tx/builder/constants.mjs +0 -1
  104. package/es/tx/builder/constants.mjs.map +1 -1
  105. package/es/tx/builder/field-types/coin-amount.d.ts +1 -1
  106. package/es/tx/builder/field-types/coin-amount.mjs +2 -1
  107. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  108. package/es/tx/builder/field-types/deposit.d.ts +1 -1
  109. package/es/tx/builder/field-types/entry.mjs +2 -1
  110. package/es/tx/builder/field-types/entry.mjs.map +1 -1
  111. package/es/tx/builder/field-types/index.d.ts +2 -2
  112. package/es/tx/builder/helpers.d.ts +8 -1
  113. package/es/tx/builder/helpers.mjs +53 -9
  114. package/es/tx/builder/helpers.mjs.map +1 -1
  115. package/es/tx/builder/index.d.ts +4 -2
  116. package/es/tx/builder/index.mjs +0 -1
  117. package/es/tx/builder/index.mjs.map +1 -1
  118. package/es/tx/builder/schema.d.ts +9 -9
  119. package/es/tx/execution-cost.d.ts +17 -0
  120. package/es/tx/execution-cost.mjs +17 -0
  121. package/es/tx/execution-cost.mjs.map +1 -1
  122. package/es/tx/validator.mjs +6 -3
  123. package/es/tx/validator.mjs.map +1 -1
  124. package/es/utils/amount-formatter.d.ts +1 -2
  125. package/es/utils/amount-formatter.mjs +2 -2
  126. package/es/utils/amount-formatter.mjs.map +1 -1
  127. package/es/utils/autorest.mjs +6 -8
  128. package/es/utils/autorest.mjs.map +1 -1
  129. package/es/utils/crypto.d.ts +1 -0
  130. package/es/utils/crypto.mjs +12 -2
  131. package/es/utils/crypto.mjs.map +1 -1
  132. package/es/utils/errors.d.ts +2 -2
  133. package/es/utils/errors.mjs.map +1 -1
  134. package/es/utils/other.d.ts +1 -0
  135. package/es/utils/other.mjs +5 -0
  136. package/es/utils/other.mjs.map +1 -1
  137. package/es/utils/typed-data.d.ts +45 -0
  138. package/es/utils/typed-data.mjs +71 -0
  139. package/es/utils/typed-data.mjs.map +1 -0
  140. package/package.json +23 -4
  141. package/src/AeSdkBase.ts +30 -5
  142. package/src/AeSdkMethods.ts +31 -50
  143. package/src/AeSdkWallet.ts +27 -5
  144. package/src/Middleware.ts +141 -0
  145. package/src/MiddlewareSubscriber.ts +207 -0
  146. package/src/Node.ts +1 -1
  147. package/src/account/Base.ts +20 -3
  148. package/src/account/Generalized.ts +5 -0
  149. package/src/account/Ledger.ts +5 -0
  150. package/src/account/Memory.ts +15 -0
  151. package/src/account/Rpc.ts +19 -7
  152. package/src/aens.ts +1 -1
  153. package/src/aepp-wallet-communication/rpc/RpcClient.ts +11 -3
  154. package/src/aepp-wallet-communication/rpc/types.ts +11 -0
  155. package/src/aepp-wallet-communication/schema.ts +2 -17
  156. package/src/aepp-wallet-communication/wallet-detector.ts +1 -2
  157. package/src/apis/compiler/compiler.ts +8 -1
  158. package/src/apis/compiler/models/index.ts +1 -8
  159. package/src/apis/compiler/models/mappers.ts +0 -36
  160. package/src/apis/middleware/index.ts +2 -0
  161. package/src/apis/middleware/middleware.ts +1807 -0
  162. package/src/apis/middleware/models/index.ts +1747 -0
  163. package/src/apis/middleware/models/mappers.ts +3370 -0
  164. package/src/apis/middleware/models/parameters.ts +463 -0
  165. package/src/chain.ts +3 -2
  166. package/src/channel/Base.ts +5 -5
  167. package/src/channel/internal.ts +2 -0
  168. package/src/contract/Contract.ts +2 -1
  169. package/src/contract/compiler/Base.ts +26 -0
  170. package/src/contract/compiler/Cli.ts +27 -3
  171. package/src/contract/compiler/Http.ts +21 -2
  172. package/src/contract/compiler/HttpNode.ts +6 -0
  173. package/src/deprecated.ts +23 -0
  174. package/src/index-browser.ts +77 -15
  175. package/src/tx/builder/constants.ts +0 -1
  176. package/src/tx/builder/field-types/coin-amount.ts +2 -1
  177. package/src/tx/builder/field-types/entry.ts +1 -1
  178. package/src/tx/builder/helpers.ts +54 -9
  179. package/src/tx/builder/index.ts +6 -9
  180. package/src/tx/execution-cost.ts +17 -0
  181. package/src/tx/validator.ts +4 -2
  182. package/src/utils/amount-formatter.ts +1 -1
  183. package/src/utils/autorest.ts +5 -10
  184. package/src/utils/crypto.ts +12 -2
  185. package/src/utils/errors.ts +2 -2
  186. package/src/utils/other.ts +5 -0
  187. package/src/utils/typed-data.ts +95 -0
  188. package/types-legacy/ts4.2/AeSdkBase.d.ts +11 -3
  189. package/types-legacy/ts4.2/AeSdkMethods.d.ts +9 -14
  190. package/types-legacy/ts4.2/Middleware.d.ts +46 -0
  191. package/types-legacy/ts4.2/MiddlewareSubscriber.d.ts +30 -0
  192. package/types-legacy/ts4.2/Node.d.ts +1 -1
  193. package/types-legacy/ts4.2/account/Base.d.ts +14 -2
  194. package/types-legacy/ts4.2/account/Generalized.d.ts +1 -0
  195. package/types-legacy/ts4.2/account/Ledger.d.ts +1 -0
  196. package/types-legacy/ts4.2/account/Memory.d.ts +2 -0
  197. package/types-legacy/ts4.2/account/Rpc.d.ts +1 -6
  198. package/types-legacy/ts4.2/aens.d.ts +1 -1
  199. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +10 -0
  200. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +1 -8
  201. package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +1 -1
  202. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +1 -7
  203. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +0 -1
  204. package/types-legacy/ts4.2/apis/middleware/index.d.ts +2 -0
  205. package/types-legacy/ts4.2/apis/middleware/middleware.d.ts +309 -0
  206. package/types-legacy/ts4.2/apis/middleware/models/index.d.ts +1496 -0
  207. package/types-legacy/ts4.2/apis/middleware/models/mappers.d.ts +102 -0
  208. package/types-legacy/ts4.2/apis/middleware/models/parameters.d.ts +43 -0
  209. package/types-legacy/ts4.2/chain.d.ts +2 -1
  210. package/types-legacy/ts4.2/channel/Base.d.ts +1 -1
  211. package/types-legacy/ts4.2/contract/Contract.d.ts +1 -2
  212. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +21 -0
  213. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +2 -0
  214. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +2 -0
  215. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +1 -0
  216. package/types-legacy/ts4.2/deprecated.d.ts +14 -0
  217. package/types-legacy/ts4.2/index-browser.d.ts +20 -14
  218. package/types-legacy/ts4.2/tx/builder/constants.d.ts +0 -1
  219. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +1 -1
  220. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +1 -1
  221. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +2 -2
  222. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +8 -1
  223. package/types-legacy/ts4.2/tx/builder/index.d.ts +4 -2
  224. package/types-legacy/ts4.2/tx/builder/schema.d.ts +9 -9
  225. package/types-legacy/ts4.2/tx/execution-cost.d.ts +17 -0
  226. package/types-legacy/ts4.2/utils/amount-formatter.d.ts +1 -2
  227. package/types-legacy/ts4.2/utils/crypto.d.ts +1 -0
  228. package/types-legacy/ts4.2/utils/errors.d.ts +2 -2
  229. package/types-legacy/ts4.2/utils/other.d.ts +1 -0
  230. package/types-legacy/ts4.2/utils/typed-data.d.ts +60 -0
  231. package/types-legacy/ts4.5/AeSdkBase.d.ts +11 -3
  232. package/types-legacy/ts4.5/AeSdkMethods.d.ts +9 -14
  233. package/types-legacy/ts4.5/Middleware.d.ts +46 -0
  234. package/types-legacy/ts4.5/MiddlewareSubscriber.d.ts +30 -0
  235. package/types-legacy/ts4.5/Node.d.ts +1 -1
  236. package/types-legacy/ts4.5/account/Base.d.ts +14 -2
  237. package/types-legacy/ts4.5/account/Generalized.d.ts +1 -0
  238. package/types-legacy/ts4.5/account/Ledger.d.ts +1 -0
  239. package/types-legacy/ts4.5/account/Memory.d.ts +2 -0
  240. package/types-legacy/ts4.5/account/Rpc.d.ts +1 -6
  241. package/types-legacy/ts4.5/aens.d.ts +1 -1
  242. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +10 -0
  243. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +1 -8
  244. package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +1 -1
  245. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +1 -7
  246. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +0 -1
  247. package/types-legacy/ts4.5/apis/middleware/index.d.ts +2 -0
  248. package/types-legacy/ts4.5/apis/middleware/middleware.d.ts +309 -0
  249. package/types-legacy/ts4.5/apis/middleware/models/index.d.ts +1496 -0
  250. package/types-legacy/ts4.5/apis/middleware/models/mappers.d.ts +102 -0
  251. package/types-legacy/ts4.5/apis/middleware/models/parameters.d.ts +43 -0
  252. package/types-legacy/ts4.5/chain.d.ts +2 -1
  253. package/types-legacy/ts4.5/channel/Base.d.ts +1 -1
  254. package/types-legacy/ts4.5/contract/Contract.d.ts +1 -2
  255. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +21 -0
  256. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +2 -0
  257. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +2 -0
  258. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +1 -0
  259. package/types-legacy/ts4.5/deprecated.d.ts +14 -0
  260. package/types-legacy/ts4.5/index-browser.d.ts +20 -14
  261. package/types-legacy/ts4.5/tx/builder/constants.d.ts +0 -1
  262. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +1 -1
  263. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +1 -1
  264. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +2 -2
  265. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +8 -1
  266. package/types-legacy/ts4.5/tx/builder/index.d.ts +4 -2
  267. package/types-legacy/ts4.5/tx/builder/schema.d.ts +9 -9
  268. package/types-legacy/ts4.5/tx/execution-cost.d.ts +17 -0
  269. package/types-legacy/ts4.5/utils/amount-formatter.d.ts +1 -2
  270. package/types-legacy/ts4.5/utils/crypto.d.ts +1 -0
  271. package/types-legacy/ts4.5/utils/errors.d.ts +2 -2
  272. package/types-legacy/ts4.5/utils/other.d.ts +1 -0
  273. package/types-legacy/ts4.5/utils/typed-data.d.ts +60 -0
  274. package/es/typings/@aeternity__aepp-calldata/index.d.mjs +0 -2
  275. package/es/typings/@aeternity__aepp-calldata/index.d.mjs.map +0 -1
  276. package/src/typings/@aeternity__aepp-calldata/index.d.ts +0 -20
@@ -90,7 +90,7 @@ const getLowerBoundPrefix = exponent => {
90
90
  var _prefixes$find;
91
91
  return (_prefixes$find = prefixes.find(p => p.magnitude <= exponent)) !== null && _prefixes$find !== void 0 ? _prefixes$find : prefixes[prefixes.length - 1];
92
92
  };
93
- export default (rawValue => {
93
+ export const prefixedAmount = rawValue => {
94
94
  var _value$e;
95
95
  const value = new BigNumber(rawValue);
96
96
  const exp = (_value$e = value.e) !== null && _value$e !== void 0 ? _value$e : 0;
@@ -100,5 +100,5 @@ export default (rawValue => {
100
100
  } = (exp < 0 ? getNearestPrefix : getLowerBoundPrefix)(exp);
101
101
  const v = value.shiftedBy(-magnitude).precision(9 + Math.min(exp - magnitude, 0)).toFixed();
102
102
  return `${v}${name !== '' ? ' ' : ''}${name}`;
103
- });
103
+ };
104
104
  //# sourceMappingURL=amount-formatter.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"amount-formatter.mjs","names":["BigNumber","isBigNumber","ArgumentError","AE_AMOUNT_FORMATS","DENOMINATION_MAGNITUDE","AE","MILI_AE","MICRO_AE","NANO_AE","PICO_AE","FEMTO_AE","AETTOS","formatAmount","value","_ref","denomination","targetDenomination","toString","shiftedBy","toFixed","toAe","arguments","length","undefined","toAettos","prefixes","name","magnitude","getNearestPrefix","exponent","reduce","p","n","Math","abs","getLowerBoundPrefix","_prefixes$find","find","rawValue","_value$e","exp","e","v","precision","min"],"sources":["../../src/utils/amount-formatter.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { isBigNumber } from './bignumber';\nimport { ArgumentError } from './errors';\n\nexport enum AE_AMOUNT_FORMATS {\n AE = 'ae',\n MILI_AE = 'miliAE',\n MICRO_AE = 'microAE',\n NANO_AE = 'nanoAE',\n PICO_AE = 'picoAE',\n FEMTO_AE = 'femtoAE',\n AETTOS = 'aettos',\n}\n\n/**\n * DENOMINATION_MAGNITUDE\n */\nconst DENOMINATION_MAGNITUDE = {\n [AE_AMOUNT_FORMATS.AE]: 0,\n [AE_AMOUNT_FORMATS.MILI_AE]: -3,\n [AE_AMOUNT_FORMATS.MICRO_AE]: -6,\n [AE_AMOUNT_FORMATS.NANO_AE]: -9,\n [AE_AMOUNT_FORMATS.PICO_AE]: -12,\n [AE_AMOUNT_FORMATS.FEMTO_AE]: -15,\n [AE_AMOUNT_FORMATS.AETTOS]: -18,\n} as const;\n\n/**\n * Convert amount from one to other denomination\n * @param value - amount to convert\n * @param options - options\n * @param options.denomination - denomination of amount, can be ['ae', 'aettos']\n * @param options.targetDenomination - target denomination,\n * can be ['ae', 'aettos']\n */\nexport const formatAmount = (\n value: string | number | bigint | BigNumber,\n { denomination = AE_AMOUNT_FORMATS.AETTOS, targetDenomination = AE_AMOUNT_FORMATS.AETTOS }:\n { denomination?: AE_AMOUNT_FORMATS; targetDenomination?: AE_AMOUNT_FORMATS },\n): string => {\n if (!isBigNumber(value)) throw new ArgumentError('value', 'a number', value);\n\n return new BigNumber(typeof value === 'bigint' ? value.toString() : value)\n .shiftedBy(DENOMINATION_MAGNITUDE[denomination] - DENOMINATION_MAGNITUDE[targetDenomination])\n .toFixed();\n};\n\n/**\n * Convert amount to AE\n * @param value - amount to convert\n * @param options - options\n * @param options.denomination - denomination of amount, can be ['ae', 'aettos']\n */\nexport const toAe = (\n value: string | number | BigNumber,\n { denomination = AE_AMOUNT_FORMATS.AETTOS }: { denomination?: AE_AMOUNT_FORMATS } = {},\n): string => formatAmount(value, { denomination, targetDenomination: AE_AMOUNT_FORMATS.AE });\n\n/**\n * Convert amount to aettos\n * @param value - amount to convert\n * @param options - options\n * @param options.denomination - denomination of amount, can be ['ae', 'aettos']\n */\nexport const toAettos = (\n value: string | number | BigNumber,\n { denomination = AE_AMOUNT_FORMATS.AE }: { denomination?: AE_AMOUNT_FORMATS } = {},\n): string => formatAmount(value, { denomination });\n\ninterface Prefix {\n name: string;\n magnitude: number;\n}\n\nconst prefixes: Prefix[] = [\n { name: 'exa', magnitude: 18 },\n { name: 'giga', magnitude: 9 },\n { name: '', magnitude: 0 },\n { name: 'pico', magnitude: -12 },\n];\n\nconst getNearestPrefix = (exponent: number): Prefix => prefixes.reduce((p, n) => (\n Math.abs(n.magnitude - exponent) < Math.abs(p.magnitude - exponent) ? n : p));\n\nconst getLowerBoundPrefix = (exponent: number): Prefix => prefixes\n .find((p) => p.magnitude <= exponent) ?? prefixes[prefixes.length - 1];\n\nexport default (rawValue: string | number | BigNumber): string => {\n const value: BigNumber = new BigNumber(rawValue);\n\n const exp = value.e ?? 0;\n const { name, magnitude } = (exp < 0 ? getNearestPrefix : getLowerBoundPrefix)(exp);\n const v = value\n .shiftedBy(-magnitude)\n .precision(9 + Math.min(exp - magnitude, 0))\n .toFixed();\n return `${v}${name !== '' ? ' ' : ''}${name}`;\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,WAAW;AAAA,SACXC,aAAa;AAEtB,WAAYC,iBAAiB;;AAU7B;AACA;AACA;AAFA,WAVYA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;AAAA,GAAjBA,iBAAiB,KAAjBA,iBAAiB;AAa7B,MAAMC,sBAAsB,GAAG;EAC7B,CAACD,iBAAiB,CAACE,EAAE,GAAG,CAAC;EACzB,CAACF,iBAAiB,CAACG,OAAO,GAAG,CAAC,CAAC;EAC/B,CAACH,iBAAiB,CAACI,QAAQ,GAAG,CAAC,CAAC;EAChC,CAACJ,iBAAiB,CAACK,OAAO,GAAG,CAAC,CAAC;EAC/B,CAACL,iBAAiB,CAACM,OAAO,GAAG,CAAC,EAAE;EAChC,CAACN,iBAAiB,CAACO,QAAQ,GAAG,CAAC,EAAE;EACjC,CAACP,iBAAiB,CAACQ,MAAM,GAAG,CAAC;AAC/B,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGA,CAC1BC,KAA2C,EAAAC,IAAA,KAGhC;EAAA,IAFX;IAAEC,YAAY,GAAGZ,iBAAiB,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AAG,GAAG,EAAG,GAAEA,IAAK,EAAC;AAC/C,CAAC"}
1
+ {"version":3,"file":"amount-formatter.mjs","names":["BigNumber","isBigNumber","ArgumentError","AE_AMOUNT_FORMATS","DENOMINATION_MAGNITUDE","AE","MILI_AE","MICRO_AE","NANO_AE","PICO_AE","FEMTO_AE","AETTOS","formatAmount","value","_ref","denomination","targetDenomination","toString","shiftedBy","toFixed","toAe","arguments","length","undefined","toAettos","prefixes","name","magnitude","getNearestPrefix","exponent","reduce","p","n","Math","abs","getLowerBoundPrefix","_prefixes$find","find","prefixedAmount","rawValue","_value$e","exp","e","v","precision","min"],"sources":["../../src/utils/amount-formatter.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { isBigNumber } from './bignumber';\nimport { ArgumentError } from './errors';\n\nexport enum AE_AMOUNT_FORMATS {\n AE = 'ae',\n MILI_AE = 'miliAE',\n MICRO_AE = 'microAE',\n NANO_AE = 'nanoAE',\n PICO_AE = 'picoAE',\n FEMTO_AE = 'femtoAE',\n AETTOS = 'aettos',\n}\n\n/**\n * DENOMINATION_MAGNITUDE\n */\nconst DENOMINATION_MAGNITUDE = {\n [AE_AMOUNT_FORMATS.AE]: 0,\n [AE_AMOUNT_FORMATS.MILI_AE]: -3,\n [AE_AMOUNT_FORMATS.MICRO_AE]: -6,\n [AE_AMOUNT_FORMATS.NANO_AE]: -9,\n [AE_AMOUNT_FORMATS.PICO_AE]: -12,\n [AE_AMOUNT_FORMATS.FEMTO_AE]: -15,\n [AE_AMOUNT_FORMATS.AETTOS]: -18,\n} as const;\n\n/**\n * Convert amount from one to other denomination\n * @param value - amount to convert\n * @param options - options\n * @param options.denomination - denomination of amount, can be ['ae', 'aettos']\n * @param options.targetDenomination - target denomination,\n * can be ['ae', 'aettos']\n */\nexport const formatAmount = (\n value: string | number | bigint | BigNumber,\n { denomination = AE_AMOUNT_FORMATS.AETTOS, targetDenomination = AE_AMOUNT_FORMATS.AETTOS }:\n { denomination?: AE_AMOUNT_FORMATS; targetDenomination?: AE_AMOUNT_FORMATS },\n): string => {\n if (!isBigNumber(value)) throw new ArgumentError('value', 'a number', value);\n\n return new BigNumber(typeof value === 'bigint' ? value.toString() : value)\n .shiftedBy(DENOMINATION_MAGNITUDE[denomination] - DENOMINATION_MAGNITUDE[targetDenomination])\n .toFixed();\n};\n\n/**\n * Convert amount to AE\n * @param value - amount to convert\n * @param options - options\n * @param options.denomination - denomination of amount, can be ['ae', 'aettos']\n */\nexport const toAe = (\n value: string | number | BigNumber,\n { denomination = AE_AMOUNT_FORMATS.AETTOS }: { denomination?: AE_AMOUNT_FORMATS } = {},\n): string => formatAmount(value, { denomination, targetDenomination: AE_AMOUNT_FORMATS.AE });\n\n/**\n * Convert amount to aettos\n * @param value - amount to convert\n * @param options - options\n * @param options.denomination - denomination of amount, can be ['ae', 'aettos']\n */\nexport const toAettos = (\n value: string | number | BigNumber,\n { denomination = AE_AMOUNT_FORMATS.AE }: { denomination?: AE_AMOUNT_FORMATS } = {},\n): string => formatAmount(value, { denomination });\n\ninterface Prefix {\n name: string;\n magnitude: number;\n}\n\nconst prefixes: Prefix[] = [\n { name: 'exa', magnitude: 18 },\n { name: 'giga', magnitude: 9 },\n { name: '', magnitude: 0 },\n { name: 'pico', magnitude: -12 },\n];\n\nconst getNearestPrefix = (exponent: number): Prefix => prefixes.reduce((p, n) => (\n Math.abs(n.magnitude - exponent) < Math.abs(p.magnitude - exponent) ? n : p));\n\nconst getLowerBoundPrefix = (exponent: number): Prefix => prefixes\n .find((p) => p.magnitude <= exponent) ?? prefixes[prefixes.length - 1];\n\nexport const prefixedAmount = (rawValue: string | number | BigNumber): string => {\n const value: BigNumber = new BigNumber(rawValue);\n\n const exp = value.e ?? 0;\n const { name, magnitude } = (exp < 0 ? getNearestPrefix : getLowerBoundPrefix)(exp);\n const v = value\n .shiftedBy(-magnitude)\n .precision(9 + Math.min(exp - magnitude, 0))\n .toFixed();\n return `${v}${name !== '' ? ' ' : ''}${name}`;\n};\n"],"mappings":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MI,mBAAmB,GAAIN,QAAgB;EAAA,IAAAO,cAAA;EAAA,QAAAA,cAAA,GAAaX,QAAQ,CAC/DY,IAAI,CAAEN,CAAC,IAAKA,CAAC,CAACJ,SAAS,IAAIE,QAAQ,CAAC,cAAAO,cAAA,cAAAA,cAAA,GAAIX,QAAQ,CAACA,QAAQ,CAACH,MAAM,GAAG,CAAC,CAAC;AAAA;AAExE,OAAO,MAAMgB,cAAc,GAAIC,QAAqC,IAAa;EAAA,IAAAC,QAAA;EAC/E,MAAM3B,KAAgB,GAAG,IAAIb,SAAS,CAACuC,QAAQ,CAAC;EAEhD,MAAME,GAAG,IAAAD,QAAA,GAAG3B,KAAK,CAAC6B,CAAC,cAAAF,QAAA,cAAAA,QAAA,GAAI,CAAC;EACxB,MAAM;IAAEd,IAAI;IAAEC;EAAU,CAAC,GAAG,CAACc,GAAG,GAAG,CAAC,GAAGb,gBAAgB,GAAGO,mBAAmB,EAAEM,GAAG,CAAC;EACnF,MAAME,CAAC,GAAG9B,KAAK,CACZK,SAAS,CAAC,CAACS,SAAS,CAAC,CACrBiB,SAAS,CAAC,CAAC,GAAGX,IAAI,CAACY,GAAG,CAACJ,GAAG,GAAGd,SAAS,EAAE,CAAC,CAAC,CAAC,CAC3CR,OAAO,EAAE;EACZ,OAAQ,GAAEwB,CAAE,GAAEjB,IAAI,KAAK,EAAE,GAAG,GAAG,GAAG,EAAG,GAAEA,IAAK,EAAC;AAC/C,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { RestError } from '@azure/core-rest-pipeline';
2
2
  import { pause } from "./other.mjs";
3
3
  import semverSatisfies from "./semver-satisfies.mjs";
4
- import { UnexpectedTsError, UnsupportedVersionError } from "./errors.mjs";
4
+ import { UnsupportedVersionError } from "./errors.mjs";
5
5
  export const genRequestQueuesPolicy = () => {
6
6
  const requestQueues = new Map();
7
7
  return {
@@ -105,20 +105,18 @@ export const genRetryOnFailurePolicy = (retryCount, retryOverallDelay) => ({
105
105
  const intervals = new Array(retryCount).fill(0).map((_, idx) => ((idx + 1) / retryCount) ** 2);
106
106
  const intervalSum = intervals.reduce((a, b) => a + b);
107
107
  const intervalsInMs = intervals.map(el => el / intervalSum * retryOverallDelay);
108
- let error;
108
+ let error = new RestError('Not expected to be thrown');
109
109
  for (let attempt = 0; attempt <= retryCount; attempt += 1) {
110
- if (error != null) {
111
- var _error$response$statu, _error$response2;
112
- if (!(error instanceof RestError) || statusesToNotRetry.includes((_error$response$statu = (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) !== null && _error$response$statu !== void 0 ? _error$response$statu : 0)) throw error;
113
- await pause(intervalsInMs[attempt - 1]);
114
- }
110
+ if (attempt !== 0) await pause(intervalsInMs[attempt - 1]);
115
111
  try {
116
112
  return await next(request);
117
113
  } catch (e) {
114
+ var _e$response$status, _e$response;
115
+ if (!(e instanceof RestError)) throw e;
116
+ if (statusesToNotRetry.includes((_e$response$status = (_e$response = e.response) === null || _e$response === void 0 ? void 0 : _e$response.status) !== null && _e$response$status !== void 0 ? _e$response$status : 0)) throw e;
118
117
  error = e;
119
118
  }
120
119
  }
121
- if (error == null) throw new UnexpectedTsError();
122
120
  throw error;
123
121
  }
124
122
  },
@@ -1 +1 @@
1
- {"version":3,"file":"autorest.mjs","names":["RestError","pause","semverSatisfies","UnexpectedTsError","UnsupportedVersionError","genRequestQueuesPolicy","requestQueues","Map","policy","name","sendRequest","request","next","_requestQueues$get","key","headers","get","delete","getResponse","req","Promise","resolve","then","set","position","genCombineGetRequestsPolicy","pendingGetRequests","_pendingGetRequests$g","method","JSON","stringify","url","body","response","genAggressiveCacheGetResponsesPolicy","getRequests","_getRequests$get","genErrorFormatterPolicy","getMessage","error","_error$response","bodyAsText","parse","e","message","URL","pathname","slice","genVersionCheckPolicy","ignorePath","versionPromise","geVersion","ltVersion","version","Error","args","genRetryOnFailurePolicy","retryCount","retryOverallDelay","statusesToNotRetry","intervals","Array","fill","map","_","idx","intervalSum","reduce","a","b","intervalsInMs","el","attempt","_error$response$statu","_error$response2","includes","status"],"sources":["../../src/utils/autorest.ts"],"sourcesContent":["import { RestError, PipelineResponse, PipelinePolicy } from '@azure/core-rest-pipeline';\nimport { AdditionalPolicyConfig } from '@azure/core-client';\nimport { pause } from './other';\nimport semverSatisfies from './semver-satisfies';\nimport { UnexpectedTsError, UnsupportedVersionError } from './errors';\n\nexport const genRequestQueuesPolicy = (): AdditionalPolicyConfig => {\n const requestQueues = new Map<string, Promise<unknown>>();\n\n return {\n policy: {\n name: 'request-queues',\n async sendRequest(request, next) {\n const key = request.headers.get('__queue');\n request.headers.delete('__queue');\n const getResponse = async (): Promise<PipelineResponse> => next(request);\n if (key == null) return getResponse();\n const req = (requestQueues.get(key) ?? Promise.resolve()).then(getResponse, getResponse);\n // TODO: remove after fixing https://github.com/aeternity/aeternity/issues/3803\n // gap to ensure that node won't reject the nonce\n requestQueues.set(key, req.then(async () => pause(750)));\n return req;\n },\n },\n position: 'perCall',\n };\n};\n\nexport const genCombineGetRequestsPolicy = (): AdditionalPolicyConfig => {\n const pendingGetRequests = new Map<string, Promise<PipelineResponse>>();\n\n return {\n policy: {\n name: 'combine-get-requests',\n async sendRequest(request, next) {\n if (request.method !== 'GET') return next(request);\n const key = JSON.stringify([request.url, request.body]);\n const response = pendingGetRequests.get(key) ?? next(request);\n pendingGetRequests.set(key, response);\n try {\n return await response;\n } finally {\n pendingGetRequests.delete(key);\n }\n },\n },\n position: 'perCall',\n };\n};\n\nexport const genAggressiveCacheGetResponsesPolicy = (): AdditionalPolicyConfig => {\n const getRequests = new Map<string, Promise<PipelineResponse>>();\n\n return {\n policy: {\n name: 'aggressive-cache-get-responses',\n async sendRequest(request, next) {\n if (request.method !== 'GET') return next(request);\n const key = JSON.stringify([request.url, request.body]);\n const response = getRequests.get(key) ?? next(request);\n getRequests.set(key, response);\n return response;\n },\n },\n position: 'perCall',\n };\n};\n\nexport const genErrorFormatterPolicy = (\n getMessage: (b: any) => string,\n): AdditionalPolicyConfig => ({\n policy: {\n name: 'error-formatter',\n async sendRequest(request, next) {\n try {\n return await next(request);\n } catch (error) {\n if (!(error instanceof RestError) || error.request == null) throw error;\n if (error.response?.bodyAsText == null) throw error;\n\n let body;\n try {\n body = JSON.parse(error.response.bodyAsText);\n } catch (e) {\n throw error;\n }\n error.message = `${new URL(error.request.url).pathname.slice(1)} error`;\n const message = getMessage(body);\n if (message !== '') error.message += `:${message}`;\n throw error;\n }\n },\n },\n position: 'perCall',\n});\n\nexport const genVersionCheckPolicy = (\n name: string,\n ignorePath: string,\n versionPromise: Promise<string | Error>,\n geVersion: string,\n ltVersion: string,\n): PipelinePolicy => ({\n name: 'version-check',\n async sendRequest(request, next) {\n if (new URL(request.url).pathname === ignorePath) return next(request);\n const version = await versionPromise;\n if (version instanceof Error) throw version;\n const args = [version, geVersion, ltVersion] as const;\n if (!semverSatisfies(...args)) throw new UnsupportedVersionError(name, ...args);\n return next(request);\n },\n});\n\nexport const genRetryOnFailurePolicy = (\n retryCount: number,\n retryOverallDelay: number,\n): AdditionalPolicyConfig => ({\n policy: {\n name: 'retry-on-failure',\n async sendRequest(request, next) {\n const statusesToNotRetry = [200, 400, 403];\n\n const intervals = new Array(retryCount).fill(0)\n .map((_, idx) => ((idx + 1) / retryCount) ** 2);\n const intervalSum = intervals.reduce((a, b) => a + b);\n const intervalsInMs = intervals.map((el) => (el / intervalSum) * retryOverallDelay);\n\n let error: Error | undefined;\n for (let attempt = 0; attempt <= retryCount; attempt += 1) {\n if (error != null) {\n if (\n !(error instanceof RestError)\n || statusesToNotRetry.includes(error.response?.status ?? 0)\n ) throw error;\n await pause(intervalsInMs[attempt - 1]);\n }\n try {\n return await next(request);\n } catch (e) {\n error = e;\n }\n }\n if (error == null) throw new UnexpectedTsError();\n throw error;\n },\n },\n position: 'perCall',\n});\n"],"mappings":"AAAA,SAASA,SAAS,QAA0C,2BAA2B;AAAC,SAE/EC,KAAK;AAAA,OACPC,eAAe;AAAA,SACbC,iBAAiB,EAAEC,uBAAuB;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EnC,KAAK,YAAYvC,SAAS,CAAC,IAC1B2D,kBAAkB,CAACgB,QAAQ,EAAAF,qBAAA,IAAAC,gBAAA,GAACnC,KAAK,CAACN,QAAQ,cAAAyC,gBAAA,uBAAdA,gBAAA,CAAgBE,MAAM,cAAAH,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC,EAC3D,MAAMlC,KAAK;UACb,MAAMtC,KAAK,CAACqE,aAAa,CAACE,OAAO,GAAG,CAAC,CAAC,CAAC;QACzC;QACA,IAAI;UACF,OAAO,MAAM5D,IAAI,CAACD,OAAO,CAAC;QAC5B,CAAC,CAAC,OAAOgC,CAAC,EAAE;UACVJ,KAAK,GAAGI,CAAC;QACX;MACF;MACA,IAAIJ,KAAK,IAAI,IAAI,EAAE,MAAM,IAAIpC,iBAAiB,EAAE;MAChD,MAAMoC,KAAK;IACb;EACF,CAAC;EACDf,QAAQ,EAAE;AACZ,CAAC,CAAC"}
1
+ {"version":3,"file":"autorest.mjs","names":["RestError","pause","semverSatisfies","UnsupportedVersionError","genRequestQueuesPolicy","requestQueues","Map","policy","name","sendRequest","request","next","_requestQueues$get","key","headers","get","delete","getResponse","req","Promise","resolve","then","set","position","genCombineGetRequestsPolicy","pendingGetRequests","_pendingGetRequests$g","method","JSON","stringify","url","body","response","genAggressiveCacheGetResponsesPolicy","getRequests","_getRequests$get","genErrorFormatterPolicy","getMessage","error","_error$response","bodyAsText","parse","e","message","URL","pathname","slice","genVersionCheckPolicy","ignorePath","versionPromise","geVersion","ltVersion","version","Error","args","genRetryOnFailurePolicy","retryCount","retryOverallDelay","statusesToNotRetry","intervals","Array","fill","map","_","idx","intervalSum","reduce","a","b","intervalsInMs","el","attempt","_e$response$status","_e$response","includes","status"],"sources":["../../src/utils/autorest.ts"],"sourcesContent":["import { RestError, PipelineResponse, PipelinePolicy } from '@azure/core-rest-pipeline';\nimport { AdditionalPolicyConfig } from '@azure/core-client';\nimport { pause } from './other';\nimport semverSatisfies from './semver-satisfies';\nimport { UnsupportedVersionError } from './errors';\n\nexport const genRequestQueuesPolicy = (): AdditionalPolicyConfig => {\n const requestQueues = new Map<string, Promise<unknown>>();\n\n return {\n policy: {\n name: 'request-queues',\n async sendRequest(request, next) {\n const key = request.headers.get('__queue');\n request.headers.delete('__queue');\n const getResponse = async (): Promise<PipelineResponse> => next(request);\n if (key == null) return getResponse();\n const req = (requestQueues.get(key) ?? Promise.resolve()).then(getResponse, getResponse);\n // TODO: remove after fixing https://github.com/aeternity/aeternity/issues/3803\n // gap to ensure that node won't reject the nonce\n requestQueues.set(key, req.then(async () => pause(750)));\n return req;\n },\n },\n position: 'perCall',\n };\n};\n\nexport const genCombineGetRequestsPolicy = (): AdditionalPolicyConfig => {\n const pendingGetRequests = new Map<string, Promise<PipelineResponse>>();\n\n return {\n policy: {\n name: 'combine-get-requests',\n async sendRequest(request, next) {\n if (request.method !== 'GET') return next(request);\n const key = JSON.stringify([request.url, request.body]);\n const response = pendingGetRequests.get(key) ?? next(request);\n pendingGetRequests.set(key, response);\n try {\n return await response;\n } finally {\n pendingGetRequests.delete(key);\n }\n },\n },\n position: 'perCall',\n };\n};\n\nexport const genAggressiveCacheGetResponsesPolicy = (): AdditionalPolicyConfig => {\n const getRequests = new Map<string, Promise<PipelineResponse>>();\n\n return {\n policy: {\n name: 'aggressive-cache-get-responses',\n async sendRequest(request, next) {\n if (request.method !== 'GET') return next(request);\n const key = JSON.stringify([request.url, request.body]);\n const response = getRequests.get(key) ?? next(request);\n getRequests.set(key, response);\n return response;\n },\n },\n position: 'perCall',\n };\n};\n\nexport const genErrorFormatterPolicy = (\n getMessage: (b: any) => string,\n): AdditionalPolicyConfig => ({\n policy: {\n name: 'error-formatter',\n async sendRequest(request, next) {\n try {\n return await next(request);\n } catch (error) {\n if (!(error instanceof RestError) || error.request == null) throw error;\n if (error.response?.bodyAsText == null) throw error;\n\n let body;\n try {\n body = JSON.parse(error.response.bodyAsText);\n } catch (e) {\n throw error;\n }\n error.message = `${new URL(error.request.url).pathname.slice(1)} error`;\n const message = getMessage(body);\n if (message !== '') error.message += `:${message}`;\n throw error;\n }\n },\n },\n position: 'perCall',\n});\n\nexport const genVersionCheckPolicy = (\n name: string,\n ignorePath: string,\n versionPromise: Promise<string | Error>,\n geVersion: string,\n ltVersion: string,\n): PipelinePolicy => ({\n name: 'version-check',\n async sendRequest(request, next) {\n if (new URL(request.url).pathname === ignorePath) return next(request);\n const version = await versionPromise;\n if (version instanceof Error) throw version;\n const args = [version, geVersion, ltVersion] as const;\n if (!semverSatisfies(...args)) throw new UnsupportedVersionError(name, ...args);\n return next(request);\n },\n});\n\nexport const genRetryOnFailurePolicy = (\n retryCount: number,\n retryOverallDelay: number,\n): AdditionalPolicyConfig => ({\n policy: {\n name: 'retry-on-failure',\n async sendRequest(request, next) {\n const statusesToNotRetry = [200, 400, 403];\n\n const intervals = new Array(retryCount).fill(0)\n .map((_, idx) => ((idx + 1) / retryCount) ** 2);\n const intervalSum = intervals.reduce((a, b) => a + b);\n const intervalsInMs = intervals.map((el) => (el / intervalSum) * retryOverallDelay);\n\n let error = new RestError('Not expected to be thrown');\n for (let attempt = 0; attempt <= retryCount; attempt += 1) {\n if (attempt !== 0) await pause(intervalsInMs[attempt - 1]);\n try {\n return await next(request);\n } catch (e) {\n if (!(e instanceof RestError)) throw e;\n if (statusesToNotRetry.includes(e.response?.status ?? 0)) throw e;\n error = e;\n }\n }\n throw error;\n },\n },\n position: 'perCall',\n});\n"],"mappings":"AAAA,SAASA,SAAS,QAA0C,2BAA2B;AAAC,SAE/EC,KAAK;AAAA,OACPC,eAAe;AAAA,SACbC,uBAAuB;AAEhC,OAAO,MAAMC,sBAAsB,GAAGA,CAAA,KAA8B;EAClE,MAAMC,aAAa,GAAG,IAAIC,GAAG,EAA4B;EAEzD,OAAO;IACLC,MAAM,EAAE;MACNC,IAAI,EAAE,gBAAgB;MACtB,MAAMC,WAAWA,CAACC,OAAO,EAAEC,IAAI,EAAE;QAAA,IAAAC,kBAAA;QAC/B,MAAMC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C,CAAC;UACtC,IAAIgB,kBAAkB,CAACgB,QAAQ,EAAAF,kBAAA,IAAAC,WAAA,GAAC/B,CAAC,CAACV,QAAQ,cAAAyC,WAAA,uBAAVA,WAAA,CAAYE,MAAM,cAAAH,kBAAA,cAAAA,kBAAA,GAAI,CAAC,CAAC,EAAE,MAAM9B,CAAC;UACjEJ,KAAK,GAAGI,CAAC;QACX;MACF;MACA,MAAMJ,KAAK;IACb;EACF,CAAC;EACDf,QAAQ,EAAE;AACZ,CAAC,CAAC"}
@@ -74,6 +74,7 @@ export declare function sign(data: string | Uint8Array, privateKey: string | Uin
74
74
  * @returns is data was signed by address
75
75
  */
76
76
  export declare function verify(data: Uint8Array, signature: Uint8Array, address: Encoded.AccountAddress): boolean;
77
+ export declare const messagePrefixLength: Buffer;
77
78
  export declare function messageToHash(message: string): Buffer;
78
79
  export declare function signMessage(message: string, privateKey: string | Buffer): Uint8Array;
79
80
  /**
@@ -15,6 +15,7 @@ const {
15
15
  } = _varuintBitcoin;
16
16
  import { concatBuffers } from "./other.mjs";
17
17
  import { decode, encode, Encoding } from "./encoder.mjs";
18
+ import { ArgumentError } from "./errors.mjs";
18
19
  /**
19
20
  * Generate address from secret key
20
21
  * @param secret - Private key as hex string
@@ -36,6 +37,10 @@ export function isAddressValid(address) {
36
37
  let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Encoding.AccountAddress;
37
38
  try {
38
39
  decode(address);
40
+ const actualPrefix = address.split('_')[0];
41
+ if (actualPrefix !== prefix) {
42
+ throw new ArgumentError('Encoded string type', prefix, actualPrefix);
43
+ }
39
44
  return true;
40
45
  } catch (e) {
41
46
  return false;
@@ -142,10 +147,13 @@ export function sign(data, privateKey) {
142
147
  export function verify(data, signature, address) {
143
148
  return nacl.sign.detached.verify(data, signature, decode(address));
144
149
  }
150
+ const messagePrefix = _Buffer.from('aeternity Signed Message:\n', 'utf8');
151
+ export const messagePrefixLength = varuintEncode(messagePrefix.length);
152
+
153
+ // TODO: consider rename to hashMessage
145
154
  export function messageToHash(message) {
146
- const p = _Buffer.from('aeternity Signed Message:\n', 'utf8');
147
155
  const msg = _Buffer.from(message, 'utf8');
148
- return hash(concatBuffers([varuintEncode(p.length), p, varuintEncode(msg.length), msg]));
156
+ return hash(concatBuffers([messagePrefixLength, messagePrefix, varuintEncode(msg.length), msg]));
149
157
  }
150
158
  export function signMessage(message, privateKey) {
151
159
  return sign(messageToHash(message), privateKey);
@@ -158,6 +166,8 @@ export function signMessage(message, privateKey) {
158
166
  * @param address - Address to verify against
159
167
  * @returns is data was signed by address
160
168
  */
169
+ // TODO: deprecate in favour of `verify(messageToHash(message), ...`, also the name is confusing
170
+ // it should contain "signature"
161
171
  export function verifyMessage(message, signature, address) {
162
172
  return verify(messageToHash(message), signature, address);
163
173
  }
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.mjs","names":["nacl","_blakejsBlake2bJs","blake2b","_varuintBitcoin","encode","varuintEncode","concatBuffers","decode","Encoding","getAddressFromPriv","secret","secretBuffer","_Buffer","from","keys","sign","keyPair","fromSecretKey","publicKey","AccountAddress","isAddressValid","address","prefix","arguments","length","undefined","e","genSalt","random","BigUint64Array","randomBytes","buffer","Number","BigInt","MAX_SAFE_INTEGER","encodeUnsigned","value","binary","allocUnsafe","writeUInt32BE","slice","findIndex","i","hash","input","encodeContractAddress","owner","nonce","ContractAddress","generateKeyPairFromSecret","generateKeyPair","raw","publicBuffer","secretKey","toString","data","privateKey","detached","verify","signature","messageToHash","message","p","msg","signMessage","verifyMessage","isValidKeypair","publicKeyBuffer"],"sources":["../../src/utils/crypto.ts"],"sourcesContent":["import nacl, { SignKeyPair } from 'tweetnacl';\n// js extension is required for mjs build, not importing the whole package to reduce bundle size\n// eslint-disable-next-line import/extensions\nimport { blake2b } from 'blakejs/blake2b.js';\nimport { encode as varuintEncode } from 'varuint-bitcoin';\n\nimport { concatBuffers } from './other';\nimport {\n decode, encode, Encoded, Encoding,\n} from './encoder';\n\n/**\n * Generate address from secret key\n * @param secret - Private key as hex string\n * @returns Public key encoded as address\n */\nexport function getAddressFromPriv(secret: string | Uint8Array): Encoded.AccountAddress {\n const secretBuffer = typeof secret === 'string' ? Buffer.from(secret, 'hex') : secret;\n const keys = nacl.sign.keyPair.fromSecretKey(secretBuffer);\n return encode(keys.publicKey, Encoding.AccountAddress);\n}\n\n/**\n * Check if address is valid\n * @param address - Address\n * @param prefix - Transaction prefix. Default: 'ak'\n * @returns is valid\n */\nexport function isAddressValid(\n address: string,\n prefix: Encoding = Encoding.AccountAddress,\n): boolean {\n try {\n decode(address as Encoded.Generic<typeof prefix>);\n return true;\n } catch (e) {\n return false;\n }\n}\n\n/**\n * Generate a random salt (positive integer)\n * @returns random salt\n */\nexport function genSalt(): number {\n const [random] = new BigUint64Array(nacl.randomBytes(8).buffer);\n return Number(random % BigInt(Number.MAX_SAFE_INTEGER));\n}\n\n/**\n * Converts a positive integer to the smallest possible\n * representation in a binary digit representation\n * @param value - Value to encode\n * @returns Encoded number\n */\nexport function encodeUnsigned(value: number): Buffer {\n const binary = Buffer.allocUnsafe(4);\n binary.writeUInt32BE(value);\n return binary.slice(binary.findIndex((i) => i !== 0));\n}\n\n/**\n * Calculate 256bits Blake2b hash of `input`\n * @param input - Data to hash\n * @returns Hash\n */\nexport function hash(input: string | Uint8Array): Buffer {\n return Buffer.from(blake2b(input, undefined, 32)); // 256 bits\n}\n\n// Todo Duplicated in tx builder. remove\n/**\n * Compute contract address\n * @category contract\n * @param owner - Address of contract owner\n * @param nonce - Round when contract was created\n * @returns Contract address\n */\nexport function encodeContractAddress(\n owner: Encoded.AccountAddress,\n nonce: number,\n): Encoded.ContractAddress {\n const publicKey = decode(owner);\n const binary = concatBuffers([publicKey, encodeUnsigned(nonce)]);\n return encode(hash(binary), Encoding.ContractAddress);\n}\n\n// KEY-PAIR HELPERS\n\n/**\n * Generate keyPair from secret key\n * @param secret - secret key\n * @returns Object with Private(privateKey) and Public(publicKey) keys\n */\nexport function generateKeyPairFromSecret(secret: Uint8Array): SignKeyPair {\n return nacl.sign.keyPair.fromSecretKey(secret);\n}\n\n/**\n * Generate a random ED25519 keypair\n * @param raw - Whether to return raw (binary) keys\n * @returns Key pair\n */\nexport function generateKeyPair(raw: true): { publicKey: Buffer; secretKey: Buffer };\nexport function generateKeyPair(raw?: false): {\n publicKey: Encoded.AccountAddress; secretKey: string;\n};\nexport function generateKeyPair(raw = false): {\n publicKey: Encoded.AccountAddress | Buffer;\n secretKey: string | Buffer;\n} {\n const keyPair = nacl.sign.keyPair();\n const publicBuffer = Buffer.from(keyPair.publicKey);\n const secretBuffer = Buffer.from(keyPair.secretKey);\n\n if (raw) {\n return {\n publicKey: publicBuffer,\n secretKey: secretBuffer,\n };\n }\n return {\n publicKey: encode(publicBuffer, Encoding.AccountAddress),\n secretKey: secretBuffer.toString('hex'),\n };\n}\n\n// SIGNATURES\n\n/**\n * Generate signature\n * @param data - Data to sign\n * @param privateKey - Key to sign with\n * @returns Signature\n */\nexport function sign(data: string | Uint8Array, privateKey: string | Uint8Array): Uint8Array {\n return nacl.sign.detached(Buffer.from(data), Buffer.from(privateKey));\n}\n\n/**\n * Verify that signature was signed by public key\n * @param data - Data that was signed\n * @param signature - Signature of data\n * @param address - Address to verify against\n * @returns is data was signed by address\n */\nexport function verify(\n data: Uint8Array,\n signature: Uint8Array,\n address: Encoded.AccountAddress,\n): boolean {\n return nacl.sign.detached.verify(data, signature, decode(address));\n}\n\nexport function messageToHash(message: string): Buffer {\n const p = Buffer.from('aeternity Signed Message:\\n', 'utf8');\n const msg = Buffer.from(message, 'utf8');\n return hash(concatBuffers([varuintEncode(p.length), p, varuintEncode(msg.length), msg]));\n}\n\nexport function signMessage(message: string, privateKey: string | Buffer): Uint8Array {\n return sign(messageToHash(message), privateKey);\n}\n\n/**\n * Verify that message was signed by address\n * @param message - Message that was signed\n * @param signature - Signature of message\n * @param address - Address to verify against\n * @returns is data was signed by address\n */\nexport function verifyMessage(\n message: string,\n signature: Uint8Array,\n address: Encoded.AccountAddress,\n): boolean {\n return verify(messageToHash(message), signature, address);\n}\n\n/**\n * Check key pair for validity\n *\n * Sign a message, and then verifying that signature\n * @param privateKey - Private key to verify\n * @param publicKey - Public key to verify as hex string\n * @returns Valid?\n */\nexport function isValidKeypair(\n privateKey: string | Uint8Array,\n publicKey: string | Uint8Array,\n): boolean {\n const message = Buffer.from('TheMessage');\n const signature = sign(message, privateKey);\n const publicKeyBuffer = typeof publicKey === 'string' ? Buffer.from(publicKey, 'hex') : publicKey;\n return verify(message, signature, encode(publicKeyBuffer, Encoding.AccountAddress));\n}\n"],"mappings":";;;;AAAA,OAAOA,IAAI,MAAuB,WAAW;AAC7C;AACA;AACA,OAAAC,iBAAA,MAAwB,oBAAoB;AAAC;EAAAC;AAAA,IAAAD,iBAAA;AAC7C,OAAAE,eAAA,MAAwC,iBAAiB;AAAC;EAAAC,MAAA,EAAAC;AAAA,IAAAF,eAAA;AAAA,SAEjDG,aAAa;AAAA,SAEpBC,MAAM,EAAEH,MAAM,EAAWI,QAAQ;AAGnC;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,MAA2B,EAA0B;EACtF,MAAMC,YAAY,GAAG,OAAOD,MAAM,KAAK,QAAQ,GAAGE,OAAA,CAAOC,IAAI,CAACH,MAAM,EAAE,KAAK,CAAC,GAAGA,MAAM;EACrF,MAAMI,IAAI,GAAGd,IAAI,CAACe,IAAI,CAACC,OAAO,CAACC,aAAa,CAACN,YAAY,CAAC;EAC1D,OAAOP,MAAM,CAACU,IAAI,CAACI,SAAS,EAAEV,QAAQ,CAACW,cAAc,CAAC;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,OAAe,EAEN;EAAA,IADTC,MAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGf,QAAQ,CAACW,cAAc;EAE1C,IAAI;IACFZ,MAAM,CAACc,OAAO,CAAm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"version":3,"file":"crypto.mjs","names":["nacl","_blakejsBlake2bJs","blake2b","_varuintBitcoin","encode","varuintEncode","concatBuffers","decode","Encoding","ArgumentError","getAddressFromPriv","secret","secretBuffer","_Buffer","from","keys","sign","keyPair","fromSecretKey","publicKey","AccountAddress","isAddressValid","address","prefix","arguments","length","undefined","actualPrefix","split","e","genSalt","random","BigUint64Array","randomBytes","buffer","Number","BigInt","MAX_SAFE_INTEGER","encodeUnsigned","value","binary","allocUnsafe","writeUInt32BE","slice","findIndex","i","hash","input","encodeContractAddress","owner","nonce","ContractAddress","generateKeyPairFromSecret","generateKeyPair","raw","publicBuffer","secretKey","toString","data","privateKey","detached","verify","signature","messagePrefix","messagePrefixLength","messageToHash","message","msg","signMessage","verifyMessage","isValidKeypair","publicKeyBuffer"],"sources":["../../src/utils/crypto.ts"],"sourcesContent":["import nacl, { SignKeyPair } from 'tweetnacl';\n// js extension is required for mjs build, not importing the whole package to reduce bundle size\n// eslint-disable-next-line import/extensions\nimport { blake2b } from 'blakejs/blake2b.js';\nimport { encode as varuintEncode } from 'varuint-bitcoin';\n\nimport { concatBuffers } from './other';\nimport {\n decode, encode, Encoded, Encoding,\n} from './encoder';\nimport { ArgumentError } from './errors';\n\n/**\n * Generate address from secret key\n * @param secret - Private key as hex string\n * @returns Public key encoded as address\n */\nexport function getAddressFromPriv(secret: string | Uint8Array): Encoded.AccountAddress {\n const secretBuffer = typeof secret === 'string' ? Buffer.from(secret, 'hex') : secret;\n const keys = nacl.sign.keyPair.fromSecretKey(secretBuffer);\n return encode(keys.publicKey, Encoding.AccountAddress);\n}\n\n/**\n * Check if address is valid\n * @param address - Address\n * @param prefix - Transaction prefix. Default: 'ak'\n * @returns is valid\n */\nexport function isAddressValid(\n address: string,\n prefix: Encoding = Encoding.AccountAddress,\n): boolean {\n try {\n decode(address as Encoded.Generic<typeof prefix>);\n const actualPrefix = address.split('_')[0];\n if (actualPrefix !== prefix) {\n throw new ArgumentError('Encoded string type', prefix, actualPrefix);\n }\n return true;\n } catch (e) {\n return false;\n }\n}\n\n/**\n * Generate a random salt (positive integer)\n * @returns random salt\n */\nexport function genSalt(): number {\n const [random] = new BigUint64Array(nacl.randomBytes(8).buffer);\n return Number(random % BigInt(Number.MAX_SAFE_INTEGER));\n}\n\n/**\n * Converts a positive integer to the smallest possible\n * representation in a binary digit representation\n * @param value - Value to encode\n * @returns Encoded number\n */\nexport function encodeUnsigned(value: number): Buffer {\n const binary = Buffer.allocUnsafe(4);\n binary.writeUInt32BE(value);\n return binary.slice(binary.findIndex((i) => i !== 0));\n}\n\n/**\n * Calculate 256bits Blake2b hash of `input`\n * @param input - Data to hash\n * @returns Hash\n */\nexport function hash(input: string | Uint8Array): Buffer {\n return Buffer.from(blake2b(input, undefined, 32)); // 256 bits\n}\n\n// Todo Duplicated in tx builder. remove\n/**\n * Compute contract address\n * @category contract\n * @param owner - Address of contract owner\n * @param nonce - Round when contract was created\n * @returns Contract address\n */\nexport function encodeContractAddress(\n owner: Encoded.AccountAddress,\n nonce: number,\n): Encoded.ContractAddress {\n const publicKey = decode(owner);\n const binary = concatBuffers([publicKey, encodeUnsigned(nonce)]);\n return encode(hash(binary), Encoding.ContractAddress);\n}\n\n// KEY-PAIR HELPERS\n\n/**\n * Generate keyPair from secret key\n * @param secret - secret key\n * @returns Object with Private(privateKey) and Public(publicKey) keys\n */\nexport function generateKeyPairFromSecret(secret: Uint8Array): SignKeyPair {\n return nacl.sign.keyPair.fromSecretKey(secret);\n}\n\n/**\n * Generate a random ED25519 keypair\n * @param raw - Whether to return raw (binary) keys\n * @returns Key pair\n */\nexport function generateKeyPair(raw: true): { publicKey: Buffer; secretKey: Buffer };\nexport function generateKeyPair(raw?: false): {\n publicKey: Encoded.AccountAddress; secretKey: string;\n};\nexport function generateKeyPair(raw = false): {\n publicKey: Encoded.AccountAddress | Buffer;\n secretKey: string | Buffer;\n} {\n const keyPair = nacl.sign.keyPair();\n const publicBuffer = Buffer.from(keyPair.publicKey);\n const secretBuffer = Buffer.from(keyPair.secretKey);\n\n if (raw) {\n return {\n publicKey: publicBuffer,\n secretKey: secretBuffer,\n };\n }\n return {\n publicKey: encode(publicBuffer, Encoding.AccountAddress),\n secretKey: secretBuffer.toString('hex'),\n };\n}\n\n// SIGNATURES\n\n/**\n * Generate signature\n * @param data - Data to sign\n * @param privateKey - Key to sign with\n * @returns Signature\n */\nexport function sign(data: string | Uint8Array, privateKey: string | Uint8Array): Uint8Array {\n return nacl.sign.detached(Buffer.from(data), Buffer.from(privateKey));\n}\n\n/**\n * Verify that signature was signed by public key\n * @param data - Data that was signed\n * @param signature - Signature of data\n * @param address - Address to verify against\n * @returns is data was signed by address\n */\nexport function verify(\n data: Uint8Array,\n signature: Uint8Array,\n address: Encoded.AccountAddress,\n): boolean {\n return nacl.sign.detached.verify(data, signature, decode(address));\n}\n\nconst messagePrefix = Buffer.from('aeternity Signed Message:\\n', 'utf8');\nexport const messagePrefixLength = varuintEncode(messagePrefix.length);\n\n// TODO: consider rename to hashMessage\nexport function messageToHash(message: string): Buffer {\n const msg = Buffer.from(message, 'utf8');\n return hash(concatBuffers([messagePrefixLength, messagePrefix, varuintEncode(msg.length), msg]));\n}\n\nexport function signMessage(message: string, privateKey: string | Buffer): Uint8Array {\n return sign(messageToHash(message), privateKey);\n}\n\n/**\n * Verify that message was signed by address\n * @param message - Message that was signed\n * @param signature - Signature of message\n * @param address - Address to verify against\n * @returns is data was signed by address\n */\n// TODO: deprecate in favour of `verify(messageToHash(message), ...`, also the name is confusing\n// it should contain \"signature\"\nexport function verifyMessage(\n message: string,\n signature: Uint8Array,\n address: Encoded.AccountAddress,\n): boolean {\n return verify(messageToHash(message), signature, address);\n}\n\n/**\n * Check key pair for validity\n *\n * Sign a message, and then verifying that signature\n * @param privateKey - Private key to verify\n * @param publicKey - Public key to verify as hex string\n * @returns Valid?\n */\nexport function isValidKeypair(\n privateKey: string | Uint8Array,\n publicKey: string | Uint8Array,\n): boolean {\n const message = Buffer.from('TheMessage');\n const signature = sign(message, privateKey);\n const publicKeyBuffer = typeof publicKey === 'string' ? Buffer.from(publicKey, 'hex') : publicKey;\n return verify(message, signature, encode(publicKeyBuffer, Encoding.AccountAddress));\n}\n"],"mappings":";;;;AAAA,OAAOA,IAAI,MAAuB,WAAW;AAC7C;AACA;AACA,OAAAC,iBAAA,MAAwB,oBAAoB;AAAC;EAAAC;AAAA,IAAAD,iBAAA;AAC7C,OAAAE,eAAA,MAAwC,iBAAiB;AAAC;EAAAC,MAAA,EAAAC;AAAA,IAAAF,eAAA;AAAA,SAEjDG,aAAa;AAAA,SAEpBC,MAAM,EAAEH,MAAM,EAAWI,QAAQ;AAAA,SAE1BC,aAAa;AAEtB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,MAA2B,EAA0B;EACtF,MAAMC,YAAY,GAAG,OAAOD,MAAM,KAAK,QAAQ,GAAGE,OAAA,CAAOC,IAAI,CAACH,MAAM,EAAE,KAAK,CAAC,GAAGA,MAAM;EACrF,MAAMI,IAAI,GAAGf,IAAI,CAACgB,IAAI,CAACC,OAAO,CAACC,aAAa,CAACN,YAAY,CAAC;EAC1D,OAAOR,MAAM,CAACW,IAAI,CAACI,SAAS,EAAEX,QAAQ,CAACY,cAAc,CAAC;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,OAAe,EAEN;EAAA,IADTC,MAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGhB,QAAQ,CAACY,cAAc;EAE1C,IAAI;IACFb,MAAM,CAACe,OAAO,CAAmC;IACjD,MAAMK,YAAY,GAAGL,OAAO,CAACM,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1C,IAAID,YAAY,KAAKJ,MAAM,EAAE;MAC3B,MAAM,IAAId,aAAa,CAAC,qBAAqB,EAAEc,MAAM,EAAEI,YAAY,CAAC;IACtE;IACA,OAAO,IAAI;EAC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QAAQ,CAACY,cAAc,CAAC,CAAC;AACrF"}
@@ -240,11 +240,11 @@ export declare class UnexpectedChannelMessageError extends ChannelError {
240
240
  * @category exception
241
241
  */
242
242
  export declare class ChannelIncomingMessageError extends ChannelError {
243
- handlerError: BaseError;
243
+ handlerError: Error;
244
244
  incomingMessage: {
245
245
  [key: string]: any;
246
246
  };
247
- constructor(handlerError: BaseError, incomingMessage: {
247
+ constructor(handlerError: Error, incomingMessage: {
248
248
  [key: string]: any;
249
249
  });
250
250
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":["BaseError","Error","constructor","message","name","AccountError","AensError","AeppError","ChannelError","CompilerError","ContractError","CryptographyError","NodeError","TransactionError","WalletError","ArgumentError","argumentName","requirement","argumentValue","IllegalArgumentError","ArgumentCountMismatchError","functionName","requiredCount","providedCount","InsufficientBalanceError","MissingParamError","NoSerializerFoundError","RequestTimedOutError","height","TxTimedOutError","blocks","th","join","TypeError","UnsupportedPlatformError","UnsupportedProtocolError","NotImplementedError","UnsupportedVersionError","dependency","version","geVersion","ltVersion","InternalError","UnexpectedTsError","arguments","length","undefined","UnavailableAccountError","address","AensPointerContextError","nameOrId","prefix","InsufficientNameFeeError","nameFee","minNameFee","toString","InvalidAensNameError","InvalidRpcMessageError","MissingCallbackError","id","UnAuthorizedAccountError","onAccount","UnknownRpcClientError","UnsubscribedAccountError","ChannelCallError","ChannelConnectionError","ChannelPingTimedOutError","UnexpectedChannelMessageError","ChannelIncomingMessageError","handlerError","incomingMessage","UnknownChannelStateError","InvalidAuthDataError","BytecodeMismatchError","source","DuplicateContractError","InactiveContractError","contractAddress","InvalidMethodInvocationError","MissingContractAddressError","MissingContractDefError","MissingFunctionNameError","NodeInvocationError","transaction","NoSuchContractFunctionError","NotPayableFunctionError","amount","fn","MissingEventDefinitionError","eventNameHash","eventAddress","AmbiguousEventDefinitionError","matchedEvents","map","_ref","InvalidChecksumError","InvalidPasswordError","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownNodeLengthError","nodeLength","UnknownPathNibbleError","nibble","DuplicateNodeError","NodeNotFoundError","DecodeError","PayloadLengthError","DryRunError","IllegalBidFeeError","InvalidSignatureError","PrefixNotFoundError","tag","SchemaNotFoundError","key","TagNotFoundError","TxNotInChainError","txHash","AlreadyConnectedError","NoWalletConnectedError","RpcConnectionError"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport BigNumber from 'bignumber.js';\nimport { AensName, Int } from '../tx/builder/constants';\nimport * as Encoded from './encoder-types';\n\n/**\n * aepp-sdk originated error\n * @category exception\n */\nexport abstract class BaseError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'BaseError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AccountError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AensError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AensError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AeppError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AeppError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelError';\n }\n}\n\n/**\n * @category exception\n */\nexport class CompilerError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'CompilerError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ContractError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'ContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class CryptographyError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'CryptographyError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'NodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TransactionError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'TransactionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class WalletError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'WalletError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ArgumentError extends BaseError {\n constructor(argumentName: string, requirement: unknown, argumentValue: unknown) {\n super(`${argumentName} should be ${requirement}, got ${argumentValue} instead`);\n this.name = 'ArgumentError';\n }\n}\n\n/**\n * @category exception\n */\nexport class IllegalArgumentError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'IllegalArgumentError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ArgumentCountMismatchError extends BaseError {\n constructor(functionName: string, requiredCount: number, providedCount: number) {\n super(`${functionName} expects ${requiredCount} arguments, got ${providedCount} instead`);\n this.name = 'ArgumentCountMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InsufficientBalanceError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'InsufficientBalanceError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingParamError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingParamError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NoSerializerFoundError extends BaseError {\n constructor() {\n super('Byte serialization not supported');\n this.name = 'NoSerializerFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class RequestTimedOutError extends BaseError {\n constructor(height: number) {\n super(`Giving up at height ${height}`);\n this.name = 'RequestTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TxTimedOutError extends BaseError {\n constructor(blocks: number, th: Encoded.TxHash) {\n super([\n `Giving up after ${blocks} blocks mined`,\n `transaction hash: ${th}`,\n ].join(', '));\n this.name = 'TxTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TypeError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'TypeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedPlatformError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedPlatformError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedProtocolError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedProtocolError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NotImplementedError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'NotImplementedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedVersionError extends BaseError {\n constructor(dependency: string, version: string, geVersion: string, ltVersion: string) {\n super(`Unsupported ${dependency} version ${version}. Supported: >= ${geVersion} < ${ltVersion}`);\n this.name = 'UnsupportedVersionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InternalError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'InternalError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnexpectedTsError extends InternalError {\n constructor(message = 'Expected to not happen, required for TS') {\n super(message);\n this.name = 'UnexpectedTsError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnavailableAccountError extends AccountError {\n constructor(address: Encoded.AccountAddress) {\n super(`Account for ${address} not available`);\n this.name = 'UnavailableAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AensPointerContextError extends AensError {\n constructor(nameOrId: AensName | Encoded.Name, prefix: string) {\n super(`Name ${nameOrId} don't have pointers for ${prefix}`);\n this.name = 'AensPointerContextError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InsufficientNameFeeError extends AensError {\n constructor(nameFee: BigNumber, minNameFee: BigNumber) {\n super(`the provided fee ${nameFee.toString()} is not enough to execute the claim, required: ${minNameFee.toString()}`);\n this.name = 'InsufficientNameFeeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidAensNameError extends AensError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidAensNameError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidRpcMessageError extends AeppError {\n constructor(message: string) {\n super(`Received invalid message: ${message}`);\n this.name = 'InvalidRpcMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingCallbackError extends AeppError {\n constructor(id: number) {\n super(`Can't find callback for this messageId ${id}`);\n this.name = 'MissingCallbackError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnAuthorizedAccountError extends AeppError {\n constructor(onAccount: Encoded.AccountAddress) {\n super(`You do not have access to account ${onAccount}`);\n this.name = 'UnAuthorizedAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownRpcClientError extends AeppError {\n constructor(id: string) {\n super(`RpcClient with id ${id} do not exist`);\n this.name = 'UnknownRpcClientError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsubscribedAccountError extends AeppError {\n constructor() {\n super('You are not subscribed for an account.');\n this.name = 'UnsubscribedAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelCallError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelCallError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelConnectionError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelConnectionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelPingTimedOutError extends ChannelError {\n constructor() {\n super('Server pong timed out');\n this.name = 'ChannelPingTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnexpectedChannelMessageError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'UnexpectedChannelMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelIncomingMessageError extends ChannelError {\n handlerError: BaseError;\n\n incomingMessage: { [key: string]: any };\n\n constructor(handlerError: BaseError, incomingMessage: { [key: string]: any }) {\n super(handlerError.message);\n this.handlerError = handlerError;\n this.incomingMessage = incomingMessage;\n this.name = 'ChannelIncomingMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownChannelStateError extends ChannelError {\n constructor() {\n super('State Channels FSM entered unknown state');\n this.name = 'UnknownChannelStateError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidAuthDataError extends CompilerError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidAuthDataError';\n }\n}\n\n/**\n * @category exception\n */\nexport class BytecodeMismatchError extends ContractError {\n constructor(source: 'source code' | 'bytecode') {\n super(`Contract ${source} do not correspond to the bytecode deployed on the chain`);\n this.name = 'BytecodeMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DuplicateContractError extends ContractError {\n constructor() {\n super('Contract already deployed');\n this.name = 'DuplicateContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InactiveContractError extends ContractError {\n constructor(contractAddress: Encoded.ContractAddress) {\n super(`Contract with address ${contractAddress} not active`);\n this.name = 'InactiveContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidMethodInvocationError extends ContractError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidMethodInvocationError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingContractAddressError extends ContractError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingContractAddressError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingContractDefError extends ContractError {\n constructor() {\n super('Either ACI or sourceCode or sourceCodePath is required');\n this.name = 'MissingContractDefError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingFunctionNameError extends ContractError {\n constructor() {\n super('Function name is required');\n this.name = 'MissingFunctionNameError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeInvocationError extends ContractError {\n transaction?: Encoded.Transaction;\n\n constructor(message: string, transaction?: Encoded.Transaction) {\n super(`Invocation failed${message == null ? '' : `: \"${message}\"`}`);\n this.name = 'NodeInvocationError';\n this.transaction = transaction;\n }\n}\n\n/**\n * @category exception\n */\nexport class NoSuchContractFunctionError extends ContractError {\n constructor(name: string) {\n super(`Function ${name} doesn't exist in contract`);\n this.name = 'NoSuchContractFunctionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NotPayableFunctionError extends ContractError {\n constructor(amount: Int, fn: string) {\n super(\n `You try to pay \"${amount}\" to function \"${fn}\" which is not payable. `\n + 'Only payable function can accept coins',\n );\n this.name = 'NotPayableFunctionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingEventDefinitionError extends ContractError {\n constructor(eventNameHash: string, eventAddress: Encoded.ContractAddress) {\n super(\n `Can't find definition of ${eventNameHash} event emitted by ${eventAddress}`\n + ' (use omitUnknown option to ignore events like this)',\n );\n this.name = 'MissingEventDefinitionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AmbiguousEventDefinitionError extends ContractError {\n constructor(eventAddress: Encoded.ContractAddress, matchedEvents: Array<[string, string]>) {\n super(\n `Found multiple definitions of \"${matchedEvents[0][1]}\" event with different types emitted by`\n + ` ${eventAddress} in ${matchedEvents.map(([name]) => `\"${name}\"`).join(', ')} contracts`\n + ' (use contractAddressToName option to specify contract name corresponding to address)',\n );\n this.name = 'AmbiguousEventDefinitionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidChecksumError extends CryptographyError {\n constructor() {\n super('Invalid checksum');\n this.name = 'InvalidChecksumError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidPasswordError extends CryptographyError {\n constructor() {\n super('Invalid password or nonce');\n this.name = 'InvalidPasswordError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MerkleTreeHashMismatchError extends CryptographyError {\n constructor() {\n super('Node hash is not equal to provided one');\n this.name = 'MerkleTreeHashMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingNodeInTreeError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingNodeInTreeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownNodeLengthError extends CryptographyError {\n constructor(nodeLength: number) {\n super(`Unknown node length: ${nodeLength}`);\n this.name = 'UnknownNodeLengthError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownPathNibbleError extends CryptographyError {\n constructor(nibble: number) {\n super(`Unknown path nibble: ${nibble}`);\n this.name = 'UnknownPathNibbleError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DuplicateNodeError extends NodeError {\n constructor(name: string) {\n super(`Node with name ${name} already exist`);\n this.name = 'DuplicateNodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeNotFoundError extends NodeError {\n constructor(message: string) {\n super(message);\n this.name = 'NodeNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DecodeError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'DecodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class PayloadLengthError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'PayloadLengthError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DryRunError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'DryRunError';\n }\n}\n\n/**\n * @category exception\n */\nexport class IllegalBidFeeError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'IllegalBidFeeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidSignatureError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidSignatureError';\n }\n}\n\n/**\n * @category exception\n */\nexport class PrefixNotFoundError extends TransactionError {\n constructor(tag: number) {\n super(`Prefix for id-tag ${tag} not found.`);\n this.name = 'PrefixNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class SchemaNotFoundError extends TransactionError {\n constructor(key: string, version: number) {\n super(`Transaction schema not implemented for tag ${key} version ${version}`);\n this.name = 'SchemaNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TagNotFoundError extends TransactionError {\n constructor(prefix: string) {\n super(`Id tag for prefix ${prefix} not found.`);\n this.name = 'DecodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TxNotInChainError extends TransactionError {\n constructor(txHash: Encoded.TxHash) {\n super(`Transaction ${txHash} is removed from chain`);\n this.name = 'TxNotInChainError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AlreadyConnectedError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'AlreadyConnectedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NoWalletConnectedError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'NoWalletConnectedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class RpcConnectionError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'RpcConnectionError';\n }\n}\n"],"mappings":"AAAA;;AAKA;AACA;AACA;AACA;AACA,OAAO,MAAeA,SAAS,SAASC,KAAK,CAAC;EAC5CC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,WAAW;EACzB;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,SAASL,SAAS,CAAC;EAC1CE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,cAAc;EAC5B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAME,SAAS,SAASN,SAAS,CAAC;EACvCE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,WAAW;EACzB;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMG,SAAS,SAASP,SAAS,CAAC;EACvCE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,WAAW;EACzB;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMI,YAAY,SAASR,SAAS,CAAC;EAC1CE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,cAAc;EAC5B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMK,aAAa,SAAST,SAAS,CAAC;EAC3CE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,eAAe;EAC7B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMM,aAAa,SAASV,SAAS,CAAC;EAC3CE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GA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WAAWA,CAAC+G,GAAW,EAAE1E,OAAe,EAAE;IACxC,KAAK,CAAE,8CAA6C0E,GAAI,YAAW1E,OAAQ,EAAC,CAAC;IAC7E,IAAI,CAACnC,IAAI,GAAG,qBAAqB;EACnC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAM8G,gBAAgB,SAASrG,gBAAgB,CAAC;EACrDX,WAAWA,CAACiD,MAAc,EAAE;IAC1B,KAAK,CAAE,qBAAoBA,MAAO,aAAY,CAAC;IAC/C,IAAI,CAAC/C,IAAI,GAAG,aAAa;EAC3B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAM+G,iBAAiB,SAAStG,gBAAgB,CAAC;EACtDX,WAAWA,CAACkH,MAAsB,EAAE;IAClC,KAAK,CAAE,eAAcA,MAAO,wBAAuB,CAAC;IACpD,IAAI,CAAChH,IAAI,GAAG,mBAAmB;EACjC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMiH,qBAAqB,SAASvG,WAAW,CAAC;EACrDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,uBAAuB;EACrC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMkH,sBAAsB,SAASxG,WAAW,CAAC;EACtDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,wBAAwB;EACtC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMmH,kBAAkB,SAASzG,WAAW,CAAC;EAClDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,oBAAoB;EAClC;AACF"}
1
+ {"version":3,"file":"errors.mjs","names":["BaseError","Error","constructor","message","name","AccountError","AensError","AeppError","ChannelError","CompilerError","ContractError","CryptographyError","NodeError","TransactionError","WalletError","ArgumentError","argumentName","requirement","argumentValue","IllegalArgumentError","ArgumentCountMismatchError","functionName","requiredCount","providedCount","InsufficientBalanceError","MissingParamError","NoSerializerFoundError","RequestTimedOutError","height","TxTimedOutError","blocks","th","join","TypeError","UnsupportedPlatformError","UnsupportedProtocolError","NotImplementedError","UnsupportedVersionError","dependency","version","geVersion","ltVersion","InternalError","UnexpectedTsError","arguments","length","undefined","UnavailableAccountError","address","AensPointerContextError","nameOrId","prefix","InsufficientNameFeeError","nameFee","minNameFee","toString","InvalidAensNameError","InvalidRpcMessageError","MissingCallbackError","id","UnAuthorizedAccountError","onAccount","UnknownRpcClientError","UnsubscribedAccountError","ChannelCallError","ChannelConnectionError","ChannelPingTimedOutError","UnexpectedChannelMessageError","ChannelIncomingMessageError","handlerError","incomingMessage","UnknownChannelStateError","InvalidAuthDataError","BytecodeMismatchError","source","DuplicateContractError","InactiveContractError","contractAddress","InvalidMethodInvocationError","MissingContractAddressError","MissingContractDefError","MissingFunctionNameError","NodeInvocationError","transaction","NoSuchContractFunctionError","NotPayableFunctionError","amount","fn","MissingEventDefinitionError","eventNameHash","eventAddress","AmbiguousEventDefinitionError","matchedEvents","map","_ref","InvalidChecksumError","InvalidPasswordError","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownNodeLengthError","nodeLength","UnknownPathNibbleError","nibble","DuplicateNodeError","NodeNotFoundError","DecodeError","PayloadLengthError","DryRunError","IllegalBidFeeError","InvalidSignatureError","PrefixNotFoundError","tag","SchemaNotFoundError","key","TagNotFoundError","TxNotInChainError","txHash","AlreadyConnectedError","NoWalletConnectedError","RpcConnectionError"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport BigNumber from 'bignumber.js';\nimport { AensName, Int } from '../tx/builder/constants';\nimport * as Encoded from './encoder-types';\n\n/**\n * aepp-sdk originated error\n * @category exception\n */\nexport abstract class BaseError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'BaseError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AccountError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AensError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AensError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AeppError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'AeppError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelError';\n }\n}\n\n/**\n * @category exception\n */\nexport class CompilerError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'CompilerError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ContractError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'ContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class CryptographyError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'CryptographyError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'NodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TransactionError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'TransactionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class WalletError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'WalletError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ArgumentError extends BaseError {\n constructor(argumentName: string, requirement: unknown, argumentValue: unknown) {\n super(`${argumentName} should be ${requirement}, got ${argumentValue} instead`);\n this.name = 'ArgumentError';\n }\n}\n\n/**\n * @category exception\n */\nexport class IllegalArgumentError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'IllegalArgumentError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ArgumentCountMismatchError extends BaseError {\n constructor(functionName: string, requiredCount: number, providedCount: number) {\n super(`${functionName} expects ${requiredCount} arguments, got ${providedCount} instead`);\n this.name = 'ArgumentCountMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InsufficientBalanceError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'InsufficientBalanceError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingParamError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingParamError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NoSerializerFoundError extends BaseError {\n constructor() {\n super('Byte serialization not supported');\n this.name = 'NoSerializerFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class RequestTimedOutError extends BaseError {\n constructor(height: number) {\n super(`Giving up at height ${height}`);\n this.name = 'RequestTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TxTimedOutError extends BaseError {\n constructor(blocks: number, th: Encoded.TxHash) {\n super([\n `Giving up after ${blocks} blocks mined`,\n `transaction hash: ${th}`,\n ].join(', '));\n this.name = 'TxTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TypeError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'TypeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedPlatformError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedPlatformError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedProtocolError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'UnsupportedProtocolError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NotImplementedError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'NotImplementedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsupportedVersionError extends BaseError {\n constructor(dependency: string, version: string, geVersion: string, ltVersion: string) {\n super(`Unsupported ${dependency} version ${version}. Supported: >= ${geVersion} < ${ltVersion}`);\n this.name = 'UnsupportedVersionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InternalError extends BaseError {\n constructor(message: string) {\n super(message);\n this.name = 'InternalError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnexpectedTsError extends InternalError {\n constructor(message = 'Expected to not happen, required for TS') {\n super(message);\n this.name = 'UnexpectedTsError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnavailableAccountError extends AccountError {\n constructor(address: Encoded.AccountAddress) {\n super(`Account for ${address} not available`);\n this.name = 'UnavailableAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AensPointerContextError extends AensError {\n constructor(nameOrId: AensName | Encoded.Name, prefix: string) {\n super(`Name ${nameOrId} don't have pointers for ${prefix}`);\n this.name = 'AensPointerContextError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InsufficientNameFeeError extends AensError {\n constructor(nameFee: BigNumber, minNameFee: BigNumber) {\n super(`the provided fee ${nameFee.toString()} is not enough to execute the claim, required: ${minNameFee.toString()}`);\n this.name = 'InsufficientNameFeeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidAensNameError extends AensError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidAensNameError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidRpcMessageError extends AeppError {\n constructor(message: string) {\n super(`Received invalid message: ${message}`);\n this.name = 'InvalidRpcMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingCallbackError extends AeppError {\n constructor(id: number) {\n super(`Can't find callback for this messageId ${id}`);\n this.name = 'MissingCallbackError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnAuthorizedAccountError extends AeppError {\n constructor(onAccount: Encoded.AccountAddress) {\n super(`You do not have access to account ${onAccount}`);\n this.name = 'UnAuthorizedAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownRpcClientError extends AeppError {\n constructor(id: string) {\n super(`RpcClient with id ${id} do not exist`);\n this.name = 'UnknownRpcClientError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnsubscribedAccountError extends AeppError {\n constructor() {\n super('You are not subscribed for an account.');\n this.name = 'UnsubscribedAccountError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelCallError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelCallError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelConnectionError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'ChannelConnectionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelPingTimedOutError extends ChannelError {\n constructor() {\n super('Server pong timed out');\n this.name = 'ChannelPingTimedOutError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnexpectedChannelMessageError extends ChannelError {\n constructor(message: string) {\n super(message);\n this.name = 'UnexpectedChannelMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class ChannelIncomingMessageError extends ChannelError {\n handlerError: Error;\n\n incomingMessage: { [key: string]: any };\n\n constructor(handlerError: Error, incomingMessage: { [key: string]: any }) {\n super(handlerError.message);\n this.handlerError = handlerError;\n this.incomingMessage = incomingMessage;\n this.name = 'ChannelIncomingMessageError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownChannelStateError extends ChannelError {\n constructor() {\n super('State Channels FSM entered unknown state');\n this.name = 'UnknownChannelStateError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidAuthDataError extends CompilerError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidAuthDataError';\n }\n}\n\n/**\n * @category exception\n */\nexport class BytecodeMismatchError extends ContractError {\n constructor(source: 'source code' | 'bytecode') {\n super(`Contract ${source} do not correspond to the bytecode deployed on the chain`);\n this.name = 'BytecodeMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DuplicateContractError extends ContractError {\n constructor() {\n super('Contract already deployed');\n this.name = 'DuplicateContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InactiveContractError extends ContractError {\n constructor(contractAddress: Encoded.ContractAddress) {\n super(`Contract with address ${contractAddress} not active`);\n this.name = 'InactiveContractError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidMethodInvocationError extends ContractError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidMethodInvocationError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingContractAddressError extends ContractError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingContractAddressError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingContractDefError extends ContractError {\n constructor() {\n super('Either ACI or sourceCode or sourceCodePath is required');\n this.name = 'MissingContractDefError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingFunctionNameError extends ContractError {\n constructor() {\n super('Function name is required');\n this.name = 'MissingFunctionNameError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeInvocationError extends ContractError {\n transaction?: Encoded.Transaction;\n\n constructor(message: string, transaction?: Encoded.Transaction) {\n super(`Invocation failed${message == null ? '' : `: \"${message}\"`}`);\n this.name = 'NodeInvocationError';\n this.transaction = transaction;\n }\n}\n\n/**\n * @category exception\n */\nexport class NoSuchContractFunctionError extends ContractError {\n constructor(name: string) {\n super(`Function ${name} doesn't exist in contract`);\n this.name = 'NoSuchContractFunctionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NotPayableFunctionError extends ContractError {\n constructor(amount: Int, fn: string) {\n super(\n `You try to pay \"${amount}\" to function \"${fn}\" which is not payable. `\n + 'Only payable function can accept coins',\n );\n this.name = 'NotPayableFunctionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingEventDefinitionError extends ContractError {\n constructor(eventNameHash: string, eventAddress: Encoded.ContractAddress) {\n super(\n `Can't find definition of ${eventNameHash} event emitted by ${eventAddress}`\n + ' (use omitUnknown option to ignore events like this)',\n );\n this.name = 'MissingEventDefinitionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AmbiguousEventDefinitionError extends ContractError {\n constructor(eventAddress: Encoded.ContractAddress, matchedEvents: Array<[string, string]>) {\n super(\n `Found multiple definitions of \"${matchedEvents[0][1]}\" event with different types emitted by`\n + ` ${eventAddress} in ${matchedEvents.map(([name]) => `\"${name}\"`).join(', ')} contracts`\n + ' (use contractAddressToName option to specify contract name corresponding to address)',\n );\n this.name = 'AmbiguousEventDefinitionError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidChecksumError extends CryptographyError {\n constructor() {\n super('Invalid checksum');\n this.name = 'InvalidChecksumError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidPasswordError extends CryptographyError {\n constructor() {\n super('Invalid password or nonce');\n this.name = 'InvalidPasswordError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MerkleTreeHashMismatchError extends CryptographyError {\n constructor() {\n super('Node hash is not equal to provided one');\n this.name = 'MerkleTreeHashMismatchError';\n }\n}\n\n/**\n * @category exception\n */\nexport class MissingNodeInTreeError extends CryptographyError {\n constructor(message: string) {\n super(message);\n this.name = 'MissingNodeInTreeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownNodeLengthError extends CryptographyError {\n constructor(nodeLength: number) {\n super(`Unknown node length: ${nodeLength}`);\n this.name = 'UnknownNodeLengthError';\n }\n}\n\n/**\n * @category exception\n */\nexport class UnknownPathNibbleError extends CryptographyError {\n constructor(nibble: number) {\n super(`Unknown path nibble: ${nibble}`);\n this.name = 'UnknownPathNibbleError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DuplicateNodeError extends NodeError {\n constructor(name: string) {\n super(`Node with name ${name} already exist`);\n this.name = 'DuplicateNodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NodeNotFoundError extends NodeError {\n constructor(message: string) {\n super(message);\n this.name = 'NodeNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DecodeError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'DecodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class PayloadLengthError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'PayloadLengthError';\n }\n}\n\n/**\n * @category exception\n */\nexport class DryRunError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'DryRunError';\n }\n}\n\n/**\n * @category exception\n */\nexport class IllegalBidFeeError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'IllegalBidFeeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class InvalidSignatureError extends TransactionError {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidSignatureError';\n }\n}\n\n/**\n * @category exception\n */\nexport class PrefixNotFoundError extends TransactionError {\n constructor(tag: number) {\n super(`Prefix for id-tag ${tag} not found.`);\n this.name = 'PrefixNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class SchemaNotFoundError extends TransactionError {\n constructor(key: string, version: number) {\n super(`Transaction schema not implemented for tag ${key} version ${version}`);\n this.name = 'SchemaNotFoundError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TagNotFoundError extends TransactionError {\n constructor(prefix: string) {\n super(`Id tag for prefix ${prefix} not found.`);\n this.name = 'DecodeError';\n }\n}\n\n/**\n * @category exception\n */\nexport class TxNotInChainError extends TransactionError {\n constructor(txHash: Encoded.TxHash) {\n super(`Transaction ${txHash} is removed from chain`);\n this.name = 'TxNotInChainError';\n }\n}\n\n/**\n * @category exception\n */\nexport class AlreadyConnectedError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'AlreadyConnectedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class NoWalletConnectedError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'NoWalletConnectedError';\n }\n}\n\n/**\n * @category exception\n */\nexport class RpcConnectionError extends WalletError {\n constructor(message: string) {\n super(message);\n this.name = 'RpcConnectionError';\n }\n}\n"],"mappings":"AAAA;;AAKA;AACA;AACA;AACA;AACA,OAAO,MAAeA,SAAS,SAASC,KAAK,CAAC;EAC5CC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,WAAW;EACzB;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,SAASL,SAAS,CAAC;EAC1CE,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,cAAc;EAC5B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAME,SAAS,SAASN,SAAS,CAAC;EACvCE,WAAWA,CAACC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AO,wBAAuB,CAAC;IACpD,IAAI,CAAChH,IAAI,GAAG,mBAAmB;EACjC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMiH,qBAAqB,SAASvG,WAAW,CAAC;EACrDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,uBAAuB;EACrC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMkH,sBAAsB,SAASxG,WAAW,CAAC;EACtDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,wBAAwB;EACtC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMmH,kBAAkB,SAASzG,WAAW,CAAC;EAClDZ,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,oBAAoB;EAClC;AACF"}
@@ -20,3 +20,4 @@ export declare function isKeyOfObject<T extends object>(key: string | number | s
20
20
  export declare function isItemOfArray<T>(item: any, array: readonly T[]): item is T;
21
21
  export declare function isAccountNotFoundError(error: Error): boolean;
22
22
  export type UnionToIntersection<Union> = (Union extends any ? (k: Union) => void : never) extends ((k: infer Intersection) => void) ? Intersection : never;
23
+ export declare function ensureError(error: unknown): asserts error is Error;
@@ -41,4 +41,9 @@ export function isAccountNotFoundError(error) {
41
41
  }
42
42
 
43
43
  // based on https://stackoverflow.com/a/50375286/6176994
44
+
45
+ export function ensureError(error) {
46
+ if (error instanceof Error) return;
47
+ throw error;
48
+ }
44
49
  //# sourceMappingURL=other.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"other.mjs","names":["RestError","pause","duration","Promise","resolve","setTimeout","mapObject","object","fn","Object","fromEntries","entries","map","isWebpack4Buffer","_Buffer","concat","Uint8Array","from","error","concatBuffers","list","totalLength","el","isKeyOfObject","key","isItemOfArray","item","array","includes","isAccountNotFoundError","statusCode","message"],"sources":["../../src/utils/other.ts"],"sourcesContent":["import { RestError } from '@azure/core-rest-pipeline';\n\nexport const pause = async (duration: number): Promise<void> => new Promise((resolve) => {\n setTimeout(resolve, duration);\n});\n\nexport const mapObject = <InputV, OutputV>(\n object: { [k: string]: InputV },\n fn: (\n value: [string, InputV], index: number, array: Array<[string, InputV]>\n ) => [number | string, OutputV],\n): { [k: string]: OutputV } => Object.fromEntries(Object.entries(object).map(fn));\n\n// remove after dropping webpack4 support\nconst isWebpack4Buffer = (() => {\n try {\n Buffer.concat([Uint8Array.from([])]);\n return false;\n } catch (error) {\n return true;\n }\n})();\n\nexport const concatBuffers = isWebpack4Buffer\n ? (list: readonly Uint8Array[], totalLength?: number): Buffer => (\n Buffer.concat(list.map((el) => Buffer.from(el)), totalLength)\n )\n : Buffer.concat;\n\n/**\n * Object key type guard\n * @param key - Maybe object key\n * @param object - Object\n */\nexport function isKeyOfObject<T extends object>(\n key: string | number | symbol,\n object: T,\n): key is keyof T {\n return key in object;\n}\n\n/**\n * Array item type guard\n * @param item - Maybe array item\n * @param array - Array\n */\nexport function isItemOfArray<T>(item: any, array: readonly T[]): item is T {\n return array.includes(item);\n}\n\nexport function isAccountNotFoundError(error: Error): boolean {\n return error instanceof RestError && error.statusCode === 404\n && error.message.includes('Account not found');\n}\n\n// based on https://stackoverflow.com/a/50375286/6176994\nexport type UnionToIntersection<Union> =\n (Union extends any ? (k: Union) => void : never) extends ((k: infer Intersection) => void)\n ? Intersection : never;\n"],"mappings":";;;;AAAA,SAASA,SAAS,QAAQ,2BAA2B;AAErD,OAAO,MAAMC,KAAK,GAAG,MAAOC,QAAgB,IAAoB,IAAIC,OAAO,CAAEC,OAAO,IAAK;EACvFC,UAAU,CAACD,OAAO,EAAEF,QAAQ,CAAC;AAC/B,CAAC,CAAC;AAEF,OAAO,MAAMI,SAAS,GAAGA,CACvBC,MAA+B,EAC/BC,EAE+B,KACFC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACJ,MAAM,CAAC,CAACK,GAAG,CAACJ,EAAE,CAAC,CAAC;;AAEjF;AACA,MAAMK,gBAAgB,GAAG,CAAC,MAAM;EAC9B,IAAI;IACFC,OAAA,CAAOC,MAAM,CAAC,CAACC,UAAU,CAACC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,OAAO,KAAK;EACd,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,OAAO,IAAI;EACb;AACF,CAAC,GAAG;AAEJ,OAAO,MAAMC,aAAa,GAAGN,gBAAgB,GACzC,CAACO,IAA2B,EAAEC,WAAoB,KAClDP,OAAA,CAAOC,MAAM,CAACK,IAAI,CAACR,GAAG,CAAEU,EAAE,IAAKR,OAAA,CAAOG,IAAI,CAACK,EAAE,CAAC,CAAC,EAAED,WAAW,CAC7D,GACCP,OAAA,CAAOC,MAAM;;AAEjB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,aAAaA,CAC3BC,GAA6B,EAC7BjB,MAAS,EACO;EAChB,OAAOiB,GAAG,IAAIjB,MAAM;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASkB,aAAaA,CAAIC,IAAS,EAAEC,KAAmB,EAAa;EAC1E,OAAOA,KAAK,CAACC,QAAQ,CAACF,IAAI,CAAC;AAC7B;AAEA,OAAO,SAASG,sBAAsBA,CAACX,KAAY,EAAW;EAC5D,OAAOA,KAAK,YAAYlB,SAAS,IAAIkB,KAAK,CAACY,UAAU,KAAK,GAAG,IACxDZ,KAAK,CAACa,OAAO,CAACH,QAAQ,CAAC,mBAAmB,CAAC;AAClD;;AAEA"}
1
+ {"version":3,"file":"other.mjs","names":["RestError","pause","duration","Promise","resolve","setTimeout","mapObject","object","fn","Object","fromEntries","entries","map","isWebpack4Buffer","_Buffer","concat","Uint8Array","from","error","concatBuffers","list","totalLength","el","isKeyOfObject","key","isItemOfArray","item","array","includes","isAccountNotFoundError","statusCode","message","ensureError","Error"],"sources":["../../src/utils/other.ts"],"sourcesContent":["import { RestError } from '@azure/core-rest-pipeline';\n\nexport const pause = async (duration: number): Promise<void> => new Promise((resolve) => {\n setTimeout(resolve, duration);\n});\n\nexport const mapObject = <InputV, OutputV>(\n object: { [k: string]: InputV },\n fn: (\n value: [string, InputV], index: number, array: Array<[string, InputV]>\n ) => [number | string, OutputV],\n): { [k: string]: OutputV } => Object.fromEntries(Object.entries(object).map(fn));\n\n// remove after dropping webpack4 support\nconst isWebpack4Buffer = (() => {\n try {\n Buffer.concat([Uint8Array.from([])]);\n return false;\n } catch (error) {\n return true;\n }\n})();\n\nexport const concatBuffers = isWebpack4Buffer\n ? (list: readonly Uint8Array[], totalLength?: number): Buffer => (\n Buffer.concat(list.map((el) => Buffer.from(el)), totalLength)\n )\n : Buffer.concat;\n\n/**\n * Object key type guard\n * @param key - Maybe object key\n * @param object - Object\n */\nexport function isKeyOfObject<T extends object>(\n key: string | number | symbol,\n object: T,\n): key is keyof T {\n return key in object;\n}\n\n/**\n * Array item type guard\n * @param item - Maybe array item\n * @param array - Array\n */\nexport function isItemOfArray<T>(item: any, array: readonly T[]): item is T {\n return array.includes(item);\n}\n\nexport function isAccountNotFoundError(error: Error): boolean {\n return error instanceof RestError && error.statusCode === 404\n && error.message.includes('Account not found');\n}\n\n// based on https://stackoverflow.com/a/50375286/6176994\nexport type UnionToIntersection<Union> =\n (Union extends any ? (k: Union) => void : never) extends ((k: infer Intersection) => void)\n ? Intersection : never;\n\nexport function ensureError(error: unknown): asserts error is Error {\n if (error instanceof Error) return;\n throw error;\n}\n"],"mappings":";;;;AAAA,SAASA,SAAS,QAAQ,2BAA2B;AAErD,OAAO,MAAMC,KAAK,GAAG,MAAOC,QAAgB,IAAoB,IAAIC,OAAO,CAAEC,OAAO,IAAK;EACvFC,UAAU,CAACD,OAAO,EAAEF,QAAQ,CAAC;AAC/B,CAAC,CAAC;AAEF,OAAO,MAAMI,SAAS,GAAGA,CACvBC,MAA+B,EAC/BC,EAE+B,KACFC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACJ,MAAM,CAAC,CAACK,GAAG,CAACJ,EAAE,CAAC,CAAC;;AAEjF;AACA,MAAMK,gBAAgB,GAAG,CAAC,MAAM;EAC9B,IAAI;IACFC,OAAA,CAAOC,MAAM,CAAC,CAACC,UAAU,CAACC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,OAAO,KAAK;EACd,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,OAAO,IAAI;EACb;AACF,CAAC,GAAG;AAEJ,OAAO,MAAMC,aAAa,GAAGN,gBAAgB,GACzC,CAACO,IAA2B,EAAEC,WAAoB,KAClDP,OAAA,CAAOC,MAAM,CAACK,IAAI,CAACR,GAAG,CAAEU,EAAE,IAAKR,OAAA,CAAOG,IAAI,CAACK,EAAE,CAAC,CAAC,EAAED,WAAW,CAC7D,GACCP,OAAA,CAAOC,MAAM;;AAEjB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,aAAaA,CAC3BC,GAA6B,EAC7BjB,MAAS,EACO;EAChB,OAAOiB,GAAG,IAAIjB,MAAM;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASkB,aAAaA,CAAIC,IAAS,EAAEC,KAAmB,EAAa;EAC1E,OAAOA,KAAK,CAACC,QAAQ,CAACF,IAAI,CAAC;AAC7B;AAEA,OAAO,SAASG,sBAAsBA,CAACX,KAAY,EAAW;EAC5D,OAAOA,KAAK,YAAYlB,SAAS,IAAIkB,KAAK,CAACY,UAAU,KAAK,GAAG,IACxDZ,KAAK,CAACa,OAAO,CAACH,QAAQ,CAAC,mBAAmB,CAAC;AAClD;;AAEA;;AAKA,OAAO,SAASI,WAAWA,CAACd,KAAc,EAA0B;EAClE,IAAIA,KAAK,YAAYe,KAAK,EAAE;EAC5B,MAAMf,KAAK;AACb"}
@@ -0,0 +1,45 @@
1
+ /// <reference types="node" />
2
+ import { Encoded } from './encoder';
3
+ /**
4
+ * Hashes arbitrary object, can be used to inline the aci hash to contract source code
5
+ */
6
+ export declare function hashJson(data: unknown): Buffer;
7
+ export type AciValue = 'void' | 'unit' | 'int' | 'bool' | 'string' | 'bits' | 'hash' | 'signature' | 'address' | 'contract_pubkey' | 'Chain.ttl' | 'Chain.ga_meta_tx' | 'Chain.paying_for_tx' | 'Chain.base_tx' | 'AENS.pointee' | 'AENS.name' | 'MCL_BLS12_381.fr' | 'MCL_BLS12_381.fp' | {
8
+ 'Set.set': readonly [AciValue];
9
+ } | {
10
+ bytes: number;
11
+ } | {
12
+ list: readonly [AciValue];
13
+ } | {
14
+ map: readonly [AciValue, AciValue];
15
+ } | {
16
+ tuple: readonly AciValue[];
17
+ } | {
18
+ record: ReadonlyArray<{
19
+ name: string;
20
+ type: AciValue;
21
+ }>;
22
+ } | {
23
+ variant: ReadonlyArray<{
24
+ [key: string]: readonly AciValue[];
25
+ }>;
26
+ } | {
27
+ option: readonly [AciValue];
28
+ } | {
29
+ oracle: readonly [AciValue, AciValue];
30
+ } | {
31
+ oracle_query: readonly [AciValue, AciValue];
32
+ };
33
+ export interface Domain {
34
+ name?: string;
35
+ version?: number;
36
+ networkId?: string;
37
+ contractAddress?: Encoded.ContractAddress;
38
+ }
39
+ export declare function encodeFateValue(value: unknown, aci: AciValue): Encoded.ContractBytearray;
40
+ export declare function decodeFateValue(value: Encoded.ContractBytearray, aci: AciValue): Encoded.ContractBytearray;
41
+ /**
42
+ * Hashes domain object, can be used to inline domain hash to contract source code
43
+ */
44
+ export declare function hashDomain(domain: Domain): Buffer;
45
+ export declare function hashTypedData(data: Encoded.ContractBytearray, aci: AciValue, domain: Domain): Buffer;
@@ -0,0 +1,71 @@
1
+ // js extension is required for mjs build
2
+ // @ts-expect-error see https://github.com/aeternity/aepp-calldata-js/issues/216
3
+ // eslint-disable-next-line import/extensions
4
+ import ContractByteArrayEncoder from '@aeternity/aepp-calldata/src/ContractByteArrayEncoder.js';
5
+ // @ts-expect-error see https://github.com/aeternity/aepp-calldata-js/issues/216
6
+ // eslint-disable-next-line import/extensions
7
+ import AciTypeResolver from '@aeternity/aepp-calldata/src/AciTypeResolver.js';
8
+ import canonicalize from 'canonicalize';
9
+ import { decode } from "./encoder.mjs";
10
+ import { hash, messagePrefixLength } from "./crypto.mjs";
11
+ import { concatBuffers } from "./other.mjs";
12
+ /**
13
+ * Hashes arbitrary object, can be used to inline the aci hash to contract source code
14
+ */
15
+ export function hashJson(data) {
16
+ var _canonicalize;
17
+ return hash((_canonicalize = canonicalize(data)) !== null && _canonicalize !== void 0 ? _canonicalize : '');
18
+ }
19
+
20
+ // TODO: move this type to calldata library https://github.com/aeternity/aepp-calldata-js/issues/215
21
+ // based on https://github.com/aeternity/aepp-calldata-js/blob/82b5a98f9b308482627da8d7484d213e9cf87151/src/AciTypeResolver.js#L129
22
+
23
+ // TODO: replace with api on calldata side https://github.com/aeternity/aepp-calldata-js/issues/216
24
+ export function encodeFateValue(value, aci) {
25
+ const contractByteArrayEncoder = new ContractByteArrayEncoder();
26
+ const aciTypeResolver = new AciTypeResolver([]);
27
+ aciTypeResolver.isCustomType = () => false;
28
+ return contractByteArrayEncoder.encode(aciTypeResolver.resolveType(aci), value);
29
+ }
30
+
31
+ // TODO: replace with api on calldata side https://github.com/aeternity/aepp-calldata-js/issues/216
32
+ export function decodeFateValue(value, aci) {
33
+ const contractByteArrayEncoder = new ContractByteArrayEncoder();
34
+ const aciTypeResolver = new AciTypeResolver([]);
35
+ aciTypeResolver.isCustomType = () => false;
36
+ return contractByteArrayEncoder.decodeWithType(value, aciTypeResolver.resolveType(aci));
37
+ }
38
+
39
+ /**
40
+ * Hashes domain object, can be used to inline domain hash to contract source code
41
+ */
42
+ export function hashDomain(domain) {
43
+ const domainAci = {
44
+ record: [{
45
+ name: 'name',
46
+ type: {
47
+ option: ['string']
48
+ }
49
+ }, {
50
+ name: 'version',
51
+ type: {
52
+ option: ['int']
53
+ }
54
+ }, {
55
+ name: 'networkId',
56
+ type: {
57
+ option: ['string']
58
+ }
59
+ }, {
60
+ name: 'contractAddress',
61
+ type: {
62
+ option: ['contract_pubkey']
63
+ }
64
+ }]
65
+ };
66
+ return hash(decode(encodeFateValue(domain, domainAci)));
67
+ }
68
+ export function hashTypedData(data, aci, domain) {
69
+ return hash(concatBuffers([messagePrefixLength, new Uint8Array([0]), hashDomain(domain), hashJson(aci), hash(decode(data))]));
70
+ }
71
+ //# sourceMappingURL=typed-data.mjs.map