@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
@@ -25,7 +25,8 @@ export default {
25
25
  serialize(
26
26
  value: Int | undefined,
27
27
  txFields: { name: AensName } & Parameters<typeof coinAmount['serialize']>[1],
28
+ parameters: Parameters<typeof coinAmount['serialize']>[2],
28
29
  ): Buffer {
29
- return coinAmount.serialize.call(this, value, txFields);
30
+ return coinAmount.serialize.call(this, value, txFields, parameters);
30
31
  },
31
32
  };
@@ -0,0 +1,40 @@
1
+ import { isAccountNotFoundError } from '../../../utils/other';
2
+ import shortUInt from './short-u-int';
3
+ import Node from '../../../Node';
4
+ import { ArgumentError } from '../../../utils/errors';
5
+ import { NextNonceStrategy } from '../../../apis/node';
6
+
7
+ export default function genNonceField<SenderKey extends string>(senderKey: SenderKey): {
8
+ serialize: (value: number) => Buffer;
9
+ // TODO: (value: number) => Promise<number> | (value: undefined, ...) => Promise<number>
10
+ prepare: (
11
+ value: number | undefined,
12
+ params: {},
13
+ // TODO: replace `string` with AddressEncodings
14
+ options: { [key in SenderKey]: string } & { strategy?: NextNonceStrategy; onNode?: Node },
15
+ ) => Promise<number>;
16
+ deserialize: (value: Buffer) => number;
17
+ senderKey: string;
18
+ } {
19
+ return {
20
+ ...shortUInt,
21
+
22
+ async prepare(value, params, options) {
23
+ if (value != null) return value;
24
+ const { onNode, strategy } = options;
25
+ const senderId = options[senderKey];
26
+ const requirement = 'provided (or provide `nonce` instead)';
27
+ if (onNode == null) throw new ArgumentError('onNode', requirement, onNode);
28
+ if (senderId == null) throw new ArgumentError('senderId', requirement, senderId);
29
+ return (
30
+ await onNode.getAccountNextNonce(senderId.replace(/^ok_/, 'ak_'), { strategy })
31
+ .catch((error) => {
32
+ if (!isAccountNotFoundError(error)) throw error;
33
+ return { nextNonce: 1 };
34
+ })
35
+ ).nextNonce;
36
+ },
37
+
38
+ senderKey,
39
+ };
40
+ }
@@ -1,20 +1,30 @@
1
1
  import { ArgumentError } from '../../../utils/errors';
2
2
  import shortUInt from './short-u-int';
3
3
 
4
- export default function genShortUIntConstField<Value extends number>(value: Value): {
5
- serialize: (value?: Value) => Buffer;
4
+ export default function genShortUIntConstField<
5
+ Value extends number, Optional extends boolean = false,
6
+ >(constValue: Value, optional?: Optional): {
7
+ serialize: Optional extends true ? (value?: Value) => Buffer : (value: Value) => Buffer;
6
8
  deserialize: (value: Buffer) => Value;
9
+ constValue: Value;
10
+ constValueOptional: boolean;
7
11
  } {
8
12
  return {
9
- serialize(val) {
10
- if (val != null && val !== value) throw new ArgumentError('ShortUIntConst', value, val);
11
- return shortUInt.serialize(value);
13
+ serialize(value?: Value) {
14
+ if ((optional !== true || value != null) && value !== constValue) {
15
+ throw new ArgumentError('ShortUIntConst', constValue, value);
16
+ }
17
+ return shortUInt.serialize(constValue);
12
18
  },
13
19
 
14
20
  deserialize(buf) {
15
- const val = shortUInt.deserialize(buf);
16
- if (val !== value) throw new ArgumentError('ShortUIntConst', value, val);
17
- return value;
21
+ const value = shortUInt.deserialize(buf);
22
+ if (value !== constValue) throw new ArgumentError('ShortUIntConst', constValue, value);
23
+ return constValue;
18
24
  },
25
+
26
+ constValue,
27
+
28
+ constValueOptional: optional === true,
19
29
  };
20
30
  }
@@ -0,0 +1,24 @@
1
+ import shortUInt from './short-u-int';
2
+ import Node from '../../../Node';
3
+ import { ArgumentError } from '../../../utils/errors';
4
+
5
+ export default {
6
+ ...shortUInt,
7
+
8
+ serialize(value: number | undefined): Buffer {
9
+ return shortUInt.serialize(value ?? 0);
10
+ },
11
+
12
+ async prepare(
13
+ value: number | undefined,
14
+ params: {},
15
+ // TODO: { absoluteTtl: true } | { absoluteTtl: false, onNode: Node }
16
+ { onNode, absoluteTtl }: { onNode?: Node; absoluteTtl?: boolean },
17
+ ) {
18
+ if (absoluteTtl !== true && value !== 0 && value != null) {
19
+ if (onNode == null) throw new ArgumentError('onNode', 'provided', onNode);
20
+ value += (await onNode.getCurrentKeyBlock()).height;
21
+ }
22
+ return value;
23
+ },
24
+ };
@@ -0,0 +1,32 @@
1
+ import { Tag } from '../constants';
2
+ import { encode, Encoding, decode } from '../../../utils/encoder';
3
+ import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
4
+
5
+ type TagWrapping = Tag.AccountsMtree | Tag.CallsMtree | Tag.ChannelsMtree | Tag.ContractsMtree
6
+ | Tag.NameserviceMtree | Tag.OraclesMtree;
7
+
8
+ export default function genWrappedField<T extends TagWrapping>(tag: T): {
9
+ serialize: (
10
+ // TODO: replace with `(TxParams & { tag: T })['payload']`,
11
+ // but fix TS2502 value is referenced directly or indirectly in its own type annotation
12
+ value: any, options: { buildTx: typeof buildTxType }
13
+ ) => Buffer;
14
+ deserialize: (
15
+ value: Buffer, options: { unpackTx: typeof unpackTxType },
16
+ // TODO: replace with `(TxUnpacked & { tag: T })['payload']`,
17
+ // TS2577 Return type annotation circularly references itself
18
+ ) => any;
19
+ recursiveType: true;
20
+ } {
21
+ return {
22
+ serialize(payload, { buildTx }) {
23
+ return decode(buildTx({ tag, payload }));
24
+ },
25
+
26
+ deserialize(buffer, { unpackTx }) {
27
+ return unpackTx<TagWrapping>(encode(buffer, Encoding.Transaction), tag).payload;
28
+ },
29
+
30
+ recursiveType: true,
31
+ };
32
+ }
@@ -1,49 +1,26 @@
1
- import { decode as rlpDecode, encode as rlpEncode, NestedUint8Array } from 'rlp';
1
+ import { decode as rlpDecode, encode as rlpEncode } from 'rlp';
2
2
  import {
3
3
  decode, encode, Encoded, Encoding,
4
4
  } from '../../utils/encoder';
5
- import { AE_AMOUNT_FORMATS } from '../../utils/amount-formatter';
6
5
  import { hash } from '../../utils/crypto';
7
6
  import { BinaryData, Field } from './field-types';
8
- import {
9
- RawTxObject, TX_SCHEMA, TxField, TxSchema, TxTypeSchemas,
10
- } from './schema';
7
+ import { txSchema } from './schema';
8
+ import { TxUnpacked, TxParams, TxParamsAsync } from './schema.generated';
11
9
  import { Tag } from './constants';
12
10
  import { buildContractId, readInt } from './helpers';
13
11
  import { ArgumentError, DecodeError, SchemaNotFoundError } from '../../utils/errors';
14
- import { isKeyOfObject } from '../../utils/other';
15
12
 
16
13
  /**
17
14
  * JavaScript-based Transaction builder
18
15
  */
19
16
 
20
- /**
21
- * Unpack binary transaction
22
- * @category transaction builder
23
- * @param binary - Array with binary transaction field's
24
- * @param schema - Transaction schema
25
- * @returns Object with transaction field's
26
- */
27
- function unpackRawTx<Tx extends TxSchema>(
28
- binary: Uint8Array | NestedUint8Array,
29
- schema: TxField[],
30
- ): RawTxObject<Tx> {
31
- if (binary.length !== schema.length) {
32
- throw new ArgumentError('Transaction RLP length', schema.length, binary.length);
33
- }
34
- return schema
35
- .reduce<any>(
36
- (
37
- acc,
38
- [name, field],
39
- index,
40
- ) => {
41
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
42
- const deserialized = field.deserialize(binary[index] as BinaryData, { unpackTx });
43
- return { ...acc, [name]: deserialized };
44
- },
45
- {},
46
- );
17
+ export function getSchema(tag: Tag, version?: number): Array<[string, Field]> {
18
+ const schemas = txSchema.filter((s) => s.tag.constValue === tag);
19
+ if (schemas.length === 0) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, 0);
20
+ version ??= Math.max(...schemas.map((schema) => schema.version.constValue));
21
+ const schema = schemas.find((s) => s.version.constValue === version);
22
+ if (schema == null) throw new SchemaNotFoundError(`${Tag[tag]} (${tag})`, version);
23
+ return Object.entries(schema);
47
24
  }
48
25
 
49
26
  /**
@@ -51,52 +28,35 @@ function unpackRawTx<Tx extends TxSchema>(
51
28
  * @category transaction builder
52
29
  * @param params - Object with tx params
53
30
  * @param options - options
54
- * @param options.denomination - Denomination of amounts
55
31
  * @param options.prefix - Prefix of transaction
56
- * @throws {@link InvalidTxParamsError}
57
- * @returns object
58
- * @returns object.tx Base64Check transaction hash with 'tx_' prefix
59
- * @returns object.rlpEncoded rlp encoded transaction
60
- * @returns object.binary binary transaction
32
+ * @returns object Base64Check transaction hash with 'tx_' prefix
61
33
  */
62
34
  export function buildTx<
63
- TxType extends Tag,
64
35
  E extends Encoding = Encoding.Transaction,
65
36
  >(
66
- params: { tag: TxType; version?: number } & Omit<TxTypeSchemas[TxType], 'tag' | 'version'>
67
- // TODO: get it from gas-limit.ts somehow
68
- & (TxType extends Tag.ContractCreateTx | Tag.ContractCallTx
69
- | Tag.ChannelOffChainUpdateCallContract | Tag.GaAttachTx | Tag.GaMetaTx
70
- ? { gasMax?: number } : {}),
37
+ params: TxParams,
71
38
  {
72
39
  prefix,
73
- denomination = AE_AMOUNT_FORMATS.AETTOS,
74
40
  }: {
75
41
  prefix?: E;
76
- denomination?: AE_AMOUNT_FORMATS;
77
42
  } = {},
78
43
  ): Encoded.Generic<E> {
79
- const schemas = TX_SCHEMA[params.tag];
80
- params.version ??= Math.max(...Object.keys(schemas).map((a) => +a));
81
- if (!isKeyOfObject(params.version, schemas)) {
82
- throw new SchemaNotFoundError('serialization', Tag[params.tag], params.version);
83
- }
84
- const schema = schemas[params.version] as unknown as TxField[];
44
+ const schema = getSchema(params.tag, params.version);
85
45
 
86
- const binary = schema.map(([key, field]: [keyof TxSchema, Field]) => (
46
+ const binary = schema.map(([key, field]) => (
87
47
  field.serialize(
48
+ // @ts-expect-error the type of `params[key]` can't be determined accurately
88
49
  params[key],
89
50
  {
90
51
  ...params,
91
52
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
92
53
  unpackTx,
93
54
  buildTx,
94
- denomination,
95
55
  rebuildTx: (overrideParams: any) => buildTx(
96
56
  { ...params, ...overrideParams },
97
- { denomination },
98
57
  ),
99
58
  },
59
+ params,
100
60
  )
101
61
  ));
102
62
 
@@ -104,27 +64,53 @@ export function buildTx<
104
64
  return encode(rlpEncode(binary), prefix ?? Encoding.Transaction);
105
65
  }
106
66
 
67
+ export type BuildTxOptions <TxType extends Tag, OmitFields extends string> =
68
+ Omit<TxParamsAsync & { tag: TxType }, 'tag' | OmitFields>;
69
+
70
+ /**
71
+ * @category transaction builder
72
+ */
73
+ export async function buildTxAsync(params: TxParamsAsync): Promise<Encoded.Transaction> {
74
+ await Promise.all(
75
+ getSchema(params.tag, params.version)
76
+ .map(async ([key, field]) => {
77
+ if (field.prepare == null) return;
78
+ // @ts-expect-error the type of `params[key]` can't be determined accurately
79
+ params[key] = await field.prepare(params[key], params, params);
80
+ }),
81
+ );
82
+
83
+ // @ts-expect-error after preparation properties should be compatible with sync tx builder
84
+ return buildTx(params);
85
+ }
86
+
107
87
  /**
108
- * Unpack transaction hash
88
+ * Unpack transaction encoded as string
109
89
  * @category transaction builder
110
90
  * @param encodedTx - Transaction to unpack
111
91
  * @param txType - Expected transaction type
112
- * @returns object
113
- * @returns object.tx Object with transaction param's
114
- * @returns object.txType Transaction type
92
+ * @returns Object with transaction param's
115
93
  */
116
94
  export function unpackTx<TxType extends Tag>(
117
- encodedTx: Encoded.Transaction | Encoded.Poi,
95
+ encodedTx: Encoded.Transaction | Encoded.Poi | Encoded.StateTrees | Encoded.CallStateTree,
118
96
  txType?: TxType,
119
- ): RawTxObject<TxTypeSchemas[TxType]> {
97
+ ): TxUnpacked & { tag: TxType } {
120
98
  const binary = rlpDecode(decode(encodedTx));
121
99
  const tag = +readInt(binary[0] as Buffer);
122
- if (!isKeyOfObject(tag, TX_SCHEMA)) throw new DecodeError(`Unknown transaction tag: ${tag}`);
123
- if (txType != null && txType !== tag) throw new DecodeError(`Expected transaction to have ${Tag[txType]} tag, got ${Tag[tag]} instead`);
124
100
  const version = +readInt(binary[1] as Buffer);
125
- if (!isKeyOfObject(version, TX_SCHEMA[tag])) throw new SchemaNotFoundError('deserialization', `tag ${tag}`, version);
126
- const schema = TX_SCHEMA[tag][version];
127
- return unpackRawTx<TxTypeSchemas[TxType]>(binary, schema);
101
+ const schema = getSchema(tag, version);
102
+ if (txType != null && txType !== tag) throw new DecodeError(`Expected transaction to have ${Tag[txType]} tag, got ${Tag[tag]} instead`);
103
+ if (binary.length !== schema.length) {
104
+ throw new ArgumentError('Transaction RLP length', schema.length, binary.length);
105
+ }
106
+ return schema.reduce<any>(
107
+ (acc, [name, field], index) => {
108
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
109
+ const deserialized = field.deserialize(binary[index] as BinaryData, { unpackTx });
110
+ return { ...acc, [name]: deserialized };
111
+ },
112
+ {},
113
+ ) as any;
128
114
  }
129
115
 
130
116
  /**
@@ -149,9 +135,9 @@ export function buildTxHash(rawTx: Encoded.Transaction | Uint8Array): Encoded.Tx
149
135
  export function buildContractIdByContractTx(
150
136
  contractTx: Encoded.Transaction,
151
137
  ): Encoded.ContractAddress {
152
- const { tag, ownerId, nonce } = unpackTx<Tag.ContractCreateTx | Tag.GaAttachTx>(contractTx);
153
- if (![Tag.ContractCreateTx, Tag.GaAttachTx].includes(tag)) {
154
- throw new ArgumentError('contractCreateTx', 'a contractCreateTx or gaAttach', tag);
138
+ const params = unpackTx(contractTx);
139
+ if (Tag.ContractCreateTx !== params.tag && Tag.GaAttachTx !== params.tag) {
140
+ throw new ArgumentError('contractTx', 'a contractCreateTx or gaAttach', params.tag);
155
141
  }
156
- return buildContractId(ownerId, +nonce);
142
+ return buildContractId(params.ownerId, params.nonce);
157
143
  }