@aeternity/aepp-sdk 13.0.0-alpha.1 → 13.0.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 (394) hide show
  1. package/README.md +1 -1
  2. package/bin/aesophia_cli +0 -0
  3. package/dist/aepp-sdk.browser-script.js +1 -1
  4. package/dist/aepp-sdk.browser-script.js.map +1 -1
  5. package/dist/aepp-sdk.browser.js +1 -1
  6. package/dist/aepp-sdk.browser.js.map +1 -1
  7. package/dist/aepp-sdk.js +1833 -1543
  8. package/dist/aepp-sdk.js.map +1 -1
  9. package/es/AeSdk.mjs.map +1 -1
  10. package/es/AeSdkAepp.d.ts +5 -4
  11. package/es/AeSdkAepp.mjs +13 -17
  12. package/es/AeSdkAepp.mjs.map +1 -1
  13. package/es/AeSdkBase.mjs.map +1 -1
  14. package/es/AeSdkMethods.d.ts +11 -12
  15. package/es/AeSdkMethods.mjs +6 -8
  16. package/es/AeSdkMethods.mjs.map +1 -1
  17. package/es/AeSdkWallet.mjs +1 -1
  18. package/es/AeSdkWallet.mjs.map +1 -1
  19. package/es/Node.d.ts +5 -1
  20. package/es/Node.mjs +11 -5
  21. package/es/Node.mjs.map +1 -1
  22. package/es/account/Base.d.ts +11 -6
  23. package/es/account/Base.mjs +0 -17
  24. package/es/account/Base.mjs.map +1 -1
  25. package/es/account/Generalized.mjs +12 -25
  26. package/es/account/Generalized.mjs.map +1 -1
  27. package/es/account/Ledger.mjs.map +1 -1
  28. package/es/account/LedgerFactory.mjs.map +1 -1
  29. package/es/account/Memory.d.ts +2 -1
  30. package/es/account/Memory.mjs +9 -21
  31. package/es/account/Memory.mjs.map +1 -1
  32. package/es/account/Rpc.mjs.map +1 -1
  33. package/es/aens.d.ts +12 -14
  34. package/es/aens.mjs +17 -31
  35. package/es/aens.mjs.map +1 -1
  36. package/es/aepp-wallet-communication/connection/Browser.mjs +0 -16
  37. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  38. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +0 -16
  39. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  40. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -16
  41. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  42. package/es/aepp-wallet-communication/connection-proxy.mjs +0 -17
  43. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  44. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +4 -5
  45. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  46. package/es/aepp-wallet-communication/rpc/types.d.ts +6 -2
  47. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  48. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  49. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -16
  50. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  51. package/es/apis/compiler/compiler.d.ts +1 -1
  52. package/es/apis/compiler/compiler.mjs +4 -20
  53. package/es/apis/compiler/compiler.mjs.map +1 -1
  54. package/es/apis/compiler/models/index.d.ts +3 -2
  55. package/es/apis/compiler/models/index.mjs.map +1 -1
  56. package/es/apis/compiler/models/mappers.d.ts +1 -1
  57. package/es/apis/compiler/models/mappers.mjs +19 -2
  58. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  59. package/es/apis/node/models/index.d.ts +15 -15
  60. package/es/apis/node/models/index.mjs.map +1 -1
  61. package/es/apis/node/models/mappers.d.ts +1 -1
  62. package/es/apis/node/models/mappers.mjs +2 -1
  63. package/es/apis/node/models/mappers.mjs.map +1 -1
  64. package/es/apis/node/models/parameters.d.ts +2 -2
  65. package/es/apis/node/models/parameters.mjs +2 -2
  66. package/es/apis/node/models/parameters.mjs.map +1 -1
  67. package/es/apis/node/node.mjs +3 -19
  68. package/es/apis/node/node.mjs.map +1 -1
  69. package/es/chain.d.ts +8 -8
  70. package/es/chain.mjs +20 -23
  71. package/es/chain.mjs.map +1 -1
  72. package/es/channel/Base.d.ts +25 -12
  73. package/es/channel/Base.mjs +23 -26
  74. package/es/channel/Base.mjs.map +1 -1
  75. package/es/channel/Contract.mjs +8 -21
  76. package/es/channel/Contract.mjs.map +1 -1
  77. package/es/channel/Spend.d.ts +4 -2
  78. package/es/channel/Spend.mjs +0 -16
  79. package/es/channel/Spend.mjs.map +1 -1
  80. package/es/channel/handlers.mjs +6 -18
  81. package/es/channel/handlers.mjs.map +1 -1
  82. package/es/channel/internal.d.ts +19 -2
  83. package/es/channel/internal.mjs +19 -19
  84. package/es/channel/internal.mjs.map +1 -1
  85. package/es/contract/Contract.d.ts +30 -85
  86. package/es/contract/Contract.mjs +197 -215
  87. package/es/contract/Contract.mjs.map +1 -1
  88. package/es/contract/compiler/Base.d.ts +10 -14
  89. package/es/contract/compiler/Base.mjs.map +1 -1
  90. package/es/contract/compiler/Cli.mjs +5 -11
  91. package/es/contract/compiler/Cli.mjs.map +1 -1
  92. package/es/contract/compiler/Http.mjs +6 -30
  93. package/es/contract/compiler/Http.mjs.map +1 -1
  94. package/es/contract/compiler/HttpNode.mjs.map +1 -1
  95. package/es/contract/compiler/getFileSystem.mjs.map +1 -1
  96. package/es/contract/delegation-signature.d.ts +43 -0
  97. package/es/contract/delegation-signature.mjs +45 -0
  98. package/es/contract/delegation-signature.mjs.map +1 -0
  99. package/es/contract/ga.d.ts +23 -7
  100. package/es/contract/ga.mjs +52 -27
  101. package/es/contract/ga.mjs.map +1 -1
  102. package/es/index-browser.d.ts +5 -4
  103. package/es/index-browser.mjs +7 -21
  104. package/es/index-browser.mjs.map +1 -1
  105. package/es/oracle.d.ts +12 -17
  106. package/es/oracle.mjs +28 -48
  107. package/es/oracle.mjs.map +1 -1
  108. package/es/spend.d.ts +19 -27
  109. package/es/spend.mjs +20 -43
  110. package/es/spend.mjs.map +1 -1
  111. package/es/tx/builder/SchemaTypes.d.ts +37 -0
  112. package/es/tx/builder/SchemaTypes.mjs +2 -0
  113. package/es/tx/builder/SchemaTypes.mjs.map +1 -0
  114. package/es/tx/builder/constants.d.ts +4 -2
  115. package/es/tx/builder/constants.mjs +2 -0
  116. package/es/tx/builder/constants.mjs.map +1 -1
  117. package/es/tx/builder/field-types/abi-version.d.ts +11 -2
  118. package/es/tx/builder/field-types/abi-version.mjs +24 -4
  119. package/es/tx/builder/field-types/abi-version.mjs.map +1 -1
  120. package/es/tx/builder/field-types/address.mjs.map +1 -1
  121. package/es/tx/builder/field-types/array.d.ts +1 -1
  122. package/es/tx/builder/field-types/array.mjs.map +1 -1
  123. package/es/tx/builder/field-types/boolean.mjs.map +1 -1
  124. package/es/tx/builder/field-types/coin-amount.d.ts +3 -4
  125. package/es/tx/builder/field-types/coin-amount.mjs +4 -5
  126. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  127. package/es/tx/builder/field-types/ct-version.d.ts +22 -3
  128. package/es/tx/builder/field-types/ct-version.mjs +32 -4
  129. package/es/tx/builder/field-types/ct-version.mjs.map +1 -1
  130. package/es/tx/builder/field-types/deposit.d.ts +2 -1
  131. package/es/tx/builder/field-types/deposit.mjs +3 -2
  132. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  133. package/es/tx/builder/field-types/encoded.d.ts +1 -1
  134. package/es/tx/builder/field-types/encoded.mjs.map +1 -1
  135. package/es/tx/builder/field-types/entry.mjs +3 -0
  136. package/es/tx/builder/field-types/entry.mjs.map +1 -1
  137. package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
  138. package/es/tx/builder/field-types/fee.d.ts +3 -1
  139. package/es/tx/builder/field-types/fee.mjs +5 -1
  140. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  141. package/es/tx/builder/field-types/field.mjs.map +1 -1
  142. package/es/tx/builder/field-types/gas-limit.d.ts +3 -2
  143. package/es/tx/builder/field-types/gas-limit.mjs +4 -2
  144. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  145. package/es/tx/builder/field-types/gas-price.d.ts +3 -1
  146. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  147. package/es/tx/builder/field-types/index.d.ts +52 -13
  148. package/es/tx/builder/field-types/index.mjs +10 -2
  149. package/es/tx/builder/field-types/index.mjs.map +1 -1
  150. package/es/tx/builder/field-types/map.d.ts +13 -0
  151. package/es/tx/builder/field-types/map.mjs +49 -0
  152. package/es/tx/builder/field-types/map.mjs.map +1 -0
  153. package/es/tx/builder/field-types/mptree.d.ts +7 -2
  154. package/es/tx/builder/field-types/mptree.mjs +5 -7
  155. package/es/tx/builder/field-types/mptree.mjs.map +1 -1
  156. package/es/tx/builder/field-types/name-fee.d.ts +1 -1
  157. package/es/tx/builder/field-types/name-fee.mjs +2 -2
  158. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  159. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  160. package/es/tx/builder/field-types/name.mjs.map +1 -1
  161. package/es/tx/builder/field-types/nonce.d.ts +14 -0
  162. package/es/tx/builder/field-types/nonce.mjs +29 -0
  163. package/es/tx/builder/field-types/nonce.mjs.map +1 -0
  164. package/es/tx/builder/field-types/pointers.mjs.map +1 -1
  165. package/es/tx/builder/field-types/raw.mjs.map +1 -1
  166. package/es/tx/builder/field-types/short-u-int-const.d.ts +4 -2
  167. package/es/tx/builder/field-types/short-u-int-const.mjs +12 -8
  168. package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -1
  169. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  170. package/es/tx/builder/field-types/string.mjs.map +1 -1
  171. package/es/tx/builder/field-types/ttl.d.ts +11 -0
  172. package/es/tx/builder/field-types/ttl.mjs +21 -0
  173. package/es/tx/builder/field-types/ttl.mjs.map +1 -0
  174. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  175. package/es/tx/builder/field-types/wrapped.d.ts +14 -0
  176. package/es/tx/builder/field-types/wrapped.mjs +22 -0
  177. package/es/tx/builder/field-types/wrapped.mjs.map +1 -0
  178. package/es/tx/builder/helpers.mjs.map +1 -1
  179. package/es/tx/builder/index.d.ts +20 -20
  180. package/es/tx/builder/index.mjs +54 -64
  181. package/es/tx/builder/index.mjs.map +1 -1
  182. package/es/tx/builder/schema.d.ts +2735 -2865
  183. package/es/tx/builder/schema.generated.d.ts +2011 -0
  184. package/es/tx/builder/schema.generated.mjs +2 -0
  185. package/es/tx/builder/schema.generated.mjs.map +1 -0
  186. package/es/tx/builder/schema.mjs +459 -155
  187. package/es/tx/builder/schema.mjs.map +1 -1
  188. package/es/tx/execution-cost.d.ts +35 -0
  189. package/es/tx/execution-cost.mjs +123 -0
  190. package/es/tx/execution-cost.mjs.map +1 -0
  191. package/es/tx/transaction-signer.d.ts +6 -0
  192. package/es/tx/transaction-signer.mjs +27 -0
  193. package/es/tx/transaction-signer.mjs.map +1 -0
  194. package/es/tx/validator.mjs +60 -109
  195. package/es/tx/validator.mjs.map +1 -1
  196. package/es/utils/amount-formatter.mjs +0 -16
  197. package/es/utils/amount-formatter.mjs.map +1 -1
  198. package/es/utils/autorest.d.ts +3 -2
  199. package/es/utils/autorest.mjs +43 -11
  200. package/es/utils/autorest.mjs.map +1 -1
  201. package/es/utils/bytes.mjs +0 -16
  202. package/es/utils/bytes.mjs.map +1 -1
  203. package/es/utils/crypto.mjs +0 -16
  204. package/es/utils/crypto.mjs.map +1 -1
  205. package/es/utils/encoder.mjs.map +1 -1
  206. package/es/utils/errors.d.ts +14 -31
  207. package/es/utils/errors.mjs +3 -33
  208. package/es/utils/errors.mjs.map +1 -1
  209. package/es/utils/hd-wallet.mjs.map +1 -1
  210. package/es/utils/json-big.mjs.map +1 -1
  211. package/es/utils/keystore.mjs.map +1 -1
  212. package/es/utils/other.d.ts +1 -1
  213. package/es/utils/other.mjs.map +1 -1
  214. package/es/utils/semver-satisfies.mjs.map +1 -1
  215. package/es/utils/string.mjs +0 -17
  216. package/es/utils/string.mjs.map +1 -1
  217. package/package.json +34 -30
  218. package/src/AeSdkAepp.ts +16 -14
  219. package/src/AeSdkMethods.ts +11 -16
  220. package/src/AeSdkWallet.ts +1 -1
  221. package/src/Node.ts +17 -6
  222. package/src/account/Base.ts +11 -22
  223. package/src/account/Generalized.ts +9 -24
  224. package/src/account/Memory.ts +14 -21
  225. package/src/aens.ts +31 -47
  226. package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
  227. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +0 -17
  228. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +0 -17
  229. package/src/aepp-wallet-communication/connection-proxy.ts +0 -17
  230. package/src/aepp-wallet-communication/rpc/types.ts +7 -2
  231. package/src/aepp-wallet-communication/wallet-detector.ts +0 -17
  232. package/src/apis/compiler/compiler.ts +3 -27
  233. package/src/apis/compiler/models/index.ts +3 -2
  234. package/src/apis/compiler/models/mappers.ts +15 -2
  235. package/src/apis/node/models/index.ts +16 -15
  236. package/src/apis/node/models/mappers.ts +2 -1
  237. package/src/apis/node/models/parameters.ts +2 -2
  238. package/src/apis/node/node.ts +3 -27
  239. package/src/chain.ts +29 -28
  240. package/src/channel/Base.ts +33 -33
  241. package/src/channel/Contract.ts +8 -23
  242. package/src/channel/Spend.ts +2 -17
  243. package/src/channel/handlers.ts +5 -18
  244. package/src/channel/internal.ts +40 -22
  245. package/src/contract/Contract.ts +161 -170
  246. package/src/contract/compiler/Base.ts +10 -14
  247. package/src/contract/compiler/Cli.ts +5 -11
  248. package/src/contract/compiler/Http.ts +6 -25
  249. package/src/contract/delegation-signature.ts +56 -0
  250. package/src/contract/ga.ts +53 -32
  251. package/src/index-browser.ts +15 -21
  252. package/src/oracle.ts +46 -56
  253. package/src/spend.ts +33 -67
  254. package/src/tx/builder/SchemaTypes.ts +79 -0
  255. package/src/tx/builder/constants.ts +2 -0
  256. package/src/tx/builder/field-types/abi-version.ts +29 -6
  257. package/src/tx/builder/field-types/array.ts +1 -1
  258. package/src/tx/builder/field-types/coin-amount.ts +6 -4
  259. package/src/tx/builder/field-types/ct-version.ts +37 -4
  260. package/src/tx/builder/field-types/deposit.ts +3 -1
  261. package/src/tx/builder/field-types/encoded.ts +1 -1
  262. package/src/tx/builder/field-types/entry.ts +8 -3
  263. package/src/tx/builder/field-types/fee.ts +6 -4
  264. package/src/tx/builder/field-types/gas-limit.ts +2 -2
  265. package/src/tx/builder/field-types/index.ts +15 -1
  266. package/src/tx/builder/field-types/map.ts +45 -0
  267. package/src/tx/builder/field-types/mptree.ts +4 -3
  268. package/src/tx/builder/field-types/name-fee.ts +2 -1
  269. package/src/tx/builder/field-types/nonce.ts +40 -0
  270. package/src/tx/builder/field-types/short-u-int-const.ts +18 -8
  271. package/src/tx/builder/field-types/ttl.ts +24 -0
  272. package/src/tx/builder/field-types/wrapped.ts +32 -0
  273. package/src/tx/builder/index.ts +57 -71
  274. package/src/tx/builder/schema.generated.ts +2013 -0
  275. package/src/tx/builder/schema.ts +544 -624
  276. package/src/tx/execution-cost.ts +146 -0
  277. package/src/tx/transaction-signer.ts +27 -0
  278. package/src/tx/validator.ts +60 -91
  279. package/src/utils/amount-formatter.ts +0 -16
  280. package/src/utils/autorest.ts +52 -11
  281. package/src/utils/bytes.ts +0 -16
  282. package/src/utils/crypto.ts +0 -16
  283. package/src/utils/errors.ts +16 -45
  284. package/src/utils/string.ts +0 -17
  285. package/types-legacy/ts4.2/AeSdkAepp.d.ts +5 -4
  286. package/types-legacy/ts4.2/AeSdkMethods.d.ts +11 -12
  287. package/types-legacy/ts4.2/Node.d.ts +5 -1
  288. package/types-legacy/ts4.2/account/Base.d.ts +11 -6
  289. package/types-legacy/ts4.2/account/Memory.d.ts +2 -1
  290. package/types-legacy/ts4.2/aens.d.ts +12 -14
  291. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +6 -2
  292. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +1 -1
  293. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +3 -2
  294. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +1 -1
  295. package/types-legacy/ts4.2/apis/node/models/index.d.ts +15 -15
  296. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +1 -1
  297. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
  298. package/types-legacy/ts4.2/chain.d.ts +8 -8
  299. package/types-legacy/ts4.2/channel/Base.d.ts +25 -12
  300. package/types-legacy/ts4.2/channel/Spend.d.ts +4 -2
  301. package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
  302. package/types-legacy/ts4.2/contract/Contract.d.ts +29 -84
  303. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +10 -14
  304. package/types-legacy/ts4.2/contract/delegation-signature.d.ts +43 -0
  305. package/types-legacy/ts4.2/contract/ga.d.ts +23 -7
  306. package/types-legacy/ts4.2/index-browser.d.ts +5 -4
  307. package/types-legacy/ts4.2/oracle.d.ts +12 -17
  308. package/types-legacy/ts4.2/spend.d.ts +19 -27
  309. package/types-legacy/ts4.2/tx/builder/SchemaTypes.d.ts +37 -0
  310. package/types-legacy/ts4.2/tx/builder/constants.d.ts +4 -2
  311. package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +11 -2
  312. package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +1 -1
  313. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +3 -4
  314. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +33 -3
  315. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +2 -1
  316. package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +1 -1
  317. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +3 -1
  318. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +3 -2
  319. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +3 -1
  320. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +52 -13
  321. package/types-legacy/ts4.2/tx/builder/field-types/map.d.ts +13 -0
  322. package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +7 -2
  323. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -1
  324. package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
  325. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +4 -2
  326. package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
  327. package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
  328. package/types-legacy/ts4.2/tx/builder/index.d.ts +23 -20
  329. package/types-legacy/ts4.2/tx/builder/schema.d.ts +2962 -4629
  330. package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +2011 -0
  331. package/types-legacy/ts4.2/tx/execution-cost.d.ts +35 -0
  332. package/types-legacy/ts4.2/tx/transaction-signer.d.ts +6 -0
  333. package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
  334. package/types-legacy/ts4.2/utils/errors.d.ts +14 -31
  335. package/types-legacy/ts4.2/utils/other.d.ts +1 -1
  336. package/types-legacy/ts4.5/AeSdkAepp.d.ts +5 -4
  337. package/types-legacy/ts4.5/AeSdkMethods.d.ts +11 -12
  338. package/types-legacy/ts4.5/Node.d.ts +5 -1
  339. package/types-legacy/ts4.5/account/Base.d.ts +11 -6
  340. package/types-legacy/ts4.5/account/Memory.d.ts +2 -1
  341. package/types-legacy/ts4.5/aens.d.ts +12 -14
  342. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +6 -2
  343. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +1 -1
  344. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +3 -2
  345. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +1 -1
  346. package/types-legacy/ts4.5/apis/node/models/index.d.ts +15 -15
  347. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +1 -1
  348. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
  349. package/types-legacy/ts4.5/chain.d.ts +8 -8
  350. package/types-legacy/ts4.5/channel/Base.d.ts +25 -12
  351. package/types-legacy/ts4.5/channel/Spend.d.ts +4 -2
  352. package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
  353. package/types-legacy/ts4.5/contract/Contract.d.ts +29 -84
  354. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +10 -14
  355. package/types-legacy/ts4.5/contract/delegation-signature.d.ts +43 -0
  356. package/types-legacy/ts4.5/contract/ga.d.ts +23 -7
  357. package/types-legacy/ts4.5/index-browser.d.ts +5 -4
  358. package/types-legacy/ts4.5/oracle.d.ts +12 -17
  359. package/types-legacy/ts4.5/spend.d.ts +19 -27
  360. package/types-legacy/ts4.5/tx/builder/SchemaTypes.d.ts +37 -0
  361. package/types-legacy/ts4.5/tx/builder/constants.d.ts +4 -2
  362. package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +11 -2
  363. package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +1 -1
  364. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +3 -4
  365. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +33 -3
  366. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +2 -1
  367. package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +1 -1
  368. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +3 -1
  369. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +3 -2
  370. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +3 -1
  371. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +52 -13
  372. package/types-legacy/ts4.5/tx/builder/field-types/map.d.ts +13 -0
  373. package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +7 -2
  374. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -1
  375. package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
  376. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +4 -2
  377. package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
  378. package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
  379. package/types-legacy/ts4.5/tx/builder/index.d.ts +23 -20
  380. package/types-legacy/ts4.5/tx/builder/schema.d.ts +2962 -4629
  381. package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +2011 -0
  382. package/types-legacy/ts4.5/tx/execution-cost.d.ts +35 -0
  383. package/types-legacy/ts4.5/tx/transaction-signer.d.ts +6 -0
  384. package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
  385. package/types-legacy/ts4.5/utils/errors.d.ts +14 -31
  386. package/types-legacy/ts4.5/utils/other.d.ts +1 -1
  387. package/es/tx/index.d.ts +0 -19
  388. package/es/tx/index.mjs +0 -115
  389. package/es/tx/index.mjs.map +0 -1
  390. package/src/apis/compiler/code-model-v4.yaml +0 -2442
  391. package/src/apis/node/code-model-v4.yaml +0 -10080
  392. package/src/tx/index.ts +0 -129
  393. package/types-legacy/ts4.2/tx/index.d.ts +0 -19
  394. package/types-legacy/ts4.5/tx/index.d.ts +0 -19
package/src/spend.ts CHANGED
@@ -1,56 +1,13 @@
1
- /*
2
- * ISC License (ISC)
3
- * Copyright (c) 2022 aeternity developers
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
8
- *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- * PERFORMANCE OF THIS SOFTWARE.
16
- */
17
1
  import BigNumber from 'bignumber.js';
18
- import { sendTransaction, getBalance, resolveName } from './chain';
19
- import { _buildTx, BuildTxOptions } from './tx';
20
- import { buildTxHash, unpackTx } from './tx/builder';
2
+ import {
3
+ sendTransaction, getBalance, resolveName, SendTransactionOptions,
4
+ } from './chain';
5
+ import { buildTxAsync, BuildTxOptions, unpackTx } from './tx/builder';
21
6
  import { ArgumentError } from './utils/errors';
22
7
  import { Encoded, Encoding } from './utils/encoder';
23
8
  import { Tag, AensName } from './tx/builder/constants';
24
9
  import AccountBase from './account/Base';
25
10
 
26
- /**
27
- * Sign and post a transaction to the chain
28
- * @category chain
29
- * @param tx - Transaction
30
- * @param options - Options
31
- * @param options.verify - Verify transaction before broadcast, throw error if not
32
- * valid
33
- * @returns Transaction
34
- */
35
- export async function send(
36
- tx: Encoded.Transaction,
37
- options: SendOptions,
38
- ): Promise<SendReturnType> {
39
- const signed = await options.onAccount.signTransaction(tx, {
40
- ...options,
41
- networkId: await options.onNode.getNetworkId(),
42
- });
43
-
44
- return options.innerTx === true
45
- ? { hash: buildTxHash(signed), rawTx: signed }
46
- : sendTransaction(signed, options);
47
- }
48
-
49
- type SendOptionsType = Parameters<AccountBase['signTransaction']>[1]
50
- & Parameters<typeof sendTransaction>[1] & { onAccount: AccountBase };
51
- export interface SendOptions extends SendOptionsType {}
52
- interface SendReturnType extends Awaited<ReturnType<typeof sendTransaction>> {}
53
-
54
11
  /**
55
12
  * Send coins to another account
56
13
  * @category chain
@@ -63,10 +20,11 @@ export async function spend(
63
20
  amount: number | string,
64
21
  recipientIdOrName: Encoded.AccountAddress | AensName,
65
22
  options: SpendOptions,
66
- ): ReturnType<typeof send> {
67
- return send(
68
- await _buildTx(Tag.SpendTx, {
23
+ ): ReturnType<typeof sendTransaction> {
24
+ return sendTransaction(
25
+ await buildTxAsync({
69
26
  ...options,
27
+ tag: Tag.SpendTx,
70
28
  senderId: options.onAccount.address,
71
29
  recipientId: await resolveName<Encoding.AccountAddress>(
72
30
  recipientIdOrName,
@@ -80,23 +38,32 @@ export async function spend(
80
38
  }
81
39
 
82
40
  type SpendOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'>
83
- & Parameters<typeof resolveName>[2] & { onAccount: AccountBase } & SendOptions;
41
+ & Parameters<typeof resolveName>[2] & { onAccount: AccountBase } & SendTransactionOptions;
84
42
  interface SpendOptions extends SpendOptionsType {}
85
43
 
86
44
  // TODO: Rename to spendFraction
87
45
  /**
88
- * Send a fraction of coin balance to another account
46
+ * Spend a fraction of coin balance to another account. Useful if needed to drain account balance
47
+ * completely, sending funds to another account (with fraction set to 1).
89
48
  * @category chain
90
49
  * @param fraction - Fraction of balance to spend (between 0 and 1)
91
50
  * @param recipientIdOrName - Address or name of recipient account
92
51
  * @param options - Options
93
- * @returns Transaction
52
+ * @example
53
+ * ```js
54
+ * // `fraction` * 100 = % of AE to be transferred (e.g. `0.42` for 42% or `1` for 100%)
55
+ * const { blockHeight } = await aeSdk.transferFunds(
56
+ * 0.42,
57
+ * 'ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E',
58
+ * );
59
+ * console.log('Transaction mined at', blockHeight);
60
+ * ```
94
61
  */
95
62
  export async function transferFunds(
96
63
  fraction: number | string,
97
64
  recipientIdOrName: AensName | Encoded.AccountAddress,
98
65
  options: TransferFundsOptions,
99
- ): ReturnType<typeof send> {
66
+ ): ReturnType<typeof sendTransaction> {
100
67
  if (fraction < 0 || fraction > 1) {
101
68
  throw new ArgumentError('fraction', 'a number between 0 and 1', fraction);
102
69
  }
@@ -111,23 +78,23 @@ export async function transferFunds(
111
78
  );
112
79
  const desiredAmount = balance.times(fraction).integerValue(BigNumber.ROUND_HALF_UP);
113
80
  const { fee } = unpackTx(
114
- await _buildTx(Tag.SpendTx, {
115
- ...options, senderId, recipientId, amount: desiredAmount,
81
+ await buildTxAsync({
82
+ ...options, tag: Tag.SpendTx, senderId, recipientId, amount: desiredAmount,
116
83
  }),
117
84
  Tag.SpendTx,
118
85
  );
119
86
  // Reducing of the amount may reduce transaction fee, so this is not completely accurate
120
87
  const amount = desiredAmount.plus(fee).gt(balance) ? balance.minus(fee) : desiredAmount;
121
- return send(
122
- await _buildTx(Tag.SpendTx, {
123
- ...options, senderId, recipientId, amount,
88
+ return sendTransaction(
89
+ await buildTxAsync({
90
+ ...options, tag: Tag.SpendTx, senderId, recipientId, amount,
124
91
  }),
125
92
  options,
126
93
  );
127
94
  }
128
95
 
129
96
  type TransferFundsOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'>
130
- & Parameters<typeof resolveName>[2] & { onAccount: AccountBase } & SendOptions;
97
+ & Parameters<typeof resolveName>[2] & { onAccount: AccountBase } & SendTransactionOptions;
131
98
  interface TransferFundsOptions extends TransferFundsOptionsType {}
132
99
 
133
100
  /**
@@ -140,17 +107,16 @@ interface TransferFundsOptions extends TransferFundsOptionsType {}
140
107
  export async function payForTransaction(
141
108
  transaction: Encoded.Transaction,
142
109
  options: PayForTransactionOptions,
143
- ): ReturnType<typeof send> {
144
- return send(
145
- await _buildTx(
146
- Tag.PayingForTx,
147
- { ...options, payerId: options.onAccount.address, tx: transaction },
148
- ),
110
+ ): ReturnType<typeof sendTransaction> {
111
+ return sendTransaction(
112
+ await buildTxAsync({
113
+ ...options, tag: Tag.PayingForTx, payerId: options.onAccount.address, tx: transaction,
114
+ }),
149
115
  options,
150
116
  );
151
117
  }
152
118
 
153
119
  interface PayForTransactionOptions extends
154
- BuildTxOptions<Tag.PayingForTx, 'payerId' | 'tx'>, SendOptions {
120
+ BuildTxOptions<Tag.PayingForTx, 'payerId' | 'tx' | 'onNode'>, SendTransactionOptions {
155
121
  onAccount: AccountBase;
156
122
  }
@@ -0,0 +1,79 @@
1
+ import { Field as OriginalField } from './field-types';
2
+ import { UnionToIntersection } from '../../utils/other';
3
+
4
+ // TODO: figure out why this override is necessary
5
+ export interface Field extends OriginalField {
6
+ serialize: (...args: any[]) => any;
7
+ }
8
+
9
+ type NullablePartial<
10
+ T,
11
+ NK extends keyof T = { [K in keyof T]: undefined extends T[K] ? K : never }[keyof T],
12
+ > = Partial<Pick<T, NK>> & Omit<T, NK>;
13
+
14
+ type Or<A, B> = A extends undefined ? B : A;
15
+
16
+ type TxParamsBySchemaInternal<SchemaItem> = {
17
+ -readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field
18
+ ? Parameters<SchemaItem[key]['serialize']>[0]
19
+ : never;
20
+ };
21
+
22
+ type TxParamsBySchemaInternalParams<
23
+ SchemaItem,
24
+ SchemaItemValues = SchemaItem[keyof SchemaItem],
25
+ > = UnionToIntersection<
26
+ SchemaItemValues extends Field
27
+ ? Or<Parameters<SchemaItemValues['serialize']>[2], {}> : never
28
+ >;
29
+
30
+ type PickIsRec<SchemaItem, Recursive extends boolean> = {
31
+ [Key in keyof SchemaItem
32
+ as SchemaItem[Key] extends Field & { recursiveType: true }
33
+ ? (Recursive extends true ? Key : never)
34
+ : (Recursive extends true ? never : Key)]: SchemaItem[Key];
35
+ };
36
+
37
+ type TxParamsBySchema<SchemaItem> = SchemaItem extends Object
38
+ ? TxParamsBySchemaInternal<PickIsRec<SchemaItem, true>> &
39
+ NullablePartial<TxParamsBySchemaInternal<PickIsRec<SchemaItem, false>>> &
40
+ TxParamsBySchemaInternalParams<PickIsRec<SchemaItem, false>>
41
+ : never;
42
+
43
+ type TxParamsAsyncBySchemaInternal<SchemaItem> = {
44
+ -readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field & { prepare: Function }
45
+ ? Parameters<SchemaItem[key]['prepare']>[0]
46
+ : SchemaItem[key] extends Field
47
+ ? Parameters<SchemaItem[key]['serialize']>[0]
48
+ : never;
49
+ };
50
+
51
+ type TxParamsAsyncBySchemaInternalParams<
52
+ SchemaItem,
53
+ SchemaItemValues = SchemaItem[keyof SchemaItem],
54
+ > = UnionToIntersection<
55
+ SchemaItemValues extends Field & { prepare: Function }
56
+ ? Or<Parameters<SchemaItemValues['prepare']>[2], {}> : {}
57
+ >;
58
+
59
+ type TxParamsAsyncBySchema<SchemaItem> = SchemaItem extends Object
60
+ ? TxParamsAsyncBySchemaInternal<PickIsRec<SchemaItem, true>>
61
+ & NullablePartial<TxParamsAsyncBySchemaInternal<PickIsRec<SchemaItem, false>>>
62
+ & TxParamsAsyncBySchemaInternalParams<PickIsRec<SchemaItem, false>>
63
+ & TxParamsBySchemaInternalParams<PickIsRec<SchemaItem, false>>
64
+ : never;
65
+
66
+ type TxUnpackedBySchema<SchemaItem> = {
67
+ -readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field
68
+ ? ReturnType<SchemaItem[key]['deserialize']>
69
+ : never;
70
+ };
71
+
72
+ export default interface SchemaTypes<
73
+ Schema extends readonly any[],
74
+ SchemaItems = Schema[number],
75
+ > {
76
+ TxParams: TxParamsBySchema<SchemaItems>;
77
+ TxParamsAsync: TxParamsAsyncBySchema<SchemaItems>;
78
+ TxUnpacked: TxUnpackedBySchema<SchemaItems>;
79
+ }
@@ -60,6 +60,7 @@ export const NAME_BID_RANGES = mapObject({
60
60
 
61
61
  export enum ConsensusProtocolVersion {
62
62
  Iris = 5,
63
+ Ceres = 6,
63
64
  }
64
65
 
65
66
  /**
@@ -149,6 +150,7 @@ export enum Tag {
149
150
  GaAttachTx = 80,
150
151
  GaMetaTx = 81,
151
152
  PayingForTx = 82,
153
+ GaMetaTxAuthData = 810,
152
154
  // KeyBlock = 100,
153
155
  // MicroBlock = 101,
154
156
  // LightMicroBlock = 102,
@@ -1,20 +1,43 @@
1
1
  import { Tag, ConsensusProtocolVersion, AbiVersion } from '../constants';
2
2
  import { getProtocolDetails } from './ct-version';
3
+ import Node from '../../../Node';
3
4
 
4
5
  export default {
6
+ _getProtocolDetails(c: ConsensusProtocolVersion, tag: Tag): AbiVersion {
7
+ const kind = Tag.ContractCallTx === tag || Tag.GaMetaTx === tag
8
+ ? 'contract-call' : 'oracle-call';
9
+ return getProtocolDetails(c, kind).abiVersion;
10
+ },
11
+
5
12
  serialize(
6
13
  value: AbiVersion | undefined,
7
- { tag, consensusProtocolVersion = ConsensusProtocolVersion.Iris }:
8
- { tag: Tag; consensusProtocolVersion: ConsensusProtocolVersion },
14
+ { tag }: { tag: Tag },
15
+ { consensusProtocolVersion = ConsensusProtocolVersion.Iris }:
16
+ { consensusProtocolVersion?: ConsensusProtocolVersion },
9
17
  ): Buffer {
10
- const result = value ?? getProtocolDetails(
11
- consensusProtocolVersion,
12
- Tag.ContractCallTx === tag || Tag.GaMetaTx === tag ? 'contract-call' : 'oracle-call',
13
- ).abiVersion;
18
+ const result = value ?? this._getProtocolDetails(consensusProtocolVersion, tag);
14
19
 
15
20
  return Buffer.from([result]);
16
21
  },
17
22
 
23
+ async prepare(
24
+ value: AbiVersion | undefined,
25
+ { tag }: { tag: Tag },
26
+ // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}
27
+ options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },
28
+ ): Promise<AbiVersion | undefined> {
29
+ if (value != null) return value;
30
+ if (options.consensusProtocolVersion != null) return undefined;
31
+ if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;
32
+ if (options.onNode != null) {
33
+ return this._getProtocolDetails(
34
+ (await options.onNode.getNodeInfo()).consensusProtocolVersion,
35
+ tag,
36
+ );
37
+ }
38
+ return undefined;
39
+ },
40
+
18
41
  deserialize(buffer: Buffer): AbiVersion {
19
42
  return buffer[0];
20
43
  },
@@ -4,7 +4,7 @@ export default function genArrayField<Input, Output, Binary>(
4
4
  deserialize: (value: Binary, params: unknown) => Output;
5
5
  },
6
6
  ): {
7
- serialize: (value: Input[], params: unknown) => Binary[];
7
+ serialize: (value: readonly Input[], params: unknown) => Binary[];
8
8
  deserialize: (value: Binary[], params: unknown) => Output[];
9
9
  } {
10
10
  return {
@@ -2,8 +2,6 @@ import uInt from './u-int';
2
2
  import { Int } from '../constants';
3
3
  import { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter';
4
4
 
5
- export interface Options { denomination?: AE_AMOUNT_FORMATS }
6
-
7
5
  export default {
8
6
  ...uInt,
9
7
 
@@ -11,11 +9,15 @@ export default {
11
9
  return value ?? '0';
12
10
  },
13
11
 
14
- serialize(value: Int | undefined, { denomination, ...options }: Options): Buffer {
12
+ serialize(
13
+ value: Int | undefined,
14
+ params: {},
15
+ { denomination = AE_AMOUNT_FORMATS.AETTOS }: { denomination?: AE_AMOUNT_FORMATS },
16
+ ): Buffer {
15
17
  return uInt.serialize(
16
18
  this.serializeAettos(
17
19
  value != null ? formatAmount(value, { denomination }) : value,
18
- options,
20
+ params,
19
21
  ),
20
22
  );
21
23
  },
@@ -1,17 +1,31 @@
1
1
  import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants';
2
+ import Node from '../../../Node';
2
3
 
3
- // First abi/vm by default
4
+ /*
5
+ * First abi/vm by default
6
+ * @see {@link https://github.com/aeternity/protocol/blob/71cf111/contracts/contract_vms.md#virtual-machines-on-the-æternity-blockchain}
7
+ */
4
8
  export const ProtocolToVmAbi = {
5
9
  [ConsensusProtocolVersion.Iris]: {
6
10
  'contract-create': {
7
11
  vmVersion: [VmVersion.Fate2], abiVersion: [AbiVersion.Fate],
8
12
  },
9
- // TODO: Ensure that AEVM (Sophia?) is still available here
10
13
  'contract-call': {
11
14
  vmVersion: [], abiVersion: [AbiVersion.Fate, AbiVersion.Sophia],
12
15
  },
13
16
  'oracle-call': {
14
- vmVersion: [], abiVersion: [AbiVersion.NoAbi, AbiVersion.Sophia],
17
+ vmVersion: [], abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],
18
+ },
19
+ },
20
+ [ConsensusProtocolVersion.Ceres]: {
21
+ 'contract-create': {
22
+ vmVersion: [VmVersion.Fate2], abiVersion: [AbiVersion.Fate],
23
+ },
24
+ 'contract-call': {
25
+ vmVersion: [], abiVersion: [AbiVersion.Fate],
26
+ },
27
+ 'oracle-call': {
28
+ vmVersion: [], abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],
15
29
  },
16
30
  },
17
31
  } as const;
@@ -35,14 +49,33 @@ export function getProtocolDetails(
35
49
  export default {
36
50
  serialize(
37
51
  value: CtVersion | undefined,
52
+ params: {},
38
53
  { consensusProtocolVersion = ConsensusProtocolVersion.Iris }:
39
- { consensusProtocolVersion: ConsensusProtocolVersion },
54
+ { consensusProtocolVersion?: ConsensusProtocolVersion },
40
55
  ): Buffer {
41
56
  value ??= getProtocolDetails(consensusProtocolVersion, 'contract-create');
42
57
 
43
58
  return Buffer.from([value.vmVersion, 0, value.abiVersion]);
44
59
  },
45
60
 
61
+ async prepare(
62
+ value: CtVersion | undefined,
63
+ params: {},
64
+ // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}
65
+ options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },
66
+ ): Promise<CtVersion | undefined> {
67
+ if (value != null) return value;
68
+ if (options.consensusProtocolVersion != null) return undefined;
69
+ if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;
70
+ if (options.onNode != null) {
71
+ return getProtocolDetails(
72
+ (await options.onNode.getNodeInfo()).consensusProtocolVersion,
73
+ 'contract-create',
74
+ );
75
+ }
76
+ return undefined;
77
+ },
78
+
46
79
  deserialize(buffer: Buffer): CtVersion {
47
80
  const [vm, , abi] = buffer;
48
81
  return { vmVersion: +vm, abiVersion: +abi };
@@ -8,14 +8,16 @@ export default {
8
8
  /**
9
9
  * @param value - Deposit value in string format. Should be equal to '0'.
10
10
  * @param options - Options
11
+ * @param parameters - Parameters
11
12
  * @returns Deposit value Buffer.
12
13
  */
13
14
  serialize(
14
15
  value: Int | undefined,
15
16
  options: Parameters<typeof coinAmount['serialize']>[1],
17
+ parameters: Parameters<typeof coinAmount['serialize']>[2],
16
18
  ): Buffer {
17
19
  value ??= 0;
18
20
  if (+value !== 0) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value.toString()} instead`);
19
- return coinAmount.serialize(value, options);
21
+ return coinAmount.serialize(value, options, parameters);
20
22
  },
21
23
  };
@@ -9,7 +9,7 @@ export default function genEncodedField<E extends Encoding, Optional extends boo
9
9
  ): {
10
10
  serialize: Optional extends true
11
11
  ? (value?: Encoded.Generic<E>) => Buffer : (value: Encoded.Generic<E>) => Buffer;
12
- deserialize: (value: Buffer) => Encoded.Generic<Encoding>;
12
+ deserialize: (value: Buffer) => Encoded.Generic<E>;
13
13
  } {
14
14
  return {
15
15
  serialize(encodedData?: Encoded.Generic<E>) {
@@ -1,24 +1,29 @@
1
- import { decode, encode, Encoding } from '../../../utils/encoder';
1
+ import {
2
+ decode, encode, Encoded, Encoding,
3
+ } from '../../../utils/encoder';
2
4
  import { Tag } from '../constants';
3
5
  import { ArgumentError } from '../../../utils/errors';
4
6
  import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
5
7
 
6
8
  export default function genEntryField<T extends Tag = Tag>(tag?: T): {
7
9
  serialize: (
8
- // TODO: replace with `Parameters<typeof buildTxType<T>>[0]`,
10
+ // TODO: replace with `TxParams & { tag: T }`,
9
11
  // but fix TS2502 value is referenced directly or indirectly in its own type annotation
10
12
  value: any,
11
13
  options: { buildTx: typeof buildTxType },
12
14
  ) => Buffer;
13
15
  deserialize: (
14
16
  value: Buffer, options: { unpackTx: typeof unpackTxType },
15
- // TODO: replace with `ReturnType<typeof unpackTxType<T>>`,
17
+ // TODO: replace with `TxUnpacked & { tag: T }`,
16
18
  // TS2577 Return type annotation circularly references itself
17
19
  ) => any;
18
20
  } {
19
21
  return {
20
22
  serialize(txParams, { buildTx }) {
21
23
  if (ArrayBuffer.isView(txParams)) return Buffer.from(txParams as any);
24
+ if (typeof txParams === 'string' && txParams.startsWith('tx_')) {
25
+ return decode(txParams as Encoded.Transaction);
26
+ }
22
27
  return decode(buildTx({ ...txParams, ...tag != null && { tag } }));
23
28
  },
24
29
 
@@ -101,12 +101,14 @@ export function buildFee(
101
101
  const { length } = decode(builtTx);
102
102
  const txObject = unpackTx(builtTx);
103
103
 
104
+ let innerTxSize = 0;
105
+ if (txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx) {
106
+ innerTxSize = decode(buildTx(txObject.tx.encodedTx)).length;
107
+ }
108
+
104
109
  return TX_FEE_BASE_GAS(txObject.tag)
105
110
  .plus(TX_FEE_OTHER_GAS(txObject.tag, length, {
106
- relativeTtl: getOracleRelativeTtl(txObject),
107
- innerTxSize: txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx
108
- ? decode(buildTx(txObject.tx.encodedTx)).length
109
- : 0,
111
+ relativeTtl: getOracleRelativeTtl(txObject), innerTxSize,
110
112
  }))
111
113
  .times(MIN_GAS_PRICE);
112
114
  }
@@ -19,15 +19,15 @@ export default {
19
19
  serialize(
20
20
  _value: number | undefined,
21
21
  {
22
- tag, rebuildTx, unpackTx, buildTx, gasMax = 6e6, _computingGasLimit,
22
+ tag, rebuildTx, unpackTx, buildTx, _computingGasLimit,
23
23
  }: {
24
24
  tag: Tag;
25
25
  rebuildTx: (params: any) => any;
26
26
  unpackTx: typeof unpackTxType;
27
27
  buildTx: typeof buildTxType;
28
- gasMax: number;
29
28
  _computingGasLimit?: number;
30
29
  },
30
+ { gasMax = 6e6 }: { gasMax?: number },
31
31
  ): Buffer {
32
32
  if (_computingGasLimit != null) return shortUInt.serialize(_computingGasLimit);
33
33
 
@@ -12,16 +12,20 @@ import _fee from './fee';
12
12
  import _field from './field';
13
13
  import _gasLimit from './gas-limit';
14
14
  import _gasPrice from './gas-price';
15
+ import _map from './map';
15
16
  import _mptree from './mptree';
16
17
  import _name from './name';
17
18
  import _nameFee from './name-fee';
18
19
  import _nameId from './name-id';
20
+ import _nonce from './nonce';
19
21
  import _pointers from './pointers';
20
22
  import _raw from './raw';
21
23
  import _shortUInt from './short-u-int';
22
24
  import _shortUIntConst from './short-u-int-const';
23
25
  import _string from './string';
26
+ import _ttl from './ttl';
24
27
  import _uInt from './u-int';
28
+ import _wrapped from './wrapped';
25
29
 
26
30
  // TODO: remove after fixing https://github.com/Gerrit0/typedoc-plugin-missing-exports/issues/15
27
31
  const abiVersion = _abiVersion;
@@ -38,22 +42,28 @@ const fee = _fee;
38
42
  const field = _field;
39
43
  const gasLimit = _gasLimit;
40
44
  const gasPrice = _gasPrice;
45
+ const map = _map;
41
46
  const mptree = _mptree;
42
47
  const name = _name;
43
48
  const nameFee = _nameFee;
44
49
  const nameId = _nameId;
50
+ const nonce = _nonce;
45
51
  const pointers = _pointers;
46
52
  const raw = _raw;
47
53
  const shortUInt = _shortUInt;
48
54
  const shortUIntConst = _shortUIntConst;
49
55
  const string = _string;
56
+ const ttl = _ttl;
50
57
  const uInt = _uInt;
58
+ const wrapped = _wrapped;
51
59
 
52
60
  export type BinaryData = Buffer | Buffer[] | Buffer[][]
53
61
  | Array<[Buffer, Array<[Buffer, Buffer[]]>]>;
54
62
  export interface Field {
55
- serialize: (value: any, options: any) => BinaryData;
63
+ serialize: (value: any, options: any, parameters: any) => BinaryData;
64
+ prepare?: (value: any, options: any, parameters: any) => Promise<any>;
56
65
  deserialize: (value: BinaryData, options: any) => any;
66
+ recursiveType?: boolean;
57
67
  }
58
68
 
59
69
  export {
@@ -71,14 +81,18 @@ export {
71
81
  field,
72
82
  gasLimit,
73
83
  gasPrice,
84
+ map,
74
85
  mptree,
75
86
  name,
76
87
  nameFee,
77
88
  nameId,
89
+ nonce,
78
90
  pointers,
79
91
  raw,
80
92
  shortUInt,
81
93
  shortUIntConst,
82
94
  string,
95
+ ttl,
83
96
  uInt,
97
+ wrapped,
84
98
  };
@@ -0,0 +1,45 @@
1
+ import { Tag } from '../constants';
2
+ import {
3
+ encode, Encoding, Encoded, decode,
4
+ } from '../../../utils/encoder';
5
+ import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
6
+
7
+ export default function genMapField<E extends Encoding, T extends Tag>(encoding: E, tag: T): {
8
+ serialize: (
9
+ // TODO: replace with `TxParams & { tag: T }`,
10
+ // but fix TS2502 value is referenced directly or indirectly in its own type annotation
11
+ value: Record<Encoded.Generic<E>, any>, options: { buildTx: typeof buildTxType }
12
+ ) => Buffer;
13
+ deserialize: (
14
+ value: Buffer, options: { unpackTx: typeof unpackTxType },
15
+ // TODO: replace with `TxUnpacked & { tag: T }`,
16
+ // TS2577 Return type annotation circularly references itself
17
+ ) => Record<Encoded.Generic<E>, any>;
18
+ recursiveType: true;
19
+ } {
20
+ return {
21
+ serialize(object, { buildTx }) {
22
+ return decode(buildTx({
23
+ tag: Tag.Mtree,
24
+ values: Object.entries(object).map(([key, value]) => ({
25
+ tag: Tag.MtreeValue,
26
+ key: decode(key as Encoded.Generic<E>),
27
+ value: decode(buildTx({ ...value as any, tag })),
28
+ })),
29
+ }));
30
+ },
31
+
32
+ deserialize(buffer, { unpackTx }) {
33
+ const { values } = unpackTx(encode(buffer, Encoding.Transaction), Tag.Mtree);
34
+ return Object.fromEntries(values
35
+ // TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066
36
+ .filter(({ key }) => encoding !== Encoding.ContractAddress || key.length === 32)
37
+ .map(({ key, value }) => [
38
+ encode(key, encoding),
39
+ unpackTx(encode(value, Encoding.Transaction), tag),
40
+ ])) as Record<Encoded.Generic<E>, any>;
41
+ },
42
+
43
+ recursiveType: true,
44
+ };
45
+ }
@@ -13,6 +13,7 @@ import {
13
13
  decode, encode, Encoded, Encoding,
14
14
  } from '../../../utils/encoder';
15
15
  import type { unpackTx } from '..';
16
+ import type { TxUnpacked } from '../schema.generated';
16
17
 
17
18
  enum NodeType {
18
19
  Branch,
@@ -176,7 +177,7 @@ class MPTree<E extends Encoding, T extends Tag> {
176
177
  * @param key - The key of the element to retrieve
177
178
  * @returns Value associated to the specified key
178
179
  */
179
- get(key: Encoded.Generic<E>): ReturnType<typeof unpackTx<T>> | undefined {
180
+ get(key: Encoded.Generic<E>): TxUnpacked & { tag: T } | undefined {
180
181
  const d = this.#getRaw(decode(key).toString('hex'));
181
182
  if (d == null) return d;
182
183
  return this.#unpackTx(encode(d, Encoding.Transaction), this.#tag);
@@ -215,14 +216,14 @@ class MPTree<E extends Encoding, T extends Tag> {
215
216
  return entries;
216
217
  }
217
218
 
218
- toObject(): Record<Encoded.Any, ReturnType<typeof unpackTx<T>>> {
219
+ toObject(): Record<Encoded.Generic<E>, TxUnpacked & { tag: T }> {
219
220
  return Object.fromEntries(this.#entriesRaw()
220
221
  // TODO: remove after resolving https://github.com/aeternity/aeternity/issues/4066
221
222
  .filter(([k]) => this.#encoding !== Encoding.ContractAddress || k.length !== 66)
222
223
  .map(([k, v]) => [
223
224
  encode(Buffer.from(k, 'hex'), this.#encoding),
224
225
  this.#unpackTx(encode(v, Encoding.Transaction), this.#tag),
225
- ]));
226
+ ])) as Record<Encoded.Generic<E>, TxUnpacked & { tag: T }>;
226
227
  }
227
228
  }
228
229