@aeternity/aepp-sdk 13.2.2 → 13.3.1

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 (494) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/bin/aesophia_cli +0 -0
  4. package/bin/aesophia_cli_8 +0 -0
  5. package/dist/aepp-sdk.browser-script.js +1 -1
  6. package/dist/aepp-sdk.browser-script.js.map +1 -1
  7. package/dist/aepp-sdk.browser.js +1 -1
  8. package/dist/aepp-sdk.browser.js.map +1 -1
  9. package/dist/aepp-sdk.js +9171 -7086
  10. package/dist/aepp-sdk.js.map +1 -1
  11. package/es/AeSdk.d.ts +3 -0
  12. package/es/AeSdk.mjs +12 -12
  13. package/es/AeSdk.mjs.map +1 -1
  14. package/es/AeSdkAepp.d.ts +0 -1
  15. package/es/AeSdkAepp.mjs +12 -16
  16. package/es/AeSdkAepp.mjs.map +1 -1
  17. package/es/AeSdkBase.d.ts +61 -6
  18. package/es/AeSdkBase.mjs +150 -69
  19. package/es/AeSdkBase.mjs.map +1 -1
  20. package/es/AeSdkMethods.d.ts +19 -7
  21. package/es/AeSdkMethods.mjs +39 -38
  22. package/es/AeSdkMethods.mjs.map +1 -1
  23. package/es/AeSdkWallet.mjs +86 -55
  24. package/es/AeSdkWallet.mjs.map +1 -1
  25. package/es/Middleware.mjs +31 -27
  26. package/es/Middleware.mjs.map +1 -1
  27. package/es/MiddlewareSubscriber.mjs +5 -14
  28. package/es/MiddlewareSubscriber.mjs.map +1 -1
  29. package/es/Node.d.ts +10 -2
  30. package/es/Node.mjs +53 -54
  31. package/es/Node.mjs.map +1 -1
  32. package/es/account/Base.d.ts +39 -3
  33. package/es/account/Base.mjs +35 -1
  34. package/es/account/Base.mjs.map +1 -1
  35. package/es/account/Generalized.d.ts +2 -0
  36. package/es/account/Generalized.mjs +15 -6
  37. package/es/account/Generalized.mjs.map +1 -1
  38. package/es/account/Ledger.d.ts +2 -0
  39. package/es/account/Ledger.mjs +14 -5
  40. package/es/account/Ledger.mjs.map +1 -1
  41. package/es/account/LedgerFactory.mjs +4 -6
  42. package/es/account/LedgerFactory.mjs.map +1 -1
  43. package/es/account/Memory.d.ts +15 -4
  44. package/es/account/Memory.mjs +96 -31
  45. package/es/account/Memory.mjs.map +1 -1
  46. package/es/account/Rpc.d.ts +16 -5
  47. package/es/account/Rpc.mjs +94 -21
  48. package/es/account/Rpc.mjs.map +1 -1
  49. package/es/aens.d.ts +17 -44
  50. package/es/aens.mjs +32 -71
  51. package/es/aens.mjs.map +1 -1
  52. package/es/aepp-wallet-communication/connection/Browser.mjs +3 -4
  53. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  54. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
  55. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +7 -5
  56. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  57. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +8 -9
  58. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  59. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +7 -7
  60. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  61. package/es/aepp-wallet-communication/rpc/types.d.ts +14 -0
  62. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  63. package/es/aepp-wallet-communication/schema.d.ts +2 -0
  64. package/es/aepp-wallet-communication/schema.mjs +2 -0
  65. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  66. package/es/aepp-wallet-communication/wallet-detector.mjs +4 -5
  67. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  68. package/es/apis/compiler/compiler.mjs.map +1 -1
  69. package/es/apis/compiler/models/index.d.ts +1 -0
  70. package/es/apis/compiler/models/index.mjs.map +1 -1
  71. package/es/apis/compiler/models/mappers.mjs +13 -0
  72. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  73. package/es/apis/compiler/models/parameters.mjs.map +1 -1
  74. package/es/apis/middleware/middleware.d.ts +23 -5
  75. package/es/apis/middleware/middleware.mjs +114 -18
  76. package/es/apis/middleware/middleware.mjs.map +1 -1
  77. package/es/apis/middleware/models/index.d.ts +164 -15
  78. package/es/apis/middleware/models/index.mjs +53 -3
  79. package/es/apis/middleware/models/index.mjs.map +1 -1
  80. package/es/apis/middleware/models/mappers.d.ts +8 -1
  81. package/es/apis/middleware/models/mappers.mjs +376 -3
  82. package/es/apis/middleware/models/mappers.mjs.map +1 -1
  83. package/es/apis/middleware/models/parameters.d.ts +6 -3
  84. package/es/apis/middleware/models/parameters.mjs +38 -11
  85. package/es/apis/middleware/models/parameters.mjs.map +1 -1
  86. package/es/apis/node/models/index.d.ts +66 -2
  87. package/es/apis/node/models/index.mjs.map +1 -1
  88. package/es/apis/node/models/mappers.d.ts +5 -1
  89. package/es/apis/node/models/mappers.mjs +229 -7
  90. package/es/apis/node/models/mappers.mjs.map +1 -1
  91. package/es/apis/node/models/parameters.d.ts +2 -2
  92. package/es/apis/node/models/parameters.mjs +2 -2
  93. package/es/apis/node/models/parameters.mjs.map +1 -1
  94. package/es/apis/node/node.d.ts +24 -3
  95. package/es/apis/node/node.mjs +135 -3
  96. package/es/apis/node/node.mjs.map +1 -1
  97. package/es/chain.d.ts +14 -44
  98. package/es/chain.mjs +125 -219
  99. package/es/chain.mjs.map +1 -1
  100. package/es/channel/Base.d.ts +3 -47
  101. package/es/channel/Base.mjs +21 -54
  102. package/es/channel/Base.mjs.map +1 -1
  103. package/es/channel/Contract.d.ts +16 -25
  104. package/es/channel/Contract.mjs +39 -63
  105. package/es/channel/Contract.mjs.map +1 -1
  106. package/es/channel/Spend.d.ts +0 -8
  107. package/es/channel/Spend.mjs +17 -29
  108. package/es/channel/Spend.mjs.map +1 -1
  109. package/es/channel/handlers.mjs +1 -1
  110. package/es/channel/handlers.mjs.map +1 -1
  111. package/es/channel/internal.d.ts +104 -5
  112. package/es/channel/internal.mjs +26 -34
  113. package/es/channel/internal.mjs.map +1 -1
  114. package/es/contract/Contract.d.ts +9 -1
  115. package/es/contract/Contract.mjs +67 -73
  116. package/es/contract/Contract.mjs.map +1 -1
  117. package/es/contract/compiler/Base.d.ts +14 -8
  118. package/es/contract/compiler/Base.mjs.map +1 -1
  119. package/es/contract/compiler/Cli.d.ts +5 -9
  120. package/es/contract/compiler/Cli.mjs +45 -23
  121. package/es/contract/compiler/Cli.mjs.map +1 -1
  122. package/es/contract/compiler/Cli8.d.ts +13 -0
  123. package/es/contract/compiler/Cli8.mjs +22 -0
  124. package/es/contract/compiler/Cli8.mjs.map +1 -0
  125. package/es/contract/compiler/Http.d.ts +3 -9
  126. package/es/contract/compiler/Http.mjs +28 -16
  127. package/es/contract/compiler/Http.mjs.map +1 -1
  128. package/es/contract/compiler/HttpNode.d.ts +2 -5
  129. package/es/contract/compiler/HttpNode.mjs.map +1 -1
  130. package/es/contract/delegation-signature.d.ts +2 -1
  131. package/es/contract/delegation-signature.mjs +18 -14
  132. package/es/contract/delegation-signature.mjs.map +1 -1
  133. package/es/contract/ga.d.ts +1 -2
  134. package/es/contract/ga.mjs +23 -25
  135. package/es/contract/ga.mjs.map +1 -1
  136. package/es/deprecated.d.ts +38 -0
  137. package/es/deprecated.mjs +45 -0
  138. package/es/deprecated.mjs.map +1 -1
  139. package/es/index-browser.d.ts +10 -5
  140. package/es/index-browser.mjs +9 -5
  141. package/es/index-browser.mjs.map +1 -1
  142. package/es/index.d.ts +1 -0
  143. package/es/index.mjs +1 -0
  144. package/es/index.mjs.map +1 -1
  145. package/es/oracle.d.ts +6 -37
  146. package/es/oracle.mjs +32 -66
  147. package/es/oracle.mjs.map +1 -1
  148. package/es/send-transaction.d.ts +53 -0
  149. package/es/send-transaction.mjs +109 -0
  150. package/es/send-transaction.mjs.map +1 -0
  151. package/es/spend.d.ts +4 -3
  152. package/es/spend.mjs +6 -1
  153. package/es/spend.mjs.map +1 -1
  154. package/es/tx/builder/common.d.ts +29 -0
  155. package/es/tx/builder/common.mjs +42 -0
  156. package/es/tx/builder/common.mjs.map +1 -0
  157. package/es/tx/builder/constants.d.ts +4 -4
  158. package/es/tx/builder/constants.mjs +6 -15
  159. package/es/tx/builder/constants.mjs.map +1 -1
  160. package/es/tx/builder/delegation/index.d.ts +20 -0
  161. package/es/tx/builder/delegation/index.mjs +24 -0
  162. package/es/tx/builder/delegation/index.mjs.map +1 -0
  163. package/es/tx/builder/delegation/schema.d.ts +130 -0
  164. package/es/tx/builder/delegation/schema.generated.d.ts +141 -0
  165. package/es/tx/builder/delegation/schema.generated.mjs +2 -0
  166. package/es/tx/builder/delegation/schema.generated.mjs.map +1 -0
  167. package/es/tx/builder/delegation/schema.mjs +54 -0
  168. package/es/tx/builder/delegation/schema.mjs.map +1 -0
  169. package/es/tx/builder/field-types/abi-version.mjs +8 -11
  170. package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
  171. package/es/tx/builder/field-types/address.mjs +1 -4
  172. package/es/tx/builder/field-types/address.mjs.map +1 -1
  173. package/es/tx/builder/field-types/coin-amount.d.ts +2 -2
  174. package/es/tx/builder/field-types/coin-amount.mjs +6 -6
  175. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  176. package/es/tx/builder/field-types/ct-version.mjs +3 -4
  177. package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
  178. package/es/tx/builder/field-types/entry.mjs +7 -13
  179. package/es/tx/builder/field-types/entry.mjs.map +1 -1
  180. package/es/tx/builder/field-types/fee.d.ts +19 -11
  181. package/es/tx/builder/field-types/fee.mjs +56 -38
  182. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  183. package/es/tx/builder/field-types/gas-limit.mjs +13 -15
  184. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  185. package/es/tx/builder/field-types/gas-price.d.ts +10 -2
  186. package/es/tx/builder/field-types/gas-price.mjs +52 -3
  187. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  188. package/es/tx/builder/field-types/index.d.ts +31 -29
  189. package/es/tx/builder/field-types/index.mjs +31 -29
  190. package/es/tx/builder/field-types/index.mjs.map +1 -1
  191. package/es/tx/builder/field-types/map.mjs +20 -31
  192. package/es/tx/builder/field-types/map.mjs.map +1 -1
  193. package/es/tx/builder/field-types/mptree.mjs +14 -29
  194. package/es/tx/builder/field-types/mptree.mjs.map +1 -1
  195. package/es/tx/builder/field-types/name-fee.d.ts +1 -1
  196. package/es/tx/builder/field-types/name-fee.mjs +1 -1
  197. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  198. package/es/tx/builder/field-types/nonce.d.ts +1 -0
  199. package/es/tx/builder/field-types/nonce.mjs +2 -0
  200. package/es/tx/builder/field-types/nonce.mjs.map +1 -1
  201. package/es/tx/builder/field-types/pointers.mjs +4 -7
  202. package/es/tx/builder/field-types/pointers.mjs.map +1 -1
  203. package/es/tx/builder/field-types/pointers2.d.ts +23 -0
  204. package/es/tx/builder/field-types/pointers2.mjs +65 -0
  205. package/es/tx/builder/field-types/pointers2.mjs.map +1 -0
  206. package/es/tx/builder/field-types/query-fee.d.ts +19 -0
  207. package/es/tx/builder/field-types/query-fee.mjs +20 -0
  208. package/es/tx/builder/field-types/query-fee.mjs.map +1 -0
  209. package/es/tx/builder/field-types/ttl.d.ts +9 -1
  210. package/es/tx/builder/field-types/ttl.mjs +19 -8
  211. package/es/tx/builder/field-types/ttl.mjs.map +1 -1
  212. package/es/tx/builder/field-types/with-default.d.ts +7 -0
  213. package/es/tx/builder/field-types/with-default.mjs +9 -0
  214. package/es/tx/builder/field-types/with-default.mjs.map +1 -0
  215. package/es/tx/builder/field-types/with-formatting.d.ts +7 -0
  216. package/es/tx/builder/field-types/with-formatting.mjs +9 -0
  217. package/es/tx/builder/field-types/with-formatting.mjs.map +1 -0
  218. package/es/tx/builder/field-types/wrapped.mjs +6 -8
  219. package/es/tx/builder/field-types/wrapped.mjs.map +1 -1
  220. package/es/tx/builder/helpers.d.ts +2 -2
  221. package/es/tx/builder/helpers.mjs +12 -21
  222. package/es/tx/builder/helpers.mjs.map +1 -1
  223. package/es/tx/builder/index.d.ts +17 -10
  224. package/es/tx/builder/index.mjs +39 -65
  225. package/es/tx/builder/index.mjs.map +1 -1
  226. package/es/tx/builder/schema.d.ts +478 -257
  227. package/es/tx/builder/schema.generated.d.ts +39 -3
  228. package/es/tx/builder/schema.generated.mjs.map +1 -1
  229. package/es/tx/builder/schema.mjs +48 -36
  230. package/es/tx/builder/schema.mjs.map +1 -1
  231. package/es/tx/execution-cost.d.ts +6 -5
  232. package/es/tx/execution-cost.mjs +16 -17
  233. package/es/tx/execution-cost.mjs.map +1 -1
  234. package/es/tx/transaction-signer.mjs +1 -4
  235. package/es/tx/transaction-signer.mjs.map +1 -1
  236. package/es/tx/validator.mjs +61 -42
  237. package/es/tx/validator.mjs.map +1 -1
  238. package/es/utils/amount-formatter.mjs +15 -22
  239. package/es/utils/amount-formatter.mjs.map +1 -1
  240. package/es/utils/autorest.d.ts +2 -3
  241. package/es/utils/autorest.mjs +40 -24
  242. package/es/utils/autorest.mjs.map +1 -1
  243. package/es/utils/bytes.mjs +1 -2
  244. package/es/utils/bytes.mjs.map +1 -1
  245. package/es/utils/crypto.d.ts +8 -4
  246. package/es/utils/crypto.mjs +17 -13
  247. package/es/utils/crypto.mjs.map +1 -1
  248. package/es/utils/errors.d.ts +6 -0
  249. package/es/utils/errors.mjs +12 -6
  250. package/es/utils/errors.mjs.map +1 -1
  251. package/es/utils/hd-wallet.d.ts +2 -0
  252. package/es/utils/hd-wallet.mjs +6 -5
  253. package/es/utils/hd-wallet.mjs.map +1 -1
  254. package/es/utils/json-big.mjs +2 -10
  255. package/es/utils/json-big.mjs.map +1 -1
  256. package/es/utils/jwt.d.ts +53 -0
  257. package/es/utils/jwt.mjs +120 -0
  258. package/es/utils/jwt.mjs.map +1 -0
  259. package/es/utils/keystore.d.ts +6 -2
  260. package/es/utils/keystore.mjs +8 -16
  261. package/es/utils/keystore.mjs.map +1 -1
  262. package/es/utils/typed-data.mjs +1 -0
  263. package/es/utils/typed-data.mjs.map +1 -1
  264. package/es/utils/wrap-proxy.d.ts +2 -0
  265. package/es/utils/wrap-proxy.mjs +15 -0
  266. package/es/utils/wrap-proxy.mjs.map +1 -0
  267. package/package.json +57 -51
  268. package/src/AeSdk.ts +3 -0
  269. package/src/AeSdkAepp.ts +0 -1
  270. package/src/AeSdkBase.ts +97 -10
  271. package/src/AeSdkMethods.ts +37 -33
  272. package/src/AeSdkWallet.ts +22 -3
  273. package/src/Middleware.ts +16 -8
  274. package/src/MiddlewareSubscriber.ts +1 -1
  275. package/src/Node.ts +37 -18
  276. package/src/account/Base.ts +62 -3
  277. package/src/account/Generalized.ts +10 -0
  278. package/src/account/Ledger.ts +10 -0
  279. package/src/account/Memory.ts +83 -9
  280. package/src/account/Rpc.ts +69 -6
  281. package/src/aens.ts +35 -56
  282. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +3 -0
  283. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +2 -2
  284. package/src/aepp-wallet-communication/rpc/RpcClient.ts +4 -2
  285. package/src/aepp-wallet-communication/rpc/types.ts +13 -0
  286. package/src/aepp-wallet-communication/schema.ts +2 -0
  287. package/src/apis/compiler/compiler.ts +93 -93
  288. package/src/apis/compiler/models/index.ts +1 -0
  289. package/src/apis/compiler/models/mappers.ts +178 -165
  290. package/src/apis/compiler/models/parameters.ts +18 -18
  291. package/src/apis/middleware/middleware.ts +462 -341
  292. package/src/apis/middleware/models/index.ts +258 -56
  293. package/src/apis/middleware/models/mappers.ts +2357 -1919
  294. package/src/apis/middleware/models/parameters.ts +172 -142
  295. package/src/apis/node/models/index.ts +79 -2
  296. package/src/apis/node/models/mappers.ts +1529 -1302
  297. package/src/apis/node/models/parameters.ts +51 -51
  298. package/src/apis/node/node.ts +420 -275
  299. package/src/chain.ts +42 -128
  300. package/src/channel/Base.ts +14 -47
  301. package/src/channel/Contract.ts +18 -26
  302. package/src/channel/Spend.ts +0 -8
  303. package/src/channel/internal.ts +115 -13
  304. package/src/contract/Contract.ts +26 -8
  305. package/src/contract/compiler/Base.ts +15 -8
  306. package/src/contract/compiler/Cli.ts +37 -21
  307. package/src/contract/compiler/Cli8.ts +17 -0
  308. package/src/contract/compiler/Http.ts +24 -14
  309. package/src/contract/compiler/HttpNode.ts +2 -2
  310. package/src/contract/delegation-signature.ts +11 -5
  311. package/src/contract/ga.ts +4 -3
  312. package/src/deprecated.ts +36 -0
  313. package/src/index-browser.ts +14 -7
  314. package/src/index.ts +1 -0
  315. package/src/oracle.ts +11 -54
  316. package/src/send-transaction.ts +136 -0
  317. package/src/spend.ts +25 -11
  318. package/src/tx/builder/common.ts +74 -0
  319. package/src/tx/builder/constants.ts +6 -9
  320. package/src/tx/builder/delegation/index.ts +28 -0
  321. package/src/tx/builder/delegation/schema.generated.ts +143 -0
  322. package/src/tx/builder/delegation/schema.ts +61 -0
  323. package/src/tx/builder/field-types/coin-amount.ts +3 -2
  324. package/src/tx/builder/field-types/entry.ts +1 -4
  325. package/src/tx/builder/field-types/fee.ts +71 -43
  326. package/src/tx/builder/field-types/gas-limit.ts +4 -4
  327. package/src/tx/builder/field-types/gas-price.ts +70 -14
  328. package/src/tx/builder/field-types/index.ts +31 -59
  329. package/src/tx/builder/field-types/name-fee.ts +1 -1
  330. package/src/tx/builder/field-types/nonce.ts +7 -1
  331. package/src/tx/builder/field-types/pointers2.ts +62 -0
  332. package/src/tx/builder/field-types/query-fee.ts +25 -0
  333. package/src/tx/builder/field-types/ttl.ts +13 -3
  334. package/src/tx/builder/field-types/with-default.ts +18 -0
  335. package/src/tx/builder/field-types/with-formatting.ts +18 -0
  336. package/src/tx/builder/helpers.ts +2 -2
  337. package/src/tx/builder/index.ts +42 -59
  338. package/src/tx/builder/schema.generated.ts +39 -3
  339. package/src/tx/builder/schema.ts +55 -29
  340. package/src/tx/execution-cost.ts +6 -5
  341. package/src/tx/validator.ts +31 -5
  342. package/src/utils/autorest.ts +36 -27
  343. package/src/utils/crypto.ts +23 -13
  344. package/src/utils/errors.ts +10 -0
  345. package/src/utils/hd-wallet.ts +2 -0
  346. package/src/utils/jwt.ts +126 -0
  347. package/src/utils/keystore.ts +6 -2
  348. package/src/utils/wrap-proxy.ts +24 -0
  349. package/types-legacy/ts4.2/AeSdk.d.ts +3 -0
  350. package/types-legacy/ts4.2/AeSdkAepp.d.ts +0 -1
  351. package/types-legacy/ts4.2/AeSdkBase.d.ts +61 -6
  352. package/types-legacy/ts4.2/AeSdkMethods.d.ts +19 -7
  353. package/types-legacy/ts4.2/Node.d.ts +14 -1
  354. package/types-legacy/ts4.2/account/Base.d.ts +39 -3
  355. package/types-legacy/ts4.2/account/Generalized.d.ts +2 -0
  356. package/types-legacy/ts4.2/account/Ledger.d.ts +2 -0
  357. package/types-legacy/ts4.2/account/Memory.d.ts +15 -4
  358. package/types-legacy/ts4.2/account/Rpc.d.ts +16 -5
  359. package/types-legacy/ts4.2/aens.d.ts +17 -44
  360. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
  361. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +14 -0
  362. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +2 -0
  363. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +1 -0
  364. package/types-legacy/ts4.2/apis/middleware/middleware.d.ts +23 -5
  365. package/types-legacy/ts4.2/apis/middleware/models/index.d.ts +164 -15
  366. package/types-legacy/ts4.2/apis/middleware/models/mappers.d.ts +8 -1
  367. package/types-legacy/ts4.2/apis/middleware/models/parameters.d.ts +6 -3
  368. package/types-legacy/ts4.2/apis/node/models/index.d.ts +66 -2
  369. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +5 -1
  370. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
  371. package/types-legacy/ts4.2/apis/node/node.d.ts +24 -3
  372. package/types-legacy/ts4.2/chain.d.ts +14 -44
  373. package/types-legacy/ts4.2/channel/Base.d.ts +3 -47
  374. package/types-legacy/ts4.2/channel/Contract.d.ts +16 -25
  375. package/types-legacy/ts4.2/channel/Spend.d.ts +0 -8
  376. package/types-legacy/ts4.2/channel/internal.d.ts +104 -5
  377. package/types-legacy/ts4.2/contract/Contract.d.ts +9 -1
  378. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +14 -8
  379. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +5 -9
  380. package/types-legacy/ts4.2/contract/compiler/Cli8.d.ts +13 -0
  381. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +3 -9
  382. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +2 -5
  383. package/types-legacy/ts4.2/contract/delegation-signature.d.ts +2 -1
  384. package/types-legacy/ts4.2/contract/ga.d.ts +1 -2
  385. package/types-legacy/ts4.2/deprecated.d.ts +38 -0
  386. package/types-legacy/ts4.2/index-browser.d.ts +10 -5
  387. package/types-legacy/ts4.2/index.d.ts +1 -0
  388. package/types-legacy/ts4.2/oracle.d.ts +6 -37
  389. package/types-legacy/ts4.2/send-transaction.d.ts +53 -0
  390. package/types-legacy/ts4.2/spend.d.ts +4 -3
  391. package/types-legacy/ts4.2/tx/builder/common.d.ts +32 -0
  392. package/types-legacy/ts4.2/tx/builder/constants.d.ts +4 -4
  393. package/types-legacy/ts4.2/tx/builder/delegation/index.d.ts +20 -0
  394. package/types-legacy/ts4.2/tx/builder/delegation/schema.d.ts +136 -0
  395. package/types-legacy/ts4.2/tx/builder/delegation/schema.generated.d.ts +141 -0
  396. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +2 -2
  397. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +19 -11
  398. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +10 -2
  399. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +31 -29
  400. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -1
  401. package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +1 -0
  402. package/types-legacy/ts4.2/tx/builder/field-types/pointers2.d.ts +26 -0
  403. package/types-legacy/ts4.2/tx/builder/field-types/query-fee.d.ts +19 -0
  404. package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +9 -1
  405. package/types-legacy/ts4.2/tx/builder/field-types/with-default.d.ts +7 -0
  406. package/types-legacy/ts4.2/tx/builder/field-types/with-formatting.d.ts +7 -0
  407. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +2 -2
  408. package/types-legacy/ts4.2/tx/builder/index.d.ts +17 -10
  409. package/types-legacy/ts4.2/tx/builder/schema.d.ts +482 -257
  410. package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +39 -3
  411. package/types-legacy/ts4.2/tx/execution-cost.d.ts +6 -5
  412. package/types-legacy/ts4.2/utils/autorest.d.ts +2 -3
  413. package/types-legacy/ts4.2/utils/crypto.d.ts +8 -4
  414. package/types-legacy/ts4.2/utils/errors.d.ts +6 -0
  415. package/types-legacy/ts4.2/utils/hd-wallet.d.ts +2 -0
  416. package/types-legacy/ts4.2/utils/jwt.d.ts +53 -0
  417. package/types-legacy/ts4.2/utils/keystore.d.ts +6 -2
  418. package/types-legacy/ts4.2/utils/wrap-proxy.d.ts +2 -0
  419. package/types-legacy/ts4.5/AeSdk.d.ts +3 -0
  420. package/types-legacy/ts4.5/AeSdkAepp.d.ts +0 -1
  421. package/types-legacy/ts4.5/AeSdkBase.d.ts +61 -6
  422. package/types-legacy/ts4.5/AeSdkMethods.d.ts +19 -7
  423. package/types-legacy/ts4.5/Node.d.ts +14 -1
  424. package/types-legacy/ts4.5/account/Base.d.ts +39 -3
  425. package/types-legacy/ts4.5/account/Generalized.d.ts +2 -0
  426. package/types-legacy/ts4.5/account/Ledger.d.ts +2 -0
  427. package/types-legacy/ts4.5/account/Memory.d.ts +15 -4
  428. package/types-legacy/ts4.5/account/Rpc.d.ts +16 -5
  429. package/types-legacy/ts4.5/aens.d.ts +17 -44
  430. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +3 -0
  431. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +14 -0
  432. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +2 -0
  433. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +1 -0
  434. package/types-legacy/ts4.5/apis/middleware/middleware.d.ts +23 -5
  435. package/types-legacy/ts4.5/apis/middleware/models/index.d.ts +164 -15
  436. package/types-legacy/ts4.5/apis/middleware/models/mappers.d.ts +8 -1
  437. package/types-legacy/ts4.5/apis/middleware/models/parameters.d.ts +6 -3
  438. package/types-legacy/ts4.5/apis/node/models/index.d.ts +66 -2
  439. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +5 -1
  440. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
  441. package/types-legacy/ts4.5/apis/node/node.d.ts +24 -3
  442. package/types-legacy/ts4.5/chain.d.ts +14 -44
  443. package/types-legacy/ts4.5/channel/Base.d.ts +3 -47
  444. package/types-legacy/ts4.5/channel/Contract.d.ts +16 -25
  445. package/types-legacy/ts4.5/channel/Spend.d.ts +0 -8
  446. package/types-legacy/ts4.5/channel/internal.d.ts +104 -5
  447. package/types-legacy/ts4.5/contract/Contract.d.ts +9 -1
  448. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +14 -8
  449. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +5 -9
  450. package/types-legacy/ts4.5/contract/compiler/Cli8.d.ts +13 -0
  451. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +3 -9
  452. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +2 -5
  453. package/types-legacy/ts4.5/contract/delegation-signature.d.ts +2 -1
  454. package/types-legacy/ts4.5/contract/ga.d.ts +1 -2
  455. package/types-legacy/ts4.5/deprecated.d.ts +38 -0
  456. package/types-legacy/ts4.5/index-browser.d.ts +10 -5
  457. package/types-legacy/ts4.5/index.d.ts +1 -0
  458. package/types-legacy/ts4.5/oracle.d.ts +6 -37
  459. package/types-legacy/ts4.5/send-transaction.d.ts +53 -0
  460. package/types-legacy/ts4.5/spend.d.ts +4 -3
  461. package/types-legacy/ts4.5/tx/builder/common.d.ts +32 -0
  462. package/types-legacy/ts4.5/tx/builder/constants.d.ts +4 -4
  463. package/types-legacy/ts4.5/tx/builder/delegation/index.d.ts +20 -0
  464. package/types-legacy/ts4.5/tx/builder/delegation/schema.d.ts +136 -0
  465. package/types-legacy/ts4.5/tx/builder/delegation/schema.generated.d.ts +141 -0
  466. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +2 -2
  467. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +19 -11
  468. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +10 -2
  469. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +31 -29
  470. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -1
  471. package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +1 -0
  472. package/types-legacy/ts4.5/tx/builder/field-types/pointers2.d.ts +26 -0
  473. package/types-legacy/ts4.5/tx/builder/field-types/query-fee.d.ts +19 -0
  474. package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +9 -1
  475. package/types-legacy/ts4.5/tx/builder/field-types/with-default.d.ts +7 -0
  476. package/types-legacy/ts4.5/tx/builder/field-types/with-formatting.d.ts +7 -0
  477. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +2 -2
  478. package/types-legacy/ts4.5/tx/builder/index.d.ts +17 -10
  479. package/types-legacy/ts4.5/tx/builder/schema.d.ts +482 -257
  480. package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +39 -3
  481. package/types-legacy/ts4.5/tx/execution-cost.d.ts +6 -5
  482. package/types-legacy/ts4.5/utils/autorest.d.ts +2 -3
  483. package/types-legacy/ts4.5/utils/crypto.d.ts +8 -4
  484. package/types-legacy/ts4.5/utils/errors.d.ts +6 -0
  485. package/types-legacy/ts4.5/utils/hd-wallet.d.ts +2 -0
  486. package/types-legacy/ts4.5/utils/jwt.d.ts +53 -0
  487. package/types-legacy/ts4.5/utils/keystore.d.ts +6 -2
  488. package/types-legacy/ts4.5/utils/wrap-proxy.d.ts +2 -0
  489. package/es/tx/builder/field-types/deposit.d.ts +0 -15
  490. package/es/tx/builder/field-types/deposit.mjs +0 -18
  491. package/es/tx/builder/field-types/deposit.mjs.map +0 -1
  492. package/src/tx/builder/field-types/deposit.ts +0 -23
  493. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +0 -15
  494. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +0 -15
@@ -2,46 +2,35 @@ import { Tag } from "../constants.mjs";
2
2
  import { encode, Encoding, decode } from "../../../utils/encoder.mjs";
3
3
  export default function genMapField(encoding, tag) {
4
4
  return {
5
- serialize(object, _ref) {
6
- let {
7
- buildTx
8
- } = _ref;
5
+ serialize(object, {
6
+ buildTx
7
+ }) {
9
8
  return decode(buildTx({
10
9
  tag: Tag.Mtree,
11
- values: Object.entries(object).map(_ref2 => {
12
- let [key, value] = _ref2;
13
- return {
14
- tag: Tag.MtreeValue,
15
- key: decode(key),
16
- value: decode(buildTx({
17
- ...value,
18
- tag
19
- }))
20
- };
21
- })
10
+ values: Object.entries(object).map(([key, value]) => ({
11
+ tag: Tag.MtreeValue,
12
+ key: decode(key),
13
+ value: decode(buildTx({
14
+ ...value,
15
+ tag
16
+ }))
17
+ }))
22
18
  }));
23
19
  },
24
- deserialize(buffer, _ref3) {
25
- let {
26
- unpackTx
27
- } = _ref3;
20
+ deserialize(buffer, {
21
+ unpackTx
22
+ }) {
28
23
  const {
29
24
  values
30
25
  } = unpackTx(encode(buffer, Encoding.Transaction), Tag.Mtree);
31
26
  return Object.fromEntries(values
32
27
  // TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066
33
- .filter(_ref4 => {
34
- let {
35
- key
36
- } = _ref4;
37
- return encoding !== Encoding.ContractAddress || key.length === 32;
38
- }).map(_ref5 => {
39
- let {
40
- key,
41
- value
42
- } = _ref5;
43
- return [encode(key, encoding), unpackTx(encode(value, Encoding.Transaction), tag)];
44
- }));
28
+ .filter(({
29
+ key
30
+ }) => encoding !== Encoding.ContractAddress || key.length === 32).map(({
31
+ key,
32
+ value
33
+ }) => [encode(key, encoding), unpackTx(encode(value, Encoding.Transaction), tag)]));
45
34
  },
46
35
  recursiveType: true
47
36
  };
@@ -1 +1 @@
1
- {"version":3,"file":"map.mjs","names":["Tag","encode","Encoding","decode","genMapField","encoding","tag","serialize","object","_ref","buildTx","Mtree","values","Object","entries","map","_ref2","key","value","MtreeValue","deserialize","buffer","_ref3","unpackTx","Transaction","fromEntries","filter","_ref4","ContractAddress","length","_ref5","recursiveType"],"sources":["../../../../src/tx/builder/field-types/map.ts"],"sourcesContent":["import { Tag } from '../constants';\nimport {\n encode, Encoding, Encoded, decode,\n} from '../../../utils/encoder';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';\n\nexport default function genMapField<E extends Encoding, T extends Tag>(encoding: E, tag: T): {\n serialize: (\n // TODO: replace with `TxParams & { tag: T }`,\n // but fix TS2502 value is referenced directly or indirectly in its own type annotation\n value: Record<Encoded.Generic<E>, any>, options: { buildTx: typeof buildTxType }\n ) => Buffer;\n deserialize: (\n value: Buffer, options: { unpackTx: typeof unpackTxType },\n // TODO: replace with `TxUnpacked & { tag: T }`,\n // TS2577 Return type annotation circularly references itself\n ) => Record<Encoded.Generic<E>, any>;\n recursiveType: true;\n} {\n return {\n serialize(object, { buildTx }) {\n return decode(buildTx({\n tag: Tag.Mtree,\n values: Object.entries(object).map(([key, value]) => ({\n tag: Tag.MtreeValue,\n key: decode(key as Encoded.Generic<E>),\n value: decode(buildTx({ ...value as any, tag })),\n })),\n }));\n },\n\n deserialize(buffer, { unpackTx }) {\n const { values } = unpackTx(encode(buffer, Encoding.Transaction), Tag.Mtree);\n return Object.fromEntries(values\n // TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066\n .filter(({ key }) => encoding !== Encoding.ContractAddress || key.length === 32)\n .map(({ key, value }) => [\n encode(key, encoding),\n unpackTx(encode(value, Encoding.Transaction), tag),\n ])) as Record<Encoded.Generic<E>, any>;\n },\n\n recursiveType: true,\n };\n}\n"],"mappings":"SAASA,GAAG;AAAA,SAEVC,MAAM,EAAEC,QAAQ,EAAWC,MAAM;AAInC,eAAe,SAASC,WAAWA,CAAoCC,QAAW,EAAEC,GAAM,EAYxF;EACA,OAAO;IACLC,SAASA,CAACC,MAAM,EAAAC,IAAA,EAAe;MAAA,IAAb;QAAEC;MAAQ,CAAC,GAAAD,IAAA;MAC3B,OAAON,MAAM,CAACO,OAAO,CAAC;QACpBJ,GAAG,EAAEN,GAAG,CAACW,KAAK;QACdC,MAAM,EAAEC,MAAM,CAACC,OAAO,CAACN,MAAM,CAAC,CAACO,GAAG,CAACC,KAAA;UAAA,IAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,KAAA;UAAA,OAAM;YACpDV,GAAG,EAAEN,GAAG,CAACmB,UAAU;YACnBF,GAAG,EAAEd,MAAM,CAACc,GAAyB,CAAC;YACtCC,KAAK,EAAEf,MAAM,CAACO,OAAO,CAAC;cAAE,GAAGQ,KAAY;cAAEZ;YAAI,CAAC,CAAC;UACjD,CAAC;QAAA,CAAC;MACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEDc,WAAWA,CAACC,MAAM,EAAAC,KAAA,EAAgB;MAAA,IAAd;QAAEC;MAAS,CAAC,GAAAD,KAAA;MAC9B,MAAM;QAAEV;MAAO,CAAC,GAAGW,QAAQ,CAACtB,MAAM,CAACoB,MAAM,EAAEnB,QAAQ,CAACsB,WAAW,CAAC,EAAExB,GAAG,CAACW,KAAK,CAAC;MAC5E,OAAOE,MAAM,CAACY,WAAW,CAACb;MACxB;MAAA,CACCc,MAAM,CAACC,KAAA;QAAA,IAAC;UAAEV;QAAI,CAAC,GAAAU,KAAA;QAAA,OAAKtB,QAAQ,KAAKH,QAAQ,CAAC0B,eAAe,IAAIX,GAAG,CAACY,MAAM,KAAK,EAAE;MAAA,EAAC,CAC/Ed,GAAG,CAACe,KAAA;QAAA,IAAC;UAAEb,GAAG;UAAEC;QAAM,CAAC,GAAAY,KAAA;QAAA,OAAK,CACvB7B,MAAM,CAACgB,GAAG,EAAEZ,QAAQ,CAAC,EACrBkB,QAAQ,CAACtB,MAAM,CAACiB,KAAK,EAAEhB,QAAQ,CAACsB,WAAW,CAAC,EAAElB,GAAG,CAAC,CACnD;MAAA,EAAC,CAAC;IACP,CAAC;IAEDyB,aAAa,EAAE;EACjB,CAAC;AACH"}
1
+ {"version":3,"file":"map.mjs","names":["Tag","encode","Encoding","decode","genMapField","encoding","tag","serialize","object","buildTx","Mtree","values","Object","entries","map","key","value","MtreeValue","deserialize","buffer","unpackTx","Transaction","fromEntries","filter","ContractAddress","length","recursiveType"],"sources":["../../../../src/tx/builder/field-types/map.ts"],"sourcesContent":["import { Tag } from '../constants';\nimport {\n encode, Encoding, Encoded, decode,\n} from '../../../utils/encoder';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';\n\nexport default function genMapField<E extends Encoding, T extends Tag>(encoding: E, tag: T): {\n serialize: (\n // TODO: replace with `TxParams & { tag: T }`,\n // but fix TS2502 value is referenced directly or indirectly in its own type annotation\n value: Record<Encoded.Generic<E>, any>, options: { buildTx: typeof buildTxType }\n ) => Buffer;\n deserialize: (\n value: Buffer, options: { unpackTx: typeof unpackTxType },\n // TODO: replace with `TxUnpacked & { tag: T }`,\n // TS2577 Return type annotation circularly references itself\n ) => Record<Encoded.Generic<E>, any>;\n recursiveType: true;\n} {\n return {\n serialize(object, { buildTx }) {\n return decode(buildTx({\n tag: Tag.Mtree,\n values: Object.entries(object).map(([key, value]) => ({\n tag: Tag.MtreeValue,\n key: decode(key as Encoded.Generic<E>),\n value: decode(buildTx({ ...value as any, tag })),\n })),\n }));\n },\n\n deserialize(buffer, { unpackTx }) {\n const { values } = unpackTx(encode(buffer, Encoding.Transaction), Tag.Mtree);\n return Object.fromEntries(values\n // TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066\n .filter(({ key }) => encoding !== Encoding.ContractAddress || key.length === 32)\n .map(({ key, value }) => [\n encode(key, encoding),\n unpackTx(encode(value, Encoding.Transaction), tag),\n ])) as Record<Encoded.Generic<E>, any>;\n },\n\n recursiveType: true,\n };\n}\n"],"mappings":"SAASA,GAAG;AAAA,SAEVC,MAAM,EAAEC,QAAQ,EAAWC,MAAM;AAInC,eAAe,SAASC,WAAWA,CAAoCC,QAAW,EAAEC,GAAM,EAYxF;EACA,OAAO;IACLC,SAASA,CAACC,MAAM,EAAE;MAAEC;IAAQ,CAAC,EAAE;MAC7B,OAAON,MAAM,CAACM,OAAO,CAAC;QACpBH,GAAG,EAAEN,GAAG,CAACU,KAAK;QACdC,MAAM,EAAEC,MAAM,CAACC,OAAO,CAACL,MAAM,CAAC,CAACM,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,MAAM;UACpDV,GAAG,EAAEN,GAAG,CAACiB,UAAU;UACnBF,GAAG,EAAEZ,MAAM,CAACY,GAAyB,CAAC;UACtCC,KAAK,EAAEb,MAAM,CAACM,OAAO,CAAC;YAAE,GAAGO,KAAY;YAAEV;UAAI,CAAC,CAAC;QACjD,CAAC,CAAC;MACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEDY,WAAWA,CAACC,MAAM,EAAE;MAAEC;IAAS,CAAC,EAAE;MAChC,MAAM;QAAET;MAAO,CAAC,GAAGS,QAAQ,CAACnB,MAAM,CAACkB,MAAM,EAAEjB,QAAQ,CAACmB,WAAW,CAAC,EAAErB,GAAG,CAACU,KAAK,CAAC;MAC5E,OAAOE,MAAM,CAACU,WAAW,CAACX;MACxB;MAAA,CACCY,MAAM,CAAC,CAAC;QAAER;MAAI,CAAC,KAAKV,QAAQ,KAAKH,QAAQ,CAACsB,eAAe,IAAIT,GAAG,CAACU,MAAM,KAAK,EAAE,CAAC,CAC/EX,GAAG,CAAC,CAAC;QAAEC,GAAG;QAAEC;MAAM,CAAC,KAAK,CACvBf,MAAM,CAACc,GAAG,EAAEV,QAAQ,CAAC,EACrBe,QAAQ,CAACnB,MAAM,CAACe,KAAK,EAAEd,QAAQ,CAACmB,WAAW,CAAC,EAAEf,GAAG,CAAC,CACnD,CAAC,CAAC;IACP,CAAC;IAEDoB,aAAa,EAAE;EACjB,CAAC;AACH"}
@@ -4,12 +4,13 @@ const {
4
4
  } = _buffer;
5
5
  import _classPrivateFieldSet from "@babel/runtime-corejs3/helpers/classPrivateFieldSet";
6
6
  import _classPrivateFieldGet from "@babel/runtime-corejs3/helpers/classPrivateFieldGet";
7
+ var _MPTree;
7
8
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
8
9
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
9
10
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
10
- function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
11
- function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; }
12
- function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } }
11
+ function _classPrivateMethodGet(receiver, privateSet, fn) { _assertClassBrand(privateSet, receiver); return fn; }
12
+ function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _assertClassBrand(classConstructor, receiver); return method; }
13
+ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
13
14
  import _rlp from 'rlp';
14
15
  const {
15
16
  encode: rlpEncode
@@ -86,8 +87,7 @@ class MPTree {
86
87
  _classPrivateFieldSet(this, _isComplete, false);
87
88
  return;
88
89
  }
89
- Object.entries(_classPrivateFieldGet(this, _nodes)).forEach(_ref => {
90
- let [key, node] = _ref;
90
+ Object.entries(_classPrivateFieldGet(this, _nodes)).forEach(([key, node]) => {
91
91
  if (_classStaticPrivateMethodGet(MPTree, MPTree, _nodeHash).call(MPTree, node) !== key) throw new MerkleTreeHashMismatchError();
92
92
  const {
93
93
  type
@@ -122,10 +122,7 @@ class MPTree {
122
122
  * @returns Binary
123
123
  */
124
124
  serialize() {
125
- return [_Buffer.from(_classPrivateFieldGet(this, _rootHash), 'hex'), Object.entries(_classPrivateFieldGet(this, _nodes)).map(_ref2 => {
126
- let [mptHash, value] = _ref2;
127
- return [_Buffer.from(mptHash, 'hex'), value];
128
- })];
125
+ return [_Buffer.from(_classPrivateFieldGet(this, _rootHash), 'hex'), Object.entries(_classPrivateFieldGet(this, _nodes)).map(([mptHash, value]) => [_Buffer.from(mptHash, 'hex'), value])];
129
126
  }
130
127
  /**
131
128
  * Retrieve value from Merkle Patricia Tree
@@ -139,15 +136,10 @@ class MPTree {
139
136
  }
140
137
  toObject() {
141
138
  return Object.fromEntries(_classPrivateMethodGet(this, _entriesRaw, _entriesRaw2).call(this) // TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066
142
- .filter(_ref3 => {
143
- let [k] = _ref3;
144
- return _classPrivateFieldGet(this, _encoding) !== Encoding.ContractAddress || k.length !== 66;
145
- }).map(_ref4 => {
146
- let [k, v] = _ref4;
147
- return [encode(_Buffer.from(k, 'hex'), _classPrivateFieldGet(this, _encoding)), _classPrivateFieldGet(this, _unpackTx).call(this, encode(v, Encoding.Transaction), _classPrivateFieldGet(this, _tag))];
148
- }));
139
+ .filter(([k]) => _classPrivateFieldGet(this, _encoding) !== Encoding.ContractAddress || k.length !== 66).map(([k, v]) => [encode(_Buffer.from(k, 'hex'), _classPrivateFieldGet(this, _encoding)), _classPrivateFieldGet(this, _unpackTx).call(this, encode(v, Encoding.Transaction), _classPrivateFieldGet(this, _tag))]));
149
140
  }
150
141
  }
142
+ _MPTree = MPTree;
151
143
  function _nodeHash(node) {
152
144
  return _Buffer.from(hash(rlpEncode(node))).toString('hex');
153
145
  }
@@ -192,7 +184,7 @@ function _getRaw2(_key) {
192
184
  type,
193
185
  value,
194
186
  path
195
- } = _classStaticPrivateMethodGet(MPTree, MPTree, _parseNode).call(MPTree, node);
187
+ } = _classStaticPrivateMethodGet(_MPTree, _MPTree, _parseNode).call(_MPTree, node);
196
188
  switch (type) {
197
189
  case NodeType.Branch:
198
190
  if (key.length === 0) return value;
@@ -224,16 +216,10 @@ function _entriesRaw2() {
224
216
  type,
225
217
  value,
226
218
  path
227
- } = _classStaticPrivateMethodGet(MPTree, MPTree, _parseNode).call(MPTree, node);
219
+ } = _classStaticPrivateMethodGet(_MPTree, _MPTree, _parseNode).call(_MPTree, node);
228
220
  switch (type) {
229
221
  case NodeType.Branch:
230
- node.slice(0, 16).map((t, idx) => [t, idx]).filter(_ref6 => {
231
- let [t] = _ref6;
232
- return t.length;
233
- }).forEach(_ref7 => {
234
- let [t, idx] = _ref7;
235
- return rec(t.toString('hex'), key + idx.toString(16));
236
- });
222
+ node.slice(0, 16).map((t, idx) => [t, idx]).filter(([t]) => t.length).forEach(([t, idx]) => rec(t.toString('hex'), key + idx.toString(16)));
237
223
  if (value != null) entries.push([key, value]);
238
224
  break;
239
225
  case NodeType.Extension:
@@ -255,10 +241,9 @@ export default function genMPTreeField(encoding, tag) {
255
241
  serialize(value) {
256
242
  return value.serialize();
257
243
  },
258
- deserialize(value, _ref5) {
259
- let {
260
- unpackTx
261
- } = _ref5;
244
+ deserialize(value, {
245
+ unpackTx
246
+ }) {
262
247
  return new MPTree(value, encoding, tag, unpackTx);
263
248
  }
264
249
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mptree.mjs","names":["_rlp","encode","rlpEncode","hash","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownPathNibbleError","UnexpectedTsError","UnknownNodeLengthError","InternalError","decode","Encoding","NodeType","_rootHash","WeakMap","_isComplete","_nodes","_encoding","_tag","_unpackTx","_getRaw","WeakSet","_entriesRaw","MPTree","isComplete","_classPrivateFieldGet","constructor","binary","encoding","tag","unpTx","_classPrivateMethodInitSpec","_classPrivateFieldInitSpec","writable","value","_classPrivateFieldSet","toString","Object","fromEntries","map","node","keys","length","entries","forEach","_ref","key","_classStaticPrivateMethodGet","_nodeHash","call","type","_parseNode","Branch","slice","filter","n","Extension","Leaf","isEqual","tree","serialize","_Buffer","from","_ref2","mptHash","get","d","_classPrivateMethodGet","_getRaw2","Transaction","toObject","_entriesRaw2","_ref3","k","ContractAddress","_ref4","v","nibble","includes","path","_key","searchFrom","undefined","substring","rec","t","idx","_ref6","_ref7","push","genMPTreeField","deserialize","_ref5","unpackTx"],"sources":["../../../../src/tx/builder/field-types/mptree.ts"],"sourcesContent":["import { encode as rlpEncode, Input } from 'rlp';\nimport { Tag } from '../constants';\nimport { hash } from '../../../utils/crypto';\nimport {\n MerkleTreeHashMismatchError,\n MissingNodeInTreeError,\n UnknownPathNibbleError,\n UnexpectedTsError,\n UnknownNodeLengthError,\n InternalError,\n} from '../../../utils/errors';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../../utils/encoder';\nimport type { unpackTx } from '..';\nimport type { TxUnpacked } from '../schema.generated';\n\nenum NodeType {\n Branch,\n Extension,\n Leaf,\n}\n\ntype MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>];\n\nclass MPTree<E extends Encoding, T extends Tag> {\n readonly #rootHash: string;\n\n #isComplete = true;\n\n get isComplete(): boolean {\n return this.#isComplete;\n }\n\n readonly #nodes: { [key: string]: Buffer[] };\n\n readonly #encoding: E;\n\n readonly #tag: T;\n\n readonly #unpackTx: typeof unpackTx;\n\n static #nodeHash(node: Input): string {\n return Buffer.from(hash(rlpEncode(node))).toString('hex');\n }\n\n /**\n * Deserialize Merkle Patricia Tree\n * @param binary - Binary\n * @param tag - Tag to use to decode value\n * @param unpTx - Implementation of unpackTx use to decode values\n * @returns Merkle Patricia Tree\n */\n constructor(binary: MPTreeBinary, encoding: E, tag: T, unpTx: typeof unpackTx) {\n this.#encoding = encoding;\n this.#tag = tag;\n this.#unpackTx = unpTx;\n this.#rootHash = binary[0].toString('hex');\n this.#nodes = Object.fromEntries(\n binary[1].map((node) => [node[0].toString('hex'), node[1]]),\n );\n\n if (this.#nodes[this.#rootHash] == null) {\n if (Object.keys(this.#nodes).length !== 0) {\n throw new MissingNodeInTreeError('Can\\'t find a node by root hash');\n }\n this.#isComplete = false;\n return;\n }\n Object.entries(this.#nodes).forEach(([key, node]) => {\n if (MPTree.#nodeHash(node) !== key) throw new MerkleTreeHashMismatchError();\n const { type } = MPTree.#parseNode(node);\n switch (type) {\n case NodeType.Branch:\n node\n .slice(0, 16)\n .filter((n) => n.length)\n .forEach((n) => {\n // TODO: enable after resolving https://github.com/aeternity/aeternity/issues/4066\n // if (n.length !== 32) {\n // throw new ArgumentError('MPTree branch item length', 32, n.length);\n // }\n if (this.#nodes[n.toString('hex')] == null) this.#isComplete = false;\n });\n break;\n case NodeType.Extension:\n if (this.#nodes[node[1].toString('hex')] == null) {\n throw new MissingNodeInTreeError('Can\\'t find a node by hash in extension node');\n }\n break;\n case NodeType.Leaf:\n break;\n default:\n throw new InternalError(`Unknown MPTree node type: ${type}`);\n }\n });\n }\n\n isEqual(tree: MPTree<E, T>): boolean {\n return this.#rootHash === tree.#rootHash;\n }\n\n static #parseNode(node: Buffer[]): { type: NodeType; value?: Buffer; path?: string } {\n switch (node.length) {\n case 17:\n return {\n type: NodeType.Branch,\n ...node[16].length !== 0 && { value: node[16] },\n };\n case 2: {\n const nibble = node[0][0] >> 4; // eslint-disable-line no-bitwise\n if (nibble > 3) throw new UnknownPathNibbleError(nibble);\n const type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf;\n const slice = [0, 2].includes(nibble) ? 2 : 1;\n return {\n type,\n ...type === NodeType.Leaf && { value: node[1] },\n path: node[0].toString('hex').slice(slice),\n };\n }\n default:\n throw new UnknownNodeLengthError(node.length);\n }\n }\n\n /**\n * Serialize Merkle Patricia Tree\n * @returns Binary\n */\n serialize(): MPTreeBinary {\n return [\n Buffer.from(this.#rootHash, 'hex'),\n Object.entries(this.#nodes).map(([mptHash, value]) => ([\n Buffer.from(mptHash, 'hex'),\n value,\n ])),\n ];\n }\n\n /**\n * Retrieve value from Merkle Patricia Tree\n * @param _key - The key of the element to retrieve\n * @returns Value associated to the specified key\n */\n #getRaw(_key: string): Buffer | undefined {\n let searchFrom = this.#rootHash;\n let key = _key;\n while (true) { // eslint-disable-line no-constant-condition\n const node = this.#nodes[searchFrom];\n if (node == null) {\n if (!this.isComplete) return undefined;\n throw new InternalError('Can\\'t find node in complete tree');\n }\n const { type, value, path } = MPTree.#parseNode(node);\n switch (type) {\n case NodeType.Branch:\n if (key.length === 0) return value;\n searchFrom = node[+`0x${key[0]}`].toString('hex');\n key = key.substring(1);\n break;\n case NodeType.Extension:\n if (key.substring(0, path?.length) !== path) return undefined;\n searchFrom = node[1].toString('hex');\n key = key.substring(path.length);\n break;\n case NodeType.Leaf:\n if (path !== key) return undefined;\n return value;\n default:\n throw new InternalError(`Unknown MPTree node type: ${type}`);\n }\n }\n }\n\n /**\n * Retrieve value from Merkle Patricia Tree\n * @param key - The key of the element to retrieve\n * @returns Value associated to the specified key\n */\n get(key: Encoded.Generic<E>): TxUnpacked & { tag: T } | undefined {\n const d = this.#getRaw(decode(key).toString('hex'));\n if (d == null) return d;\n return this.#unpackTx(encode(d, Encoding.Transaction), this.#tag);\n }\n\n #entriesRaw(): Array<[string, Buffer]> {\n const entries: Array<[string, Buffer]> = [];\n const rec = (searchFrom: string, key: string): void => {\n const node = this.#nodes[searchFrom];\n if (node == null) {\n if (!this.isComplete) return;\n throw new InternalError('Can\\'t find node in complete tree');\n }\n const { type, value, path } = MPTree.#parseNode(node);\n switch (type) {\n case NodeType.Branch:\n node\n .slice(0, 16)\n .map((t, idx): [typeof t, number] => [t, idx])\n .filter(([t]) => t.length)\n .forEach(([t, idx]) => rec(t.toString('hex'), key + idx.toString(16)));\n if (value != null) entries.push([key, value]);\n break;\n case NodeType.Extension:\n rec(node[1].toString('hex'), key + path);\n break;\n case NodeType.Leaf:\n if (value == null) throw new UnexpectedTsError();\n entries.push([key + path, value]);\n break;\n default:\n throw new InternalError(`Unknown MPTree node type: ${type}`);\n }\n };\n rec(this.#rootHash, '');\n return entries;\n }\n\n toObject(): Record<Encoded.Generic<E>, TxUnpacked & { tag: T }> {\n return Object.fromEntries(this.#entriesRaw()\n // TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066\n .filter(([k]) => this.#encoding !== Encoding.ContractAddress || k.length !== 66)\n .map(([k, v]) => [\n encode(Buffer.from(k, 'hex'), this.#encoding),\n this.#unpackTx(encode(v, Encoding.Transaction), this.#tag),\n ])) as Record<Encoded.Generic<E>, TxUnpacked & { tag: T }>;\n }\n}\n\nexport default function genMPTreeField<E extends Encoding, T extends Tag>(encoding: E, tag: T): {\n serialize: (value: MPTree<E, T>) => MPTreeBinary;\n deserialize: (value: MPTreeBinary, o: { unpackTx: typeof unpackTx }) => MPTree<E, T>;\n} {\n return {\n serialize(value) {\n return value.serialize();\n },\n\n deserialize(value, { unpackTx }) {\n return new MPTree(value, encoding, tag, unpackTx);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;AAAA,OAAAA,IAAA,MAA2C,KAAK;AAAC;EAAAC,MAAA,EAAAC;AAAA,IAAAF,IAAA;AAAA,SAExCG,IAAI;AAAA,SAEXC,2BAA2B,EAC3BC,sBAAsB,EACtBC,sBAAsB,EACtBC,iBAAiB,EACjBC,sBAAsB,EACtBC,aAAa;AAAA,SAGbC,MAAM,EAAET,MAAM,EAAWU,QAAQ;AAAA,IAK9BC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ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QACrB4B,GAAG,CAAC5C,IAAI,CAAC,CAAC,CAAC,CAACJ,QAAQ,CAAC,KAAK,CAAC,EAAEU,GAAG,GAAGiC,IAAI,CAAC;QACxC;MACF,KAAKnE,QAAQ,CAAC6C,IAAI;QAChB,IAAIvB,KAAK,IAAI,IAAI,EAAE,MAAM,IAAI3B,iBAAiB,CAAC,CAAC;QAChDoC,OAAO,CAAC8C,IAAI,CAAC,CAAC3C,GAAG,GAAGiC,IAAI,EAAE7C,KAAK,CAAC,CAAC;QACjC;MACF;QACE,MAAM,IAAIzB,aAAa,CAAE,6BAA4ByC,IAAK,EAAC,CAAC;IAChE;EACF,CAAC;EACDkC,GAAG,CAAA3D,qBAAA,CAAC,IAAI,EAAAZ,SAAA,GAAY,EAAE,CAAC;EACvB,OAAO8B,OAAO;AAChB;AAaF,eAAe,SAAS+C,cAAcA,CAAoC9D,QAAW,EAAEC,GAAM,EAG3F;EACA,OAAO;IACL+B,SAASA,CAAC1B,KAAK,EAAE;MACf,OAAOA,KAAK,CAAC0B,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED+B,WAAWA,CAACzD,KAAK,EAAA0D,KAAA,EAAgB;MAAA,IAAd;QAAEC;MAAS,CAAC,GAAAD,KAAA;MAC7B,OAAO,IAAIrE,MAAM,CAACW,KAAK,EAAEN,QAAQ,EAAEC,GAAG,EAAEgE,QAAQ,CAAC;IACnD;EACF,CAAC;AACH"}
1
+ {"version":3,"file":"mptree.mjs","names":["_rlp","encode","rlpEncode","hash","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownPathNibbleError","UnexpectedTsError","UnknownNodeLengthError","InternalError","decode","Encoding","NodeType","_rootHash","WeakMap","_isComplete","_nodes","_encoding","_tag","_unpackTx","_getRaw","WeakSet","_entriesRaw","MPTree","isComplete","_classPrivateFieldGet","constructor","binary","encoding","tag","unpTx","_classPrivateMethodInitSpec","_classPrivateFieldInitSpec","writable","value","_classPrivateFieldSet","toString","Object","fromEntries","map","node","keys","length","entries","forEach","key","_classStaticPrivateMethodGet","_nodeHash","call","type","_parseNode","Branch","slice","filter","n","Extension","Leaf","isEqual","tree","serialize","_Buffer","from","mptHash","get","d","_classPrivateMethodGet","_getRaw2","Transaction","toObject","_entriesRaw2","k","ContractAddress","v","_MPTree","nibble","includes","path","_key","searchFrom","undefined","substring","rec","t","idx","push","genMPTreeField","deserialize","unpackTx"],"sources":["../../../../src/tx/builder/field-types/mptree.ts"],"sourcesContent":["import { encode as rlpEncode, Input } from 'rlp';\nimport { Tag } from '../constants';\nimport { hash } from '../../../utils/crypto';\nimport {\n MerkleTreeHashMismatchError,\n MissingNodeInTreeError,\n UnknownPathNibbleError,\n UnexpectedTsError,\n UnknownNodeLengthError,\n InternalError,\n} from '../../../utils/errors';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../../utils/encoder';\nimport type { unpackTx } from '..';\nimport type { TxUnpacked } from '../schema.generated';\n\nenum NodeType {\n Branch,\n Extension,\n Leaf,\n}\n\ntype MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>];\n\nclass MPTree<E extends Encoding, T extends Tag> {\n readonly #rootHash: string;\n\n #isComplete = true;\n\n get isComplete(): boolean {\n return this.#isComplete;\n }\n\n readonly #nodes: { [key: string]: Buffer[] };\n\n readonly #encoding: E;\n\n readonly #tag: T;\n\n readonly #unpackTx: typeof unpackTx;\n\n static #nodeHash(node: Input): string {\n return Buffer.from(hash(rlpEncode(node))).toString('hex');\n }\n\n /**\n * Deserialize Merkle Patricia Tree\n * @param binary - Binary\n * @param tag - Tag to use to decode value\n * @param unpTx - Implementation of unpackTx use to decode values\n * @returns Merkle Patricia Tree\n */\n constructor(binary: MPTreeBinary, encoding: E, tag: T, unpTx: typeof unpackTx) {\n this.#encoding = encoding;\n this.#tag = tag;\n this.#unpackTx = unpTx;\n this.#rootHash = binary[0].toString('hex');\n this.#nodes = Object.fromEntries(\n binary[1].map((node) => [node[0].toString('hex'), node[1]]),\n );\n\n if (this.#nodes[this.#rootHash] == null) {\n if (Object.keys(this.#nodes).length !== 0) {\n throw new MissingNodeInTreeError('Can\\'t find a node by root hash');\n }\n this.#isComplete = false;\n return;\n }\n Object.entries(this.#nodes).forEach(([key, node]) => {\n if (MPTree.#nodeHash(node) !== key) throw new MerkleTreeHashMismatchError();\n const { type } = MPTree.#parseNode(node);\n switch (type) {\n case NodeType.Branch:\n node\n .slice(0, 16)\n .filter((n) => n.length)\n .forEach((n) => {\n // TODO: enable after resolving https://github.com/aeternity/aeternity/issues/4066\n // if (n.length !== 32) {\n // throw new ArgumentError('MPTree branch item length', 32, n.length);\n // }\n if (this.#nodes[n.toString('hex')] == null) this.#isComplete = false;\n });\n break;\n case NodeType.Extension:\n if (this.#nodes[node[1].toString('hex')] == null) {\n throw new MissingNodeInTreeError('Can\\'t find a node by hash in extension node');\n }\n break;\n case NodeType.Leaf:\n break;\n default:\n throw new InternalError(`Unknown MPTree node type: ${type}`);\n }\n });\n }\n\n isEqual(tree: MPTree<E, T>): boolean {\n return this.#rootHash === tree.#rootHash;\n }\n\n static #parseNode(node: Buffer[]): { type: NodeType; value?: Buffer; path?: string } {\n switch (node.length) {\n case 17:\n return {\n type: NodeType.Branch,\n ...node[16].length !== 0 && { value: node[16] },\n };\n case 2: {\n const nibble = node[0][0] >> 4; // eslint-disable-line no-bitwise\n if (nibble > 3) throw new UnknownPathNibbleError(nibble);\n const type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf;\n const slice = [0, 2].includes(nibble) ? 2 : 1;\n return {\n type,\n ...type === NodeType.Leaf && { value: node[1] },\n path: node[0].toString('hex').slice(slice),\n };\n }\n default:\n throw new UnknownNodeLengthError(node.length);\n }\n }\n\n /**\n * Serialize Merkle Patricia Tree\n * @returns Binary\n */\n serialize(): MPTreeBinary {\n return [\n Buffer.from(this.#rootHash, 'hex'),\n Object.entries(this.#nodes).map(([mptHash, value]) => ([\n Buffer.from(mptHash, 'hex'),\n value,\n ])),\n ];\n }\n\n /**\n * Retrieve value from Merkle Patricia Tree\n * @param _key - The key of the element to retrieve\n * @returns Value associated to the specified key\n */\n #getRaw(_key: string): Buffer | undefined {\n let searchFrom = this.#rootHash;\n let key = _key;\n while (true) { // eslint-disable-line no-constant-condition\n const node = this.#nodes[searchFrom];\n if (node == null) {\n if (!this.isComplete) return undefined;\n throw new InternalError('Can\\'t find node in complete tree');\n }\n const { type, value, path } = MPTree.#parseNode(node);\n switch (type) {\n case NodeType.Branch:\n if (key.length === 0) return value;\n searchFrom = node[+`0x${key[0]}`].toString('hex');\n key = key.substring(1);\n break;\n case NodeType.Extension:\n if (key.substring(0, path?.length) !== path) return undefined;\n searchFrom = node[1].toString('hex');\n key = key.substring(path.length);\n break;\n case NodeType.Leaf:\n if (path !== key) return undefined;\n return value;\n default:\n throw new InternalError(`Unknown MPTree node type: ${type}`);\n }\n }\n }\n\n /**\n * Retrieve value from Merkle Patricia Tree\n * @param key - The key of the element to retrieve\n * @returns Value associated to the specified key\n */\n get(key: Encoded.Generic<E>): TxUnpacked & { tag: T } | undefined {\n const d = this.#getRaw(decode(key).toString('hex'));\n if (d == null) return d;\n return this.#unpackTx(encode(d, Encoding.Transaction), this.#tag);\n }\n\n #entriesRaw(): Array<[string, Buffer]> {\n const entries: Array<[string, Buffer]> = [];\n const rec = (searchFrom: string, key: string): void => {\n const node = this.#nodes[searchFrom];\n if (node == null) {\n if (!this.isComplete) return;\n throw new InternalError('Can\\'t find node in complete tree');\n }\n const { type, value, path } = MPTree.#parseNode(node);\n switch (type) {\n case NodeType.Branch:\n node\n .slice(0, 16)\n .map((t, idx): [typeof t, number] => [t, idx])\n .filter(([t]) => t.length)\n .forEach(([t, idx]) => rec(t.toString('hex'), key + idx.toString(16)));\n if (value != null) entries.push([key, value]);\n break;\n case NodeType.Extension:\n rec(node[1].toString('hex'), key + path);\n break;\n case NodeType.Leaf:\n if (value == null) throw new UnexpectedTsError();\n entries.push([key + path, value]);\n break;\n default:\n throw new InternalError(`Unknown MPTree node type: ${type}`);\n }\n };\n rec(this.#rootHash, '');\n return entries;\n }\n\n toObject(): Record<Encoded.Generic<E>, TxUnpacked & { tag: T }> {\n return Object.fromEntries(this.#entriesRaw()\n // TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066\n .filter(([k]) => this.#encoding !== Encoding.ContractAddress || k.length !== 66)\n .map(([k, v]) => [\n encode(Buffer.from(k, 'hex'), this.#encoding),\n this.#unpackTx(encode(v, Encoding.Transaction), this.#tag),\n ])) as Record<Encoded.Generic<E>, TxUnpacked & { tag: T }>;\n }\n}\n\nexport default function genMPTreeField<E extends Encoding, T extends Tag>(encoding: E, tag: T): {\n serialize: (value: MPTree<E, T>) => MPTreeBinary;\n deserialize: (value: MPTreeBinary, o: { unpackTx: typeof unpackTx }) => MPTree<E, T>;\n} {\n return {\n serialize(value) {\n return value.serialize();\n },\n\n deserialize(value, { unpackTx }) {\n return new MPTree(value, encoding, tag, unpackTx);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,OAAAA,IAAA,MAA2C,KAAK;AAAC;EAAAC,MAAA,EAAAC;AAAA,IAAAF,IAAA;AAAA,SAExCG,IAAI;AAAA,SAEXC,2BAA2B,EAC3BC,sBAAsB,EACtBC,sBAAsB,EACtBC,iBAAiB,EACjBC,sBAAsB,EACtBC,aAAa;AAAA,SAGbC,MAAM,EAAET,MAAM,EAAWU,QAAQ;AAAA,IAK9BC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA,EAARA,QAAQ;AAAA,IAAAC,SAAA,oBAAAC,OAAA;AAAA,IAAAC,WAAA,oBAAAD,OAAA;AAAA,IAAAE,MAAA,oBAAAF,OAAA;AAAA,IAAAG,SAAA,oBAAAH,OAAA;AAAA,IAAAI,IAAA,oBAAAJ,OAAA;AAAA,IAAAK,SAAA,oBAAAL,OAAA;AAAA,IAAAM,OAAA,oBAAAC,OAAA;AAAA,IAAA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AAoCzD,QAAW,EAAEC,GAAM,EAG3F;EACA,OAAO;IACL8B,SAASA,CAACzB,KAAK,EAAE;MACf,OAAOA,KAAK,CAACyB,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED2B,WAAWA,CAACpD,KAAK,EAAE;MAAEqD;IAAS,CAAC,EAAE;MAC/B,OAAO,IAAIhE,MAAM,CAACW,KAAK,EAAEN,QAAQ,EAAEC,GAAG,EAAE0D,QAAQ,CAAC;IACnD;EACF,CAAC;AACH"}
@@ -6,7 +6,7 @@ declare const _default: {
6
6
  name: AensName;
7
7
  }): string;
8
8
  /**
9
- * @param value - AENS name fee Buffer
9
+ * @param value - AENS name fee
10
10
  * @param txFields - Transaction fields
11
11
  * @param txFields.name - AENS Name in transaction
12
12
  */
@@ -11,7 +11,7 @@ export default {
11
11
  return value.toFixed();
12
12
  },
13
13
  /**
14
- * @param value - AENS name fee Buffer
14
+ * @param value - AENS name fee
15
15
  * @param txFields - Transaction fields
16
16
  * @param txFields.name - AENS Name in transaction
17
17
  */
@@ -1 +1 @@
1
- {"version":3,"file":"name-fee.mjs","names":["BigNumber","getMinimumNameFee","InsufficientNameFeeError","coinAmount","serializeAettos","_value","txFields","minNameFee","name","value","gt","toFixed","serialize","parameters","call"],"sources":["../../../../src/tx/builder/field-types/name-fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { getMinimumNameFee } from '../helpers';\nimport { InsufficientNameFeeError } from '../../../utils/errors';\nimport coinAmount from './coin-amount';\nimport { AensName, Int } from '../constants';\n\nexport default {\n ...coinAmount,\n\n serializeAettos(\n _value: string | undefined,\n txFields: { name: AensName },\n ): string {\n const minNameFee = getMinimumNameFee(txFields.name);\n const value = new BigNumber(_value ?? minNameFee);\n if (minNameFee.gt(value)) throw new InsufficientNameFeeError(value, minNameFee);\n return value.toFixed();\n },\n\n /**\n * @param value - AENS name fee Buffer\n * @param txFields - Transaction fields\n * @param txFields.name - AENS Name in transaction\n */\n serialize(\n value: Int | undefined,\n txFields: { name: AensName } & Parameters<typeof coinAmount['serialize']>[1],\n parameters: Parameters<typeof coinAmount['serialize']>[2],\n ): Buffer {\n return coinAmount.serialize.call(this, value, txFields, parameters);\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,iBAAiB;AAAA,SACjBC,wBAAwB;AAAA,OAC1BC,UAAU;AAGjB,eAAe;EACb,GAAGA,UAAU;EAEbC,eAAeA,CACbC,MAA0B,EAC1BC,QAA4B,EACpB;IACR,MAAMC,UAAU,GAAGN,iBAAiB,CAACK,QAAQ,CAACE,IAAI,CAAC;IACnD,MAAMC,KAAK,GAAG,IAAIT,SAAS,CAACK,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIE,UAAU,CAAC;IACjD,IAAIA,UAAU,CAACG,EAAE,CAACD,KAAK,CAAC,EAAE,MAAM,IAAIP,wBAAwB,CAACO,KAAK,EAAEF,UAAU,CAAC;IAC/E,OAAOE,KAAK,CAACE,OAAO,CAAC,CAAC;EACxB,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,SAASA,CACPH,KAAsB,EACtBH,QAA4E,EAC5EO,UAAyD,EACjD;IACR,OAAOV,UAAU,CAACS,SAAS,CAACE,IAAI,CAAC,IAAI,EAAEL,KAAK,EAAEH,QAAQ,EAAEO,UAAU,CAAC;EACrE;AACF,CAAC"}
1
+ {"version":3,"file":"name-fee.mjs","names":["BigNumber","getMinimumNameFee","InsufficientNameFeeError","coinAmount","serializeAettos","_value","txFields","minNameFee","name","value","gt","toFixed","serialize","parameters","call"],"sources":["../../../../src/tx/builder/field-types/name-fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { getMinimumNameFee } from '../helpers';\nimport { InsufficientNameFeeError } from '../../../utils/errors';\nimport coinAmount from './coin-amount';\nimport { AensName, Int } from '../constants';\n\nexport default {\n ...coinAmount,\n\n serializeAettos(\n _value: string | undefined,\n txFields: { name: AensName },\n ): string {\n const minNameFee = getMinimumNameFee(txFields.name);\n const value = new BigNumber(_value ?? minNameFee);\n if (minNameFee.gt(value)) throw new InsufficientNameFeeError(value, minNameFee);\n return value.toFixed();\n },\n\n /**\n * @param value - AENS name fee\n * @param txFields - Transaction fields\n * @param txFields.name - AENS Name in transaction\n */\n serialize(\n value: Int | undefined,\n txFields: { name: AensName } & Parameters<typeof coinAmount['serialize']>[1],\n parameters: Parameters<typeof coinAmount['serialize']>[2],\n ): Buffer {\n return coinAmount.serialize.call(this, value, txFields, parameters);\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,iBAAiB;AAAA,SACjBC,wBAAwB;AAAA,OAC1BC,UAAU;AAGjB,eAAe;EACb,GAAGA,UAAU;EAEbC,eAAeA,CACbC,MAA0B,EAC1BC,QAA4B,EACpB;IACR,MAAMC,UAAU,GAAGN,iBAAiB,CAACK,QAAQ,CAACE,IAAI,CAAC;IACnD,MAAMC,KAAK,GAAG,IAAIT,SAAS,CAACK,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIE,UAAU,CAAC;IACjD,IAAIA,UAAU,CAACG,EAAE,CAACD,KAAK,CAAC,EAAE,MAAM,IAAIP,wBAAwB,CAACO,KAAK,EAAEF,UAAU,CAAC;IAC/E,OAAOE,KAAK,CAACE,OAAO,CAAC,CAAC;EACxB,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,SAASA,CACPH,KAAsB,EACtBH,QAA4E,EAC5EO,UAAyD,EACjD;IACR,OAAOV,UAAU,CAACS,SAAS,CAACE,IAAI,CAAC,IAAI,EAAEL,KAAK,EAAEH,QAAQ,EAAEO,UAAU,CAAC;EACrE;AACF,CAAC"}
@@ -8,6 +8,7 @@ export default function genNonceField<SenderKey extends string>(senderKey: Sende
8
8
  } & {
9
9
  strategy?: NextNonceStrategy;
10
10
  onNode?: Node;
11
+ _isInternalBuild?: boolean;
11
12
  }) => Promise<number>;
12
13
  deserialize: (value: Buffer) => number;
13
14
  senderKey: string;
@@ -6,6 +6,8 @@ export default function genNonceField(senderKey) {
6
6
  ...shortUInt,
7
7
  async prepare(value, params, options) {
8
8
  if (value != null) return value;
9
+ // TODO: uncomment the below line
10
+ // if (options._isInternalBuild === true) return 0;
9
11
  const {
10
12
  onNode,
11
13
  strategy
@@ -1 +1 @@
1
- {"version":3,"file":"nonce.mjs","names":["isAccountNotFoundError","shortUInt","ArgumentError","genNonceField","senderKey","prepare","value","params","options","onNode","strategy","senderId","requirement","getAccountNextNonce","replace","catch","error","nextNonce"],"sources":["../../../../src/tx/builder/field-types/nonce.ts"],"sourcesContent":["import { isAccountNotFoundError } from '../../../utils/other';\nimport shortUInt from './short-u-int';\nimport Node from '../../../Node';\nimport { ArgumentError } from '../../../utils/errors';\nimport { NextNonceStrategy } from '../../../apis/node';\n\nexport default function genNonceField<SenderKey extends string>(senderKey: SenderKey): {\n serialize: (value: number) => Buffer;\n // TODO: (value: number) => Promise<number> | (value: undefined, ...) => Promise<number>\n prepare: (\n value: number | undefined,\n params: {},\n // TODO: replace `string` with AddressEncodings\n options: { [key in SenderKey]: string } & { strategy?: NextNonceStrategy; onNode?: Node },\n ) => Promise<number>;\n deserialize: (value: Buffer) => number;\n senderKey: string;\n} {\n return {\n ...shortUInt,\n\n async prepare(value, params, options) {\n if (value != null) return value;\n const { onNode, strategy } = options;\n const senderId = options[senderKey];\n const requirement = 'provided (or provide `nonce` instead)';\n if (onNode == null) throw new ArgumentError('onNode', requirement, onNode);\n if (senderId == null) throw new ArgumentError('senderId', requirement, senderId);\n return (\n await onNode.getAccountNextNonce(senderId.replace(/^ok_/, 'ak_'), { strategy })\n .catch((error) => {\n if (!isAccountNotFoundError(error)) throw error;\n return { nextNonce: 1 };\n })\n ).nextNonce;\n },\n\n senderKey,\n };\n}\n"],"mappings":"SAASA,sBAAsB;AAAA,OACxBC,SAAS;AAAA,SAEPC,aAAa;AAGtB,eAAe,SAASC,aAAaA,CAA2BC,SAAoB,EAWlF;EACA,OAAO;IACL,GAAGH,SAAS;IAEZ,MAAMI,OAAOA,CAACC,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAE;MACpC,IAAIF,KAAK,IAAI,IAAI,EAAE,OAAOA,KAAK;MAC/B,MAAM;QAAEG,MAAM;QAAEC;MAAS,CAAC,GAAGF,OAAO;MACpC,MAAMG,QAAQ,GAAGH,OAAO,CAACJ,SAAS,CAAC;MACnC,MAAMQ,WAAW,GAAG,uCAAuC;MAC3D,IAAIH,MAAM,IAAI,IAAI,EAAE,MAAM,IAAIP,aAAa,CAAC,QAAQ,EAAEU,WAAW,EAAEH,MAAM,CAAC;MAC1E,IAAIE,QAAQ,IAAI,IAAI,EAAE,MAAM,IAAIT,aAAa,CAAC,UAAU,EAAEU,WAAW,EAAED,QAAQ,CAAC;MAChF,OAAO,CACL,MAAMF,MAAM,CAACI,mBAAmB,CAACF,QAAQ,CAACG,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;QAAEJ;MAAS,CAAC,CAAC,CAC5EK,KAAK,CAAEC,KAAK,IAAK;QAChB,IAAI,CAAChB,sBAAsB,CAACgB,KAAK,CAAC,EAAE,MAAMA,KAAK;QAC/C,OAAO;UAAEC,SAAS,EAAE;QAAE,CAAC;MACzB,CAAC,CAAC,EACJA,SAAS;IACb,CAAC;IAEDb;EACF,CAAC;AACH"}
1
+ {"version":3,"file":"nonce.mjs","names":["isAccountNotFoundError","shortUInt","ArgumentError","genNonceField","senderKey","prepare","value","params","options","onNode","strategy","senderId","requirement","getAccountNextNonce","replace","catch","error","nextNonce"],"sources":["../../../../src/tx/builder/field-types/nonce.ts"],"sourcesContent":["import { isAccountNotFoundError } from '../../../utils/other';\nimport shortUInt from './short-u-int';\nimport Node from '../../../Node';\nimport { ArgumentError } from '../../../utils/errors';\nimport { NextNonceStrategy } from '../../../apis/node';\n\nexport default function genNonceField<SenderKey extends string>(senderKey: SenderKey): {\n serialize: (value: number) => Buffer;\n // TODO: (value: number) => Promise<number> | (value: undefined, ...) => Promise<number>\n prepare: (\n value: number | undefined,\n params: {},\n // TODO: replace `string` with AddressEncodings\n options: { [key in SenderKey]: string } & {\n strategy?: NextNonceStrategy;\n onNode?: Node;\n _isInternalBuild?: boolean;\n },\n ) => Promise<number>;\n deserialize: (value: Buffer) => number;\n senderKey: string;\n} {\n return {\n ...shortUInt,\n\n async prepare(value, params, options) {\n if (value != null) return value;\n // TODO: uncomment the below line\n // if (options._isInternalBuild === true) return 0;\n const { onNode, strategy } = options;\n const senderId = options[senderKey];\n const requirement = 'provided (or provide `nonce` instead)';\n if (onNode == null) throw new ArgumentError('onNode', requirement, onNode);\n if (senderId == null) throw new ArgumentError('senderId', requirement, senderId);\n return (\n await onNode.getAccountNextNonce(senderId.replace(/^ok_/, 'ak_'), { strategy })\n .catch((error) => {\n if (!isAccountNotFoundError(error)) throw error;\n return { nextNonce: 1 };\n })\n ).nextNonce;\n },\n\n senderKey,\n };\n}\n"],"mappings":"SAASA,sBAAsB;AAAA,OACxBC,SAAS;AAAA,SAEPC,aAAa;AAGtB,eAAe,SAASC,aAAaA,CAA2BC,SAAoB,EAelF;EACA,OAAO;IACL,GAAGH,SAAS;IAEZ,MAAMI,OAAOA,CAACC,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAE;MACpC,IAAIF,KAAK,IAAI,IAAI,EAAE,OAAOA,KAAK;MAC/B;MACA;MACA,MAAM;QAAEG,MAAM;QAAEC;MAAS,CAAC,GAAGF,OAAO;MACpC,MAAMG,QAAQ,GAAGH,OAAO,CAACJ,SAAS,CAAC;MACnC,MAAMQ,WAAW,GAAG,uCAAuC;MAC3D,IAAIH,MAAM,IAAI,IAAI,EAAE,MAAM,IAAIP,aAAa,CAAC,QAAQ,EAAEU,WAAW,EAAEH,MAAM,CAAC;MAC1E,IAAIE,QAAQ,IAAI,IAAI,EAAE,MAAM,IAAIT,aAAa,CAAC,UAAU,EAAEU,WAAW,EAAED,QAAQ,CAAC;MAChF,OAAO,CACL,MAAMF,MAAM,CAACI,mBAAmB,CAACF,QAAQ,CAACG,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;QAAEJ;MAAS,CAAC,CAAC,CAC5EK,KAAK,CAAEC,KAAK,IAAK;QAChB,IAAI,CAAChB,sBAAsB,CAACgB,KAAK,CAAC,EAAE,MAAMA,KAAK;QAC/C,OAAO;UAAEC,SAAS,EAAE;QAAE,CAAC;MACzB,CAAC,CAAC,EACJA,SAAS;IACb,CAAC;IAEDb;EACF,CAAC;AACH"}
@@ -24,13 +24,10 @@ export default {
24
24
  * @returns Deserialize pointer array
25
25
  */
26
26
  deserialize(pointers) {
27
- return pointers.map(_ref => {
28
- let [key, id] = _ref;
29
- return {
30
- key: key.toString(),
31
- id: addressAny.deserialize(id)
32
- };
33
- });
27
+ return pointers.map(([key, id]) => ({
28
+ key: key.toString(),
29
+ id: addressAny.deserialize(id)
30
+ }));
34
31
  }
35
32
  };
36
33
  //# sourceMappingURL=pointers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pointers.mjs","names":["toBytes","IllegalArgumentError","address","idTagToEncoding","addressAny","serialize","pointers","length","map","pointer","key","id","deserialize","_ref","toString"],"sources":["../../../../src/tx/builder/field-types/pointers.ts"],"sourcesContent":["import { NamePointer as NamePointerString } from '../../../apis/node';\nimport { toBytes } from '../../../utils/bytes';\nimport { Encoded } from '../../../utils/encoder';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport address, { AddressEncodings, idTagToEncoding } from './address';\n\nconst addressAny = address(...idTagToEncoding);\n\n// TODO: remove after fixing node types\ntype NamePointer = NamePointerString & {\n id: Encoded.Generic<AddressEncodings>;\n};\n\nexport default {\n /**\n * Helper function to build pointers for name update TX\n * @param pointers - Array of pointers\n * `([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])`\n * @returns Serialized pointers array\n */\n serialize(pointers: NamePointer[]): Buffer[][] {\n if (pointers.length > 32) {\n throw new IllegalArgumentError(`Expected 32 pointers or less, got ${pointers.length} instead`);\n }\n\n return pointers.map(\n (pointer) => [toBytes(pointer.key), addressAny.serialize(pointer.id)],\n );\n },\n\n /**\n * Helper function to read pointers from name update TX\n * @param pointers - Array of pointers\n * @returns Deserialize pointer array\n */\n deserialize(pointers: Array<[key: Buffer, id: Buffer]>): NamePointer[] {\n return pointers.map(\n ([key, id]) => ({ key: key.toString(), id: addressAny.deserialize(id) }),\n );\n },\n};\n"],"mappings":"SACSA,OAAO;AAAA,SAEPC,oBAAoB;AAAA,OACtBC,OAAO,IAAsBC,eAAe;AAEnD,MAAMC,UAAU,GAAGF,OAAO,CAAC,GAAGC,eAAe,CAAC;;AAE9C;;AAKA,eAAe;EACb;AACF;AACA;AACA;AACA;AACA;EACEE,SAASA,CAACC,QAAuB,EAAc;IAC7C,IAAIA,QAAQ,CAACC,MAAM,GAAG,EAAE,EAAE;MACxB,MAAM,IAAIN,oBAAoB,CAAE,qCAAoCK,QAAQ,CAACC,MAAO,UAAS,CAAC;IAChG;IAEA,OAAOD,QAAQ,CAACE,GAAG,CAChBC,OAAO,IAAK,CAACT,OAAO,CAACS,OAAO,CAACC,GAAG,CAAC,EAAEN,UAAU,CAACC,SAAS,CAACI,OAAO,CAACE,EAAE,CAAC,CACtE,CAAC;EACH,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAACN,QAA0C,EAAiB;IACrE,OAAOA,QAAQ,CAACE,GAAG,CACjBK,IAAA;MAAA,IAAC,CAACH,GAAG,EAAEC,EAAE,CAAC,GAAAE,IAAA;MAAA,OAAM;QAAEH,GAAG,EAAEA,GAAG,CAACI,QAAQ,CAAC,CAAC;QAAEH,EAAE,EAAEP,UAAU,CAACQ,WAAW,CAACD,EAAE;MAAE,CAAC;IAAA,CACzE,CAAC;EACH;AACF,CAAC"}
1
+ {"version":3,"file":"pointers.mjs","names":["toBytes","IllegalArgumentError","address","idTagToEncoding","addressAny","serialize","pointers","length","map","pointer","key","id","deserialize","toString"],"sources":["../../../../src/tx/builder/field-types/pointers.ts"],"sourcesContent":["import { NamePointer as NamePointerString } from '../../../apis/node';\nimport { toBytes } from '../../../utils/bytes';\nimport { Encoded } from '../../../utils/encoder';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport address, { AddressEncodings, idTagToEncoding } from './address';\n\nconst addressAny = address(...idTagToEncoding);\n\n// TODO: remove after fixing node types\ntype NamePointer = NamePointerString & {\n id: Encoded.Generic<AddressEncodings>;\n};\n\nexport default {\n /**\n * Helper function to build pointers for name update TX\n * @param pointers - Array of pointers\n * `([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])`\n * @returns Serialized pointers array\n */\n serialize(pointers: NamePointer[]): Buffer[][] {\n if (pointers.length > 32) {\n throw new IllegalArgumentError(`Expected 32 pointers or less, got ${pointers.length} instead`);\n }\n\n return pointers.map(\n (pointer) => [toBytes(pointer.key), addressAny.serialize(pointer.id)],\n );\n },\n\n /**\n * Helper function to read pointers from name update TX\n * @param pointers - Array of pointers\n * @returns Deserialize pointer array\n */\n deserialize(pointers: Array<[key: Buffer, id: Buffer]>): NamePointer[] {\n return pointers.map(\n ([key, id]) => ({ key: key.toString(), id: addressAny.deserialize(id) }),\n );\n },\n};\n"],"mappings":"SACSA,OAAO;AAAA,SAEPC,oBAAoB;AAAA,OACtBC,OAAO,IAAsBC,eAAe;AAEnD,MAAMC,UAAU,GAAGF,OAAO,CAAC,GAAGC,eAAe,CAAC;;AAE9C;;AAKA,eAAe;EACb;AACF;AACA;AACA;AACA;AACA;EACEE,SAASA,CAACC,QAAuB,EAAc;IAC7C,IAAIA,QAAQ,CAACC,MAAM,GAAG,EAAE,EAAE;MACxB,MAAM,IAAIN,oBAAoB,CAAE,qCAAoCK,QAAQ,CAACC,MAAO,UAAS,CAAC;IAChG;IAEA,OAAOD,QAAQ,CAACE,GAAG,CAChBC,OAAO,IAAK,CAACT,OAAO,CAACS,OAAO,CAACC,GAAG,CAAC,EAAEN,UAAU,CAACC,SAAS,CAACI,OAAO,CAACE,EAAE,CAAC,CACtE,CAAC;EACH,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAACN,QAA0C,EAAiB;IACrE,OAAOA,QAAQ,CAACE,GAAG,CACjB,CAAC,CAACE,GAAG,EAAEC,EAAE,CAAC,MAAM;MAAED,GAAG,EAAEA,GAAG,CAACG,QAAQ,CAAC,CAAC;MAAEF,EAAE,EAAEP,UAAU,CAACQ,WAAW,CAACD,EAAE;IAAE,CAAC,CACzE,CAAC;EACH;AACF,CAAC"}
@@ -0,0 +1,23 @@
1
+ /// <reference types="node" />
2
+ import { NamePointer as NamePointerString } from '../../../apis/node';
3
+ import { Encoded, Encoding } from '../../../utils/encoder';
4
+ import { AddressEncodings } from './address';
5
+ type NamePointer = NamePointerString & {
6
+ id: Encoded.Generic<AddressEncodings | Encoding.Bytearray>;
7
+ };
8
+ declare const _default: {
9
+ /**
10
+ * Helper function to build pointers for name update TX
11
+ * @param pointers - Array of pointers
12
+ * `([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])`
13
+ * @returns Serialized pointers array
14
+ */
15
+ serialize(pointers: NamePointer[]): Buffer[][];
16
+ /**
17
+ * Helper function to read pointers from name update TX
18
+ * @param pointers - Array of pointers
19
+ * @returns Deserialize pointer array
20
+ */
21
+ deserialize(pointers: Array<[key: Buffer, id: Buffer]>): NamePointer[];
22
+ };
23
+ export default _default;
@@ -0,0 +1,65 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import { toBytes } from "../../../utils/bytes.mjs";
6
+ import { Encoding, decode, encode } from "../../../utils/encoder.mjs";
7
+ import { isAddressValid } from "../../../utils/crypto.mjs";
8
+ import { IllegalArgumentError, DecodeError, ArgumentError } from "../../../utils/errors.mjs";
9
+ import address, { idTagToEncoding } from "./address.mjs";
10
+ const ID_TAG = _Buffer.from([1]);
11
+ const DATA_TAG = _Buffer.from([2]);
12
+ const DATA_LENGTH_MAX = 1024;
13
+ const addressAny = address(...idTagToEncoding);
14
+
15
+ // TODO: remove after fixing node types
16
+
17
+ export default {
18
+ /**
19
+ * Helper function to build pointers for name update TX
20
+ * @param pointers - Array of pointers
21
+ * `([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])`
22
+ * @returns Serialized pointers array
23
+ */
24
+ serialize(pointers) {
25
+ if (pointers.length > 32) {
26
+ throw new IllegalArgumentError(`Expected 32 pointers or less, got ${pointers.length} instead`);
27
+ }
28
+ return pointers.map(({
29
+ key,
30
+ id
31
+ }) => {
32
+ let payload;
33
+ if (isAddressValid(id, ...idTagToEncoding)) payload = [ID_TAG, addressAny.serialize(id)];
34
+ if (isAddressValid(id, Encoding.Bytearray)) {
35
+ const data = decode(id);
36
+ if (data.length > DATA_LENGTH_MAX) {
37
+ throw new ArgumentError('Raw pointer', `shorter than ${DATA_LENGTH_MAX + 1} bytes`, `${data.length} bytes`);
38
+ }
39
+ payload = [DATA_TAG, data];
40
+ }
41
+ if (payload == null) throw new DecodeError(`Unknown AENS pointer value: ${id}`);
42
+ return [toBytes(key), _Buffer.concat(payload)];
43
+ });
44
+ },
45
+ /**
46
+ * Helper function to read pointers from name update TX
47
+ * @param pointers - Array of pointers
48
+ * @returns Deserialize pointer array
49
+ */
50
+ deserialize(pointers) {
51
+ return pointers.map(([bKey, bId]) => {
52
+ const tag = bId.subarray(0, 1);
53
+ const payload = bId.subarray(1);
54
+ let id;
55
+ if (tag.equals(ID_TAG)) id = addressAny.deserialize(payload);
56
+ if (tag.equals(DATA_TAG)) id = encode(payload, Encoding.Bytearray);
57
+ if (id == null) throw new DecodeError(`Unknown AENS pointer tag: ${tag}`);
58
+ return {
59
+ key: bKey.toString(),
60
+ id
61
+ };
62
+ });
63
+ }
64
+ };
65
+ //# sourceMappingURL=pointers2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointers2.mjs","names":["toBytes","Encoding","decode","encode","isAddressValid","IllegalArgumentError","DecodeError","ArgumentError","address","idTagToEncoding","ID_TAG","_Buffer","from","DATA_TAG","DATA_LENGTH_MAX","addressAny","serialize","pointers","length","map","key","id","payload","Bytearray","data","concat","deserialize","bKey","bId","tag","subarray","equals","toString"],"sources":["../../../../src/tx/builder/field-types/pointers2.ts"],"sourcesContent":["import { NamePointer as NamePointerString } from '../../../apis/node';\nimport { toBytes } from '../../../utils/bytes';\nimport {\n Encoded, Encoding, decode, encode,\n} from '../../../utils/encoder';\nimport { isAddressValid } from '../../../utils/crypto';\nimport { IllegalArgumentError, DecodeError, ArgumentError } from '../../../utils/errors';\nimport address, { AddressEncodings, idTagToEncoding } from './address';\n\nconst ID_TAG = Buffer.from([1]);\nconst DATA_TAG = Buffer.from([2]);\nconst DATA_LENGTH_MAX = 1024;\nconst addressAny = address(...idTagToEncoding);\n\n// TODO: remove after fixing node types\ntype NamePointer = NamePointerString & {\n id: Encoded.Generic<AddressEncodings | Encoding.Bytearray>;\n};\n\nexport default {\n /**\n * Helper function to build pointers for name update TX\n * @param pointers - Array of pointers\n * `([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])`\n * @returns Serialized pointers array\n */\n serialize(pointers: NamePointer[]): Buffer[][] {\n if (pointers.length > 32) {\n throw new IllegalArgumentError(`Expected 32 pointers or less, got ${pointers.length} instead`);\n }\n return pointers.map(({ key, id }) => {\n let payload;\n if (isAddressValid(id, ...idTagToEncoding)) payload = [ID_TAG, addressAny.serialize(id)];\n if (isAddressValid(id, Encoding.Bytearray)) {\n const data = decode(id);\n if (data.length > DATA_LENGTH_MAX) {\n throw new ArgumentError('Raw pointer', `shorter than ${DATA_LENGTH_MAX + 1} bytes`, `${data.length} bytes`);\n }\n payload = [DATA_TAG, data];\n }\n if (payload == null) throw new DecodeError(`Unknown AENS pointer value: ${id}`);\n return [toBytes(key), Buffer.concat(payload)];\n });\n },\n\n /**\n * Helper function to read pointers from name update TX\n * @param pointers - Array of pointers\n * @returns Deserialize pointer array\n */\n deserialize(pointers: Array<[key: Buffer, id: Buffer]>): NamePointer[] {\n return pointers.map(([bKey, bId]) => {\n const tag = bId.subarray(0, 1);\n const payload = bId.subarray(1);\n let id;\n if (tag.equals(ID_TAG)) id = addressAny.deserialize(payload);\n if (tag.equals(DATA_TAG)) id = encode(payload, Encoding.Bytearray);\n if (id == null) throw new DecodeError(`Unknown AENS pointer tag: ${tag}`);\n return { key: bKey.toString(), id };\n });\n },\n};\n"],"mappings":";;;;SACSA,OAAO;AAAA,SAELC,QAAQ,EAAEC,MAAM,EAAEC,MAAM;AAAA,SAE1BC,cAAc;AAAA,SACdC,oBAAoB,EAAEC,WAAW,EAAEC,aAAa;AAAA,OAClDC,OAAO,IAAsBC,eAAe;AAEnD,MAAMC,MAAM,GAAGC,OAAA,CAAOC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/B,MAAMC,QAAQ,GAAGF,OAAA,CAAOC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACjC,MAAME,eAAe,GAAG,IAAI;AAC5B,MAAMC,UAAU,GAAGP,OAAO,CAAC,GAAGC,eAAe,CAAC;;AAE9C;;AAKA,eAAe;EACb;AACF;AACA;AACA;AACA;AACA;EACEO,SAASA,CAACC,QAAuB,EAAc;IAC7C,IAAIA,QAAQ,CAACC,MAAM,GAAG,EAAE,EAAE;MACxB,MAAM,IAAIb,oBAAoB,CAAE,qCAAoCY,QAAQ,CAACC,MAAO,UAAS,CAAC;IAChG;IACA,OAAOD,QAAQ,CAACE,GAAG,CAAC,CAAC;MAAEC,GAAG;MAAEC;IAAG,CAAC,KAAK;MACnC,IAAIC,OAAO;MACX,IAAIlB,cAAc,CAACiB,EAAE,EAAE,GAAGZ,eAAe,CAAC,EAAEa,OAAO,GAAG,CAACZ,MAAM,EAAEK,UAAU,CAACC,SAAS,CAACK,EAAE,CAAC,CAAC;MACxF,IAAIjB,cAAc,CAACiB,EAAE,EAAEpB,QAAQ,CAACsB,SAAS,CAAC,EAAE;QAC1C,MAAMC,IAAI,GAAGtB,MAAM,CAACmB,EA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
+ /// <reference types="node" />
2
+ import { Int } from '../constants';
3
+ import Node from '../../../Node';
4
+ import { Encoded } from '../../../utils/encoder';
5
+ /**
6
+ * Oracle query fee
7
+ */
8
+ declare const _default: {
9
+ prepare(value: Int | undefined, params: {}, options: {
10
+ oracleId?: Encoded.OracleAddress;
11
+ onNode?: Node;
12
+ }): Promise<Int>;
13
+ serializeAettos(value: string | undefined, params: {}, options: {}): string;
14
+ serialize(value: Int | undefined, params: {}, { denomination, ...options }: {
15
+ denomination?: import("../../..").AE_AMOUNT_FORMATS | undefined;
16
+ }): Buffer;
17
+ deserialize(value: Buffer): string;
18
+ };
19
+ export default _default;
@@ -0,0 +1,20 @@
1
+ import coinAmount from "./coin-amount.mjs";
2
+ import { ArgumentError } from "../../../utils/errors.mjs";
3
+ /**
4
+ * Oracle query fee
5
+ */
6
+ export default {
7
+ ...coinAmount,
8
+ async prepare(value, params, options) {
9
+ if (value != null) return value;
10
+ const {
11
+ onNode,
12
+ oracleId
13
+ } = options;
14
+ const requirement = 'provided (or provide `queryFee` instead)';
15
+ if (onNode == null) throw new ArgumentError('onNode', requirement, onNode);
16
+ if (oracleId == null) throw new ArgumentError('oracleId', requirement, oracleId);
17
+ return (await onNode.getOracleByPubkey(oracleId)).queryFee.toString();
18
+ }
19
+ };
20
+ //# sourceMappingURL=query-fee.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-fee.mjs","names":["coinAmount","ArgumentError","prepare","value","params","options","onNode","oracleId","requirement","getOracleByPubkey","queryFee","toString"],"sources":["../../../../src/tx/builder/field-types/query-fee.ts"],"sourcesContent":["import coinAmount from './coin-amount';\nimport { Int } from '../constants';\nimport Node from '../../../Node';\nimport { Encoded } from '../../../utils/encoder';\nimport { ArgumentError } from '../../../utils/errors';\n\n/**\n * Oracle query fee\n */\nexport default {\n ...coinAmount,\n\n async prepare(\n value: Int | undefined,\n params: {},\n options: { oracleId?: Encoded.OracleAddress; onNode?: Node },\n ) {\n if (value != null) return value;\n const { onNode, oracleId } = options;\n const requirement = 'provided (or provide `queryFee` instead)';\n if (onNode == null) throw new ArgumentError('onNode', requirement, onNode);\n if (oracleId == null) throw new ArgumentError('oracleId', requirement, oracleId);\n return (await onNode.getOracleByPubkey(oracleId)).queryFee.toString();\n },\n};\n"],"mappings":"OAAOA,UAAU;AAAA,SAIRC,aAAa;AAEtB;AACA;AACA;AACA,eAAe;EACb,GAAGD,UAAU;EAEb,MAAME,OAAOA,CACXC,KAAsB,EACtBC,MAAU,EACVC,OAA4D,EAC5D;IACA,IAAIF,KAAK,IAAI,IAAI,EAAE,OAAOA,KAAK;IAC/B,MAAM;MAAEG,MAAM;MAAEC;IAAS,CAAC,GAAGF,OAAO;IACpC,MAAMG,WAAW,GAAG,0CAA0C;IAC9D,IAAIF,MAAM,IAAI,IAAI,EAAE,MAAM,IAAIL,aAAa,CAAC,QAAQ,EAAEO,WAAW,EAAEF,MAAM,CAAC;IAC1E,IAAIC,QAAQ,IAAI,IAAI,EAAE,MAAM,IAAIN,aAAa,CAAC,UAAU,EAAEO,WAAW,EAAED,QAAQ,CAAC;IAChF,OAAO,CAAC,MAAMD,MAAM,CAACG,iBAAiB,CAACF,QAAQ,CAAC,EAAEG,QAAQ,CAACC,QAAQ,CAAC,CAAC;EACvE;AACF,CAAC"}
@@ -1,10 +1,18 @@
1
1
  /// <reference types="node" />
2
2
  import Node from '../../../Node';
3
+ import { _getPollInterval } from '../../../chain';
4
+ /**
5
+ * Time to leave
6
+ */
3
7
  declare const _default: {
4
8
  serialize(value: number | undefined): Buffer;
5
- prepare(value: number | undefined, params: {}, { onNode, absoluteTtl }: {
9
+ prepare(value: number | undefined, params: {}, { onNode, absoluteTtl, _isInternalBuild, ...options }: {
6
10
  onNode?: Node | undefined;
7
11
  absoluteTtl?: boolean | undefined;
12
+ _isInternalBuild?: boolean | undefined;
13
+ } & {
14
+ _expectedMineRate?: number | undefined;
15
+ _microBlockCycle?: number | undefined;
8
16
  }): Promise<number | undefined>;
9
17
  deserialize(value: Buffer): number;
10
18
  };
@@ -1,19 +1,30 @@
1
1
  import shortUInt from "./short-u-int.mjs";
2
2
  import { ArgumentError } from "../../../utils/errors.mjs";
3
+ import { getHeight } from "../../../chain.mjs";
4
+ /**
5
+ * Time to leave
6
+ */
3
7
  export default {
4
8
  ...shortUInt,
5
9
  serialize(value) {
6
10
  return shortUInt.serialize(value !== null && value !== void 0 ? value : 0);
7
11
  },
8
- async prepare(value, params, // TODO: { absoluteTtl: true } | { absoluteTtl: false, onNode: Node }
9
- _ref) {
10
- let {
11
- onNode,
12
- absoluteTtl
13
- } = _ref;
14
- if (absoluteTtl !== true && value !== 0 && value != null) {
12
+ async prepare(value, params,
13
+ // TODO: { absoluteTtl: true } | { absoluteTtl: false, onNode: Node }
14
+ {
15
+ onNode,
16
+ absoluteTtl,
17
+ _isInternalBuild,
18
+ ...options
19
+ }) {
20
+ if (absoluteTtl !== true && value !== 0 && (value != null || _isInternalBuild === true)) {
21
+ var _value;
15
22
  if (onNode == null) throw new ArgumentError('onNode', 'provided', onNode);
16
- value += (await onNode.getCurrentKeyBlock()).height;
23
+ value = ((_value = value) !== null && _value !== void 0 ? _value : 3) + (await getHeight({
24
+ ...options,
25
+ onNode,
26
+ cached: true
27
+ }));
17
28
  }
18
29
  return value;
19
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ttl.mjs","names":["shortUInt","ArgumentError","serialize","value","prepare","params","_ref","onNode","absoluteTtl","getCurrentKeyBlock","height"],"sources":["../../../../src/tx/builder/field-types/ttl.ts"],"sourcesContent":["import shortUInt from './short-u-int';\nimport Node from '../../../Node';\nimport { ArgumentError } from '../../../utils/errors';\n\nexport default {\n ...shortUInt,\n\n serialize(value: number | undefined): Buffer {\n return shortUInt.serialize(value ?? 0);\n },\n\n async prepare(\n value: number | undefined,\n params: {},\n // TODO: { absoluteTtl: true } | { absoluteTtl: false, onNode: Node }\n { onNode, absoluteTtl }: { onNode?: Node; absoluteTtl?: boolean },\n ) {\n if (absoluteTtl !== true && value !== 0 && value != null) {\n if (onNode == null) throw new ArgumentError('onNode', 'provided', onNode);\n value += (await onNode.getCurrentKeyBlock()).height;\n }\n return value;\n },\n};\n"],"mappings":"OAAOA,SAAS;AAAA,SAEPC,aAAa;AAEtB,eAAe;EACb,GAAGD,SAAS;EAEZE,SAASA,CAACC,KAAyB,EAAU;IAC3C,OAAOH,SAAS,CAACE,SAAS,CAACC,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,CAAC,CAAC;EACxC,CAAC;EAED,MAAMC,OAAOA,CACXD,KAAyB,EACzBE,MAAU,EACV;EAAAC,IAAA,EAEA;IAAA,IADA;MAAEC,MAAM;MAAEC;IAAsD,CAAC,GAAAF,IAAA;IAEjE,IAAIE,WAAW,KAAK,IAAI,IAAIL,KAAK,KAAK,CAAC,IAAIA,KAAK,IAAI,IAAI,EAAE;MACxD,IAAII,MAAM,IAAI,IAAI,EAAE,MAAM,IAAIN,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAEM,MAAM,CAAC;MACzEJ,KAAK,IAAI,CAAC,MAAMI,MAAM,CAACE,kBAAkB,CAAC,CAAC,EAAEC,MAAM;IACrD;IACA,OAAOP,KAAK;EACd;AACF,CAAC"}
1
+ {"version":3,"file":"ttl.mjs","names":["shortUInt","ArgumentError","getHeight","serialize","value","prepare","params","onNode","absoluteTtl","_isInternalBuild","options","_value","cached"],"sources":["../../../../src/tx/builder/field-types/ttl.ts"],"sourcesContent":["import shortUInt from './short-u-int';\nimport Node from '../../../Node';\nimport { ArgumentError } from '../../../utils/errors';\nimport { _getPollInterval, getHeight } from '../../../chain';\n\n/**\n * Time to leave\n */\nexport default {\n ...shortUInt,\n\n serialize(value: number | undefined): Buffer {\n return shortUInt.serialize(value ?? 0);\n },\n\n async prepare(\n value: number | undefined,\n params: {},\n // TODO: { absoluteTtl: true } | { absoluteTtl: false, onNode: Node }\n {\n onNode, absoluteTtl, _isInternalBuild, ...options\n }: {\n onNode?: Node;\n absoluteTtl?: boolean;\n _isInternalBuild?: boolean;\n } & Parameters<typeof _getPollInterval>[1],\n ) {\n if (absoluteTtl !== true && value !== 0 && (value != null || _isInternalBuild === true)) {\n if (onNode == null) throw new ArgumentError('onNode', 'provided', onNode);\n value = (value ?? 3) + await getHeight({ ...options, onNode, cached: true });\n }\n return value;\n },\n};\n"],"mappings":"OAAOA,SAAS;AAAA,SAEPC,aAAa;AAAA,SACKC,SAAS;AAEpC;AACA;AACA;AACA,eAAe;EACb,GAAGF,SAAS;EAEZG,SAASA,CAACC,KAAyB,EAAU;IAC3C,OAAOJ,SAAS,CAACG,SAAS,CAACC,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,CAAC,CAAC;EACxC,CAAC;EAED,MAAMC,OAAOA,CACXD,KAAyB,EACzBE,MAAU;EACV;EACA;IACEC,MAAM;IAAEC,WAAW;IAAEC,gBAAgB;IAAE,GAAGC;EAKH,CAAC,EAC1C;IACA,IAAIF,WAAW,KAAK,IAAI,IAAIJ,KAAK,KAAK,CAAC,KAAKA,KAAK,IAAI,IAAI,IAAIK,gBAAgB,KAAK,IAAI,CAAC,EAAE;MAAA,IAAAE,MAAA;MACvF,IAAIJ,MAAM,IAAI,IAAI,EAAE,MAAM,IAAIN,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAEM,MAAM,CAAC;MACzEH,KAAK,GAAG,EAAAO,MAAA,GAACP,KAAK,cAAAO,MAAA,cAAAA,MAAA,GAAI,CAAC,KAAI,MAAMT,SAAS,CAAC;QAAE,GAAGQ,OAAO;QAAEH,MAAM;QAAEK,MAAM,EAAE;MAAK,CAAC,CAAC;IAC9E;IACA,OAAOR,KAAK;EACd;AACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ export default function withDefault<Input, Output, Binary>(defaultValue: Input, field: {
2
+ serialize: (value: Input, params: unknown) => Binary;
3
+ deserialize: (value: Binary, params: unknown) => Output;
4
+ }): {
5
+ serialize: (value: Input | undefined, params: unknown) => Binary;
6
+ deserialize: (value: Binary, params: unknown) => Output;
7
+ };