@aeternity/aepp-sdk 12.1.2 → 13.0.0-alpha.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 (475) hide show
  1. package/dist/aepp-sdk.browser-script.js +1 -1
  2. package/dist/aepp-sdk.browser-script.js.map +1 -1
  3. package/dist/aepp-sdk.browser.js +1 -1
  4. package/dist/aepp-sdk.browser.js.map +1 -1
  5. package/dist/aepp-sdk.js +6580 -8860
  6. package/dist/aepp-sdk.js.map +1 -1
  7. package/es/AeSdk.d.ts +7 -3
  8. package/es/AeSdk.mjs +17 -22
  9. package/es/AeSdk.mjs.map +1 -1
  10. package/es/AeSdkAepp.d.ts +6 -5
  11. package/es/AeSdkAepp.mjs +7 -30
  12. package/es/AeSdkAepp.mjs.map +1 -1
  13. package/es/AeSdkBase.d.ts +18 -140
  14. package/es/AeSdkBase.mjs +27 -185
  15. package/es/AeSdkBase.mjs.map +1 -1
  16. package/es/AeSdkMethods.d.ts +124 -0
  17. package/es/AeSdkMethods.mjs +122 -0
  18. package/es/AeSdkMethods.mjs.map +1 -0
  19. package/es/AeSdkWallet.d.ts +7 -21
  20. package/es/AeSdkWallet.mjs +38 -86
  21. package/es/AeSdkWallet.mjs.map +1 -1
  22. package/es/Node.d.ts +7 -12
  23. package/es/Node.mjs +34 -47
  24. package/es/Node.mjs.map +1 -1
  25. package/es/account/Base.d.ts +24 -40
  26. package/es/account/Base.mjs +1 -101
  27. package/es/account/Base.mjs.map +1 -1
  28. package/es/account/Generalized.d.ts +16 -0
  29. package/es/account/Generalized.mjs +111 -0
  30. package/es/account/Generalized.mjs.map +1 -0
  31. package/es/account/Ledger.d.ts +28 -0
  32. package/es/account/Ledger.mjs +101 -0
  33. package/es/account/Ledger.mjs.map +1 -0
  34. package/es/account/LedgerFactory.d.ts +39 -0
  35. package/es/account/LedgerFactory.mjs +81 -0
  36. package/es/account/LedgerFactory.mjs.map +1 -0
  37. package/es/account/Memory.d.ts +13 -17
  38. package/es/account/Memory.mjs +43 -65
  39. package/es/account/Memory.mjs.map +1 -1
  40. package/es/account/Rpc.d.ts +6 -8
  41. package/es/account/Rpc.mjs +14 -32
  42. package/es/account/Rpc.mjs.map +1 -1
  43. package/es/aens.d.ts +3 -3
  44. package/es/aens.mjs +42 -41
  45. package/es/aens.mjs.map +1 -1
  46. package/es/aepp-wallet-communication/connection/Browser.mjs +9 -13
  47. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  48. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +3 -7
  49. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  50. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -1
  51. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -31
  52. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  53. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  54. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +3 -3
  55. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +4 -41
  56. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  57. package/es/aepp-wallet-communication/rpc/types.d.ts +7 -1
  58. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  59. package/es/aepp-wallet-communication/schema.mjs +14 -68
  60. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  61. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
  62. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  63. package/es/apis/compiler/compiler.d.ts +23 -29
  64. package/es/apis/compiler/compiler.mjs +128 -189
  65. package/es/apis/compiler/compiler.mjs.map +1 -1
  66. package/es/apis/compiler/index.mjs.map +1 -1
  67. package/es/apis/compiler/models/index.d.ts +82 -135
  68. package/es/apis/compiler/models/index.mjs +1 -47
  69. package/es/apis/compiler/models/index.mjs.map +1 -1
  70. package/es/apis/compiler/models/mappers.d.ts +8 -8
  71. package/es/apis/compiler/models/mappers.mjs +165 -183
  72. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  73. package/es/apis/compiler/models/parameters.d.ts +0 -1
  74. package/es/apis/compiler/models/parameters.mjs +5 -9
  75. package/es/apis/compiler/models/parameters.mjs.map +1 -1
  76. package/es/apis/node/index.mjs.map +1 -1
  77. package/es/apis/node/models/index.d.ts +48 -48
  78. package/es/apis/node/models/mappers.mjs +12 -6
  79. package/es/apis/node/models/mappers.mjs.map +1 -1
  80. package/es/apis/node/models/parameters.mjs.map +1 -1
  81. package/es/apis/node/node.mjs +43 -84
  82. package/es/apis/node/node.mjs.map +1 -1
  83. package/es/chain.d.ts +1 -1
  84. package/es/chain.mjs +33 -58
  85. package/es/chain.mjs.map +1 -1
  86. package/es/channel/Base.d.ts +195 -0
  87. package/es/channel/Base.mjs +290 -0
  88. package/es/channel/Base.mjs.map +1 -0
  89. package/es/channel/Contract.d.ts +247 -0
  90. package/es/channel/Contract.mjs +420 -0
  91. package/es/channel/Contract.mjs.map +1 -0
  92. package/es/channel/Spend.d.ts +217 -0
  93. package/es/channel/Spend.mjs +383 -0
  94. package/es/channel/Spend.mjs.map +1 -0
  95. package/es/channel/handlers.d.ts +8 -21
  96. package/es/channel/handlers.mjs +141 -891
  97. package/es/channel/handlers.mjs.map +1 -1
  98. package/es/channel/internal.d.ts +27 -21
  99. package/es/channel/internal.mjs +98 -190
  100. package/es/channel/internal.mjs.map +1 -1
  101. package/es/contract/{Compiler.d.ts → CompilerHttp.d.ts} +3 -3
  102. package/es/contract/{Compiler.mjs → CompilerHttp.mjs} +8 -13
  103. package/es/contract/CompilerHttp.mjs.map +1 -0
  104. package/es/contract/Contract.d.ts +235 -0
  105. package/es/contract/Contract.mjs +534 -0
  106. package/es/contract/Contract.mjs.map +1 -0
  107. package/es/contract/ga.d.ts +7 -33
  108. package/es/contract/ga.mjs +20 -112
  109. package/es/contract/ga.mjs.map +1 -1
  110. package/es/index.d.ts +9 -6
  111. package/es/index.mjs +8 -6
  112. package/es/index.mjs.map +1 -1
  113. package/es/oracle.d.ts +5 -5
  114. package/es/oracle.mjs +33 -39
  115. package/es/oracle.mjs.map +1 -1
  116. package/es/spend.d.ts +3 -3
  117. package/es/spend.mjs +17 -20
  118. package/es/spend.mjs.map +1 -1
  119. package/es/tx/builder/constants.d.ts +2 -1
  120. package/es/tx/builder/constants.mjs +12 -12
  121. package/es/tx/builder/constants.mjs.map +1 -1
  122. package/es/tx/builder/field-types/address.d.ts +15 -0
  123. package/es/tx/builder/field-types/address.mjs +42 -0
  124. package/es/tx/builder/field-types/address.mjs.map +1 -0
  125. package/es/tx/builder/field-types/addresses.d.ts +6 -0
  126. package/es/tx/builder/field-types/addresses.mjs +13 -0
  127. package/es/tx/builder/field-types/addresses.mjs.map +1 -0
  128. package/es/tx/builder/field-types/coin-amount.d.ts +1 -2
  129. package/es/tx/builder/field-types/coin-amount.mjs +4 -12
  130. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  131. package/es/tx/builder/field-types/deposit.d.ts +0 -1
  132. package/es/tx/builder/field-types/deposit.mjs +2 -4
  133. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  134. package/es/tx/builder/field-types/enumeration.d.ts +5 -0
  135. package/es/tx/builder/field-types/enumeration.mjs +21 -0
  136. package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
  137. package/es/tx/builder/field-types/fee.d.ts +1 -9
  138. package/es/tx/builder/field-types/fee.mjs +9 -25
  139. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  140. package/es/tx/builder/field-types/field.mjs +0 -2
  141. package/es/tx/builder/field-types/field.mjs.map +1 -1
  142. package/es/tx/builder/field-types/gas-limit.mjs +4 -9
  143. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  144. package/es/tx/builder/field-types/gas-price.d.ts +1 -2
  145. package/es/tx/builder/field-types/gas-price.mjs +3 -7
  146. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  147. package/es/tx/builder/field-types/index.d.ts +23 -11
  148. package/es/tx/builder/field-types/index.mjs +10 -3
  149. package/es/tx/builder/field-types/index.mjs.map +1 -1
  150. package/es/tx/builder/field-types/name-fee.d.ts +0 -1
  151. package/es/tx/builder/field-types/name-fee.mjs +3 -5
  152. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  153. package/es/tx/builder/field-types/name-id.d.ts +1 -4
  154. package/es/tx/builder/field-types/name-id.mjs +4 -10
  155. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  156. package/es/tx/builder/field-types/name.mjs +0 -2
  157. package/es/tx/builder/field-types/name.mjs.map +1 -1
  158. package/es/tx/builder/field-types/pointers.d.ts +23 -0
  159. package/es/tx/builder/field-types/pointers.mjs +36 -0
  160. package/es/tx/builder/field-types/pointers.mjs.map +1 -0
  161. package/es/tx/builder/field-types/short-u-int.mjs +0 -2
  162. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  163. package/es/tx/builder/field-types/u-int.d.ts +1 -1
  164. package/es/tx/builder/field-types/u-int.mjs +3 -4
  165. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  166. package/es/tx/builder/helpers.d.ts +2 -32
  167. package/es/tx/builder/helpers.mjs +19 -71
  168. package/es/tx/builder/helpers.mjs.map +1 -1
  169. package/es/tx/builder/index.d.ts +1 -21
  170. package/es/tx/builder/index.mjs +29 -148
  171. package/es/tx/builder/index.mjs.map +1 -1
  172. package/es/tx/builder/schema.d.ts +336 -176
  173. package/es/tx/builder/schema.mjs +71 -78
  174. package/es/tx/builder/schema.mjs.map +1 -1
  175. package/es/tx/index.d.ts +3 -33
  176. package/es/tx/index.mjs +26 -43
  177. package/es/tx/index.mjs.map +1 -1
  178. package/es/tx/validator.d.ts +2 -2
  179. package/es/tx/validator.mjs +86 -59
  180. package/es/tx/validator.mjs.map +1 -1
  181. package/es/typings/{@aeternity__argon2-browser → @aeternity__aepp-calldata}/index.d.mjs +0 -0
  182. package/es/typings/@aeternity__aepp-calldata/index.d.mjs.map +1 -0
  183. package/es/utils/amount-formatter.mjs +4 -10
  184. package/es/utils/amount-formatter.mjs.map +1 -1
  185. package/es/utils/autorest.d.ts +1 -0
  186. package/es/utils/autorest.mjs +17 -19
  187. package/es/utils/autorest.mjs.map +1 -1
  188. package/es/utils/bignumber.mjs +4 -7
  189. package/es/utils/bignumber.mjs.map +1 -1
  190. package/es/utils/bytes.d.ts +0 -17
  191. package/es/utils/bytes.mjs +6 -35
  192. package/es/utils/bytes.mjs.map +1 -1
  193. package/es/utils/crypto.d.ts +15 -8
  194. package/es/utils/crypto.mjs +40 -40
  195. package/es/utils/crypto.mjs.map +1 -1
  196. package/es/utils/encoder-types.d.ts +28 -28
  197. package/es/utils/encoder-types.mjs +0 -1
  198. package/es/utils/encoder-types.mjs.map +1 -1
  199. package/es/utils/encoder.d.ts +0 -1
  200. package/es/utils/encoder.mjs +7 -15
  201. package/es/utils/encoder.mjs.map +1 -1
  202. package/es/utils/errors.d.ts +12 -6
  203. package/es/utils/errors.mjs +87 -163
  204. package/es/utils/errors.mjs.map +1 -1
  205. package/es/utils/hd-wallet.d.ts +27 -19
  206. package/es/utils/hd-wallet.mjs +42 -26
  207. package/es/utils/hd-wallet.mjs.map +1 -1
  208. package/es/utils/json-big.mjs +0 -8
  209. package/es/utils/json-big.mjs.map +1 -1
  210. package/es/utils/keystore.d.ts +2 -0
  211. package/es/utils/keystore.mjs +37 -36
  212. package/es/utils/keystore.mjs.map +1 -1
  213. package/es/utils/mptree.d.ts +1 -1
  214. package/es/utils/mptree.mjs +4 -26
  215. package/es/utils/mptree.mjs.map +1 -1
  216. package/es/utils/other.d.ts +3 -1
  217. package/es/utils/other.mjs +11 -7
  218. package/es/utils/other.mjs.map +1 -1
  219. package/es/utils/semver-satisfies.mjs +0 -3
  220. package/es/utils/semver-satisfies.mjs.map +1 -1
  221. package/es/utils/string.d.ts +0 -12
  222. package/es/utils/string.mjs +1 -21
  223. package/es/utils/string.mjs.map +1 -1
  224. package/package.json +87 -48
  225. package/src/AeSdk.ts +15 -11
  226. package/src/AeSdkAepp.ts +9 -7
  227. package/src/AeSdkBase.ts +28 -202
  228. package/src/AeSdkMethods.ts +170 -0
  229. package/src/AeSdkWallet.ts +16 -47
  230. package/src/Node.ts +11 -15
  231. package/src/account/Base.ts +29 -75
  232. package/src/account/Generalized.ts +98 -0
  233. package/src/account/Ledger.ts +131 -0
  234. package/src/account/LedgerFactory.ts +86 -0
  235. package/src/account/Memory.ts +46 -60
  236. package/src/account/Rpc.ts +17 -26
  237. package/src/aens.ts +10 -9
  238. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +5 -4
  239. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
  240. package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
  241. package/src/aepp-wallet-communication/rpc/types.ts +11 -1
  242. package/src/aepp-wallet-communication/schema.ts +18 -18
  243. package/src/apis/compiler/code-model-v4.yaml +681 -888
  244. package/src/apis/compiler/compiler.ts +113 -154
  245. package/src/apis/compiler/models/index.ts +80 -140
  246. package/src/apis/compiler/models/mappers.ts +165 -183
  247. package/src/apis/compiler/models/parameters.ts +6 -12
  248. package/src/chain.ts +6 -3
  249. package/src/channel/Base.ts +327 -0
  250. package/src/channel/Contract.ts +487 -0
  251. package/src/channel/Spend.ts +403 -0
  252. package/src/channel/handlers.ts +154 -573
  253. package/src/channel/internal.ts +113 -142
  254. package/src/contract/{Compiler.ts → CompilerHttp.ts} +5 -5
  255. package/src/contract/Contract.ts +620 -0
  256. package/src/contract/ga.ts +18 -104
  257. package/src/index.ts +9 -8
  258. package/src/oracle.ts +7 -7
  259. package/src/spend.ts +5 -13
  260. package/src/tx/builder/constants.ts +1 -0
  261. package/src/tx/builder/field-types/address.ts +52 -0
  262. package/src/tx/builder/field-types/addresses.ts +18 -0
  263. package/src/tx/builder/field-types/coin-amount.ts +2 -8
  264. package/src/tx/builder/field-types/enumeration.ts +21 -0
  265. package/src/tx/builder/field-types/fee.ts +1 -3
  266. package/src/tx/builder/field-types/gas-limit.ts +2 -2
  267. package/src/tx/builder/field-types/gas-price.ts +0 -2
  268. package/src/tx/builder/field-types/index.ts +16 -6
  269. package/src/tx/builder/field-types/name-fee.ts +1 -1
  270. package/src/tx/builder/field-types/name-id.ts +7 -10
  271. package/src/tx/builder/field-types/pointers.ts +41 -0
  272. package/src/tx/builder/field-types/u-int.ts +3 -2
  273. package/src/tx/builder/helpers.ts +10 -60
  274. package/src/tx/builder/index.ts +6 -65
  275. package/src/tx/builder/schema.ts +89 -100
  276. package/src/tx/index.ts +19 -15
  277. package/src/tx/validator.ts +36 -18
  278. package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
  279. package/src/utils/autorest.ts +16 -1
  280. package/src/utils/bytes.ts +5 -33
  281. package/src/utils/crypto.ts +23 -16
  282. package/src/utils/encoder.ts +0 -1
  283. package/src/utils/errors.ts +18 -12
  284. package/src/utils/hd-wallet.ts +30 -9
  285. package/src/utils/keystore.ts +24 -21
  286. package/src/utils/other.ts +16 -1
  287. package/src/utils/string.ts +0 -20
  288. package/types-legacy/ts4.2/AeSdk.d.ts +41 -0
  289. package/types-legacy/ts4.2/AeSdkAepp.d.ts +71 -0
  290. package/types-legacy/ts4.2/AeSdkBase.d.ts +91 -0
  291. package/types-legacy/ts4.2/AeSdkMethods.d.ts +141 -0
  292. package/types-legacy/ts4.2/AeSdkWallet.d.ts +90 -0
  293. package/types-legacy/ts4.2/Node.d.ts +78 -0
  294. package/types-legacy/ts4.2/account/Base.d.ts +52 -0
  295. package/types-legacy/ts4.2/account/Generalized.d.ts +16 -0
  296. package/types-legacy/ts4.2/account/Ledger.d.ts +28 -0
  297. package/types-legacy/ts4.2/account/LedgerFactory.d.ts +39 -0
  298. package/types-legacy/ts4.2/account/Memory.d.ts +22 -0
  299. package/types-legacy/ts4.2/account/Rpc.d.ts +25 -0
  300. package/types-legacy/ts4.2/aens.d.ts +222 -0
  301. package/types-legacy/ts4.2/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  302. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
  303. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  304. package/types-legacy/ts4.2/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  305. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  306. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +83 -0
  307. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +133 -0
  308. package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  309. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +86 -0
  310. package/types-legacy/ts4.2/apis/compiler/index.d.ts +2 -0
  311. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +195 -0
  312. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +23 -0
  313. package/types-legacy/ts4.2/apis/compiler/models/parameters.d.ts +12 -0
  314. package/types-legacy/ts4.2/apis/node/index.d.ts +2 -0
  315. package/types-legacy/ts4.2/apis/node/models/index.d.ts +1065 -0
  316. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +95 -0
  317. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +17 -0
  318. package/types-legacy/ts4.2/apis/node/node.d.ts +215 -0
  319. package/types-legacy/ts4.2/chain.d.ts +248 -0
  320. package/types-legacy/ts4.2/channel/Base.d.ts +194 -0
  321. package/types-legacy/ts4.2/channel/Contract.d.ts +247 -0
  322. package/types-legacy/ts4.2/channel/Spend.d.ts +217 -0
  323. package/types-legacy/ts4.2/channel/handlers.d.ts +21 -0
  324. package/types-legacy/ts4.2/channel/internal.d.ts +107 -0
  325. package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +18 -0
  326. package/types-legacy/ts4.2/contract/Contract.d.ts +237 -0
  327. package/types-legacy/ts4.2/contract/ga.d.ts +43 -0
  328. package/types-legacy/ts4.2/globals.d.ts +16 -0
  329. package/types-legacy/ts4.2/index.d.ts +39 -0
  330. package/types-legacy/ts4.2/oracle.d.ts +161 -0
  331. package/types-legacy/ts4.2/spend.d.ts +62 -0
  332. package/types-legacy/ts4.2/tx/builder/constants.d.ts +71 -0
  333. package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +22 -0
  334. package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +6 -0
  335. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +12 -0
  336. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +14 -0
  337. package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -0
  338. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +17 -0
  339. package/types-legacy/ts4.2/tx/builder/field-types/field.d.ts +6 -0
  340. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +12 -0
  341. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +7 -0
  342. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +85 -0
  343. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +19 -0
  344. package/types-legacy/ts4.2/tx/builder/field-types/name-id.d.ts +11 -0
  345. package/types-legacy/ts4.2/tx/builder/field-types/name.d.ts +13 -0
  346. package/types-legacy/ts4.2/tx/builder/field-types/pointers.d.ts +26 -0
  347. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int.d.ts +6 -0
  348. package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +8 -0
  349. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
  350. package/types-legacy/ts4.2/tx/builder/index.d.ts +68 -0
  351. package/types-legacy/ts4.2/tx/builder/schema.d.ts +2963 -0
  352. package/types-legacy/ts4.2/tx/index.d.ts +34 -0
  353. package/types-legacy/ts4.2/tx/validator.d.ts +20 -0
  354. package/types-legacy/ts4.2/utils/amount-formatter.d.ts +42 -0
  355. package/types-legacy/ts4.2/utils/autorest.d.ts +7 -0
  356. package/types-legacy/ts4.2/utils/bignumber.d.ts +13 -0
  357. package/types-legacy/ts4.2/utils/bytes.d.ts +9 -0
  358. package/types-legacy/ts4.2/utils/crypto.d.ts +95 -0
  359. package/types-legacy/ts4.2/utils/encoder-types.d.ts +61 -0
  360. package/types-legacy/ts4.2/utils/encoder.d.ts +24 -0
  361. package/types-legacy/ts4.2/utils/errors.d.ts +480 -0
  362. package/types-legacy/ts4.2/utils/hd-wallet.d.ts +65 -0
  363. package/types-legacy/ts4.2/utils/json-big.d.ts +5 -0
  364. package/types-legacy/ts4.2/utils/keystore.d.ts +53 -0
  365. package/types-legacy/ts4.2/utils/mptree.d.ts +32 -0
  366. package/types-legacy/ts4.2/utils/other.d.ts +31 -0
  367. package/types-legacy/ts4.2/utils/semver-satisfies.d.ts +1 -0
  368. package/types-legacy/ts4.2/utils/string.d.ts +12 -0
  369. package/types-legacy/ts4.5/AeSdk.d.ts +41 -0
  370. package/types-legacy/ts4.5/AeSdkAepp.d.ts +71 -0
  371. package/types-legacy/ts4.5/AeSdkBase.d.ts +91 -0
  372. package/types-legacy/ts4.5/AeSdkMethods.d.ts +141 -0
  373. package/types-legacy/ts4.5/AeSdkWallet.d.ts +90 -0
  374. package/types-legacy/ts4.5/Node.d.ts +78 -0
  375. package/types-legacy/ts4.5/account/Base.d.ts +52 -0
  376. package/types-legacy/ts4.5/account/Generalized.d.ts +16 -0
  377. package/types-legacy/ts4.5/account/Ledger.d.ts +28 -0
  378. package/types-legacy/ts4.5/account/LedgerFactory.d.ts +39 -0
  379. package/types-legacy/ts4.5/account/Memory.d.ts +22 -0
  380. package/types-legacy/ts4.5/account/Rpc.d.ts +25 -0
  381. package/types-legacy/ts4.5/aens.d.ts +222 -0
  382. package/types-legacy/ts4.5/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  383. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
  384. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  385. package/types-legacy/ts4.5/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  386. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  387. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +83 -0
  388. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +133 -0
  389. package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  390. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +86 -0
  391. package/types-legacy/ts4.5/apis/compiler/index.d.ts +2 -0
  392. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +195 -0
  393. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +23 -0
  394. package/types-legacy/ts4.5/apis/compiler/models/parameters.d.ts +12 -0
  395. package/types-legacy/ts4.5/apis/node/index.d.ts +2 -0
  396. package/types-legacy/ts4.5/apis/node/models/index.d.ts +1065 -0
  397. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +95 -0
  398. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +17 -0
  399. package/types-legacy/ts4.5/apis/node/node.d.ts +215 -0
  400. package/types-legacy/ts4.5/chain.d.ts +248 -0
  401. package/types-legacy/ts4.5/channel/Base.d.ts +194 -0
  402. package/types-legacy/ts4.5/channel/Contract.d.ts +247 -0
  403. package/types-legacy/ts4.5/channel/Spend.d.ts +217 -0
  404. package/types-legacy/ts4.5/channel/handlers.d.ts +21 -0
  405. package/types-legacy/ts4.5/channel/internal.d.ts +107 -0
  406. package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +18 -0
  407. package/types-legacy/ts4.5/contract/Contract.d.ts +237 -0
  408. package/types-legacy/ts4.5/contract/ga.d.ts +43 -0
  409. package/types-legacy/ts4.5/index.d.ts +38 -0
  410. package/types-legacy/ts4.5/oracle.d.ts +161 -0
  411. package/types-legacy/ts4.5/spend.d.ts +62 -0
  412. package/types-legacy/ts4.5/tx/builder/constants.d.ts +71 -0
  413. package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +22 -0
  414. package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +6 -0
  415. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +12 -0
  416. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +14 -0
  417. package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -0
  418. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +17 -0
  419. package/types-legacy/ts4.5/tx/builder/field-types/field.d.ts +6 -0
  420. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +12 -0
  421. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +7 -0
  422. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +85 -0
  423. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +19 -0
  424. package/types-legacy/ts4.5/tx/builder/field-types/name-id.d.ts +11 -0
  425. package/types-legacy/ts4.5/tx/builder/field-types/name.d.ts +13 -0
  426. package/types-legacy/ts4.5/tx/builder/field-types/pointers.d.ts +26 -0
  427. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int.d.ts +6 -0
  428. package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +8 -0
  429. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
  430. package/types-legacy/ts4.5/tx/builder/index.d.ts +68 -0
  431. package/types-legacy/ts4.5/tx/builder/schema.d.ts +2963 -0
  432. package/types-legacy/ts4.5/tx/index.d.ts +34 -0
  433. package/types-legacy/ts4.5/tx/validator.d.ts +20 -0
  434. package/types-legacy/ts4.5/utils/amount-formatter.d.ts +42 -0
  435. package/types-legacy/ts4.5/utils/autorest.d.ts +7 -0
  436. package/types-legacy/ts4.5/utils/bignumber.d.ts +13 -0
  437. package/types-legacy/ts4.5/utils/bytes.d.ts +9 -0
  438. package/types-legacy/ts4.5/utils/crypto.d.ts +95 -0
  439. package/types-legacy/ts4.5/utils/encoder-types.d.ts +61 -0
  440. package/types-legacy/ts4.5/utils/encoder.d.ts +24 -0
  441. package/types-legacy/ts4.5/utils/errors.d.ts +480 -0
  442. package/types-legacy/ts4.5/utils/hd-wallet.d.ts +65 -0
  443. package/types-legacy/ts4.5/utils/json-big.d.ts +5 -0
  444. package/types-legacy/ts4.5/utils/keystore.d.ts +53 -0
  445. package/types-legacy/ts4.5/utils/mptree.d.ts +32 -0
  446. package/types-legacy/ts4.5/utils/other.d.ts +31 -0
  447. package/types-legacy/ts4.5/utils/semver-satisfies.d.ts +1 -0
  448. package/types-legacy/ts4.5/utils/string.d.ts +12 -0
  449. package/es/channel/index.d.ts +0 -625
  450. package/es/channel/index.mjs +0 -975
  451. package/es/channel/index.mjs.map +0 -1
  452. package/es/contract/Compiler.mjs.map +0 -1
  453. package/es/contract/aci.d.ts +0 -127
  454. package/es/contract/aci.mjs +0 -509
  455. package/es/contract/aci.mjs.map +0 -1
  456. package/es/contract/methods.d.ts +0 -71
  457. package/es/contract/methods.mjs +0 -104
  458. package/es/contract/methods.mjs.map +0 -1
  459. package/es/deprecated/index.d.ts +0 -143
  460. package/es/deprecated/index.mjs +0 -162
  461. package/es/deprecated/index.mjs.map +0 -1
  462. package/es/deprecated/methods.d.ts +0 -18
  463. package/es/deprecated/methods.mjs +0 -26
  464. package/es/deprecated/methods.mjs.map +0 -1
  465. package/es/tx/builder/address.d.ts +0 -25
  466. package/es/tx/builder/address.mjs +0 -45
  467. package/es/tx/builder/address.mjs.map +0 -1
  468. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +0 -1
  469. package/src/channel/index.ts +0 -1025
  470. package/src/contract/aci.ts +0 -538
  471. package/src/contract/methods.ts +0 -123
  472. package/src/deprecated/index.ts +0 -172
  473. package/src/deprecated/methods.ts +0 -25
  474. package/src/tx/builder/address.ts +0 -50
  475. package/src/typings/@aeternity__argon2-browser/index.d.ts +0 -3
@@ -18,10 +18,10 @@ import BigNumber from 'bignumber.js';
18
18
  import { isBigNumber } from "./bignumber.mjs";
19
19
  import { ArgumentError } from "./errors.mjs";
20
20
  export let AE_AMOUNT_FORMATS;
21
+
21
22
  /**
22
23
  * DENOMINATION_MAGNITUDE
23
24
  */
24
-
25
25
  (function (AE_AMOUNT_FORMATS) {
26
26
  AE_AMOUNT_FORMATS["AE"] = "ae";
27
27
  AE_AMOUNT_FORMATS["MILI_AE"] = "miliAE";
@@ -31,7 +31,6 @@ export let AE_AMOUNT_FORMATS;
31
31
  AE_AMOUNT_FORMATS["FEMTO_AE"] = "femtoAE";
32
32
  AE_AMOUNT_FORMATS["AETTOS"] = "aettos";
33
33
  })(AE_AMOUNT_FORMATS || (AE_AMOUNT_FORMATS = {}));
34
-
35
34
  const DENOMINATION_MAGNITUDE = {
36
35
  [AE_AMOUNT_FORMATS.AE]: 0,
37
36
  [AE_AMOUNT_FORMATS.MILI_AE]: -3,
@@ -41,6 +40,7 @@ const DENOMINATION_MAGNITUDE = {
41
40
  [AE_AMOUNT_FORMATS.FEMTO_AE]: -15,
42
41
  [AE_AMOUNT_FORMATS.AETTOS]: -18
43
42
  };
43
+
44
44
  /**
45
45
  * Convert amount from one to other denomination
46
46
  * @param value - amount to convert
@@ -49,7 +49,6 @@ const DENOMINATION_MAGNITUDE = {
49
49
  * @param options.targetDenomination - target denomination,
50
50
  * can be ['ae', 'aettos']
51
51
  */
52
-
53
52
  export const formatAmount = (value, _ref) => {
54
53
  let {
55
54
  denomination = AE_AMOUNT_FORMATS.AETTOS,
@@ -58,13 +57,13 @@ export const formatAmount = (value, _ref) => {
58
57
  if (!isBigNumber(value)) throw new ArgumentError('value', 'a number', value);
59
58
  return new BigNumber(typeof value === 'bigint' ? value.toString() : value).shiftedBy(DENOMINATION_MAGNITUDE[denomination] - DENOMINATION_MAGNITUDE[targetDenomination]).toFixed();
60
59
  };
60
+
61
61
  /**
62
62
  * Convert amount to AE
63
63
  * @param value - amount to convert
64
64
  * @param options - options
65
65
  * @param options.denomination - denomination of amount, can be ['ae', 'aettos']
66
66
  */
67
-
68
67
  export const toAe = function (value) {
69
68
  let {
70
69
  denomination = AE_AMOUNT_FORMATS.AETTOS
@@ -74,13 +73,13 @@ export const toAe = function (value) {
74
73
  targetDenomination: AE_AMOUNT_FORMATS.AE
75
74
  });
76
75
  };
76
+
77
77
  /**
78
78
  * Convert amount to aettos
79
79
  * @param value - amount to convert
80
80
  * @param options - options
81
81
  * @param options.denomination - denomination of amount, can be ['ae', 'aettos']
82
82
  */
83
-
84
83
  export const toAettos = function (value) {
85
84
  let {
86
85
  denomination = AE_AMOUNT_FORMATS.AE
@@ -102,18 +101,13 @@ const prefixes = [{
102
101
  name: 'pico',
103
102
  magnitude: -12
104
103
  }];
105
-
106
104
  const getNearestPrefix = exponent => prefixes.reduce((p, n) => Math.abs(n.magnitude - exponent) < Math.abs(p.magnitude - exponent) ? n : p);
107
-
108
105
  const getLowerBoundPrefix = exponent => {
109
106
  var _prefixes$find;
110
-
111
107
  return (_prefixes$find = prefixes.find(p => p.magnitude <= exponent)) !== null && _prefixes$find !== void 0 ? _prefixes$find : prefixes[prefixes.length - 1];
112
108
  };
113
-
114
109
  export default (rawValue => {
115
110
  var _value$e;
116
-
117
111
  const value = new BigNumber(rawValue);
118
112
  const exp = (_value$e = value.e) !== null && _value$e !== void 0 ? _value$e : 0;
119
113
  const {
@@ -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","denomination","targetDenomination","toString","shiftedBy","toFixed","toAe","toAettos","prefixes","name","magnitude","getNearestPrefix","exponent","reduce","p","n","Math","abs","getLowerBoundPrefix","find","length","rawValue","exp","e","v","precision","min"],"sources":["../../src/utils/amount-formatter.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport 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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAP,MAAsB,cAAtB;SACSC,W;SACAC,a;AAET,WAAYC,iBAAZ;AAUA;AACA;AACA;;WAZYA,iB;EAAAA,iB;EAAAA,iB;EAAAA,iB;EAAAA,iB;EAAAA,iB;EAAAA,iB;EAAAA,iB;GAAAA,iB,KAAAA,iB;;AAaZ,MAAMC,sBAAsB,GAAG;EAC7B,CAACD,iBAAiB,CAACE,EAAnB,GAAwB,CADK;EAE7B,CAACF,iBAAiB,CAACG,OAAnB,GAA6B,CAAC,CAFD;EAG7B,CAACH,iBAAiB,CAACI,QAAnB,GAA8B,CAAC,CAHF;EAI7B,CAACJ,iBAAiB,CAACK,OAAnB,GAA6B,CAAC,CAJD;EAK7B,CAACL,iBAAiB,CAACM,OAAnB,GAA6B,CAAC,EALD;EAM7B,CAACN,iBAAiB,CAACO,QAAnB,GAA8B,CAAC,EANF;EAO7B,CAACP,iBAAiB,CAACQ,MAAnB,GAA4B,CAAC;AAPA,CAA/B;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,YAAY,GAAG,CAC1BC,KAD0B,WAIf;EAAA,IAFX;IAAEC,YAAY,GAAGX,iBAAiB,CAACQ,MAAnC;IAA2CI,kBAAkB,GAAGZ,iBAAiB,CAACQ;EAAlF,CAEW;EACX,IAAI,CAACV,WAAW,CAACY,KAAD,CAAhB,EAAyB,MAAM,IAAIX,aAAJ,CAAkB,OAAlB,EAA2B,UAA3B,EAAuCW,KAAvC,CAAN;EAEzB,OAAO,IAAIb,SAAJ,CAAc,OAAOa,KAAP,KAAiB,QAAjB,GAA4BA,KAAK,CAACG,QAAN,EAA5B,GAA+CH,KAA7D,EACJI,SADI,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BAA8BJ,QAAQ,CAC/DW,IADuD,CACjDL,CAAD,IAAOA,CAAC,CAACJ,SAAF,IAAeE,QAD4B,CAA9B,2DACeJ,QAAQ,CAACA,QAAQ,CAACY,MAAT,GAAkB,CAAnB,CADvB;AAAA,CAA5B;;AAGA,gBAAgBC,QAAD,IAAmD;EAAA;;EAChE,MAAMrB,KAAgB,GAAG,IAAIb,SAAJ,CAAckC,QAAd,CAAzB;EAEA,MAAMC,GAAG,eAAGtB,KAAK,CAACuB,CAAT,+CAAc,CAAvB;EACA,MAAM;IAAEd,IAAF;IAAQC;EAAR,IAAsB,CAACY,GAAG,GAAG,CAAN,GAAUX,gBAAV,GAA6BO,mBAA9B,EAAmDI,GAAnD,CAA5B;EACA,MAAME,CAAC,GAAGxB,KAAK,CACZI,SADO,CACG,CAACM,SADJ,EAEPe,SAFO,CAEG,IAAIT,IAAI,CAACU,GAAL,CAASJ,GAAG,GAAGZ,SAAf,EAA0B,CAA1B,CAFP,EAGPL,OAHO,EAAV;EAIA,OAAQ,GAAEmB,CAAE,GAAEf,IAAI,KAAK,EAAT,GAAc,GAAd,GAAoB,EAAG,GAAEA,IAAK,EAA5C;AACD,CAVD"}
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","denomination","targetDenomination","toString","shiftedBy","toFixed","toAe","toAettos","prefixes","name","magnitude","getNearestPrefix","exponent","reduce","p","n","Math","abs","getLowerBoundPrefix","find","length","rawValue","exp","e","v","precision","min"],"sources":["../../src/utils/amount-formatter.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport 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;AACA;AACA;AACA;AACA;AACA;AACA;A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J,QAAQ,CAACA,QAAQ,CAACY,MAAM,GAAG,CAAC,CAAC;AAAA;AAExE,gBAAgBC,QAAqC,IAAa;EAAA;EAChE,MAAMrB,KAAgB,GAAG,IAAIb,SAAS,CAACkC,QAAQ,CAAC;EAEhD,MAAMC,GAAG,eAAGtB,KAAK,CAACuB,CAAC,+CAAI,CAAC;EACxB,MAAM;IAAEd,IAAI;IAAEC;EAAU,CAAC,GAAG,CAACY,GAAG,GAAG,CAAC,GAAGX,gBAAgB,GAAGO,mBAAmB,EAAEI,GAAG,CAAC;EACnF,MAAME,CAAC,GAAGxB,KAAK,CACZI,SAAS,CAAC,CAACM,SAAS,CAAC,CACrBe,SAAS,CAAC,CAAC,GAAGT,IAAI,CAACU,GAAG,CAACJ,GAAG,GAAGZ,SAAS,EAAE,CAAC,CAAC,CAAC,CAC3CL,OAAO,EAAE;EACZ,OAAQ,GAAEmB,CAAE,GAAEf,IAAI,KAAK,EAAE,GAAG,GAAG,GAAG,EAAG,GAAEA,IAAK,EAAC;AAC/C,CAAC"}
@@ -2,5 +2,6 @@ import { PipelinePolicy } from '@azure/core-rest-pipeline';
2
2
  import { AdditionalPolicyConfig } from '@azure/core-client';
3
3
  export declare const genRequestQueuesPolicy: () => AdditionalPolicyConfig;
4
4
  export declare const genCombineGetRequestsPolicy: () => AdditionalPolicyConfig;
5
+ export declare const genAggressiveCacheGetResponsesPolicy: () => PipelinePolicy;
5
6
  export declare const genErrorFormatterPolicy: (getMessage: (b: any) => string) => AdditionalPolicyConfig;
6
7
  export declare const genVersionCheckPolicy: (name: string, ignorePath: string, versionPromise: Promise<string>, geVersion: string, ltVersion: string) => PipelinePolicy;
@@ -7,23 +7,18 @@ export const genRequestQueuesPolicy = () => {
7
7
  return {
8
8
  policy: {
9
9
  name: 'request-queues',
10
-
11
10
  async sendRequest(request, next) {
12
11
  var _requestQueues$get;
13
-
14
12
  const key = request.headers.get('__queue');
15
13
  request.headers.delete('__queue');
16
-
17
14
  const getResponse = async () => next(request);
18
-
19
15
  if (key == null) return getResponse();
20
- const req = ((_requestQueues$get = requestQueues.get(key)) !== null && _requestQueues$get !== void 0 ? _requestQueues$get : Promise.resolve()).then(getResponse, getResponse); // TODO: remove after fixing https://github.com/aeternity/aeternity/issues/3803
16
+ const req = ((_requestQueues$get = requestQueues.get(key)) !== null && _requestQueues$get !== void 0 ? _requestQueues$get : Promise.resolve()).then(getResponse, getResponse);
17
+ // TODO: remove after fixing https://github.com/aeternity/aeternity/issues/3803
21
18
  // gap to ensure that node won't reject the nonce
22
-
23
19
  requestQueues.set(key, req.then(async () => pause(750)));
24
20
  return req;
25
21
  }
26
-
27
22
  },
28
23
  position: 'perCall'
29
24
  };
@@ -32,66 +27,69 @@ export const genCombineGetRequestsPolicy = () => {
32
27
  const pendingGetRequests = new Map();
33
28
  return {
34
29
  policy: {
35
- name: 'combine-requests',
36
-
30
+ name: 'combine-get-requests',
37
31
  async sendRequest(request, next) {
38
32
  var _pendingGetRequests$g;
39
-
40
33
  if (request.method !== 'GET') return next(request);
41
34
  const key = JSON.stringify([request.url, request.body]);
42
35
  const response = (_pendingGetRequests$g = pendingGetRequests.get(key)) !== null && _pendingGetRequests$g !== void 0 ? _pendingGetRequests$g : next(request);
43
36
  pendingGetRequests.set(key, response);
44
-
45
37
  try {
46
38
  return await response;
47
39
  } finally {
48
40
  pendingGetRequests.delete(key);
49
41
  }
50
42
  }
51
-
52
43
  },
53
44
  position: 'perCall'
54
45
  };
55
46
  };
47
+ export const genAggressiveCacheGetResponsesPolicy = () => {
48
+ const getRequests = new Map();
49
+ return {
50
+ name: 'aggressive-cache-get-responses',
51
+ async sendRequest(request, next) {
52
+ var _getRequests$get;
53
+ if (request.method !== 'GET') return next(request);
54
+ const key = JSON.stringify([request.url, request.body]);
55
+ const response = (_getRequests$get = getRequests.get(key)) !== null && _getRequests$get !== void 0 ? _getRequests$get : next(request);
56
+ getRequests.set(key, response);
57
+ return response;
58
+ }
59
+ };
60
+ };
56
61
  export const genErrorFormatterPolicy = getMessage => ({
57
62
  policy: {
58
63
  name: 'error-formatter',
59
-
60
64
  async sendRequest(request, next) {
61
65
  try {
62
66
  return await next(request);
63
67
  } catch (error) {
64
68
  var _error$response;
65
-
66
69
  if (!(error instanceof RestError) || error.request == null) throw error;
67
70
  if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.bodyAsText) == null) throw error;
68
71
  let body;
69
-
70
72
  try {
71
73
  body = JSON.parse(error.response.bodyAsText);
72
74
  } catch (e) {
73
75
  throw error;
74
76
  }
75
-
76
77
  error.message = `${new URL(error.request.url).pathname.slice(1)} error`;
77
78
  const message = getMessage(body);
78
79
  if (message !== '') error.message += `:${message}`;
79
80
  throw error;
80
81
  }
81
82
  }
82
-
83
83
  },
84
84
  position: 'perCall'
85
85
  });
86
86
  export const genVersionCheckPolicy = (name, ignorePath, versionPromise, geVersion, ltVersion) => ({
87
87
  name: 'version-check',
88
-
89
88
  async sendRequest(request, next) {
90
89
  if (new URL(request.url).pathname === ignorePath) return next(request);
91
90
  const args = [await versionPromise, geVersion, ltVersion];
92
91
  if (!semverSatisfies(...args)) throw new UnsupportedVersionError(name, ...args);
93
92
  return next(request);
94
93
  }
95
-
96
94
  });
97
95
  //# sourceMappingURL=autorest.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"autorest.mjs","names":["RestError","pause","semverSatisfies","UnsupportedVersionError","genRequestQueuesPolicy","requestQueues","Map","policy","name","sendRequest","request","next","key","headers","get","delete","getResponse","req","Promise","resolve","then","set","position","genCombineGetRequestsPolicy","pendingGetRequests","method","JSON","stringify","url","body","response","genErrorFormatterPolicy","getMessage","error","bodyAsText","parse","e","message","URL","pathname","slice","genVersionCheckPolicy","ignorePath","versionPromise","geVersion","ltVersion","args"],"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-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 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>,\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 args = [await versionPromise, geVersion, ltVersion] as const;\n if (!semverSatisfies(...args)) throw new UnsupportedVersionError(name, ...args);\n return next(request);\n },\n});\n"],"mappings":"AAAA,SAASA,SAAT,QAA4D,2BAA5D;SAESC,K;OACFC,e;SACEC,uB;AAET,OAAO,MAAMC,sBAAsB,GAAG,MAA8B;EAClE,MAAMC,aAAa,GAAG,IAAIC,GAAJ,EAAtB;EAEA,OAAO;IACLC,MAAM,EAAE;MACNC,IAAI,EAAE,gBADA;;MAEN,MAAMC,WAAN,CAAkBC,OAAlB,EAA2BC,IAA3B,EAAiC;QAAA;;QAC/B,MAAMC,GAAG,GAAGF,OAAO,CAACG,OAAR,CAAgBC,GAAhB,CAAoB,SAApB,CAAZ;QACAJ,OAAO,CAACG,OAAR,CAAgBE,MAAhB,CAAuB,SAAvB;;QACA,MAAMC,WAAW,GAAG,YAAuCL,IAAI,CAACD,OAAD,CAA/D;;QACA,IAAIE,GAAG,IAAI,IAAX,EAAiB,OAAOI,WAAW,EAAlB;QACjB,MAAMC,GAAG,GAAG,uBAACZ,aAAa,CAACS,GAAd,CAAkBF,GAAlB,CAAD,mEAA2BM,OAAO,CAACC,OAAR,EAA3B,EAA8CC,IAA9C,CAAmDJ,WAAnD,EAAgEA,WAAhE,CAAZ,CAL+B,CAM/B;QACA;;QACAX,aAAa,CAACgB,GAAd,CAAkBT,GAAlB,EAAuBK,GAAG,CAACG,IAAJ,CAAS,YAAYnB,KAAK,CAAC,GAAD,CAA1B,CAAvB;QACA,OAAOgB,GAAP;MACD;;IAZK,CADH;IAeLK,QAAQ,EAAE;EAfL,CAAP;AAiBD,CApBM;AAsBP,OAAO,MAAMC,2BAA2B,GAAG,MAA8B;EACvE,MAAMC,kBAAkB,GAAG,IAAIlB,GAAJ,EAA3B;EAEA,OAAO;IACLC,MAAM,EAAE;MACNC,IAAI,EAAE,kBADA;;MAEN,MAAMC,WAAN,CAAkBC,OAAlB,EAA2BC,IAA3B,EAAiC;QAAA;;QAC/B,IAAID,OA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,EAA2BW,QAA3B,CAAoCC,KAApC,CAA0C,CAA1C,CAA6C,QAAhE;QACA,MAAMH,OAAO,GAAGL,UAAU,CAACH,IAAD,CAA1B;QACA,IAAIQ,OAAO,KAAK,EAAhB,EAAoBJ,KAAK,CAACI,OAAN,IAAkB,IAAGA,OAAQ,EAA7B;QACpB,MAAMJ,KAAN;MACD;IACF;;EApBK,CADoB;EAuB5BX,QAAQ,EAAE;AAvBkB,CAFS,CAAhC;AA4BP,OAAO,MAAMmB,qBAAqB,GAAG,CACnCjC,IADmC,EAEnCkC,UAFmC,EAGnCC,cAHmC,EAInCC,SAJmC,EAKnCC,SALmC,MAMf;EACpBrC,IAAI,EAAE,eADc;;EAEpB,MAAMC,WAAN,CAAkBC,OAAlB,EAA2BC,IAA3B,EAAiC;IAC/B,IAAI,IAAI2B,GAAJ,CAAQ5B,OAAO,CAACkB,GAAhB,EAAqBW,QAArB,KAAkCG,UAAtC,EAAkD,OAAO/B,IAAI,CAACD,OAAD,CAAX;IAClD,MAAMoC,IAAI,GAAG,CAAC,MAAMH,cAAP,EAAuBC,SAAvB,EAAkCC,SAAlC,CAAb;IACA,IAAI,CAAC3C,eAAe,CAAC,GAAG4C,IAAJ,CAApB,EAA+B,MAAM,IAAI3C,uBAAJ,CAA4BK,IAA5B,EAAkC,GAAGsC,IAArC,CAAN;IAC/B,OAAOnC,IAAI,CAACD,OAAD,CAAX;EACD;;AAPmB,CANe,CAA9B"}
1
+ {"version":3,"file":"autorest.mjs","names":["RestError","pause","semverSatisfies","UnsupportedVersionError","genRequestQueuesPolicy","requestQueues","Map","policy","name","sendRequest","request","next","key","headers","get","delete","getResponse","req","Promise","resolve","then","set","position","genCombineGetRequestsPolicy","pendingGetRequests","method","JSON","stringify","url","body","response","genAggressiveCacheGetResponsesPolicy","getRequests","genErrorFormatterPolicy","getMessage","error","bodyAsText","parse","e","message","URL","pathname","slice","genVersionCheckPolicy","ignorePath","versionPromise","geVersion","ltVersion","args"],"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 = (): PipelinePolicy => {\n const getRequests = new Map<string, Promise<PipelineResponse>>();\n\n return {\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};\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>,\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 args = [await versionPromise, geVersion, ltVersion] as const;\n if (!semverSatisfies(...args)) throw new UnsupportedVersionError(name, ...args);\n return next(request);\n },\n});\n"],"mappings":"AAAA,SAASA,SAAS,QAA0C,2BAA2B;AAAC,SAE/EC,KAAK;AAAA,OACPC,eAAe;AAAA,SACbC,uBAAuB;AAEhC,OAAO,MAAMC,sBAAsB,GAAG,MAA8B;EAClE,MAAMC,aAAa,GAAG,IAAIC,GAAG,EAA4B;EAEzD,OAAO;IACLC,MAAM,EAAE;MACNC,IAAI,EAAE,gBAAgB;MACtB,MAAMC,WAAW,CAACC,OAAO,EAAEC,IAAI,EAAE;QAAA;QAC/B,MAAMC,GAAG,GAAGF,OAAO,CAACG,OAAO,CAACC,GAAG,CAAC,SAAS,CAAC;QAC1CJ,OAAO,CAACG,OAAO,CAACE,MAAM,CAAC,SAAS,CAAC;QACjC,MAAMC,WAAW,GAAG,YAAuCL,IAAI,CAACD,OAAO,CAAC;QACxE,IAAIE,GAAG,IAAI,IAAI,EAAE,OAAOI,WAAW,EAAE;QACrC,MAAMC,GAAG,GAAG,uBAACZ,aAAa,CAACS,GAAG,CAACF,GAAG,CAAC,mEAAIM,OAAO,CAACC,OAAO,EAAE,EAAEC,IAAI,CAACJ,WAAW,EAAEA,WAAW,CAAC;QACxF;QACA;QACAX,aAAa,CAACgB,GAAG,CAACT,GAAG,EAAEK,GAAG,CAACG,IA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,EACZoC,UAAkB,EAClBC,cAA+B,EAC/BC,SAAiB,EACjBC,SAAiB,MACG;EACpBvC,IAAI,EAAE,eAAe;EACrB,MAAMC,WAAW,CAACC,OAAO,EAAEC,IAAI,EAAE;IAC/B,IAAI,IAAI6B,GAAG,CAAC9B,OAAO,CAACkB,GAAG,CAAC,CAACa,QAAQ,KAAKG,UAAU,EAAE,OAAOjC,IAAI,CAACD,OAAO,CAAC;IACtE,MAAMsC,IAAI,GAAG,CAAC,MAAMH,cAAc,EAAEC,SAAS,EAAEC,SAAS,CAAU;IAClE,IAAI,CAAC7C,eAAe,CAAC,GAAG8C,IAAI,CAAC,EAAE,MAAM,IAAI7C,uBAAuB,CAACK,IAAI,EAAE,GAAGwC,IAAI,CAAC;IAC/E,OAAOrC,IAAI,CAACD,OAAO,CAAC;EACtB;AACF,CAAC,CAAC"}
@@ -1,24 +1,21 @@
1
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
2
-
3
1
  /**
4
2
  * Big Number Helpers
5
3
  */
6
4
  import BigNumber from 'bignumber.js';
5
+
7
6
  /**
8
7
  * Check if value is BigNumber, Number, BigInt or number string representation
9
8
  * @param number - number to check
10
9
  */
11
-
12
10
  export const isBigNumber = number => {
13
- var _context;
14
-
15
11
  if (typeof number === 'bigint') return true;
16
- return _includesInstanceProperty(_context = ['number', 'object', 'string']).call(_context, typeof number) // eslint-disable-next-line no-restricted-globals
12
+ return ['number', 'object', 'string'].includes(typeof number)
13
+ // eslint-disable-next-line no-restricted-globals
17
14
  && (!isNaN(number) || Number.isInteger(number) || BigNumber.isBigNumber(number));
18
15
  };
16
+
19
17
  /**
20
18
  * BigNumber ceil operation
21
19
  */
22
-
23
20
  export const ceil = bigNumber => bigNumber.integerValue(BigNumber.ROUND_CEIL);
24
21
  //# sourceMappingURL=bignumber.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bignumber.mjs","names":["BigNumber","isBigNumber","number","isNaN","Number","isInteger","ceil","bigNumber","integerValue","ROUND_CEIL"],"sources":["../../src/utils/bignumber.ts"],"sourcesContent":["/**\n * Big Number Helpers\n */\nimport BigNumber from 'bignumber.js';\n\n/**\n * Check if value is BigNumber, Number, BigInt or number string representation\n * @param number - number to check\n */\nexport const isBigNumber = (number: string | number | bigint | BigNumber): boolean => {\n if (typeof number === 'bigint') return true;\n return ['number', 'object', 'string'].includes(typeof number)\n // eslint-disable-next-line no-restricted-globals\n && (!isNaN(number as number) || Number.isInteger(number) || BigNumber.isBigNumber(number));\n};\n\n/**\n * BigNumber ceil operation\n */\nexport const ceil = (bigNumber: BigNumber): BigNumber => bigNumber\n .integerValue(BigNumber.ROUND_CEIL);\n"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,SAAP,MAAsB,cAAtB;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAIC,MAAD,IAA2D;EAAA;;EACpF,IAAI,OAAOA,MAAP,KAAkB,QAAtB,EAAgC,OAAO,IAAP;EAChC,OAAO,sCAAC,QAAD,EAAW,QAAX,EAAqB,QAArB,kBAAwC,OAAOA,MAA/C,EACL;EADK,IAED,CAACC,KAAK,CAACD,MAAD,CAAN,IAA4BE,MAAM,CAACC,SAAP,CAAiBH,MAAjB,CAA5B,IAAwDF,SAAS,CAACC,WAAV,CAAsBC,MAAtB,CAFvD,CAAP;AAGD,CALM;AAOP;AACA;AACA;;AACA,OAAO,MAAMI,IAAI,GAAIC,SAAD,IAAqCA,SAAS,CAC/DC,YADsD,CACzCR,SAAS,CAACS,UAD+B,CAAlD"}
1
+ {"version":3,"file":"bignumber.mjs","names":["BigNumber","isBigNumber","number","includes","isNaN","Number","isInteger","ceil","bigNumber","integerValue","ROUND_CEIL"],"sources":["../../src/utils/bignumber.ts"],"sourcesContent":["/**\n * Big Number Helpers\n */\nimport BigNumber from 'bignumber.js';\n\n/**\n * Check if value is BigNumber, Number, BigInt or number string representation\n * @param number - number to check\n */\nexport const isBigNumber = (number: string | number | bigint | BigNumber): boolean => {\n if (typeof number === 'bigint') return true;\n return ['number', 'object', 'string'].includes(typeof number)\n // eslint-disable-next-line no-restricted-globals\n && (!isNaN(number as number) || Number.isInteger(number) || BigNumber.isBigNumber(number));\n};\n\n/**\n * BigNumber ceil operation\n */\nexport const ceil = (bigNumber: BigNumber): BigNumber => bigNumber\n .integerValue(BigNumber.ROUND_CEIL);\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,cAAc;;AAEpC;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAIC,MAA4C,IAAc;EACpF,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE,OAAO,IAAI;EAC3C,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAACC,QAAQ,CAAC,OAAOD,MAAM;EAC1D;EAAA,IACI,CAACE,KAAK,CAACF,MAAM,CAAW,IAAIG,MAAM,CAACC,SAAS,CAACJ,MAAM,CAAC,IAAIF,SAAS,CAACC,WAAW,CAACC,MAAM,CAAC,CAAC;AAC9F,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMK,IAAI,GAAIC,SAAoB,IAAgBA,SAAS,CAC/DC,YAAY,CAACT,SAAS,CAACU,UAAU,CAAC"}
@@ -1,11 +1,5 @@
1
1
  /// <reference types="node" />
2
2
  import BigNumber from 'bignumber.js';
3
- /**
4
- * Convert bignumber to byte array
5
- * @param x - bignumber instance
6
- * @returns Buffer
7
- */
8
- export declare function bigNumberToByteArray(x: BigNumber): Buffer;
9
3
  /**
10
4
  * Convert string, number, or BigNumber to byte array
11
5
  * @param val - value to convert
@@ -13,14 +7,3 @@ export declare function bigNumberToByteArray(x: BigNumber): Buffer;
13
7
  * @returns Buffer
14
8
  */
15
9
  export declare function toBytes(val?: null | string | number | BigNumber, big?: boolean): Buffer;
16
- /**
17
- * Convert a string to a Buffer. If encoding is not specified, hex-encoding
18
- * will be used if the input is valid hex. If the input is valid base64 but
19
- * not valid hex, base64 will be used. Otherwise, utf8 will be used.
20
- * @param str - String to be converted.
21
- * @param enc - Encoding of the input string.
22
- * @returns Buffer containing the input data.
23
- */
24
- export declare function str2buf(str: string, enc?: BufferEncoding): Buffer;
25
- export declare const bytesToHex: (b: Uint8Array) => string;
26
- export declare const hexToBytes: (s: string) => Uint8Array;
@@ -2,7 +2,6 @@ import _buffer from "buffer";
2
2
  const {
3
3
  Buffer: _Buffer
4
4
  } = _buffer;
5
-
6
5
  /*
7
6
  * ISC License (ISC)
8
7
  * Copyright 2018 aeternity developers
@@ -21,58 +20,30 @@ const {
21
20
  */
22
21
  import BigNumber from 'bignumber.js';
23
22
  import { NoSerializerFoundError, TypeError } from "./errors.mjs";
24
- import { isBase64, isHex } from "./string.mjs";
25
- /**
26
- * Convert bignumber to byte array
27
- * @param x - bignumber instance
28
- * @returns Buffer
29
- */
30
-
31
- export function bigNumberToByteArray(x) {
32
- if (!x.isInteger()) throw new TypeError(`Unexpected not integer value: ${x.toFixed()}`);
33
- let hexString = x.toString(16);
34
- if (hexString.length % 2 === 1) hexString = `0${hexString}`;
35
- return _Buffer.from(hexString, 'hex');
36
- }
37
23
  /**
38
24
  * Convert string, number, or BigNumber to byte array
39
25
  * @param val - value to convert
40
26
  * @param big - enables force conversion to BigNumber
41
27
  * @returns Buffer
42
28
  */
43
-
29
+ // eslint-disable-next-line import/prefer-default-export
44
30
  export function toBytes(val) {
45
31
  let big = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
46
32
  // Encode a value to bytes.
47
33
  // If the value is an int it will be encoded as bytes big endian
48
34
  // Raises ValueError if the input is not an int or string
49
- if (val === undefined || val === null) return _Buffer.from([]);
50
35
 
36
+ if (val === undefined || val === null) return _Buffer.from([]);
51
37
  if (Number.isInteger(val) || BigNumber.isBigNumber(val) || big) {
52
38
  if (!BigNumber.isBigNumber(val)) val = new BigNumber(val);
53
- return bigNumberToByteArray(val);
39
+ if (!val.isInteger()) throw new TypeError(`Unexpected not integer value: ${val.toFixed()}`);
40
+ let hexString = val.toString(16);
41
+ if (hexString.length % 2 === 1) hexString = `0${hexString}`;
42
+ return _Buffer.from(hexString, 'hex');
54
43
  }
55
-
56
44
  if (typeof val === 'string') {
57
45
  return _Buffer.from(val);
58
46
  }
59
-
60
47
  throw new NoSerializerFoundError();
61
48
  }
62
- /**
63
- * Convert a string to a Buffer. If encoding is not specified, hex-encoding
64
- * will be used if the input is valid hex. If the input is valid base64 but
65
- * not valid hex, base64 will be used. Otherwise, utf8 will be used.
66
- * @param str - String to be converted.
67
- * @param enc - Encoding of the input string.
68
- * @returns Buffer containing the input data.
69
- */
70
-
71
- export function str2buf(str, enc) {
72
- var _ref;
73
-
74
- return _Buffer.from(str, (_ref = enc !== null && enc !== void 0 ? enc : isHex(str) ? 'hex' : undefined) !== null && _ref !== void 0 ? _ref : isBase64(str) ? 'base64' : undefined);
75
- }
76
- export const bytesToHex = b => _Buffer.from(b).toString('hex');
77
- export const hexToBytes = s => _Buffer.from(s, 'hex');
78
49
  //# sourceMappingURL=bytes.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bytes.mjs","names":["BigNumber","NoSerializerFoundError","TypeError","isBase64","isHex","bigNumberToByteArray","x","isInteger","toFixed","hexString","toString","length","from","toBytes","val","big","undefined","Number","isBigNumber","str2buf","str","enc","bytesToHex","b","hexToBytes","s"],"sources":["../../src/utils/bytes.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport BigNumber from 'bignumber.js';\nimport { NoSerializerFoundError, TypeError } from './errors';\nimport { isBase64, isHex } from './string';\n\n/**\n * Convert bignumber to byte array\n * @param x - bignumber instance\n * @returns Buffer\n */\nexport function bigNumberToByteArray(x: BigNumber): Buffer {\n if (!x.isInteger()) throw new TypeError(`Unexpected not integer value: ${x.toFixed()}`);\n let hexString = x.toString(16);\n if (hexString.length % 2 === 1) hexString = `0${hexString}`;\n return Buffer.from(hexString, 'hex');\n}\n\n/**\n * Convert string, number, or BigNumber to byte array\n * @param val - value to convert\n * @param big - enables force conversion to BigNumber\n * @returns Buffer\n */\nexport function toBytes(val?: null | string | number | BigNumber, big = false): Buffer {\n // Encode a value to bytes.\n // If the value is an int it will be encoded as bytes big endian\n // Raises ValueError if the input is not an int or string\n\n if (val === undefined || val === null) return Buffer.from([]);\n if (Number.isInteger(val) || BigNumber.isBigNumber(val) || big) {\n if (!BigNumber.isBigNumber(val)) val = new BigNumber(val);\n return bigNumberToByteArray(val);\n }\n if (typeof val === 'string') {\n return Buffer.from(val);\n }\n throw new NoSerializerFoundError();\n}\n\n/**\n * Convert a string to a Buffer. If encoding is not specified, hex-encoding\n * will be used if the input is valid hex. If the input is valid base64 but\n * not valid hex, base64 will be used. Otherwise, utf8 will be used.\n * @param str - String to be converted.\n * @param enc - Encoding of the input string.\n * @returns Buffer containing the input data.\n */\nexport function str2buf(str: string, enc?: BufferEncoding): Buffer {\n return Buffer.from(\n str,\n enc ?? (isHex(str) ? 'hex' : undefined) ?? (isBase64(str) ? 'base64' : undefined),\n );\n}\n\nexport const bytesToHex = (b: Uint8Array): string => Buffer.from(b).toString('hex');\n\nexport const hexToBytes = (s: string): Uint8Array => Buffer.from(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BAAJ,EAAN;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASkB,OAAT,CAAiBC,GAAjB,EAA8BC,GAA9B,EAA4D;EAAA;;EACjE,OAAO,QAAOT,IAAP,CACLQ,GADK,UAELC,GAFK,aAELA,GAFK,cAELA,GAFK,GAEGjB,KAAK,CAACgB,GAAD,CAAL,GAAa,KAAb,GAAqBJ,SAFxB,uCAEuCb,QAAQ,CAACiB,GAAD,CAAR,GAAgB,QAAhB,GAA2BJ,SAFlE,CAAP;AAID;AAED,OAAO,MAAMM,UAAU,GAAIC,CAAD,IAA2B,QAAOX,IAAP,CAAYW,CAAZ,EAAeb,QAAf,CAAwB,KAAxB,CAA9C;AAEP,OAAO,MAAMc,UAAU,GAAIC,CAAD,IAA2B,QAAOb,IAAP,CAAYa,CAAZ,EAAe,KAAf,CAA9C"}
1
+ {"version":3,"file":"bytes.mjs","names":["BigNumber","NoSerializerFoundError","TypeError","toBytes","val","big","undefined","from","Number","isInteger","isBigNumber","toFixed","hexString","toString","length"],"sources":["../../src/utils/bytes.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport BigNumber from 'bignumber.js';\nimport { NoSerializerFoundError, TypeError } from './errors';\n\n/**\n * Convert string, number, or BigNumber to byte array\n * @param val - value to convert\n * @param big - enables force conversion to BigNumber\n * @returns Buffer\n */\n// eslint-disable-next-line import/prefer-default-export\nexport function toBytes(val?: null | string | number | BigNumber, big = false): Buffer {\n // Encode a value to bytes.\n // If the value is an int it will be encoded as bytes big endian\n // Raises ValueError if the input is not an int or string\n\n if (val === undefined || val === null) return Buffer.from([]);\n if (Number.isInteger(val) || BigNumber.isBigNumber(val) || big) {\n if (!BigNumber.isBigNumber(val)) val = new BigNumber(val);\n if (!val.isInteger()) throw new TypeError(`Unexpected not integer value: ${val.toFixed()}`);\n let hexString = val.toString(16);\n if (hexString.length % 2 === 1) hexString = `0${hexString}`;\n return Buffer.from(hexString, 'hex');\n }\n if (typeof val === 'string') {\n return Buffer.from(val);\n }\n throw new NoSerializerFoundError();\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,sBAAsB,EAAEC,SAAS;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAO,CAACC,GAAwC,EAAuB;EAAA,IAArBC,GAAG,uEAAG,KAAK;EAC3E;EACA;EACA;;EAEA,IAAID,GAAG,KAAKE,SAAS,IAAIF,GAAG,KAAK,IAAI,EAAE,OAAO,QAAOG,IAAI,CAAC,EAAE,CAAC;EAC7D,IAAIC,MAAM,CAACC,SAAS,CAACL,GAAG,CAAC,IAAIJ,SAAS,CAACU,WAAW,CAACN,GAAG,CAAC,IAAIC,GAAG,EAAE;IAC9D,IAAI,CAACL,SAAS,CAACU,WAAW,CAACN,GAAG,CAAC,EAAEA,GAAG,GAAG,IAAIJ,SAAS,CAACI,GAAG,CAAC;IACzD,IAAI,CAACA,GAAG,CAACK,SAAS,EAAE,EAAE,MAAM,IAAIP,SAAS,CAAE,iCAAgCE,GAAG,CAACO,OAAO,EAAG,EAAC,CAAC;IAC3F,IAAIC,SAAS,GAAGR,GAAG,CAACS,QAAQ,CAAC,EAAE,CAAC;IAChC,IAAID,SAAS,CAACE,MAAM,GAAG,CAAC,KAAK,CAAC,EAAEF,SAAS,GAAI,IAAGA,SAAU,EAAC;IAC3D,OAAO,QAAOL,IAAI,CAACK,SAAS,EAAE,KAAK,CAAC;EACtC;EACA,IAAI,OAAOR,GAAG,KAAK,QAAQ,EAAE;IAC3B,OAAO,QAAOG,IAAI,CAACH,GAAG,CAAC;EACzB;EACA,MAAM,IAAIH,sBAAsB,EAAE;AACpC"}
@@ -3,7 +3,7 @@ import { SignKeyPair } from 'tweetnacl';
3
3
  import { Encoded, Encoding } from './encoder';
4
4
  /**
5
5
  * Generate address from secret key
6
- * @param secret - Private key
6
+ * @param secret - Private key as hex string
7
7
  * @returns Public key encoded as address
8
8
  */
9
9
  export declare function getAddressFromPriv(secret: string | Uint8Array): Encoded.AccountAddress;
@@ -68,21 +68,28 @@ export declare function generateKeyPair(raw?: false): {
68
68
  export declare function sign(data: string | Uint8Array, privateKey: string | Uint8Array): Uint8Array;
69
69
  /**
70
70
  * Verify that signature was signed by public key
71
- * @param data - Data to verify
72
- * @param signature - Signature to verify
73
- * @param publicKey - Key to verify against
74
- * @returns Valid?
71
+ * @param data - Data that was signed
72
+ * @param signature - Signature of data
73
+ * @param address - Address to verify against
74
+ * @returns is data was signed by address
75
75
  */
76
- export declare function verify(data: Uint8Array, signature: Uint8Array, publicKey: string | Uint8Array): boolean;
76
+ export declare function verify(data: Uint8Array, signature: Uint8Array, address: Encoded.AccountAddress): boolean;
77
77
  export declare function messageToHash(message: string): Buffer;
78
78
  export declare function signMessage(message: string, privateKey: string | Buffer): Uint8Array;
79
- export declare function verifyMessage(str: string, signature: Uint8Array, publicKey: string | Uint8Array): boolean;
79
+ /**
80
+ * Verify that message was signed by address
81
+ * @param message - Message that was signed
82
+ * @param signature - Signature of message
83
+ * @param address - Address to verify against
84
+ * @returns is data was signed by address
85
+ */
86
+ export declare function verifyMessage(message: string, signature: Uint8Array, address: Encoded.AccountAddress): boolean;
80
87
  /**
81
88
  * Check key pair for validity
82
89
  *
83
90
  * Sign a message, and then verifying that signature
84
91
  * @param privateKey - Private key to verify
85
- * @param publicKey - Public key to verify
92
+ * @param publicKey - Public key to verify as hex string
86
93
  * @returns Valid?
87
94
  */
88
95
  export declare function isValidKeypair(privateKey: string | Uint8Array, publicKey: string | Uint8Array): boolean;