@aeternity/aepp-sdk 13.0.0-alpha.1 → 13.0.0-beta.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 (388) hide show
  1. package/bin/aesophia_cli +0 -0
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.map +1 -1
  4. package/dist/aepp-sdk.browser.js +1 -1
  5. package/dist/aepp-sdk.browser.js.map +1 -1
  6. package/dist/aepp-sdk.js +1792 -1525
  7. package/dist/aepp-sdk.js.map +1 -1
  8. package/es/AeSdk.mjs.map +1 -1
  9. package/es/AeSdkAepp.mjs.map +1 -1
  10. package/es/AeSdkBase.mjs.map +1 -1
  11. package/es/AeSdkMethods.d.ts +11 -12
  12. package/es/AeSdkMethods.mjs +6 -8
  13. package/es/AeSdkMethods.mjs.map +1 -1
  14. package/es/AeSdkWallet.mjs +1 -1
  15. package/es/AeSdkWallet.mjs.map +1 -1
  16. package/es/Node.d.ts +5 -1
  17. package/es/Node.mjs +11 -5
  18. package/es/Node.mjs.map +1 -1
  19. package/es/account/Base.d.ts +11 -6
  20. package/es/account/Base.mjs +0 -17
  21. package/es/account/Base.mjs.map +1 -1
  22. package/es/account/Generalized.mjs +11 -24
  23. package/es/account/Generalized.mjs.map +1 -1
  24. package/es/account/Ledger.mjs.map +1 -1
  25. package/es/account/LedgerFactory.mjs.map +1 -1
  26. package/es/account/Memory.d.ts +2 -1
  27. package/es/account/Memory.mjs +9 -21
  28. package/es/account/Memory.mjs.map +1 -1
  29. package/es/account/Rpc.mjs.map +1 -1
  30. package/es/aens.d.ts +12 -14
  31. package/es/aens.mjs +17 -31
  32. package/es/aens.mjs.map +1 -1
  33. package/es/aepp-wallet-communication/connection/Browser.mjs +0 -16
  34. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  35. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +0 -16
  36. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  37. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -16
  38. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  39. package/es/aepp-wallet-communication/connection-proxy.mjs +0 -17
  40. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  41. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +4 -5
  42. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  43. package/es/aepp-wallet-communication/rpc/types.d.ts +6 -2
  44. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  45. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  46. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -16
  47. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  48. package/es/apis/compiler/compiler.d.ts +1 -1
  49. package/es/apis/compiler/compiler.mjs +4 -20
  50. package/es/apis/compiler/compiler.mjs.map +1 -1
  51. package/es/apis/compiler/models/index.d.ts +3 -2
  52. package/es/apis/compiler/models/index.mjs.map +1 -1
  53. package/es/apis/compiler/models/mappers.d.ts +1 -1
  54. package/es/apis/compiler/models/mappers.mjs +19 -2
  55. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  56. package/es/apis/node/models/index.d.ts +15 -15
  57. package/es/apis/node/models/index.mjs.map +1 -1
  58. package/es/apis/node/models/mappers.d.ts +1 -1
  59. package/es/apis/node/models/mappers.mjs +2 -1
  60. package/es/apis/node/models/mappers.mjs.map +1 -1
  61. package/es/apis/node/models/parameters.d.ts +2 -2
  62. package/es/apis/node/models/parameters.mjs +2 -2
  63. package/es/apis/node/models/parameters.mjs.map +1 -1
  64. package/es/apis/node/node.mjs +3 -19
  65. package/es/apis/node/node.mjs.map +1 -1
  66. package/es/chain.d.ts +8 -8
  67. package/es/chain.mjs +19 -22
  68. package/es/chain.mjs.map +1 -1
  69. package/es/channel/Base.d.ts +25 -12
  70. package/es/channel/Base.mjs +23 -26
  71. package/es/channel/Base.mjs.map +1 -1
  72. package/es/channel/Contract.mjs +8 -21
  73. package/es/channel/Contract.mjs.map +1 -1
  74. package/es/channel/Spend.d.ts +4 -2
  75. package/es/channel/Spend.mjs +0 -16
  76. package/es/channel/Spend.mjs.map +1 -1
  77. package/es/channel/handlers.mjs +6 -18
  78. package/es/channel/handlers.mjs.map +1 -1
  79. package/es/channel/internal.d.ts +19 -2
  80. package/es/channel/internal.mjs +19 -19
  81. package/es/channel/internal.mjs.map +1 -1
  82. package/es/contract/Contract.d.ts +30 -85
  83. package/es/contract/Contract.mjs +174 -211
  84. package/es/contract/Contract.mjs.map +1 -1
  85. package/es/contract/compiler/Base.d.ts +7 -14
  86. package/es/contract/compiler/Base.mjs.map +1 -1
  87. package/es/contract/compiler/Cli.mjs +5 -11
  88. package/es/contract/compiler/Cli.mjs.map +1 -1
  89. package/es/contract/compiler/Http.mjs +6 -30
  90. package/es/contract/compiler/Http.mjs.map +1 -1
  91. package/es/contract/compiler/HttpNode.mjs.map +1 -1
  92. package/es/contract/compiler/getFileSystem.mjs.map +1 -1
  93. package/es/contract/delegation-signature.d.ts +43 -0
  94. package/es/contract/delegation-signature.mjs +45 -0
  95. package/es/contract/delegation-signature.mjs.map +1 -0
  96. package/es/contract/ga.d.ts +23 -7
  97. package/es/contract/ga.mjs +52 -27
  98. package/es/contract/ga.mjs.map +1 -1
  99. package/es/index-browser.d.ts +4 -3
  100. package/es/index-browser.mjs +6 -20
  101. package/es/index-browser.mjs.map +1 -1
  102. package/es/oracle.d.ts +12 -17
  103. package/es/oracle.mjs +28 -48
  104. package/es/oracle.mjs.map +1 -1
  105. package/es/spend.d.ts +19 -27
  106. package/es/spend.mjs +20 -43
  107. package/es/spend.mjs.map +1 -1
  108. package/es/tx/builder/SchemaTypes.d.ts +37 -0
  109. package/es/tx/builder/SchemaTypes.mjs +2 -0
  110. package/es/tx/builder/SchemaTypes.mjs.map +1 -0
  111. package/es/tx/builder/constants.d.ts +4 -2
  112. package/es/tx/builder/constants.mjs +2 -0
  113. package/es/tx/builder/constants.mjs.map +1 -1
  114. package/es/tx/builder/field-types/abi-version.d.ts +11 -2
  115. package/es/tx/builder/field-types/abi-version.mjs +24 -4
  116. package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
  117. package/es/tx/builder/field-types/address.mjs.map +1 -1
  118. package/es/tx/builder/field-types/array.d.ts +1 -1
  119. package/es/tx/builder/field-types/array.mjs.map +1 -1
  120. package/es/tx/builder/field-types/boolean.mjs.map +1 -1
  121. package/es/tx/builder/field-types/coin-amount.d.ts +3 -4
  122. package/es/tx/builder/field-types/coin-amount.mjs +4 -5
  123. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  124. package/es/tx/builder/field-types/ct-version.d.ts +22 -3
  125. package/es/tx/builder/field-types/ct-version.mjs +32 -4
  126. package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
  127. package/es/tx/builder/field-types/deposit.d.ts +2 -1
  128. package/es/tx/builder/field-types/deposit.mjs +3 -2
  129. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  130. package/es/tx/builder/field-types/encoded.d.ts +1 -1
  131. package/es/tx/builder/field-types/encoded.mjs.map +1 -1
  132. package/es/tx/builder/field-types/entry.mjs +3 -0
  133. package/es/tx/builder/field-types/entry.mjs.map +1 -1
  134. package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
  135. package/es/tx/builder/field-types/fee.d.ts +3 -1
  136. package/es/tx/builder/field-types/fee.mjs +5 -1
  137. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  138. package/es/tx/builder/field-types/field.mjs.map +1 -1
  139. package/es/tx/builder/field-types/gas-limit.d.ts +3 -2
  140. package/es/tx/builder/field-types/gas-limit.mjs +4 -2
  141. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  142. package/es/tx/builder/field-types/gas-price.d.ts +3 -1
  143. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  144. package/es/tx/builder/field-types/index.d.ts +52 -13
  145. package/es/tx/builder/field-types/index.mjs +10 -2
  146. package/es/tx/builder/field-types/index.mjs.map +1 -1
  147. package/es/tx/builder/field-types/map.d.ts +13 -0
  148. package/es/tx/builder/field-types/map.mjs +49 -0
  149. package/es/tx/builder/field-types/map.mjs.map +1 -0
  150. package/es/tx/builder/field-types/mptree.d.ts +7 -2
  151. package/es/tx/builder/field-types/mptree.mjs +5 -7
  152. package/es/tx/builder/field-types/mptree.mjs.map +1 -1
  153. package/es/tx/builder/field-types/name-fee.d.ts +1 -1
  154. package/es/tx/builder/field-types/name-fee.mjs +2 -2
  155. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  156. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  157. package/es/tx/builder/field-types/name.mjs.map +1 -1
  158. package/es/tx/builder/field-types/nonce.d.ts +14 -0
  159. package/es/tx/builder/field-types/nonce.mjs +29 -0
  160. package/es/tx/builder/field-types/nonce.mjs.map +1 -0
  161. package/es/tx/builder/field-types/pointers.mjs.map +1 -1
  162. package/es/tx/builder/field-types/raw.mjs.map +1 -1
  163. package/es/tx/builder/field-types/short-u-int-const.d.ts +4 -2
  164. package/es/tx/builder/field-types/short-u-int-const.mjs +12 -8
  165. package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -1
  166. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  167. package/es/tx/builder/field-types/string.mjs.map +1 -1
  168. package/es/tx/builder/field-types/ttl.d.ts +11 -0
  169. package/es/tx/builder/field-types/ttl.mjs +21 -0
  170. package/es/tx/builder/field-types/ttl.mjs.map +1 -0
  171. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  172. package/es/tx/builder/field-types/wrapped.d.ts +14 -0
  173. package/es/tx/builder/field-types/wrapped.mjs +22 -0
  174. package/es/tx/builder/field-types/wrapped.mjs.map +1 -0
  175. package/es/tx/builder/helpers.mjs.map +1 -1
  176. package/es/tx/builder/index.d.ts +20 -20
  177. package/es/tx/builder/index.mjs +54 -64
  178. package/es/tx/builder/index.mjs.map +1 -1
  179. package/es/tx/builder/schema.d.ts +2735 -2865
  180. package/es/tx/builder/schema.generated.d.ts +2011 -0
  181. package/es/tx/builder/schema.generated.mjs +2 -0
  182. package/es/tx/builder/schema.generated.mjs.map +1 -0
  183. package/es/tx/builder/schema.mjs +459 -155
  184. package/es/tx/builder/schema.mjs.map +1 -1
  185. package/es/tx/execution-cost.d.ts +35 -0
  186. package/es/tx/execution-cost.mjs +123 -0
  187. package/es/tx/execution-cost.mjs.map +1 -0
  188. package/es/tx/transaction-signer.d.ts +6 -0
  189. package/es/tx/transaction-signer.mjs +27 -0
  190. package/es/tx/transaction-signer.mjs.map +1 -0
  191. package/es/tx/validator.mjs +60 -109
  192. package/es/tx/validator.mjs.map +1 -1
  193. package/es/utils/amount-formatter.mjs +0 -16
  194. package/es/utils/amount-formatter.mjs.map +1 -1
  195. package/es/utils/autorest.d.ts +3 -2
  196. package/es/utils/autorest.mjs +43 -11
  197. package/es/utils/autorest.mjs.map +1 -1
  198. package/es/utils/bytes.mjs +0 -16
  199. package/es/utils/bytes.mjs.map +1 -1
  200. package/es/utils/crypto.mjs +0 -16
  201. package/es/utils/crypto.mjs.map +1 -1
  202. package/es/utils/encoder.mjs.map +1 -1
  203. package/es/utils/errors.d.ts +14 -31
  204. package/es/utils/errors.mjs +2 -32
  205. package/es/utils/errors.mjs.map +1 -1
  206. package/es/utils/hd-wallet.mjs.map +1 -1
  207. package/es/utils/json-big.mjs.map +1 -1
  208. package/es/utils/keystore.mjs.map +1 -1
  209. package/es/utils/other.d.ts +1 -1
  210. package/es/utils/other.mjs.map +1 -1
  211. package/es/utils/semver-satisfies.mjs.map +1 -1
  212. package/es/utils/string.mjs +0 -17
  213. package/es/utils/string.mjs.map +1 -1
  214. package/package.json +34 -30
  215. package/src/AeSdkMethods.ts +11 -16
  216. package/src/AeSdkWallet.ts +1 -1
  217. package/src/Node.ts +17 -6
  218. package/src/account/Base.ts +11 -22
  219. package/src/account/Generalized.ts +8 -23
  220. package/src/account/Memory.ts +14 -21
  221. package/src/aens.ts +31 -47
  222. package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
  223. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +0 -17
  224. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +0 -17
  225. package/src/aepp-wallet-communication/connection-proxy.ts +0 -17
  226. package/src/aepp-wallet-communication/rpc/types.ts +6 -2
  227. package/src/aepp-wallet-communication/wallet-detector.ts +0 -17
  228. package/src/apis/compiler/compiler.ts +3 -27
  229. package/src/apis/compiler/models/index.ts +3 -2
  230. package/src/apis/compiler/models/mappers.ts +15 -2
  231. package/src/apis/node/models/index.ts +16 -15
  232. package/src/apis/node/models/mappers.ts +2 -1
  233. package/src/apis/node/models/parameters.ts +2 -2
  234. package/src/apis/node/node.ts +3 -27
  235. package/src/chain.ts +28 -27
  236. package/src/channel/Base.ts +33 -33
  237. package/src/channel/Contract.ts +8 -23
  238. package/src/channel/Spend.ts +2 -17
  239. package/src/channel/handlers.ts +5 -18
  240. package/src/channel/internal.ts +40 -22
  241. package/src/contract/Contract.ts +133 -163
  242. package/src/contract/compiler/Base.ts +7 -14
  243. package/src/contract/compiler/Cli.ts +5 -11
  244. package/src/contract/compiler/Http.ts +6 -25
  245. package/src/contract/delegation-signature.ts +56 -0
  246. package/src/contract/ga.ts +53 -32
  247. package/src/index-browser.ts +12 -20
  248. package/src/oracle.ts +46 -56
  249. package/src/spend.ts +33 -67
  250. package/src/tx/builder/SchemaTypes.ts +79 -0
  251. package/src/tx/builder/constants.ts +2 -0
  252. package/src/tx/builder/field-types/abi-version.ts +29 -6
  253. package/src/tx/builder/field-types/array.ts +1 -1
  254. package/src/tx/builder/field-types/coin-amount.ts +6 -4
  255. package/src/tx/builder/field-types/ct-version.ts +37 -4
  256. package/src/tx/builder/field-types/deposit.ts +3 -1
  257. package/src/tx/builder/field-types/encoded.ts +1 -1
  258. package/src/tx/builder/field-types/entry.ts +8 -3
  259. package/src/tx/builder/field-types/fee.ts +6 -4
  260. package/src/tx/builder/field-types/gas-limit.ts +2 -2
  261. package/src/tx/builder/field-types/index.ts +15 -1
  262. package/src/tx/builder/field-types/map.ts +45 -0
  263. package/src/tx/builder/field-types/mptree.ts +4 -3
  264. package/src/tx/builder/field-types/name-fee.ts +2 -1
  265. package/src/tx/builder/field-types/nonce.ts +40 -0
  266. package/src/tx/builder/field-types/short-u-int-const.ts +18 -8
  267. package/src/tx/builder/field-types/ttl.ts +24 -0
  268. package/src/tx/builder/field-types/wrapped.ts +32 -0
  269. package/src/tx/builder/index.ts +57 -71
  270. package/src/tx/builder/schema.generated.ts +2013 -0
  271. package/src/tx/builder/schema.ts +544 -624
  272. package/src/tx/execution-cost.ts +146 -0
  273. package/src/tx/transaction-signer.ts +27 -0
  274. package/src/tx/validator.ts +60 -91
  275. package/src/utils/amount-formatter.ts +0 -16
  276. package/src/utils/autorest.ts +52 -11
  277. package/src/utils/bytes.ts +0 -16
  278. package/src/utils/crypto.ts +0 -16
  279. package/src/utils/errors.ts +15 -44
  280. package/src/utils/string.ts +0 -17
  281. package/types-legacy/ts4.2/AeSdkMethods.d.ts +11 -12
  282. package/types-legacy/ts4.2/Node.d.ts +5 -1
  283. package/types-legacy/ts4.2/account/Base.d.ts +11 -6
  284. package/types-legacy/ts4.2/account/Memory.d.ts +2 -1
  285. package/types-legacy/ts4.2/aens.d.ts +12 -14
  286. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +6 -2
  287. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +1 -1
  288. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +3 -2
  289. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +1 -1
  290. package/types-legacy/ts4.2/apis/node/models/index.d.ts +15 -15
  291. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +1 -1
  292. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
  293. package/types-legacy/ts4.2/chain.d.ts +8 -8
  294. package/types-legacy/ts4.2/channel/Base.d.ts +25 -12
  295. package/types-legacy/ts4.2/channel/Spend.d.ts +4 -2
  296. package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
  297. package/types-legacy/ts4.2/contract/Contract.d.ts +29 -84
  298. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +7 -14
  299. package/types-legacy/ts4.2/contract/delegation-signature.d.ts +43 -0
  300. package/types-legacy/ts4.2/contract/ga.d.ts +23 -7
  301. package/types-legacy/ts4.2/index-browser.d.ts +4 -3
  302. package/types-legacy/ts4.2/oracle.d.ts +12 -17
  303. package/types-legacy/ts4.2/spend.d.ts +19 -27
  304. package/types-legacy/ts4.2/tx/builder/SchemaTypes.d.ts +37 -0
  305. package/types-legacy/ts4.2/tx/builder/constants.d.ts +4 -2
  306. package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +11 -2
  307. package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +1 -1
  308. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +3 -4
  309. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +33 -3
  310. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +2 -1
  311. package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +1 -1
  312. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +3 -1
  313. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +3 -2
  314. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +3 -1
  315. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +52 -13
  316. package/types-legacy/ts4.2/tx/builder/field-types/map.d.ts +13 -0
  317. package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +7 -2
  318. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -1
  319. package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
  320. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +4 -2
  321. package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
  322. package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
  323. package/types-legacy/ts4.2/tx/builder/index.d.ts +23 -20
  324. package/types-legacy/ts4.2/tx/builder/schema.d.ts +2962 -4629
  325. package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +2011 -0
  326. package/types-legacy/ts4.2/tx/execution-cost.d.ts +35 -0
  327. package/types-legacy/ts4.2/tx/transaction-signer.d.ts +6 -0
  328. package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
  329. package/types-legacy/ts4.2/utils/errors.d.ts +14 -31
  330. package/types-legacy/ts4.2/utils/other.d.ts +1 -1
  331. package/types-legacy/ts4.5/AeSdkMethods.d.ts +11 -12
  332. package/types-legacy/ts4.5/Node.d.ts +5 -1
  333. package/types-legacy/ts4.5/account/Base.d.ts +11 -6
  334. package/types-legacy/ts4.5/account/Memory.d.ts +2 -1
  335. package/types-legacy/ts4.5/aens.d.ts +12 -14
  336. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +6 -2
  337. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +1 -1
  338. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +3 -2
  339. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +1 -1
  340. package/types-legacy/ts4.5/apis/node/models/index.d.ts +15 -15
  341. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +1 -1
  342. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
  343. package/types-legacy/ts4.5/chain.d.ts +8 -8
  344. package/types-legacy/ts4.5/channel/Base.d.ts +25 -12
  345. package/types-legacy/ts4.5/channel/Spend.d.ts +4 -2
  346. package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
  347. package/types-legacy/ts4.5/contract/Contract.d.ts +29 -84
  348. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +7 -14
  349. package/types-legacy/ts4.5/contract/delegation-signature.d.ts +43 -0
  350. package/types-legacy/ts4.5/contract/ga.d.ts +23 -7
  351. package/types-legacy/ts4.5/index-browser.d.ts +4 -3
  352. package/types-legacy/ts4.5/oracle.d.ts +12 -17
  353. package/types-legacy/ts4.5/spend.d.ts +19 -27
  354. package/types-legacy/ts4.5/tx/builder/SchemaTypes.d.ts +37 -0
  355. package/types-legacy/ts4.5/tx/builder/constants.d.ts +4 -2
  356. package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +11 -2
  357. package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +1 -1
  358. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +3 -4
  359. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +33 -3
  360. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +2 -1
  361. package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +1 -1
  362. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +3 -1
  363. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +3 -2
  364. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +3 -1
  365. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +52 -13
  366. package/types-legacy/ts4.5/tx/builder/field-types/map.d.ts +13 -0
  367. package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +7 -2
  368. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -1
  369. package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
  370. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +4 -2
  371. package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
  372. package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
  373. package/types-legacy/ts4.5/tx/builder/index.d.ts +23 -20
  374. package/types-legacy/ts4.5/tx/builder/schema.d.ts +2962 -4629
  375. package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +2011 -0
  376. package/types-legacy/ts4.5/tx/execution-cost.d.ts +35 -0
  377. package/types-legacy/ts4.5/tx/transaction-signer.d.ts +6 -0
  378. package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
  379. package/types-legacy/ts4.5/utils/errors.d.ts +14 -31
  380. package/types-legacy/ts4.5/utils/other.d.ts +1 -1
  381. package/es/tx/index.d.ts +0 -19
  382. package/es/tx/index.mjs +0 -115
  383. package/es/tx/index.mjs.map +0 -1
  384. package/src/apis/compiler/code-model-v4.yaml +0 -2442
  385. package/src/apis/node/code-model-v4.yaml +0 -10080
  386. package/src/tx/index.ts +0 -129
  387. package/types-legacy/ts4.2/tx/index.d.ts +0 -19
  388. package/types-legacy/ts4.5/tx/index.d.ts +0 -19
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","names":["BigNumber","genSalt","hash","decode","encode","Encoding","toBytes","concatBuffers","NAME_BID_RANGES","NAME_BID_TIMEOUT_BLOCKS","NAME_FEE_BID_INCREMENT","NAME_MAX_LENGTH_FEE","ceil","ArgumentError","IllegalBidFeeError","buildContractId","ownerId","nonce","ownerIdAndNonce","from","b2bHash","ContractAddress","oracleQueryId","senderId","oracleId","_int32","val","nonceBE","alloc","length","OracleQueryId","produceNameId","name","toLowerCase","Name","commitmentHash","salt","toString","padStart","Commitment","readInt","buf","AENS_SUFFIX","isNameValid","endsWith","encodingToPointerKey","AccountAddress","OracleAddress","Channel","getDefaultPointerKey","identifier","encoding","substring","result","find","e","map","join","getMinimumNameFee","nameLength","Math","min","computeBidFee","startFee","increment","Number","times","plus","computeAuctionEndBlock","claimHeight","h","isAuctionName"],"sources":["../../../src/tx/builder/helpers.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { genSalt, hash } from '../../utils/crypto';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../utils/encoder';\nimport { toBytes } from '../../utils/bytes';\nimport { concatBuffers } from '../../utils/other';\nimport {\n AensName,\n NAME_BID_RANGES,\n NAME_BID_TIMEOUT_BLOCKS,\n NAME_FEE_BID_INCREMENT,\n NAME_MAX_LENGTH_FEE,\n} from './constants';\nimport { ceil } from '../../utils/bignumber';\nimport { ArgumentError, IllegalBidFeeError } from '../../utils/errors';\n\n/**\n * JavaScript-based Transaction builder helper function's\n */\n\n/**\n * Build a contract public key\n * @category contract\n * @param ownerId - The public key of the owner account\n * @param nonce - the nonce of the transaction\n * @returns Contract public key\n */\nexport function buildContractId(\n ownerId: Encoded.AccountAddress,\n nonce: number | BigNumber,\n): Encoded.ContractAddress {\n const ownerIdAndNonce = Buffer.from([...decode(ownerId), ...toBytes(nonce)]);\n const b2bHash = hash(ownerIdAndNonce);\n return encode(b2bHash, Encoding.ContractAddress);\n}\n\n/**\n * Build a oracle query id\n * @category oracle\n * @param senderId - The public key of the sender account\n * @param nonce - the nonce of the transaction\n * @param oracleId - The oracle public key\n * @returns Contract public key\n */\nexport function oracleQueryId(\n senderId: Encoded.AccountAddress,\n nonce: number | BigNumber | string,\n oracleId: Encoded.OracleAddress,\n): Encoded.OracleQueryId {\n function _int32(val: number | string | BigNumber): Buffer {\n const nonceBE = toBytes(val, true);\n return concatBuffers([Buffer.alloc(32 - nonceBE.length), nonceBE]);\n }\n\n const b2bHash = hash(\n Buffer.from([...decode(senderId), ..._int32(nonce), ...decode(oracleId)]),\n );\n return encode(b2bHash, Encoding.OracleQueryId);\n}\n\n/**\n * Encode an AENS name\n * @category AENS\n * @param name - Name to encode\n * @returns `nm_` prefixed encoded AENS name\n */\nexport function produceNameId(name: AensName): Encoded.Name {\n return encode(hash(name.toLowerCase()), Encoding.Name);\n}\n\n/**\n * Generate the commitment hash by hashing the salt and\n * name, base 58 encoding the result and prepending 'cm_'\n * @category transaction builder\n * @param name - Name to be registered\n * @param salt - Random number\n * @returns Commitment hash\n */\nexport function commitmentHash(\n name: AensName,\n salt: number = genSalt(),\n): Encoded.Commitment {\n return encode(\n hash(concatBuffers([\n Buffer.from(name.toLowerCase()),\n Buffer.from(salt.toString(16).padStart(64, '0'), 'hex'),\n ])),\n Encoding.Commitment,\n );\n}\n\n/**\n * Utility function to convert bytes to int\n * @category transaction builder\n * @param buf - Value\n * @returns Buffer Buffer from number(BigEndian)\n */\nexport function readInt(buf: Buffer = Buffer.from([])): string {\n return new BigNumber(Buffer.from(buf).toString('hex'), 16).toString(10);\n}\n\nconst AENS_SUFFIX = '.chain';\n\n/**\n * Is AENS name valid\n * @category AENS\n * @param name - AENS name\n */\nexport function isNameValid(name: string): name is AensName {\n // TODO: probably there are stronger requirements\n return name.endsWith(AENS_SUFFIX);\n}\n\nconst encodingToPointerKey = [\n [Encoding.AccountAddress, 'account_pubkey'],\n [Encoding.OracleAddress, 'oracle_pubkey'],\n [Encoding.ContractAddress, 'contract_pubkey'],\n [Encoding.Channel, 'channel'],\n] as const;\n\n/**\n * @category AENS\n * @param identifier - account/oracle/contract address, or channel\n * @returns default AENS pointer key\n */\nexport function getDefaultPointerKey(\n identifier: Encoded.Generic<typeof encodingToPointerKey[number][0]>,\n): typeof encodingToPointerKey[number][1] {\n decode(identifier);\n const encoding = identifier.substring(0, 2);\n const result = encodingToPointerKey.find(([e]) => e === encoding)?.[1];\n if (result != null) return result;\n throw new ArgumentError(\n 'identifier',\n `prefixed with one of ${encodingToPointerKey.map(([e]) => `${e}_`).join(', ')}`,\n identifier,\n );\n}\n\n/**\n * Get the minimum AENS name fee\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @returns the minimum fee for the AENS name auction\n */\nexport function getMinimumNameFee(name: AensName): BigNumber {\n const nameLength = name.length - AENS_SUFFIX.length;\n return NAME_BID_RANGES[Math.min(nameLength, NAME_MAX_LENGTH_FEE)];\n}\n\n/**\n * Compute bid fee for AENS auction\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @param options - Options\n * @param options.startFee - Auction start fee\n * @param options.increment - Bid multiplier(In percentage, must be between 0 and 1)\n * @returns Bid fee\n */\nexport function computeBidFee(\n name: AensName,\n { startFee, increment = NAME_FEE_BID_INCREMENT }:\n { startFee?: number | string | BigNumber; increment?: number } = {},\n): BigNumber {\n if (!(Number(increment) === increment && increment % 1 !== 0)) throw new IllegalBidFeeError(`Increment must be float. Current increment ${increment}`);\n if (increment < NAME_FEE_BID_INCREMENT) throw new IllegalBidFeeError(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`);\n // FIXME: increment should be used somehow here\n return ceil(\n new BigNumber(startFee ?? getMinimumNameFee(name))\n .times(new BigNumber(NAME_FEE_BID_INCREMENT).plus(1)),\n );\n}\n\n/**\n * Compute auction end height\n * @category AENS\n * @param name - Name to compute auction end for\n * @param claimHeight - Auction starting height\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273}\n * @returns Auction end height\n */\nexport function computeAuctionEndBlock(name: AensName, claimHeight: number): number {\n const length = name.length - AENS_SUFFIX.length;\n const h = (length <= 4 ? 62 * NAME_BID_TIMEOUT_BLOCKS : null)\n ?? (length <= 8 ? 31 * NAME_BID_TIMEOUT_BLOCKS : null)\n ?? (length <= 12 ? NAME_BID_TIMEOUT_BLOCKS : null)\n ?? 0;\n return h + claimHeight;\n}\n\n/**\n * Is name accept going to auction\n * @category AENS\n */\nexport function isAuctionName(name: AensName): boolean {\n return name.length < 13 + AENS_SUFFIX.length;\n}\n"],"mappings":";;;;AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,OAAO,EAAEC,IAAI;AAAA,SAEpBC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,OAAO;AAAA,SACPC,aAAa;AAAA,SAGpBC,eAAe,EACfC,uBAAuB,EACvBC,sBAAsB,EACtBC,mBAAmB;AAAA,SAEZC,IAAI;AAAA,SACJC,aAAa,EAAEC,kBAAkB;AAE1C;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAe,CAC7BC,OAA+B,EAC/BC,KAAyB,EACA;EACzB,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ACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsB,CAACpC,IAAc,EAAEqC,WAAmB,EAAU;EAAA;EAClF,MAAMxC,MAAM,GAAGG,IAAI,CAACH,MAAM,GAAGa,WAAW,CAACb,MAAM;EAC/C,MAAMyC,CAAC,8BAAIzC,MAAM,IAAI,CAAC,GAAG,EAAE,GAAGpB,uBAAuB,GAAG,IAAI,yCACtDoB,MAAM,IAAI,CAAC,GAAG,EAAE,GAAGpB,uBAAuB,GAAG,IAAI,yCACjDoB,MAAM,IAAI,EAAE,GAAGpB,uBAAuB,GAAG,IAAI,yCAC9C,CAAC;EACN,OAAO6D,CAAC,GAAGD,WAAW;AACxB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASE,aAAa,CAACvC,IAAc,EAAW;EACrD,OAAOA,IAAI,CAACH,MAAM,GAAG,EAAE,GAAGa,WAAW,CAACb,MAAM;AAC9C"}
1
+ {"version":3,"file":"helpers.mjs","names":["BigNumber","genSalt","hash","decode","encode","Encoding","toBytes","concatBuffers","NAME_BID_RANGES","NAME_BID_TIMEOUT_BLOCKS","NAME_FEE_BID_INCREMENT","NAME_MAX_LENGTH_FEE","ceil","ArgumentError","IllegalBidFeeError","buildContractId","ownerId","nonce","ownerIdAndNonce","_Buffer","from","b2bHash","ContractAddress","oracleQueryId","senderId","oracleId","_int32","val","nonceBE","alloc","length","OracleQueryId","produceNameId","name","toLowerCase","Name","commitmentHash","salt","arguments","undefined","toString","padStart","Commitment","readInt","buf","AENS_SUFFIX","isNameValid","endsWith","encodingToPointerKey","AccountAddress","OracleAddress","Channel","getDefaultPointerKey","identifier","_encodingToPointerKey","encoding","substring","result","find","_ref","e","map","_ref2","join","getMinimumNameFee","nameLength","Math","min","computeBidFee","startFee","increment","Number","times","plus","computeAuctionEndBlock","claimHeight","_ref3","_ref4","_ref5","h","isAuctionName"],"sources":["../../../src/tx/builder/helpers.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { genSalt, hash } from '../../utils/crypto';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../utils/encoder';\nimport { toBytes } from '../../utils/bytes';\nimport { concatBuffers } from '../../utils/other';\nimport {\n AensName,\n NAME_BID_RANGES,\n NAME_BID_TIMEOUT_BLOCKS,\n NAME_FEE_BID_INCREMENT,\n NAME_MAX_LENGTH_FEE,\n} from './constants';\nimport { ceil } from '../../utils/bignumber';\nimport { ArgumentError, IllegalBidFeeError } from '../../utils/errors';\n\n/**\n * JavaScript-based Transaction builder helper function's\n */\n\n/**\n * Build a contract public key\n * @category contract\n * @param ownerId - The public key of the owner account\n * @param nonce - the nonce of the transaction\n * @returns Contract public key\n */\nexport function buildContractId(\n ownerId: Encoded.AccountAddress,\n nonce: number | BigNumber,\n): Encoded.ContractAddress {\n const ownerIdAndNonce = Buffer.from([...decode(ownerId), ...toBytes(nonce)]);\n const b2bHash = hash(ownerIdAndNonce);\n return encode(b2bHash, Encoding.ContractAddress);\n}\n\n/**\n * Build a oracle query id\n * @category oracle\n * @param senderId - The public key of the sender account\n * @param nonce - the nonce of the transaction\n * @param oracleId - The oracle public key\n * @returns Contract public key\n */\nexport function oracleQueryId(\n senderId: Encoded.AccountAddress,\n nonce: number | BigNumber | string,\n oracleId: Encoded.OracleAddress,\n): Encoded.OracleQueryId {\n function _int32(val: number | string | BigNumber): Buffer {\n const nonceBE = toBytes(val, true);\n return concatBuffers([Buffer.alloc(32 - nonceBE.length), nonceBE]);\n }\n\n const b2bHash = hash(\n Buffer.from([...decode(senderId), ..._int32(nonce), ...decode(oracleId)]),\n );\n return encode(b2bHash, Encoding.OracleQueryId);\n}\n\n/**\n * Encode an AENS name\n * @category AENS\n * @param name - Name to encode\n * @returns `nm_` prefixed encoded AENS name\n */\nexport function produceNameId(name: AensName): Encoded.Name {\n return encode(hash(name.toLowerCase()), Encoding.Name);\n}\n\n/**\n * Generate the commitment hash by hashing the salt and\n * name, base 58 encoding the result and prepending 'cm_'\n * @category transaction builder\n * @param name - Name to be registered\n * @param salt - Random number\n * @returns Commitment hash\n */\nexport function commitmentHash(\n name: AensName,\n salt: number = genSalt(),\n): Encoded.Commitment {\n return encode(\n hash(concatBuffers([\n Buffer.from(name.toLowerCase()),\n Buffer.from(salt.toString(16).padStart(64, '0'), 'hex'),\n ])),\n Encoding.Commitment,\n );\n}\n\n/**\n * Utility function to convert bytes to int\n * @category transaction builder\n * @param buf - Value\n * @returns Buffer Buffer from number(BigEndian)\n */\nexport function readInt(buf: Buffer = Buffer.from([])): string {\n return new BigNumber(Buffer.from(buf).toString('hex'), 16).toString(10);\n}\n\nconst AENS_SUFFIX = '.chain';\n\n/**\n * Is AENS name valid\n * @category AENS\n * @param name - AENS name\n */\nexport function isNameValid(name: string): name is AensName {\n // TODO: probably there are stronger requirements\n return name.endsWith(AENS_SUFFIX);\n}\n\nconst encodingToPointerKey = [\n [Encoding.AccountAddress, 'account_pubkey'],\n [Encoding.OracleAddress, 'oracle_pubkey'],\n [Encoding.ContractAddress, 'contract_pubkey'],\n [Encoding.Channel, 'channel'],\n] as const;\n\n/**\n * @category AENS\n * @param identifier - account/oracle/contract address, or channel\n * @returns default AENS pointer key\n */\nexport function getDefaultPointerKey(\n identifier: Encoded.Generic<typeof encodingToPointerKey[number][0]>,\n): typeof encodingToPointerKey[number][1] {\n decode(identifier);\n const encoding = identifier.substring(0, 2);\n const result = encodingToPointerKey.find(([e]) => e === encoding)?.[1];\n if (result != null) return result;\n throw new ArgumentError(\n 'identifier',\n `prefixed with one of ${encodingToPointerKey.map(([e]) => `${e}_`).join(', ')}`,\n identifier,\n );\n}\n\n/**\n * Get the minimum AENS name fee\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @returns the minimum fee for the AENS name auction\n */\nexport function getMinimumNameFee(name: AensName): BigNumber {\n const nameLength = name.length - AENS_SUFFIX.length;\n return NAME_BID_RANGES[Math.min(nameLength, NAME_MAX_LENGTH_FEE)];\n}\n\n/**\n * Compute bid fee for AENS auction\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @param options - Options\n * @param options.startFee - Auction start fee\n * @param options.increment - Bid multiplier(In percentage, must be between 0 and 1)\n * @returns Bid fee\n */\nexport function computeBidFee(\n name: AensName,\n { startFee, increment = NAME_FEE_BID_INCREMENT }:\n { startFee?: number | string | BigNumber; increment?: number } = {},\n): BigNumber {\n if (!(Number(increment) === increment && increment % 1 !== 0)) throw new IllegalBidFeeError(`Increment must be float. Current increment ${increment}`);\n if (increment < NAME_FEE_BID_INCREMENT) throw new IllegalBidFeeError(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`);\n // FIXME: increment should be used somehow here\n return ceil(\n new BigNumber(startFee ?? getMinimumNameFee(name))\n .times(new BigNumber(NAME_FEE_BID_INCREMENT).plus(1)),\n );\n}\n\n/**\n * Compute auction end height\n * @category AENS\n * @param name - Name to compute auction end for\n * @param claimHeight - Auction starting height\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273}\n * @returns Auction end height\n */\nexport function computeAuctionEndBlock(name: AensName, claimHeight: number): number {\n const length = name.length - AENS_SUFFIX.length;\n const h = (length <= 4 ? 62 * NAME_BID_TIMEOUT_BLOCKS : null)\n ?? (length <= 8 ? 31 * NAME_BID_TIMEOUT_BLOCKS : null)\n ?? (length <= 12 ? NAME_BID_TIMEOUT_BLOCKS : null)\n ?? 0;\n return h + claimHeight;\n}\n\n/**\n * Is name accept going to auction\n * @category AENS\n */\nexport function isAuctionName(name: AensName): boolean {\n return name.length < 13 + AENS_SUFFIX.length;\n}\n"],"mappings":";;;;AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,OAAO,EAAEC,IAAI;AAAA,SAEpBC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,OAAO;AAAA,SACPC,aAAa;AAAA,SAGpBC,eAAe,EACfC,uBAAuB,EACvBC,sBAAsB,EACtBC,mBAAmB;AAAA,SAEZC,IAAI;AA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M;AAC9C"}
@@ -1,39 +1,39 @@
1
1
  import { Encoded, Encoding } from '../../utils/encoder';
2
- import { AE_AMOUNT_FORMATS } from '../../utils/amount-formatter';
3
- import { RawTxObject, TxTypeSchemas } from './schema';
2
+ import { Field } from './field-types';
3
+ import { TxUnpacked, TxParams, TxParamsAsync } from './schema.generated';
4
4
  import { Tag } from './constants';
5
+ /**
6
+ * JavaScript-based Transaction builder
7
+ */
8
+ export declare function getSchema(tag: Tag, version?: number): Array<[string, Field]>;
5
9
  /**
6
10
  * Build transaction hash
7
11
  * @category transaction builder
8
12
  * @param params - Object with tx params
9
13
  * @param options - options
10
- * @param options.denomination - Denomination of amounts
11
14
  * @param options.prefix - Prefix of transaction
12
- * @throws {@link InvalidTxParamsError}
13
- * @returns object
14
- * @returns object.tx Base64Check transaction hash with 'tx_' prefix
15
- * @returns object.rlpEncoded rlp encoded transaction
16
- * @returns object.binary binary transaction
15
+ * @returns object Base64Check transaction hash with 'tx_' prefix
17
16
  */
18
- export declare function buildTx<TxType extends Tag, E extends Encoding = Encoding.Transaction>(params: {
19
- tag: TxType;
20
- version?: number;
21
- } & Omit<TxTypeSchemas[TxType], 'tag' | 'version'> & (TxType extends Tag.ContractCreateTx | Tag.ContractCallTx | Tag.ChannelOffChainUpdateCallContract | Tag.GaAttachTx | Tag.GaMetaTx ? {
22
- gasMax?: number;
23
- } : {}), { prefix, denomination, }?: {
17
+ export declare function buildTx<E extends Encoding = Encoding.Transaction>(params: TxParams, { prefix, }?: {
24
18
  prefix?: E;
25
- denomination?: AE_AMOUNT_FORMATS;
26
19
  }): Encoded.Generic<E>;
20
+ export type BuildTxOptions<TxType extends Tag, OmitFields extends string> = Omit<TxParamsAsync & {
21
+ tag: TxType;
22
+ }, 'tag' | OmitFields>;
27
23
  /**
28
- * Unpack transaction hash
24
+ * @category transaction builder
25
+ */
26
+ export declare function buildTxAsync(params: TxParamsAsync): Promise<Encoded.Transaction>;
27
+ /**
28
+ * Unpack transaction encoded as string
29
29
  * @category transaction builder
30
30
  * @param encodedTx - Transaction to unpack
31
31
  * @param txType - Expected transaction type
32
- * @returns object
33
- * @returns object.tx Object with transaction param's
34
- * @returns object.txType Transaction type
32
+ * @returns Object with transaction param's
35
33
  */
36
- export declare function unpackTx<TxType extends Tag>(encodedTx: Encoded.Transaction | Encoded.Poi, txType?: TxType): RawTxObject<TxTypeSchemas[TxType]>;
34
+ export declare function unpackTx<TxType extends Tag>(encodedTx: Encoded.Transaction | Encoded.Poi | Encoded.StateTrees | Encoded.CallStateTree, txType?: TxType): TxUnpacked & {
35
+ tag: TxType;
36
+ };
37
37
  /**
38
38
  * Build a transaction hash
39
39
  * @category transaction builder
@@ -4,38 +4,22 @@ const {
4
4
  encode: rlpEncode
5
5
  } = _rlp;
6
6
  import { decode, encode, Encoding } from "../../utils/encoder.mjs";
7
- import { AE_AMOUNT_FORMATS } from "../../utils/amount-formatter.mjs";
8
7
  import { hash } from "../../utils/crypto.mjs";
9
- import { TX_SCHEMA } from "./schema.mjs";
8
+ import { txSchema } from "./schema.mjs";
10
9
  import { Tag } from "./constants.mjs";
11
10
  import { buildContractId, readInt } from "./helpers.mjs";
12
11
  import { ArgumentError, DecodeError, SchemaNotFoundError } from "../../utils/errors.mjs";
13
- import { isKeyOfObject } from "../../utils/other.mjs";
14
12
  /**
15
13
  * JavaScript-based Transaction builder
16
14
  */
17
- /**
18
- * Unpack binary transaction
19
- * @category transaction builder
20
- * @param binary - Array with binary transaction field's
21
- * @param schema - Transaction schema
22
- * @returns Object with transaction field's
23
- */
24
- function unpackRawTx(binary, schema) {
25
- if (binary.length !== schema.length) {
26
- throw new ArgumentError('Transaction RLP length', schema.length, binary.length);
27
- }
28
- return schema.reduce((acc, _ref, index) => {
29
- let [name, field] = _ref;
30
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
31
- const deserialized = field.deserialize(binary[index], {
32
- unpackTx
33
- });
34
- return {
35
- ...acc,
36
- [name]: deserialized
37
- };
38
- }, {});
15
+ export function getSchema(tag, version) {
16
+ var _version;
17
+ const schemas = txSchema.filter(s => s.tag.constValue === tag);
18
+ if (schemas.length === 0) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, 0);
19
+ (_version = version) !== null && _version !== void 0 ? _version : version = Math.max(...schemas.map(schema => schema.version.constValue));
20
+ const schema = schemas.find(s => s.version.constValue === version);
21
+ if (schema == null) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, version);
22
+ return Object.entries(schema);
39
23
  }
40
24
 
41
25
  /**
@@ -43,65 +27,75 @@ function unpackRawTx(binary, schema) {
43
27
  * @category transaction builder
44
28
  * @param params - Object with tx params
45
29
  * @param options - options
46
- * @param options.denomination - Denomination of amounts
47
30
  * @param options.prefix - Prefix of transaction
48
- * @throws {@link InvalidTxParamsError}
49
- * @returns object
50
- * @returns object.tx Base64Check transaction hash with 'tx_' prefix
51
- * @returns object.rlpEncoded rlp encoded transaction
52
- * @returns object.binary binary transaction
31
+ * @returns object Base64Check transaction hash with 'tx_' prefix
53
32
  */
54
33
  export function buildTx(params) {
55
- var _params$version;
56
34
  let {
57
- prefix,
58
- denomination = AE_AMOUNT_FORMATS.AETTOS
35
+ prefix
59
36
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
60
- const schemas = TX_SCHEMA[params.tag];
61
- (_params$version = params.version) !== null && _params$version !== void 0 ? _params$version : params.version = Math.max(...Object.keys(schemas).map(a => +a));
62
- if (!isKeyOfObject(params.version, schemas)) {
63
- throw new SchemaNotFoundError('serialization', Tag[params.tag], params.version);
64
- }
65
- const schema = schemas[params.version];
66
- const binary = schema.map(_ref2 => {
67
- let [key, field] = _ref2;
68
- return field.serialize(params[key], {
37
+ const schema = getSchema(params.tag, params.version);
38
+ const binary = schema.map(_ref => {
39
+ let [key, field] = _ref;
40
+ return field.serialize(
41
+ // @ts-expect-error the type of `params[key]` can't be determined accurately
42
+ params[key], {
69
43
  ...params,
70
44
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
71
45
  unpackTx,
72
46
  buildTx,
73
- denomination,
74
47
  rebuildTx: overrideParams => buildTx({
75
48
  ...params,
76
49
  ...overrideParams
77
- }, {
78
- denomination
79
50
  })
80
- });
51
+ }, params);
81
52
  });
82
53
 
83
54
  // @ts-expect-error looks like a TypeScript edge case
84
55
  return encode(rlpEncode(binary), prefix !== null && prefix !== void 0 ? prefix : Encoding.Transaction);
85
56
  }
57
+ /**
58
+ * @category transaction builder
59
+ */
60
+ export async function buildTxAsync(params) {
61
+ await Promise.all(getSchema(params.tag, params.version).map(async _ref2 => {
62
+ let [key, field] = _ref2;
63
+ if (field.prepare == null) return;
64
+ // @ts-expect-error the type of `params[key]` can't be determined accurately
65
+ params[key] = await field.prepare(params[key], params, params);
66
+ }));
67
+
68
+ // @ts-expect-error after preparation properties should be compatible with sync tx builder
69
+ return buildTx(params);
70
+ }
86
71
 
87
72
  /**
88
- * Unpack transaction hash
73
+ * Unpack transaction encoded as string
89
74
  * @category transaction builder
90
75
  * @param encodedTx - Transaction to unpack
91
76
  * @param txType - Expected transaction type
92
- * @returns object
93
- * @returns object.tx Object with transaction param's
94
- * @returns object.txType Transaction type
77
+ * @returns Object with transaction param's
95
78
  */
96
79
  export function unpackTx(encodedTx, txType) {
97
80
  const binary = rlpDecode(decode(encodedTx));
98
81
  const tag = +readInt(binary[0]);
99
- if (!isKeyOfObject(tag, TX_SCHEMA)) throw new DecodeError(`Unknown transaction tag: ${tag}`);
100
- if (txType != null && txType !== tag) throw new DecodeError(`Expected transaction to have ${Tag[txType]} tag, got ${Tag[tag]} instead`);
101
82
  const version = +readInt(binary[1]);
102
- if (!isKeyOfObject(version, TX_SCHEMA[tag])) throw new SchemaNotFoundError('deserialization', `tag ${tag}`, version);
103
- const schema = TX_SCHEMA[tag][version];
104
- return unpackRawTx(binary, schema);
83
+ const schema = getSchema(tag, version);
84
+ if (txType != null && txType !== tag) throw new DecodeError(`Expected transaction to have ${Tag[txType]} tag, got ${Tag[tag]} instead`);
85
+ if (binary.length !== schema.length) {
86
+ throw new ArgumentError('Transaction RLP length', schema.length, binary.length);
87
+ }
88
+ return schema.reduce((acc, _ref3, index) => {
89
+ let [name, field] = _ref3;
90
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
91
+ const deserialized = field.deserialize(binary[index], {
92
+ unpackTx
93
+ });
94
+ return {
95
+ ...acc,
96
+ [name]: deserialized
97
+ };
98
+ }, {});
105
99
  }
106
100
 
107
101
  /**
@@ -122,14 +116,10 @@ export function buildTxHash(rawTx) {
122
116
  * @returns Contract public key
123
117
  */
124
118
  export function buildContractIdByContractTx(contractTx) {
125
- const {
126
- tag,
127
- ownerId,
128
- nonce
129
- } = unpackTx(contractTx);
130
- if (![Tag.ContractCreateTx, Tag.GaAttachTx].includes(tag)) {
131
- throw new ArgumentError('contractCreateTx', 'a contractCreateTx or gaAttach', tag);
119
+ const params = unpackTx(contractTx);
120
+ if (Tag.ContractCreateTx !== params.tag && Tag.GaAttachTx !== params.tag) {
121
+ throw new ArgumentError('contractTx', 'a contractCreateTx or gaAttach', params.tag);
132
122
  }
133
- return buildContractId(ownerId, +nonce);
123
+ return buildContractId(params.ownerId, params.nonce);
134
124
  }
135
125
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["decode","encode","Encoding","AE_AMOUNT_FORMATS","hash","TX_SCHEMA","Tag","buildContractId","readInt","ArgumentError","DecodeError","SchemaNotFoundError","isKeyOfObject","unpackRawTx","binary","schema","length","reduce","acc","index","name","field","deserialized","deserialize","unpackTx","buildTx","params","prefix","denomination","AETTOS","schemas","tag","version","Math","max","Object","keys","map","a","key","serialize","rebuildTx","overrideParams","rlpEncode","Transaction","encodedTx","txType","rlpDecode","buildTxHash","rawTx","data","startsWith","TxHash","buildContractIdByContractTx","contractTx","ownerId","nonce","ContractCreateTx","GaAttachTx","includes"],"sources":["../../../src/tx/builder/index.ts"],"sourcesContent":["import { decode as rlpDecode, encode as rlpEncode, NestedUint8Array } from 'rlp';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../utils/encoder';\nimport { AE_AMOUNT_FORMATS } from '../../utils/amount-formatter';\nimport { hash } from '../../utils/crypto';\nimport { BinaryData, Field } from './field-types';\nimport {\n RawTxObject, TX_SCHEMA, TxField, TxSchema, TxTypeSchemas,\n} from './schema';\nimport { Tag } from './constants';\nimport { buildContractId, readInt } from './helpers';\nimport { ArgumentError, DecodeError, SchemaNotFoundError } from '../../utils/errors';\nimport { isKeyOfObject } from '../../utils/other';\n\n/**\n * JavaScript-based Transaction builder\n */\n\n/**\n * Unpack binary transaction\n * @category transaction builder\n * @param binary - Array with binary transaction field's\n * @param schema - Transaction schema\n * @returns Object with transaction field's\n */\nfunction unpackRawTx<Tx extends TxSchema>(\n binary: Uint8Array | NestedUint8Array,\n schema: TxField[],\n): RawTxObject<Tx> {\n if (binary.length !== schema.length) {\n throw new ArgumentError('Transaction RLP length', schema.length, binary.length);\n }\n return schema\n .reduce<any>(\n (\n acc,\n [name, field],\n index,\n ) => {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const deserialized = field.deserialize(binary[index] as BinaryData, { unpackTx });\n return { ...acc, [name]: deserialized };\n },\n {},\n );\n}\n\n/**\n * Build transaction hash\n * @category transaction builder\n * @param params - Object with tx params\n * @param options - options\n * @param options.denomination - Denomination of amounts\n * @param options.prefix - Prefix of transaction\n * @throws {@link InvalidTxParamsError}\n * @returns object\n * @returns object.tx Base64Check transaction hash with 'tx_' prefix\n * @returns object.rlpEncoded rlp encoded transaction\n * @returns object.binary binary transaction\n */\nexport function buildTx<\n TxType extends Tag,\n E extends Encoding = Encoding.Transaction,\n>(\n params: { tag: TxType; version?: number } & Omit<TxTypeSchemas[TxType], 'tag' | 'version'>\n // TODO: get it from gas-limit.ts somehow\n & (TxType extends Tag.ContractCreateTx | Tag.ContractCallTx\n | Tag.ChannelOffChainUpdateCallContract | Tag.GaAttachTx | Tag.GaMetaTx\n ? { gasMax?: number } : {}),\n {\n prefix,\n denomination = AE_AMOUNT_FORMATS.AETTOS,\n }: {\n prefix?: E;\n denomination?: AE_AMOUNT_FORMATS;\n } = {},\n): Encoded.Generic<E> {\n const schemas = TX_SCHEMA[params.tag];\n params.version ??= Math.max(...Object.keys(schemas).map((a) => +a));\n if (!isKeyOfObject(params.version, schemas)) {\n throw new SchemaNotFoundError('serialization', Tag[params.tag], params.version);\n }\n const schema = schemas[params.version] as unknown as TxField[];\n\n const binary = schema.map(([key, field]: [keyof TxSchema, Field]) => (\n field.serialize(\n params[key],\n {\n ...params,\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n unpackTx,\n buildTx,\n denomination,\n rebuildTx: (overrideParams: any) => buildTx(\n { ...params, ...overrideParams },\n { denomination },\n ),\n },\n )\n ));\n\n // @ts-expect-error looks like a TypeScript edge case\n return encode(rlpEncode(binary), prefix ?? Encoding.Transaction);\n}\n\n/**\n * Unpack transaction hash\n * @category transaction builder\n * @param encodedTx - Transaction to unpack\n * @param txType - Expected transaction type\n * @returns object\n * @returns object.tx Object with transaction param's\n * @returns object.txType Transaction type\n */\nexport function unpackTx<TxType extends Tag>(\n encodedTx: Encoded.Transaction | Encoded.Poi,\n txType?: TxType,\n): RawTxObject<TxTypeSchemas[TxType]> {\n const binary = rlpDecode(decode(encodedTx));\n const tag = +readInt(binary[0] as Buffer);\n if (!isKeyOfObject(tag, TX_SCHEMA)) throw new DecodeError(`Unknown transaction tag: ${tag}`);\n if (txType != null && txType !== tag) throw new DecodeError(`Expected transaction to have ${Tag[txType]} tag, got ${Tag[tag]} instead`);\n const version = +readInt(binary[1] as Buffer);\n if (!isKeyOfObject(version, TX_SCHEMA[tag])) throw new SchemaNotFoundError('deserialization', `tag ${tag}`, version);\n const schema = TX_SCHEMA[tag][version];\n return unpackRawTx<TxTypeSchemas[TxType]>(binary, schema);\n}\n\n/**\n * Build a transaction hash\n * @category transaction builder\n * @param rawTx - base64 or rlp encoded transaction\n * @returns Transaction hash\n */\nexport function buildTxHash(rawTx: Encoded.Transaction | Uint8Array): Encoded.TxHash {\n const data = typeof rawTx === 'string' && rawTx.startsWith('tx_')\n ? decode(rawTx)\n : rawTx;\n return encode(hash(data), Encoding.TxHash);\n}\n\n/**\n * Build a contract public key by contractCreateTx or gaAttach\n * @category contract\n * @param contractTx - Transaction\n * @returns Contract public key\n */\nexport function buildContractIdByContractTx(\n contractTx: Encoded.Transaction,\n): Encoded.ContractAddress {\n const { tag, ownerId, nonce } = unpackTx<Tag.ContractCreateTx | Tag.GaAttachTx>(contractTx);\n if (![Tag.ContractCreateTx, Tag.GaAttachTx].includes(tag)) {\n throw new ArgumentError('contractCreateTx', 'a contractCreateTx or gaAttach', tag);\n }\n return buildContractId(ownerId, +nonce);\n}\n"],"mappings":"AAAA,iBAA2E,KAAK;AAAC;EAAA;EAAA;AAAA;AAAA,SAE/EA,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,iBAAiB;AAAA,SACjBC,IAAI;AAAA,SAGEC,SAAS;AAAA,SAEfC,GAAG;AAAA,SACHC,eAAe,EAAEC,OAAO;AAAA,SACxBC,aAAa,EAAEC,WAAW,EAAEC,mBAAmB;AAAA,SAC/CC,aAAa;AAEtB;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,WAAW,CAClBC,MAAqC,EACrCC,MAAiB,EACA;EACjB,IAAID,MAAM,CAACE,MAAM,KAAKD,MAAM,CAACC,MAAM,EAAE;IACnC,MAAM,IAAIP,aAAa,CAAC,wBAAwB,EAAEM,MAAM,CAACC,MAAM,EAAEF,MAAM,CAACE,MAAM,CAAC;EACjF;EACA,OAAOD,MAAM,CACVE,MAAM,CACP,CACEC,GAAG,QAEHC,KAAK,KACF;IAAA,IAFH,CAACC,IAAI,EAAEC,KAAK,CAAC;IAGb;IACA,MAAMC,YAAY,GAAGD,KAAK,CAACE,WAAW,CAACT,MAAM,CAACK,KAAK,CAAC,EAAgB;MAAEK;IAAS,CAAC,CAAC;IACjF,OAAO;MAAE,GAA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,GACbA,KAAK;EACT,OAAOhD,MAAM,CAACG,IAAI,CAAC8C,IAAI,CAAC,EAAEhD,QAAQ,CAACkD,MAAM,CAAC;AAC5C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,2BAA2B,CACzCC,UAA+B,EACN;EACzB,MAAM;IAAEvB,GAAG;IAAEwB,OAAO;IAAEC;EAAM,CAAC,GAAGhC,QAAQ,CAAwC8B,UAAU,CAAC;EAC3F,IAAI,CAAC,CAAChD,GAAG,CAACmD,gBAAgB,EAAEnD,GAAG,CAACoD,UAAU,CAAC,CAACC,QAAQ,CAAC5B,GAAG,CAAC,EAAE;IACzD,MAAM,IAAItB,aAAa,CAAC,kBAAkB,EAAE,gCAAgC,EAAEsB,GAAG,CAAC;EACpF;EACA,OAAOxB,eAAe,CAACgD,OAAO,EAAE,CAACC,KAAK,CAAC;AACzC"}
1
+ {"version":3,"file":"index.mjs","names":["_rlp","decode","rlpDecode","encode","rlpEncode","Encoding","hash","txSchema","Tag","buildContractId","readInt","ArgumentError","DecodeError","SchemaNotFoundError","getSchema","tag","version","_version","schemas","filter","s","constValue","length","Math","max","map","schema","find","Object","entries","buildTx","params","prefix","arguments","undefined","binary","_ref","key","field","serialize","unpackTx","rebuildTx","overrideParams","Transaction","buildTxAsync","Promise","all","_ref2","prepare","encodedTx","txType","reduce","acc","_ref3","index","name","deserialized","deserialize","buildTxHash","rawTx","data","startsWith","TxHash","buildContractIdByContractTx","contractTx","ContractCreateTx","GaAttachTx","ownerId","nonce"],"sources":["../../../src/tx/builder/index.ts"],"sourcesContent":["import { decode as rlpDecode, encode as rlpEncode } from 'rlp';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../utils/encoder';\nimport { hash } from '../../utils/crypto';\nimport { BinaryData, Field } from './field-types';\nimport { txSchema } from './schema';\nimport { TxUnpacked, TxParams, TxParamsAsync } from './schema.generated';\nimport { Tag } from './constants';\nimport { buildContractId, readInt } from './helpers';\nimport { ArgumentError, DecodeError, SchemaNotFoundError } from '../../utils/errors';\n\n/**\n * JavaScript-based Transaction builder\n */\n\nexport function getSchema(tag: Tag, version?: number): Array<[string, Field]> {\n const schemas = txSchema.filter((s) => s.tag.constValue === tag);\n if (schemas.length === 0) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, 0);\n version ??= Math.max(...schemas.map((schema) => schema.version.constValue));\n const schema = schemas.find((s) => s.version.constValue === version);\n if (schema == null) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, version);\n return Object.entries(schema);\n}\n\n/**\n * Build transaction hash\n * @category transaction builder\n * @param params - Object with tx params\n * @param options - options\n * @param options.prefix - Prefix of transaction\n * @returns object Base64Check transaction hash with 'tx_' prefix\n */\nexport function buildTx<\n E extends Encoding = Encoding.Transaction,\n>(\n params: TxParams,\n {\n prefix,\n }: {\n prefix?: E;\n } = {},\n): Encoded.Generic<E> {\n const schema = getSchema(params.tag, params.version);\n\n const binary = schema.map(([key, field]) => (\n field.serialize(\n // @ts-expect-error the type of `params[key]` can't be determined accurately\n params[key],\n {\n ...params,\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n unpackTx,\n buildTx,\n rebuildTx: (overrideParams: any) => buildTx(\n { ...params, ...overrideParams },\n ),\n },\n params,\n )\n ));\n\n // @ts-expect-error looks like a TypeScript edge case\n return encode(rlpEncode(binary), prefix ?? Encoding.Transaction);\n}\n\nexport type BuildTxOptions <TxType extends Tag, OmitFields extends string> =\n Omit<TxParamsAsync & { tag: TxType }, 'tag' | OmitFields>;\n\n/**\n * @category transaction builder\n */\nexport async function buildTxAsync(params: TxParamsAsync): Promise<Encoded.Transaction> {\n await Promise.all(\n getSchema(params.tag, params.version)\n .map(async ([key, field]) => {\n if (field.prepare == null) return;\n // @ts-expect-error the type of `params[key]` can't be determined accurately\n params[key] = await field.prepare(params[key], params, params);\n }),\n );\n\n // @ts-expect-error after preparation properties should be compatible with sync tx builder\n return buildTx(params);\n}\n\n/**\n * Unpack transaction encoded as string\n * @category transaction builder\n * @param encodedTx - Transaction to unpack\n * @param txType - Expected transaction type\n * @returns Object with transaction param's\n */\nexport function unpackTx<TxType extends Tag>(\n encodedTx: Encoded.Transaction | Encoded.Poi | Encoded.StateTrees | Encoded.CallStateTree,\n txType?: TxType,\n): TxUnpacked & { tag: TxType } {\n const binary = rlpDecode(decode(encodedTx));\n const tag = +readInt(binary[0] as Buffer);\n const version = +readInt(binary[1] as Buffer);\n const schema = getSchema(tag, version);\n if (txType != null && txType !== tag) throw new DecodeError(`Expected transaction to have ${Tag[txType]} tag, got ${Tag[tag]} instead`);\n if (binary.length !== schema.length) {\n throw new ArgumentError('Transaction RLP length', schema.length, binary.length);\n }\n return schema.reduce<any>(\n (acc, [name, field], index) => {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const deserialized = field.deserialize(binary[index] as BinaryData, { unpackTx });\n return { ...acc, [name]: deserialized };\n },\n {},\n ) as any;\n}\n\n/**\n * Build a transaction hash\n * @category transaction builder\n * @param rawTx - base64 or rlp encoded transaction\n * @returns Transaction hash\n */\nexport function buildTxHash(rawTx: Encoded.Transaction | Uint8Array): Encoded.TxHash {\n const data = typeof rawTx === 'string' && rawTx.startsWith('tx_')\n ? decode(rawTx)\n : rawTx;\n return encode(hash(data), Encoding.TxHash);\n}\n\n/**\n * Build a contract public key by contractCreateTx or gaAttach\n * @category contract\n * @param contractTx - Transaction\n * @returns Contract public key\n */\nexport function buildContractIdByContractTx(\n contractTx: Encoded.Transaction,\n): Encoded.ContractAddress {\n const params = unpackTx(contractTx);\n if (Tag.ContractCreateTx !== params.tag && Tag.GaAttachTx !== params.tag) {\n throw new ArgumentError('contractTx', 'a contractCreateTx or gaAttach', params.tag);\n }\n return buildContractId(params.ownerId, params.nonce);\n}\n"],"mappings":"AAAA,OAAAA,IAAA,MAAyD,KAAK;AAAC;EAAAC,MAAA,EAAAC,SAAA;EAAAC,MAAA,EAAAC;AAAA,IAAAJ,IAAA;AAAA,SAE7DC,MAAM,EAAEE,MAAM,EAAW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