@aeternity/aepp-sdk 13.0.0-alpha.0 → 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 (481) 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 +5595 -2249
  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.d.ts +3 -3
  11. package/es/AeSdkBase.mjs +4 -0
  12. package/es/AeSdkBase.mjs.map +1 -1
  13. package/es/AeSdkMethods.d.ts +12 -14
  14. package/es/AeSdkMethods.mjs +6 -8
  15. package/es/AeSdkMethods.mjs.map +1 -1
  16. package/es/AeSdkWallet.mjs +1 -1
  17. package/es/AeSdkWallet.mjs.map +1 -1
  18. package/es/Node.d.ts +9 -4
  19. package/es/Node.mjs +12 -6
  20. package/es/Node.mjs.map +1 -1
  21. package/es/account/Base.d.ts +13 -8
  22. package/es/account/Base.mjs +0 -17
  23. package/es/account/Base.mjs.map +1 -1
  24. package/es/account/Generalized.mjs +14 -25
  25. package/es/account/Generalized.mjs.map +1 -1
  26. package/es/account/Ledger.mjs +2 -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 +11 -22
  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 +22 -32
  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.d.ts +1 -0
  39. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +19 -20
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  41. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -16
  42. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  43. package/es/aepp-wallet-communication/connection-proxy.mjs +0 -17
  44. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  45. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -6
  46. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  47. package/es/aepp-wallet-communication/rpc/types.d.ts +6 -2
  48. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  49. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  50. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -16
  51. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  52. package/es/apis/compiler/compiler.d.ts +1 -1
  53. package/es/apis/compiler/compiler.mjs +4 -20
  54. package/es/apis/compiler/compiler.mjs.map +1 -1
  55. package/es/apis/compiler/models/index.d.ts +3 -2
  56. package/es/apis/compiler/models/index.mjs.map +1 -1
  57. package/es/apis/compiler/models/mappers.d.ts +1 -1
  58. package/es/apis/compiler/models/mappers.mjs +19 -2
  59. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  60. package/es/apis/node/models/index.d.ts +15 -15
  61. package/es/apis/node/models/index.mjs.map +1 -1
  62. package/es/apis/node/models/mappers.d.ts +1 -1
  63. package/es/apis/node/models/mappers.mjs +2 -1
  64. package/es/apis/node/models/mappers.mjs.map +1 -1
  65. package/es/apis/node/models/parameters.d.ts +2 -2
  66. package/es/apis/node/models/parameters.mjs +2 -2
  67. package/es/apis/node/models/parameters.mjs.map +1 -1
  68. package/es/apis/node/node.mjs +3 -19
  69. package/es/apis/node/node.mjs.map +1 -1
  70. package/es/chain.d.ts +17 -9
  71. package/es/chain.mjs +23 -23
  72. package/es/chain.mjs.map +1 -1
  73. package/es/channel/Base.d.ts +27 -9
  74. package/es/channel/Base.mjs +27 -27
  75. package/es/channel/Base.mjs.map +1 -1
  76. package/es/channel/Contract.d.ts +8 -7
  77. package/es/channel/Contract.mjs +8 -21
  78. package/es/channel/Contract.mjs.map +1 -1
  79. package/es/channel/Spend.d.ts +5 -1
  80. package/es/channel/Spend.mjs +4 -18
  81. package/es/channel/Spend.mjs.map +1 -1
  82. package/es/channel/handlers.mjs +16 -26
  83. package/es/channel/handlers.mjs.map +1 -1
  84. package/es/channel/internal.d.ts +19 -2
  85. package/es/channel/internal.mjs +22 -20
  86. package/es/channel/internal.mjs.map +1 -1
  87. package/es/contract/Contract.d.ts +43 -123
  88. package/es/contract/Contract.mjs +230 -250
  89. package/es/contract/Contract.mjs.map +1 -1
  90. package/es/contract/compiler/Base.d.ts +74 -0
  91. package/es/contract/compiler/Base.mjs +5 -0
  92. package/es/contract/compiler/Base.mjs.map +1 -0
  93. package/es/contract/compiler/Cli.d.ts +23 -0
  94. package/es/contract/compiler/Cli.mjs +149 -0
  95. package/es/contract/compiler/Cli.mjs.map +1 -0
  96. package/es/contract/compiler/Http.d.ts +32 -0
  97. package/es/contract/compiler/Http.mjs +94 -0
  98. package/es/contract/compiler/Http.mjs.map +1 -0
  99. package/es/contract/compiler/HttpNode.d.ts +17 -0
  100. package/es/contract/compiler/HttpNode.mjs +26 -0
  101. package/es/contract/compiler/HttpNode.mjs.map +1 -0
  102. package/es/contract/compiler/getFileSystem.d.ts +6 -0
  103. package/es/contract/compiler/getFileSystem.mjs +40 -0
  104. package/es/contract/compiler/getFileSystem.mjs.map +1 -0
  105. package/es/contract/delegation-signature.d.ts +43 -0
  106. package/es/contract/delegation-signature.mjs +45 -0
  107. package/es/contract/delegation-signature.mjs.map +1 -0
  108. package/es/contract/ga.d.ts +27 -10
  109. package/es/contract/ga.mjs +63 -29
  110. package/es/contract/ga.mjs.map +1 -1
  111. package/es/index-browser.d.ts +40 -0
  112. package/es/index-browser.mjs +41 -0
  113. package/es/index-browser.mjs.map +1 -0
  114. package/es/index.d.ts +4 -38
  115. package/es/index.mjs +4 -53
  116. package/es/index.mjs.map +1 -1
  117. package/es/oracle.d.ts +12 -17
  118. package/es/oracle.mjs +29 -49
  119. package/es/oracle.mjs.map +1 -1
  120. package/es/spend.d.ts +19 -27
  121. package/es/spend.mjs +21 -46
  122. package/es/spend.mjs.map +1 -1
  123. package/es/tx/builder/SchemaTypes.d.ts +37 -0
  124. package/es/tx/builder/SchemaTypes.mjs +2 -0
  125. package/es/tx/builder/SchemaTypes.mjs.map +1 -0
  126. package/es/tx/builder/constants.d.ts +31 -2
  127. package/es/tx/builder/constants.mjs +34 -3
  128. package/es/tx/builder/constants.mjs.map +1 -1
  129. package/es/tx/builder/field-types/abi-version.d.ts +19 -0
  130. package/es/tx/builder/field-types/abi-version.mjs +40 -0
  131. package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
  132. package/es/tx/builder/field-types/address.d.ts +5 -6
  133. package/es/tx/builder/field-types/address.mjs +17 -8
  134. package/es/tx/builder/field-types/address.mjs.map +1 -1
  135. package/es/tx/builder/field-types/array.d.ts +7 -0
  136. package/es/tx/builder/field-types/array.mjs +11 -0
  137. package/es/tx/builder/field-types/array.mjs.map +1 -0
  138. package/es/tx/builder/field-types/boolean.d.ts +6 -0
  139. package/es/tx/builder/field-types/boolean.mjs +13 -0
  140. package/es/tx/builder/field-types/boolean.mjs.map +1 -0
  141. package/es/tx/builder/field-types/coin-amount.d.ts +4 -5
  142. package/es/tx/builder/field-types/coin-amount.mjs +4 -5
  143. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  144. package/es/tx/builder/field-types/ct-version.d.ts +49 -0
  145. package/es/tx/builder/field-types/ct-version.mjs +76 -0
  146. package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
  147. package/es/tx/builder/field-types/deposit.d.ts +3 -2
  148. package/es/tx/builder/field-types/deposit.mjs +3 -2
  149. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  150. package/es/tx/builder/field-types/encoded.d.ts +6 -0
  151. package/es/tx/builder/field-types/encoded.mjs +21 -0
  152. package/es/tx/builder/field-types/encoded.mjs.map +1 -0
  153. package/es/tx/builder/field-types/entry.d.ts +11 -0
  154. package/es/tx/builder/field-types/entry.mjs +34 -0
  155. package/es/tx/builder/field-types/entry.mjs.map +1 -0
  156. package/es/tx/builder/field-types/enumeration.d.ts +5 -3
  157. package/es/tx/builder/field-types/enumeration.mjs +11 -2
  158. package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
  159. package/es/tx/builder/field-types/fee.d.ts +12 -7
  160. package/es/tx/builder/field-types/fee.mjs +28 -20
  161. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  162. package/es/tx/builder/field-types/field.mjs.map +1 -1
  163. package/es/tx/builder/field-types/gas-limit.d.ts +7 -3
  164. package/es/tx/builder/field-types/gas-limit.mjs +13 -8
  165. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  166. package/es/tx/builder/field-types/gas-price.d.ts +3 -1
  167. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  168. package/es/tx/builder/field-types/index.d.ts +107 -30
  169. package/es/tx/builder/field-types/index.mjs +38 -12
  170. package/es/tx/builder/field-types/index.mjs.map +1 -1
  171. package/es/tx/builder/field-types/map.d.ts +13 -0
  172. package/es/tx/builder/field-types/map.mjs +49 -0
  173. package/es/tx/builder/field-types/map.mjs.map +1 -0
  174. package/es/tx/builder/field-types/mptree.d.ts +42 -0
  175. package/es/tx/builder/field-types/mptree.mjs +266 -0
  176. package/es/tx/builder/field-types/mptree.mjs.map +1 -0
  177. package/es/tx/builder/field-types/name-fee.d.ts +2 -3
  178. package/es/tx/builder/field-types/name-fee.mjs +2 -2
  179. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  180. package/es/tx/builder/field-types/name-id.mjs +2 -1
  181. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  182. package/es/tx/builder/field-types/name.mjs.map +1 -1
  183. package/es/tx/builder/field-types/nonce.d.ts +14 -0
  184. package/es/tx/builder/field-types/nonce.mjs +29 -0
  185. package/es/tx/builder/field-types/nonce.mjs.map +1 -0
  186. package/es/tx/builder/field-types/pointers.mjs +2 -2
  187. package/es/tx/builder/field-types/pointers.mjs.map +1 -1
  188. package/es/tx/builder/field-types/raw.d.ts +6 -0
  189. package/es/tx/builder/field-types/raw.mjs +13 -0
  190. package/es/tx/builder/field-types/raw.mjs.map +1 -0
  191. package/es/tx/builder/field-types/short-u-int-const.d.ts +7 -0
  192. package/es/tx/builder/field-types/short-u-int-const.mjs +20 -0
  193. package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
  194. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  195. package/es/tx/builder/field-types/string.d.ts +6 -0
  196. package/es/tx/builder/field-types/string.mjs +10 -0
  197. package/es/tx/builder/field-types/string.mjs.map +1 -0
  198. package/es/tx/builder/field-types/ttl.d.ts +11 -0
  199. package/es/tx/builder/field-types/ttl.mjs +21 -0
  200. package/es/tx/builder/field-types/ttl.mjs.map +1 -0
  201. package/es/tx/builder/field-types/u-int.d.ts +1 -2
  202. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  203. package/es/tx/builder/field-types/wrapped.d.ts +14 -0
  204. package/es/tx/builder/field-types/wrapped.mjs +22 -0
  205. package/es/tx/builder/field-types/wrapped.mjs.map +1 -0
  206. package/es/tx/builder/helpers.mjs.map +1 -1
  207. package/es/tx/builder/index.d.ts +18 -36
  208. package/es/tx/builder/index.mjs +65 -236
  209. package/es/tx/builder/index.mjs.map +1 -1
  210. package/es/tx/builder/schema.d.ts +2734 -1324
  211. package/es/tx/builder/schema.generated.d.ts +2011 -0
  212. package/es/tx/builder/schema.generated.mjs +2 -0
  213. package/es/tx/builder/schema.generated.mjs.map +1 -0
  214. package/es/tx/builder/schema.mjs +459 -223
  215. package/es/tx/builder/schema.mjs.map +1 -1
  216. package/es/tx/execution-cost.d.ts +35 -0
  217. package/es/tx/execution-cost.mjs +123 -0
  218. package/es/tx/execution-cost.mjs.map +1 -0
  219. package/es/tx/transaction-signer.d.ts +6 -0
  220. package/es/tx/transaction-signer.mjs +27 -0
  221. package/es/tx/transaction-signer.mjs.map +1 -0
  222. package/es/tx/validator.d.ts +3 -5
  223. package/es/tx/validator.mjs +91 -153
  224. package/es/tx/validator.mjs.map +1 -1
  225. package/es/utils/amount-formatter.mjs +0 -16
  226. package/es/utils/amount-formatter.mjs.map +1 -1
  227. package/es/utils/autorest.d.ts +3 -2
  228. package/es/utils/autorest.mjs +43 -11
  229. package/es/utils/autorest.mjs.map +1 -1
  230. package/es/utils/bytes.mjs +1 -17
  231. package/es/utils/bytes.mjs.map +1 -1
  232. package/es/utils/crypto.mjs +0 -16
  233. package/es/utils/crypto.mjs.map +1 -1
  234. package/es/utils/encoder.mjs.map +1 -1
  235. package/es/utils/errors.d.ts +16 -38
  236. package/es/utils/errors.mjs +3 -43
  237. package/es/utils/errors.mjs.map +1 -1
  238. package/es/utils/hd-wallet.mjs.map +1 -1
  239. package/es/utils/json-big.mjs.map +1 -1
  240. package/es/utils/keystore.mjs.map +1 -1
  241. package/es/utils/other.mjs.map +1 -1
  242. package/es/utils/semver-satisfies.mjs.map +1 -1
  243. package/es/utils/string.mjs +0 -17
  244. package/es/utils/string.mjs.map +1 -1
  245. package/package.json +52 -40
  246. package/src/AeSdkBase.ts +6 -3
  247. package/src/AeSdkMethods.ts +12 -18
  248. package/src/AeSdkWallet.ts +1 -1
  249. package/src/Node.ts +23 -9
  250. package/src/account/Base.ts +13 -24
  251. package/src/account/Generalized.ts +9 -24
  252. package/src/account/Ledger.ts +1 -1
  253. package/src/account/Memory.ts +15 -22
  254. package/src/aens.ts +34 -49
  255. package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
  256. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +18 -24
  257. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +0 -17
  258. package/src/aepp-wallet-communication/connection-proxy.ts +0 -17
  259. package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
  260. package/src/aepp-wallet-communication/rpc/types.ts +6 -2
  261. package/src/aepp-wallet-communication/wallet-detector.ts +0 -17
  262. package/src/apis/compiler/compiler.ts +3 -27
  263. package/src/apis/compiler/models/index.ts +3 -2
  264. package/src/apis/compiler/models/mappers.ts +15 -2
  265. package/src/apis/node/models/index.ts +16 -15
  266. package/src/apis/node/models/mappers.ts +2 -1
  267. package/src/apis/node/models/parameters.ts +2 -2
  268. package/src/apis/node/node.ts +3 -27
  269. package/src/chain.ts +33 -30
  270. package/src/channel/Base.ts +39 -31
  271. package/src/channel/Contract.ts +18 -32
  272. package/src/channel/Spend.ts +8 -18
  273. package/src/channel/handlers.ts +14 -26
  274. package/src/channel/internal.ts +41 -23
  275. package/src/contract/Contract.ts +188 -228
  276. package/src/contract/compiler/Base.ts +87 -0
  277. package/src/contract/compiler/Cli.ts +128 -0
  278. package/src/contract/compiler/Http.ts +105 -0
  279. package/src/contract/compiler/HttpNode.ts +26 -0
  280. package/src/contract/compiler/getFileSystem.ts +42 -0
  281. package/src/contract/delegation-signature.ts +56 -0
  282. package/src/contract/ga.ts +61 -37
  283. package/src/index-browser.ts +50 -0
  284. package/src/index.ts +4 -56
  285. package/src/oracle.ts +47 -57
  286. package/src/spend.ts +34 -68
  287. package/src/tx/builder/SchemaTypes.ts +79 -0
  288. package/src/tx/builder/constants.ts +34 -3
  289. package/src/tx/builder/field-types/abi-version.ts +44 -0
  290. package/src/tx/builder/field-types/address.ts +23 -13
  291. package/src/tx/builder/field-types/array.ts +19 -0
  292. package/src/tx/builder/field-types/boolean.ts +9 -0
  293. package/src/tx/builder/field-types/coin-amount.ts +8 -5
  294. package/src/tx/builder/field-types/ct-version.ts +83 -0
  295. package/src/tx/builder/field-types/deposit.ts +4 -2
  296. package/src/tx/builder/field-types/encoded.ts +27 -0
  297. package/src/tx/builder/field-types/entry.ts +36 -0
  298. package/src/tx/builder/field-types/enumeration.ts +15 -4
  299. package/src/tx/builder/field-types/fee.ts +41 -19
  300. package/src/tx/builder/field-types/gas-limit.ts +13 -8
  301. package/src/tx/builder/field-types/index.ts +60 -17
  302. package/src/tx/builder/field-types/map.ts +45 -0
  303. package/src/tx/builder/field-types/mptree.ts +243 -0
  304. package/src/tx/builder/field-types/name-fee.ts +3 -3
  305. package/src/tx/builder/field-types/name-id.ts +1 -1
  306. package/src/tx/builder/field-types/nonce.ts +40 -0
  307. package/src/tx/builder/field-types/pointers.ts +2 -2
  308. package/src/tx/builder/field-types/raw.ts +9 -0
  309. package/src/tx/builder/field-types/short-u-int-const.ts +30 -0
  310. package/src/tx/builder/field-types/string.ts +11 -0
  311. package/src/tx/builder/field-types/ttl.ts +24 -0
  312. package/src/tx/builder/field-types/u-int.ts +1 -3
  313. package/src/tx/builder/field-types/wrapped.ts +32 -0
  314. package/src/tx/builder/index.ts +82 -280
  315. package/src/tx/builder/schema.generated.ts +2013 -0
  316. package/src/tx/builder/schema.ts +536 -666
  317. package/src/tx/execution-cost.ts +146 -0
  318. package/src/tx/transaction-signer.ts +27 -0
  319. package/src/tx/validator.ts +100 -154
  320. package/src/utils/amount-formatter.ts +0 -16
  321. package/src/utils/autorest.ts +52 -11
  322. package/src/utils/bytes.ts +1 -17
  323. package/src/utils/crypto.ts +0 -16
  324. package/src/utils/errors.ts +18 -56
  325. package/src/utils/string.ts +0 -17
  326. package/types-legacy/ts4.2/AeSdkBase.d.ts +3 -3
  327. package/types-legacy/ts4.2/AeSdkMethods.d.ts +12 -14
  328. package/types-legacy/ts4.2/Node.d.ts +8 -4
  329. package/types-legacy/ts4.2/account/Base.d.ts +13 -8
  330. package/types-legacy/ts4.2/account/Memory.d.ts +2 -1
  331. package/types-legacy/ts4.2/aens.d.ts +12 -14
  332. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  333. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +6 -2
  334. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +1 -1
  335. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +3 -2
  336. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +1 -1
  337. package/types-legacy/ts4.2/apis/node/models/index.d.ts +15 -15
  338. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +1 -1
  339. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
  340. package/types-legacy/ts4.2/chain.d.ts +17 -9
  341. package/types-legacy/ts4.2/channel/Base.d.ts +27 -9
  342. package/types-legacy/ts4.2/channel/Contract.d.ts +8 -7
  343. package/types-legacy/ts4.2/channel/Spend.d.ts +5 -1
  344. package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
  345. package/types-legacy/ts4.2/contract/Contract.d.ts +42 -122
  346. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +74 -0
  347. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
  348. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
  349. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
  350. package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
  351. package/types-legacy/ts4.2/contract/delegation-signature.d.ts +43 -0
  352. package/types-legacy/ts4.2/contract/ga.d.ts +27 -10
  353. package/types-legacy/ts4.2/index-browser.d.ts +40 -0
  354. package/types-legacy/ts4.2/index.d.ts +4 -38
  355. package/types-legacy/ts4.2/oracle.d.ts +12 -17
  356. package/types-legacy/ts4.2/spend.d.ts +19 -27
  357. package/types-legacy/ts4.2/tx/builder/SchemaTypes.d.ts +37 -0
  358. package/types-legacy/ts4.2/tx/builder/constants.d.ts +31 -2
  359. package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +19 -0
  360. package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +11 -12
  361. package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
  362. package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
  363. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +4 -5
  364. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +72 -0
  365. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +3 -2
  366. package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
  367. package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
  368. package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -3
  369. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +12 -7
  370. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +7 -3
  371. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +3 -1
  372. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +113 -30
  373. package/types-legacy/ts4.2/tx/builder/field-types/map.d.ts +13 -0
  374. package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +48 -0
  375. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +2 -3
  376. package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
  377. package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
  378. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +7 -0
  379. package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
  380. package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
  381. package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +1 -2
  382. package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
  383. package/types-legacy/ts4.2/tx/builder/index.d.ts +21 -36
  384. package/types-legacy/ts4.2/tx/builder/schema.d.ts +2971 -2926
  385. package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +2011 -0
  386. package/types-legacy/ts4.2/tx/execution-cost.d.ts +35 -0
  387. package/types-legacy/ts4.2/tx/transaction-signer.d.ts +6 -0
  388. package/types-legacy/ts4.2/tx/validator.d.ts +3 -5
  389. package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
  390. package/types-legacy/ts4.2/utils/errors.d.ts +16 -38
  391. package/types-legacy/ts4.5/AeSdkBase.d.ts +3 -3
  392. package/types-legacy/ts4.5/AeSdkMethods.d.ts +12 -14
  393. package/types-legacy/ts4.5/Node.d.ts +8 -4
  394. package/types-legacy/ts4.5/account/Base.d.ts +13 -8
  395. package/types-legacy/ts4.5/account/Memory.d.ts +2 -1
  396. package/types-legacy/ts4.5/aens.d.ts +12 -14
  397. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  398. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +6 -2
  399. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +1 -1
  400. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +3 -2
  401. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +1 -1
  402. package/types-legacy/ts4.5/apis/node/models/index.d.ts +15 -15
  403. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +1 -1
  404. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
  405. package/types-legacy/ts4.5/chain.d.ts +17 -9
  406. package/types-legacy/ts4.5/channel/Base.d.ts +27 -9
  407. package/types-legacy/ts4.5/channel/Contract.d.ts +8 -7
  408. package/types-legacy/ts4.5/channel/Spend.d.ts +5 -1
  409. package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
  410. package/types-legacy/ts4.5/contract/Contract.d.ts +42 -122
  411. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +74 -0
  412. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
  413. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
  414. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
  415. package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
  416. package/types-legacy/ts4.5/contract/delegation-signature.d.ts +43 -0
  417. package/types-legacy/ts4.5/contract/ga.d.ts +27 -10
  418. package/types-legacy/ts4.5/index-browser.d.ts +40 -0
  419. package/types-legacy/ts4.5/index.d.ts +4 -38
  420. package/types-legacy/ts4.5/oracle.d.ts +12 -17
  421. package/types-legacy/ts4.5/spend.d.ts +19 -27
  422. package/types-legacy/ts4.5/tx/builder/SchemaTypes.d.ts +37 -0
  423. package/types-legacy/ts4.5/tx/builder/constants.d.ts +31 -2
  424. package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +19 -0
  425. package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +11 -12
  426. package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
  427. package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
  428. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +4 -5
  429. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +72 -0
  430. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +3 -2
  431. package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
  432. package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
  433. package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -3
  434. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +12 -7
  435. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +7 -3
  436. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +3 -1
  437. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +113 -30
  438. package/types-legacy/ts4.5/tx/builder/field-types/map.d.ts +13 -0
  439. package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +48 -0
  440. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +2 -3
  441. package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
  442. package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
  443. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +7 -0
  444. package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
  445. package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
  446. package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +1 -2
  447. package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
  448. package/types-legacy/ts4.5/tx/builder/index.d.ts +21 -36
  449. package/types-legacy/ts4.5/tx/builder/schema.d.ts +2971 -2926
  450. package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +2011 -0
  451. package/types-legacy/ts4.5/tx/execution-cost.d.ts +35 -0
  452. package/types-legacy/ts4.5/tx/transaction-signer.d.ts +6 -0
  453. package/types-legacy/ts4.5/tx/validator.d.ts +3 -5
  454. package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
  455. package/types-legacy/ts4.5/utils/errors.d.ts +16 -38
  456. package/es/contract/CompilerHttp.d.ts +0 -18
  457. package/es/contract/CompilerHttp.mjs +0 -63
  458. package/es/contract/CompilerHttp.mjs.map +0 -1
  459. package/es/tx/builder/field-types/addresses.d.ts +0 -6
  460. package/es/tx/builder/field-types/addresses.mjs +0 -13
  461. package/es/tx/builder/field-types/addresses.mjs.map +0 -1
  462. package/es/tx/index.d.ts +0 -34
  463. package/es/tx/index.mjs +0 -172
  464. package/es/tx/index.mjs.map +0 -1
  465. package/es/utils/mptree.d.ts +0 -26
  466. package/es/utils/mptree.mjs +0 -143
  467. package/es/utils/mptree.mjs.map +0 -1
  468. package/src/apis/compiler/code-model-v4.yaml +0 -2442
  469. package/src/apis/node/code-model-v4.yaml +0 -10080
  470. package/src/contract/CompilerHttp.ts +0 -67
  471. package/src/tx/builder/field-types/addresses.ts +0 -18
  472. package/src/tx/index.ts +0 -196
  473. package/src/utils/mptree.ts +0 -145
  474. package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +0 -18
  475. package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +0 -6
  476. package/types-legacy/ts4.2/tx/index.d.ts +0 -34
  477. package/types-legacy/ts4.2/utils/mptree.d.ts +0 -32
  478. package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +0 -18
  479. package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +0 -6
  480. package/types-legacy/ts4.5/tx/index.d.ts +0 -34
  481. package/types-legacy/ts4.5/utils/mptree.d.ts +0 -32
@@ -1,12 +1,11 @@
1
1
  /// <reference types="node" />
2
- import { Int } from './u-int';
2
+ import { Int } from '../constants';
3
3
  import { AE_AMOUNT_FORMATS } from '../../../utils/amount-formatter';
4
- export interface Options {
5
- denomination?: AE_AMOUNT_FORMATS;
6
- }
7
4
  declare const _default: {
8
5
  serializeAettos(value: string | undefined): string;
9
- serialize(value: Int | undefined, { denomination, ...options }: Options): Buffer;
6
+ serialize(value: Int | undefined, params: {}, { denomination }: {
7
+ denomination?: AE_AMOUNT_FORMATS | undefined;
8
+ }): Buffer;
10
9
  deserialize(value: Buffer): string;
11
10
  };
12
11
  export default _default;
@@ -1,18 +1,17 @@
1
1
  import uInt from "./u-int.mjs";
2
- import { formatAmount } from "../../../utils/amount-formatter.mjs";
2
+ import { AE_AMOUNT_FORMATS, formatAmount } from "../../../utils/amount-formatter.mjs";
3
3
  export default {
4
4
  ...uInt,
5
5
  serializeAettos(value) {
6
6
  return value !== null && value !== void 0 ? value : '0';
7
7
  },
8
- serialize(value, _ref) {
8
+ serialize(value, params, _ref) {
9
9
  let {
10
- denomination,
11
- ...options
10
+ denomination = AE_AMOUNT_FORMATS.AETTOS
12
11
  } = _ref;
13
12
  return uInt.serialize(this.serializeAettos(value != null ? formatAmount(value, {
14
13
  denomination
15
- }) : value, options));
14
+ }) : value, params));
16
15
  }
17
16
  };
18
17
  //# sourceMappingURL=coin-amount.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"coin-amount.mjs","names":["uInt","formatAmount","serializeAettos","value","serialize","denomination","options"],"sources":["../../../../src/tx/builder/field-types/coin-amount.ts"],"sourcesContent":["import uInt, { Int } from './u-int';\nimport { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter';\n\nexport interface Options { denomination?: AE_AMOUNT_FORMATS }\n\nexport default {\n ...uInt,\n\n serializeAettos(value: string | undefined): string {\n return value ?? '0';\n },\n\n serialize(value: Int | undefined, { denomination, ...options }: Options): Buffer {\n return uInt.serialize(\n this.serializeAettos(\n value != null ? formatAmount(value, { denomination }) : value,\n options,\n ),\n );\n },\n};\n"],"mappings":"OAAOA,IAAI;AAAA,SACiBC,YAAY;AAIxC,eAAe;EACb,GAAGD,IAAI;EAEPE,eAAe,CAACC,KAAyB,EAAU;IACjD,OAAOA,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,GAAG;EACrB,CAAC;EAEDC,SAAS,CAACD,KAAsB,QAAiD;IAAA,IAA/C;MAAEE,YAAY;MAAE,GAAGC;IAAiB,CAAC;IACrE,OAAON,IAAI,CAACI,SAAS,CACnB,IAAI,CAACF,eAAe,CAClBC,KAAK,IAAI,IAAI,GAAGF,YAAY,CAACE,KAAK,EAAE;MAAEE;IAAa,CAAC,CAAC,GAAGF,KAAK,EAC7DG,OAAO,CACR,CACF;EACH;AACF,CAAC"}
1
+ {"version":3,"file":"coin-amount.mjs","names":["uInt","AE_AMOUNT_FORMATS","formatAmount","serializeAettos","value","serialize","params","_ref","denomination","AETTOS"],"sources":["../../../../src/tx/builder/field-types/coin-amount.ts"],"sourcesContent":["import uInt from './u-int';\nimport { Int } from '../constants';\nimport { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter';\n\nexport default {\n ...uInt,\n\n serializeAettos(value: string | undefined): string {\n return value ?? '0';\n },\n\n serialize(\n value: Int | undefined,\n params: {},\n { denomination = AE_AMOUNT_FORMATS.AETTOS }: { denomination?: AE_AMOUNT_FORMATS },\n ): Buffer {\n return uInt.serialize(\n this.serializeAettos(\n value != null ? formatAmount(value, { denomination }) : value,\n params,\n ),\n );\n },\n};\n"],"mappings":"OAAOA,IAAI;AAAA,SAEFC,iBAAiB,EAAEC,YAAY;AAExC,eAAe;EACb,GAAGF,IAAI;EAEPG,eAAeA,CAACC,KAAyB,EAAU;IACjD,OAAOA,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,GAAG;EACrB,CAAC;EAEDC,SAASA,CACPD,KAAsB,EACtBE,MAAU,EAAAC,IAAA,EAEF;IAAA,IADR;MAAEC,YAAY,GAAGP,iBAAiB,CAACQ;IAA6C,CAAC,GAAAF,IAAA;IAEjF,OAAOP,IAAI,CAACK,SAAS,CACnB,IAAI,CAACF,eAAe,CAClBC,KAAK,IAAI,IAAI,GAAGF,YAAY,CAACE,KAAK,EAAE;MAAEI;IAAa,CAAC,CAAC,GAAGJ,KAAK,EAC7DE,MAAM,CACP,CACF;EACH;AACF,CAAC"}
@@ -0,0 +1,49 @@
1
+ /// <reference types="node" />
2
+ import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants';
3
+ import Node from '../../../Node';
4
+ export declare const ProtocolToVmAbi: {
5
+ readonly 5: {
6
+ readonly 'contract-create': {
7
+ readonly vmVersion: readonly [VmVersion.Fate2];
8
+ readonly abiVersion: readonly [AbiVersion.Fate];
9
+ };
10
+ readonly 'contract-call': {
11
+ readonly vmVersion: readonly [];
12
+ readonly abiVersion: readonly [AbiVersion.Fate, AbiVersion.Sophia];
13
+ };
14
+ readonly 'oracle-call': {
15
+ readonly vmVersion: readonly [];
16
+ readonly abiVersion: readonly [AbiVersion.NoAbi, AbiVersion.Fate];
17
+ };
18
+ };
19
+ readonly 6: {
20
+ readonly 'contract-create': {
21
+ readonly vmVersion: readonly [VmVersion.Fate2];
22
+ readonly abiVersion: readonly [AbiVersion.Fate];
23
+ };
24
+ readonly 'contract-call': {
25
+ readonly vmVersion: readonly [];
26
+ readonly abiVersion: readonly [AbiVersion.Fate];
27
+ };
28
+ readonly 'oracle-call': {
29
+ readonly vmVersion: readonly [];
30
+ readonly abiVersion: readonly [AbiVersion.NoAbi, AbiVersion.Fate];
31
+ };
32
+ };
33
+ };
34
+ export interface CtVersion {
35
+ vmVersion: VmVersion;
36
+ abiVersion: AbiVersion;
37
+ }
38
+ export declare function getProtocolDetails(protocolVersion: ConsensusProtocolVersion, type: 'contract-create' | 'contract-call' | 'oracle-call'): CtVersion;
39
+ declare const _default: {
40
+ serialize(value: CtVersion | undefined, params: {}, { consensusProtocolVersion }: {
41
+ consensusProtocolVersion?: ConsensusProtocolVersion | undefined;
42
+ }): Buffer;
43
+ prepare(value: CtVersion | undefined, params: {}, options: {
44
+ consensusProtocolVersion?: ConsensusProtocolVersion;
45
+ onNode?: Node;
46
+ }): Promise<CtVersion | undefined>;
47
+ deserialize(buffer: Buffer): CtVersion;
48
+ };
49
+ export default _default;
@@ -0,0 +1,76 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import { ConsensusProtocolVersion, VmVersion, AbiVersion } from "../constants.mjs";
6
+ /*
7
+ * First abi/vm by default
8
+ * @see {@link https://github.com/aeternity/protocol/blob/71cf111/contracts/contract_vms.md#virtual-machines-on-the-æternity-blockchain}
9
+ */
10
+ export const ProtocolToVmAbi = {
11
+ [ConsensusProtocolVersion.Iris]: {
12
+ 'contract-create': {
13
+ vmVersion: [VmVersion.Fate2],
14
+ abiVersion: [AbiVersion.Fate]
15
+ },
16
+ 'contract-call': {
17
+ vmVersion: [],
18
+ abiVersion: [AbiVersion.Fate, AbiVersion.Sophia]
19
+ },
20
+ 'oracle-call': {
21
+ vmVersion: [],
22
+ abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate]
23
+ }
24
+ },
25
+ [ConsensusProtocolVersion.Ceres]: {
26
+ 'contract-create': {
27
+ vmVersion: [VmVersion.Fate2],
28
+ abiVersion: [AbiVersion.Fate]
29
+ },
30
+ 'contract-call': {
31
+ vmVersion: [],
32
+ abiVersion: [AbiVersion.Fate]
33
+ },
34
+ 'oracle-call': {
35
+ vmVersion: [],
36
+ abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate]
37
+ }
38
+ }
39
+ };
40
+ export function getProtocolDetails(protocolVersion, type) {
41
+ var _protocol$vmVersion$;
42
+ const protocol = ProtocolToVmAbi[protocolVersion][type];
43
+ return {
44
+ vmVersion: (_protocol$vmVersion$ = protocol.vmVersion[0]) !== null && _protocol$vmVersion$ !== void 0 ? _protocol$vmVersion$ : VmVersion.Fate2,
45
+ abiVersion: protocol.abiVersion[0]
46
+ };
47
+ }
48
+ export default {
49
+ serialize(value, params, _ref) {
50
+ var _value;
51
+ let {
52
+ consensusProtocolVersion = ConsensusProtocolVersion.Iris
53
+ } = _ref;
54
+ (_value = value) !== null && _value !== void 0 ? _value : value = getProtocolDetails(consensusProtocolVersion, 'contract-create');
55
+ return _Buffer.from([value.vmVersion, 0, value.abiVersion]);
56
+ },
57
+ async prepare(value, params,
58
+ // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}
59
+ options) {
60
+ if (value != null) return value;
61
+ if (options.consensusProtocolVersion != null) return undefined;
62
+ if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;
63
+ if (options.onNode != null) {
64
+ return getProtocolDetails((await options.onNode.getNodeInfo()).consensusProtocolVersion, 'contract-create');
65
+ }
66
+ return undefined;
67
+ },
68
+ deserialize(buffer) {
69
+ const [vm,, abi] = buffer;
70
+ return {
71
+ vmVersion: +vm,
72
+ abiVersion: +abi
73
+ };
74
+ }
75
+ };
76
+ //# sourceMappingURL=ct-version.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ct-version.mjs","names":["ConsensusProtocolVersion","VmVersion","AbiVersion","ProtocolToVmAbi","Iris","vmVersion","Fate2","abiVersion","Fate","Sophia","NoAbi","Ceres","getProtocolDetails","protocolVersion","type","_protocol$vmVersion$","protocol","serialize","value","params","_ref","_value","consensusProtocolVersion","_Buffer","from","prepare","options","undefined","Object","keys","length","onNode","getNodeInfo","deserialize","buffer","vm","abi"],"sources":["../../../../src/tx/builder/field-types/ct-version.ts"],"sourcesContent":["import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants';\nimport Node from '../../../Node';\n\n/*\n * First abi/vm by default\n * @see {@link https://github.com/aeternity/protocol/blob/71cf111/contracts/contract_vms.md#virtual-machines-on-the-æternity-blockchain}\n */\nexport const ProtocolToVmAbi = {\n [ConsensusProtocolVersion.Iris]: {\n 'contract-create': {\n vmVersion: [VmVersion.Fate2], abiVersion: [AbiVersion.Fate],\n },\n 'contract-call': {\n vmVersion: [], abiVersion: [AbiVersion.Fate, AbiVersion.Sophia],\n },\n 'oracle-call': {\n vmVersion: [], abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],\n },\n },\n [ConsensusProtocolVersion.Ceres]: {\n 'contract-create': {\n vmVersion: [VmVersion.Fate2], abiVersion: [AbiVersion.Fate],\n },\n 'contract-call': {\n vmVersion: [], abiVersion: [AbiVersion.Fate],\n },\n 'oracle-call': {\n vmVersion: [], abiVersion: [AbiVersion.NoAbi, AbiVersion.Fate],\n },\n },\n} as const;\n\nexport interface CtVersion {\n vmVersion: VmVersion;\n abiVersion: AbiVersion;\n}\n\nexport function getProtocolDetails(\n protocolVersion: ConsensusProtocolVersion,\n type: 'contract-create' | 'contract-call' | 'oracle-call',\n): CtVersion {\n const protocol = ProtocolToVmAbi[protocolVersion][type];\n return {\n vmVersion: protocol.vmVersion[0] ?? VmVersion.Fate2,\n abiVersion: protocol.abiVersion[0],\n };\n}\n\nexport default {\n serialize(\n value: CtVersion | undefined,\n params: {},\n { consensusProtocolVersion = ConsensusProtocolVersion.Iris }:\n { consensusProtocolVersion?: ConsensusProtocolVersion },\n ): Buffer {\n value ??= getProtocolDetails(consensusProtocolVersion, 'contract-create');\n\n return Buffer.from([value.vmVersion, 0, value.abiVersion]);\n },\n\n async prepare(\n value: CtVersion | undefined,\n params: {},\n // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}\n options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },\n ): Promise<CtVersion | undefined> {\n if (value != null) return value;\n if (options.consensusProtocolVersion != null) return undefined;\n if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;\n if (options.onNode != null) {\n return getProtocolDetails(\n (await options.onNode.getNodeInfo()).consensusProtocolVersion,\n 'contract-create',\n );\n }\n return undefined;\n },\n\n deserialize(buffer: Buffer): CtVersion {\n const [vm, , abi] = buffer;\n return { vmVersion: +vm, abiVersion: +abi };\n },\n};\n"],"mappings":";;;;SAASA,wBAAwB,EAAEC,SAAS,EAAEC,UAAU;AAGxD;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG;EAC7B,CAACH,wBAAwB,CAACI,IAAI,GAAG;IAC/B,iBAAiB,EAAE;MACjBC,SAAS,EAAE,CAACJ,SAAS,CAACK,KAAK,CAAC;MAAEC,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC5D,CAAC;IACD,eAAe,EAAE;MACfH,SAAS,EAAE,EAAE;MAAEE,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI,EAAEN,UAAU,CAACO,MAAM;IAChE,CAAC;IACD,aAAa,EAAE;MACbJ,SAAS,EAAE,EAAE;MAAEE,UAAU,EAAE,CAACL,UAAU,CAACQ,KAAK,EAAER,UAAU,CAACM,IAAI;IAC/D;EACF,CAAC;EACD,CAACR,wBAAwB,CAACW,KAAK,GAAG;IAChC,iBAAiB,EAAE;MACjBN,SAAS,EAAE,CAACJ,SAAS,CAACK,KAAK,CAAC;MAAEC,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC5D,CAAC;IACD,eAAe,EAAE;MACfH,SAAS,EAAE,EAAE;MAAEE,UAAU,EAAE,CAACL,UAAU,CAACM,IAAI;IAC7C,CAAC;IACD,aAAa,EAAE;MACbH,SAAS,EAAE,EAAE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vB,CAAC,MAAMc,OAAO,CAACK,MAAM,CAACC,WAAW,EAAE,EAAEV,wBAAwB,EAC7D,iBAAiB,CAClB;IACH;IACA,OAAOK,SAAS;EAClB,CAAC;EAEDM,WAAWA,CAACC,MAAc,EAAa;IACrC,MAAM,CAACC,EAAE,GAAIC,GAAG,CAAC,GAAGF,MAAM;IAC1B,OAAO;MAAE7B,SAAS,EAAE,CAAC8B,EAAE;MAAE5B,UAAU,EAAE,CAAC6B;IAAI,CAAC;EAC7C;AACF,CAAC"}
@@ -1,13 +1,14 @@
1
1
  /// <reference types="node" />
2
2
  import coinAmount from './coin-amount';
3
- import { Int } from './u-int';
3
+ import { Int } from '../constants';
4
4
  declare const _default: {
5
5
  /**
6
6
  * @param value - Deposit value in string format. Should be equal to '0'.
7
7
  * @param options - Options
8
+ * @param parameters - Parameters
8
9
  * @returns Deposit value Buffer.
9
10
  */
10
- serialize(value: Int | undefined, options: Parameters<(typeof coinAmount)['serialize']>[1]): Buffer;
11
+ serialize(value: Int | undefined, options: Parameters<(typeof coinAmount)['serialize']>[1], parameters: Parameters<(typeof coinAmount)['serialize']>[2]): Buffer;
11
12
  serializeAettos(value: string | undefined): string;
12
13
  deserialize(value: Buffer): string;
13
14
  };
@@ -5,13 +5,14 @@ export default {
5
5
  /**
6
6
  * @param value - Deposit value in string format. Should be equal to '0'.
7
7
  * @param options - Options
8
+ * @param parameters - Parameters
8
9
  * @returns Deposit value Buffer.
9
10
  */
10
- serialize(value, options) {
11
+ serialize(value, options, parameters) {
11
12
  var _value;
12
13
  (_value = value) !== null && _value !== void 0 ? _value : value = 0;
13
14
  if (+value !== 0) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value.toString()} instead`);
14
- return coinAmount.serialize(value, options);
15
+ return coinAmount.serialize(value, options, parameters);
15
16
  }
16
17
  };
17
18
  //# sourceMappingURL=deposit.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"deposit.mjs","names":["coinAmount","IllegalArgumentError","serialize","value","options","toString"],"sources":["../../../../src/tx/builder/field-types/deposit.ts"],"sourcesContent":["import coinAmount from './coin-amount';\nimport { Int } from './u-int';\nimport { IllegalArgumentError } from '../../../utils/errors';\n\nexport default {\n ...coinAmount,\n\n /**\n * @param value - Deposit value in string format. Should be equal to '0'.\n * @param options - Options\n * @returns Deposit value Buffer.\n */\n serialize(\n value: Int | undefined,\n options: Parameters<typeof coinAmount['serialize']>[1],\n ): Buffer {\n value ??= 0;\n if (+value !== 0) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value.toString()} instead`);\n return coinAmount.serialize(value, options);\n },\n};\n"],"mappings":"OAAOA,UAAU;AAAA,SAERC,oBAAoB;AAE7B,eAAe;EACb,GAAGD,UAAU;EAEb;AACF;AACA;AACA;AACA;EACEE,SAAS,CACPC,KAAsB,EACtBC,OAAsD,EAC9C;IAAA;IACR,UAAAD,KAAK,2CAALA,KAAK,GAAK,CAAC;IACX,IAAI,CAACA,KAAK,KAAK,CAAC,EAAE,MAAM,IAAIF,oBAAoB,CAAE,oEAAmEE,KAAK,CAACE,QAAQ,EAAG,UAAS,CAAC;IAChJ,OAAOL,UAAU,CAACE,SAAS,CAACC,KAAK,EAAEC,OAAO,CAAC;EAC7C;AACF,CAAC"}
1
+ {"version":3,"file":"deposit.mjs","names":["coinAmount","IllegalArgumentError","serialize","value","options","parameters","_value","toString"],"sources":["../../../../src/tx/builder/field-types/deposit.ts"],"sourcesContent":["import coinAmount from './coin-amount';\nimport { Int } from '../constants';\nimport { IllegalArgumentError } from '../../../utils/errors';\n\nexport default {\n ...coinAmount,\n\n /**\n * @param value - Deposit value in string format. Should be equal to '0'.\n * @param options - Options\n * @param parameters - Parameters\n * @returns Deposit value Buffer.\n */\n serialize(\n value: Int | undefined,\n options: Parameters<typeof coinAmount['serialize']>[1],\n parameters: Parameters<typeof coinAmount['serialize']>[2],\n ): Buffer {\n value ??= 0;\n if (+value !== 0) throw new IllegalArgumentError(`Contract deposit is not refundable, so it should be equal 0, got ${value.toString()} instead`);\n return coinAmount.serialize(value, options, parameters);\n },\n};\n"],"mappings":"OAAOA,UAAU;AAAA,SAERC,oBAAoB;AAE7B,eAAe;EACb,GAAGD,UAAU;EAEb;AACF;AACA;AACA;AACA;AACA;EACEE,SAASA,CACPC,KAAsB,EACtBC,OAAsD,EACtDC,UAAyD,EACjD;IAAA,IAAAC,MAAA;IACR,CAAAA,MAAA,GAAAH,KAAK,cAAAG,MAAA,cAAAA,MAAA,GAALH,KAAK,GAAK,CAAC;IACX,IAAI,CAACA,KAAK,KAAK,CAAC,EAAE,MAAM,IAAIF,oBAAoB,CAAE,oEAAmEE,KAAK,CAACI,QAAQ,EAAG,UAAS,CAAC;IAChJ,OAAOP,UAAU,CAACE,SAAS,CAACC,KAAK,EAAEC,OAAO,EAAEC,UAAU,CAAC;EACzD;AACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="node" />
2
+ import { Encoded, Encoding } from '../../../utils/encoder';
3
+ export default function genEncodedField<E extends Encoding, Optional extends boolean = false>(encoding: E, optional?: Optional): {
4
+ serialize: Optional extends true ? (value?: Encoded.Generic<E>) => Buffer : (value: Encoded.Generic<E>) => Buffer;
5
+ deserialize: (value: Buffer) => Encoded.Generic<E>;
6
+ };
@@ -0,0 +1,21 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import { decode, encode } from "../../../utils/encoder.mjs";
6
+ import { ArgumentError } from "../../../utils/errors.mjs";
7
+ export default function genEncodedField(encoding, optional) {
8
+ return {
9
+ serialize(encodedData) {
10
+ if (encodedData == null) {
11
+ if (optional === true) return _Buffer.from([]);
12
+ throw new ArgumentError('Encoded data', 'provided', encodedData);
13
+ }
14
+ return decode(encodedData);
15
+ },
16
+ deserialize(buffer) {
17
+ return encode(buffer, encoding);
18
+ }
19
+ };
20
+ }
21
+ //# sourceMappingURL=encoded.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoded.mjs","names":["decode","encode","ArgumentError","genEncodedField","encoding","optional","serialize","encodedData","_Buffer","from","deserialize","buffer"],"sources":["../../../../src/tx/builder/field-types/encoded.ts"],"sourcesContent":["import {\n decode, encode, Encoded, Encoding,\n} from '../../../utils/encoder';\nimport { ArgumentError } from '../../../utils/errors';\n\nexport default function genEncodedField<E extends Encoding, Optional extends boolean = false>(\n encoding: E,\n optional?: Optional,\n): {\n serialize: Optional extends true\n ? (value?: Encoded.Generic<E>) => Buffer : (value: Encoded.Generic<E>) => Buffer;\n deserialize: (value: Buffer) => Encoded.Generic<E>;\n } {\n return {\n serialize(encodedData?: Encoded.Generic<E>) {\n if (encodedData == null) {\n if (optional === true) return Buffer.from([]);\n throw new ArgumentError('Encoded data', 'provided', encodedData);\n }\n return decode(encodedData);\n },\n\n deserialize(buffer) {\n return encode(buffer, encoding);\n },\n };\n}\n"],"mappings":";;;;SACEA,MAAM,EAAEC,MAAM;AAAA,SAEPC,aAAa;AAEtB,eAAe,SAASC,eAAeA,CACrCC,QAAW,EACXC,QAAmB,EAKjB;EACF,OAAO;IACLC,SAASA,CAACC,WAAgC,EAAE;MAC1C,IAAIA,WAAW,IAAI,IAAI,EAAE;QACvB,IAAIF,QAAQ,KAAK,IAAI,EAAE,OAAOG,OAAA,CAAOC,IAAI,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAIP,aAAa,CAAC,cAAc,EAAE,UAAU,EAAEK,WAAW,CAAC;MAClE;MACA,OAAOP,MAAM,CAACO,WAAW,CAAC;IAC5B,CAAC;IAEDG,WAAWA,CAACC,MAAM,EAAE;MAClB,OAAOV,MAAM,CAACU,MAAM,EAAEP,QAAQ,CAAC;IACjC;EACF,CAAC;AACH"}
@@ -0,0 +1,11 @@
1
+ /// <reference types="node" />
2
+ import { Tag } from '../constants';
3
+ import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
4
+ export default function genEntryField<T extends Tag = Tag>(tag?: T): {
5
+ serialize: (value: any, options: {
6
+ buildTx: typeof buildTxType;
7
+ }) => Buffer;
8
+ deserialize: (value: Buffer, options: {
9
+ unpackTx: typeof unpackTxType;
10
+ }) => any;
11
+ };
@@ -0,0 +1,34 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import { decode, encode, Encoding } from "../../../utils/encoder.mjs";
6
+ import { ArgumentError } from "../../../utils/errors.mjs";
7
+ export default function genEntryField(tag) {
8
+ return {
9
+ serialize(txParams, _ref) {
10
+ let {
11
+ buildTx
12
+ } = _ref;
13
+ if (ArrayBuffer.isView(txParams)) return _Buffer.from(txParams);
14
+ if (typeof txParams === 'string' && txParams.startsWith('tx_')) {
15
+ return decode(txParams);
16
+ }
17
+ return decode(buildTx({
18
+ ...txParams,
19
+ ...(tag != null && {
20
+ tag
21
+ })
22
+ }));
23
+ },
24
+ deserialize(buf, _ref2) {
25
+ let {
26
+ unpackTx
27
+ } = _ref2;
28
+ const tx = unpackTx(encode(buf, Encoding.Transaction));
29
+ if (tag != null && tx.tag !== tag) throw new ArgumentError('Tag', tag, tx.tag);
30
+ return tx;
31
+ }
32
+ };
33
+ }
34
+ //# sourceMappingURL=entry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.mjs","names":["decode","encode","Encoding","ArgumentError","genEntryField","tag","serialize","txParams","_ref","buildTx","ArrayBuffer","isView","_Buffer","from","startsWith","deserialize","buf","_ref2","unpackTx","tx","Transaction"],"sources":["../../../../src/tx/builder/field-types/entry.ts"],"sourcesContent":["import {\n decode, encode, Encoded, Encoding,\n} from '../../../utils/encoder';\nimport { Tag } from '../constants';\nimport { ArgumentError } from '../../../utils/errors';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';\n\nexport default function genEntryField<T extends Tag = Tag>(tag?: T): {\n serialize: (\n // TODO: replace with `TxParams & { tag: T }`,\n // but fix TS2502 value is referenced directly or indirectly in its own type annotation\n value: any,\n options: { buildTx: typeof buildTxType },\n ) => Buffer;\n deserialize: (\n value: Buffer, options: { unpackTx: typeof unpackTxType },\n // TODO: replace with `TxUnpacked & { tag: T }`,\n // TS2577 Return type annotation circularly references itself\n ) => any;\n} {\n return {\n serialize(txParams, { buildTx }) {\n if (ArrayBuffer.isView(txParams)) return Buffer.from(txParams as any);\n if (typeof txParams === 'string' && txParams.startsWith('tx_')) {\n return decode(txParams as Encoded.Transaction);\n }\n return decode(buildTx({ ...txParams, ...tag != null && { tag } }));\n },\n\n deserialize(buf, { unpackTx }) {\n const tx = unpackTx(encode(buf, Encoding.Transaction));\n if (tag != null && tx.tag !== tag) throw new ArgumentError('Tag', tag, tx.tag);\n return tx;\n },\n };\n}\n"],"mappings":";;;;SACEA,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAG1BC,aAAa;AAGtB,eAAe,SAASC,aAAaA,CAAsBC,GAAO,EAYhE;EACA,OAAO;IACLC,SAASA,CAACC,QAAQ,EAAAC,IAAA,EAAe;MAAA,IAAb;QAAEC;MAAQ,CAAC,GAAAD,IAAA;MAC7B,IAAIE,WAAW,CAACC,MAAM,CAACJ,QAAQ,CAAC,EAAE,OAAOK,OAAA,CAAOC,IAAI,CAACN,QAAQ,CAAQ;MACrE,IAAI,OAAOA,QAAQ,KAAK,QAAQ,IAAIA,QAAQ,CAACO,UAAU,CAAC,KAAK,CAAC,EAAE;QAC9D,OAAOd,MAAM,CAACO,QAAQ,CAAwB;MAChD;MACA,OAAOP,MAAM,CAACS,OAAO,CAAC;QAAE,GAAGF,QAAQ;QAAE,IAAGF,GAAG,IAAI,IAAI,IAAI;UAAEA;QAAI,CAAC;MAAC,CAAC,CAAC,CAAC;IACpE,CAAC;IAEDU,WAAWA,CAACC,GAAG,EAAAC,KAAA,EAAgB;MAAA,IAAd;QAAEC;MAAS,CAAC,GAAAD,KAAA;MAC3B,MAAME,EAAE,GAAGD,QAAQ,CAACjB,MAAM,CAACe,GAAG,EAAEd,QAAQ,CAACkB,WAAW,CAAC,CAAC;MACtD,IAAIf,GAAG,IAAI,IAAI,IAAIc,EAAE,CAACd,GAAG,KAAKA,GAAG,EAAE,MAAM,IAAIF,aAAa,CAAC,KAAK,EAAEE,GAAG,EAAEc,EAAE,CAACd,GAAG,CAAC;MAC9E,OAAOc,EAAE;IACX;EACF,CAAC;AACH"}
@@ -1,5 +1,7 @@
1
1
  /// <reference types="node" />
2
- export default function genEnumerationField<Enum extends number>(): {
3
- serialize: (value: Enum) => Buffer;
4
- deserialize: (value: Buffer) => Enum;
2
+ export default function genEnumerationField<Enum extends {
3
+ [key: string]: number | string;
4
+ }>(enm: Enum): {
5
+ serialize: (value: Enum[keyof Enum]) => Buffer;
6
+ deserialize: (value: Buffer) => Enum[keyof Enum];
5
7
  };
@@ -3,18 +3,27 @@ const {
3
3
  Buffer: _Buffer
4
4
  } = _buffer;
5
5
  import { ArgumentError } from "../../../utils/errors.mjs";
6
- export default function genEnumerationField() {
6
+ import { isItemOfArray } from "../../../utils/other.mjs";
7
+ export default function genEnumerationField(enm) {
8
+ const values = Object.values(enm).filter(v => typeof v === 'number');
7
9
  return {
8
10
  serialize(value) {
9
11
  if (typeof value !== 'number') throw new ArgumentError('value', 'to be a number', value);
10
12
  if (value > 0xff) throw new ArgumentError('value', 'to be less than 256', value);
13
+ if (!isItemOfArray(value, values)) {
14
+ throw new ArgumentError('value', 'to be a value of Enum', value);
15
+ }
11
16
  return _Buffer.from([value]);
12
17
  },
13
18
  deserialize(buffer) {
14
19
  if (buffer.length !== 1) {
15
20
  throw new ArgumentError('buffer', 'to have single element', buffer.length);
16
21
  }
17
- return buffer[0];
22
+ const value = buffer[0];
23
+ if (!isItemOfArray(value, values)) {
24
+ throw new ArgumentError('value', 'to be a value of Enum', value);
25
+ }
26
+ return value;
18
27
  }
19
28
  };
20
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"enumeration.mjs","names":["ArgumentError","genEnumerationField","serialize","value","from","deserialize","buffer","length"],"sources":["../../../../src/tx/builder/field-types/enumeration.ts"],"sourcesContent":["import { ArgumentError } from '../../../utils/errors';\n\nexport default function genEnumerationField<Enum extends number>(): {\n serialize: (value: Enum) => Buffer;\n deserialize: (value: Buffer) => Enum;\n} {\n return {\n serialize(value) {\n if (typeof value !== 'number') throw new ArgumentError('value', 'to be a number', value);\n if (value > 0xff) throw new ArgumentError('value', 'to be less than 256', value);\n return Buffer.from([value]);\n },\n\n deserialize(buffer) {\n if (buffer.length !== 1) {\n throw new ArgumentError('buffer', 'to have single element', buffer.length);\n }\n return buffer[0] as Enum;\n },\n };\n}\n"],"mappings":";;;;SAASA,aAAa;AAEtB,eAAe,SAASC,mBAAmB,GAGzC;EACA,OAAO;IACLC,SAAS,CAACC,KAAK,EAAE;MACf,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE,MAAM,IAAIH,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAEG,KAAK,CAAC;MACxF,IAAIA,KAAK,GAAG,IAAI,EAAE,MAAM,IAAIH,aAAa,CAAC,OAAO,EAAE,qBAAqB,EAAEG,KAAK,CAAC;MAChF,OAAO,QAAOC,IAAI,CAAC,CAACD,KAAK,CAAC,CAAC;IAC7B,CAAC;IAEDE,WAAW,CAACC,MAAM,EAAE;MAClB,IAAIA,MAAM,CAACC,MAAM,KAAK,CAAC,EAAE;QACvB,MAAM,IAAIP,aAAa,CAAC,QAAQ,EAAE,wBAAwB,EAAEM,MAAM,CAACC,MAAM,CAAC;MAC5E;MACA,OAAOD,MAAM,CAAC,CAAC,CAAC;IAClB;EACF,CAAC;AACH"}
1
+ {"version":3,"file":"enumeration.mjs","names":["ArgumentError","isItemOfArray","genEnumerationField","enm","values","Object","filter","v","serialize","value","_Buffer","from","deserialize","buffer","length"],"sources":["../../../../src/tx/builder/field-types/enumeration.ts"],"sourcesContent":["import { ArgumentError } from '../../../utils/errors';\nimport { isItemOfArray } from '../../../utils/other';\n\nexport default function genEnumerationField<\n Enum extends { [key: string]: number | string },\n>(enm: Enum): {\n serialize: (value: Enum[keyof Enum]) => Buffer;\n deserialize: (value: Buffer) => Enum[keyof Enum];\n} {\n const values = Object.values(enm).filter((v) => typeof v === 'number');\n return {\n serialize(value) {\n if (typeof value !== 'number') throw new ArgumentError('value', 'to be a number', value);\n if (value > 0xff) throw new ArgumentError('value', 'to be less than 256', value);\n if (!isItemOfArray(value, values)) {\n throw new ArgumentError('value', 'to be a value of Enum', value);\n }\n return Buffer.from([value]);\n },\n\n deserialize(buffer) {\n if (buffer.length !== 1) {\n throw new ArgumentError('buffer', 'to have single element', buffer.length);\n }\n const value = buffer[0];\n if (!isItemOfArray(value, values)) {\n throw new ArgumentError('value', 'to be a value of Enum', value);\n }\n return value as Enum[keyof Enum];\n },\n };\n}\n"],"mappings":";;;;SAASA,aAAa;AAAA,SACbC,aAAa;AAEtB,eAAe,SAASC,mBAAmBA,CAEzCC,GAAS,EAGT;EACA,MAAMC,MAAM,GAAGC,MAAM,CAACD,MAAM,CAACD,GAAG,CAAC,CAACG,MAAM,CAAEC,CAAC,IAAK,OAAOA,CAAC,KAAK,QAAQ,CAAC;EACtE,OAAO;IACLC,SAASA,CAACC,KAAK,EAAE;MACf,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE,MAAM,IAAIT,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAES,KAAK,CAAC;MACxF,IAAIA,KAAK,GAAG,IAAI,EAAE,MAAM,IAAIT,aAAa,CAAC,OAAO,EAAE,qBAAqB,EAAES,KAAK,CAAC;MAChF,IAAI,CAACR,aAAa,CAACQ,KAAK,EAAEL,MAAM,CAAC,EAAE;QACjC,MAAM,IAAIJ,aAAa,CAAC,OAAO,EAAE,uBAAuB,EAAES,KAAK,CAAC;MAClE;MACA,OAAOC,OAAA,CAAOC,IAAI,CAAC,CAACF,KAAK,CAAC,CAAC;IAC7B,CAAC;IAEDG,WAAWA,CAACC,MAAM,EAAE;MAClB,IAAIA,MAAM,CAACC,MAAM,KAAK,CAAC,EAAE;QACvB,MAAM,IAAId,aAAa,CAAC,QAAQ,EAAE,wBAAwB,EAAEa,MAAM,CAACC,MAAM,CAAC;MAC5E;MACA,MAAML,KAAK,GAAGI,MAAM,CAAC,CAAC,CAAC;MACvB,IAAI,CAACZ,aAAa,CAACQ,KAAK,EAAEL,MAAM,CAAC,EAAE;QACjC,MAAM,IAAIJ,aAAa,CAAC,OAAO,EAAE,uBAAuB,EAAES,KAAK,CAAC;MAClE;MACA,OAAOA,KAAK;IACd;EACF,CAAC;AACH"}
@@ -1,17 +1,22 @@
1
1
  /// <reference types="node" />
2
2
  import BigNumber from 'bignumber.js';
3
- import { Tag } from '../constants';
3
+ import { Encoded } from '../../../utils/encoder';
4
+ import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
4
5
  /**
5
6
  * Calculate fee based on tx type and params
6
7
  */
7
- export declare function buildFee(txType: Tag, buildTx: any): BigNumber;
8
+ export declare function buildFee(builtTx: Encoded.Transaction, unpackTx: typeof unpackTxType, buildTx: typeof buildTxType): BigNumber;
8
9
  declare const _default: {
9
- serializeAettos(_value: string | undefined, { txType, rebuildTx, _computingMinFee }: {
10
- txType: Tag;
11
- rebuildTx: (params: any) => any;
12
- _computingMinFee?: string | undefined;
10
+ serializeAettos(_value: string | undefined, { rebuildTx, unpackTx, buildTx, _computingMinFee, _pickBiggerFee, }: {
11
+ rebuildTx: (params: any) => Encoded.Transaction;
12
+ unpackTx: typeof unpackTxType;
13
+ buildTx: typeof buildTxType;
14
+ _computingMinFee?: BigNumber | undefined;
15
+ _pickBiggerFee?: boolean | undefined;
13
16
  }): string;
14
- serialize(value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
17
+ serialize(value: import("../constants").Int | undefined, params: {}, { denomination }: {
18
+ denomination?: import("../../..").AE_AMOUNT_FORMATS | undefined;
19
+ }): Buffer;
15
20
  deserialize(value: Buffer): string;
16
21
  };
17
22
  export default _default;
@@ -3,6 +3,7 @@ import { IllegalArgumentError } from "../../../utils/errors.mjs";
3
3
  import { MIN_GAS_PRICE, Tag } from "../constants.mjs";
4
4
  import coinAmount from "./coin-amount.mjs";
5
5
  import { isKeyOfObject } from "../../../utils/other.mjs";
6
+ import { decode } from "../../../utils/encoder.mjs";
6
7
  const BASE_GAS = 15000;
7
8
  const GAS_PER_BYTE = 20;
8
9
  const KEY_BLOCK_INTERVAL = 3;
@@ -70,45 +71,49 @@ const TX_FEE_OTHER_GAS = (txType, txSize, _ref) => {
70
71
  return new BigNumber(txSize).times(GAS_PER_BYTE);
71
72
  }
72
73
  };
73
- function getOracleRelativeTtl(params, txType) {
74
+ function getOracleRelativeTtl(params) {
74
75
  const ttlKeys = {
75
76
  [Tag.OracleRegisterTx]: 'oracleTtlValue',
76
77
  [Tag.OracleExtendTx]: 'oracleTtlValue',
77
78
  [Tag.OracleQueryTx]: 'queryTtlValue',
78
79
  [Tag.OracleResponseTx]: 'responseTtlValue'
79
80
  };
80
- if (!isKeyOfObject(txType, ttlKeys)) return 1;
81
- return params[ttlKeys[txType]];
81
+ const {
82
+ tag
83
+ } = params;
84
+ if (!isKeyOfObject(tag, ttlKeys)) return 1;
85
+ return params[ttlKeys[tag]];
82
86
  }
83
87
 
84
88
  /**
85
89
  * Calculate fee based on tx type and params
86
90
  */
87
- export function buildFee(txType, buildTx) {
91
+ export function buildFee(builtTx, unpackTx, buildTx) {
88
92
  const {
89
- rlpEncoded: {
90
- length
91
- },
92
- txObject
93
- } = buildTx;
94
- return TX_FEE_BASE_GAS(txType).plus(TX_FEE_OTHER_GAS(txType, length, {
95
- relativeTtl: getOracleRelativeTtl(txObject, txType),
96
- innerTxSize: [Tag.GaMetaTx, Tag.PayingForTx].includes(txType) ? txObject.tx.tx.encodedTx.rlpEncoded.length : 0
93
+ length
94
+ } = decode(builtTx);
95
+ const txObject = unpackTx(builtTx);
96
+ let innerTxSize = 0;
97
+ if (txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx) {
98
+ innerTxSize = decode(buildTx(txObject.tx.encodedTx)).length;
99
+ }
100
+ return TX_FEE_BASE_GAS(txObject.tag).plus(TX_FEE_OTHER_GAS(txObject.tag, length, {
101
+ relativeTtl: getOracleRelativeTtl(txObject),
102
+ innerTxSize
97
103
  })).times(MIN_GAS_PRICE);
98
104
  }
99
105
 
100
106
  /**
101
107
  * Calculate min fee
102
108
  * @category transaction builder
103
- * @param txType - Transaction type
104
109
  * @param rebuildTx - Callback to get built transaction with specific fee
105
110
  */
106
- function calculateMinFee(txType, rebuildTx) {
111
+ function calculateMinFee(rebuildTx, unpackTx, buildTx) {
107
112
  let fee = new BigNumber(0);
108
113
  let previousFee;
109
114
  do {
110
115
  previousFee = fee;
111
- fee = buildFee(txType, rebuildTx(fee));
116
+ fee = buildFee(rebuildTx(fee), unpackTx, buildTx);
112
117
  } while (!fee.eq(previousFee));
113
118
  return fee;
114
119
  }
@@ -116,16 +121,19 @@ export default {
116
121
  ...coinAmount,
117
122
  serializeAettos(_value, _ref2) {
118
123
  let {
119
- txType,
120
124
  rebuildTx,
121
- _computingMinFee
125
+ unpackTx,
126
+ buildTx,
127
+ _computingMinFee,
128
+ _pickBiggerFee
122
129
  } = _ref2;
123
- if (_computingMinFee != null) return _computingMinFee;
124
- const minFee = calculateMinFee(txType, fee => rebuildTx({
130
+ if (_computingMinFee != null) return _computingMinFee.toFixed();
131
+ const minFee = calculateMinFee(fee => rebuildTx({
125
132
  _computingMinFee: fee
126
- }));
133
+ }), unpackTx, buildTx);
127
134
  const value = new BigNumber(_value !== null && _value !== void 0 ? _value : minFee);
128
135
  if (minFee.gt(value)) {
136
+ if (_pickBiggerFee === true) return minFee.toFixed();
129
137
  throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger then ${minFee}`);
130
138
  }
131
139
  return value.toFixed();
@@ -1 +1 @@
1
- {"version":3,"file":"fee.mjs","names":["BigNumber","IllegalArgumentError","MIN_GAS_PRICE","Tag","coinAmount","isKeyOfObject","BASE_GAS","GAS_PER_BYTE","KEY_BLOCK_INTERVAL","TX_FEE_BASE_GAS","txType","feeFactors","ChannelForceProgressTx","ChannelOffChainTx","ChannelOffChainUpdateCallContract","ChannelOffChainUpdateCreateContract","ChannelOffChainUpdateDeposit","ChannelOffChainUpdateWithdraw","ChannelOffChainUpdateTransfer","ContractCreateTx","ContractCallTx","GaAttachTx","GaMetaTx","PayingForTx","factor","TX_FEE_OTHER_GAS","txSize","relativeTtl","innerTxSize","OracleRegisterTx","OracleExtendTx","OracleQueryTx","OracleResponseTx","times","plus","Math","ceil","floor","minus","getOracleRelativeTtl","params","ttlKeys","buildFee","buildTx","rlpEncoded","length","txObject","includes","tx","encodedTx","calculateMinFee","rebuildTx","fee","previousFee","eq","serializeAettos","_value","_computingMinFee","minFee","value","gt","toString","toFixed"],"sources":["../../../../src/tx/builder/field-types/fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE, Tag } from '../constants';\nimport coinAmount from './coin-amount';\nimport { isKeyOfObject } from '../../../utils/other';\n\nconst BASE_GAS = 15000;\nconst GAS_PER_BYTE = 20;\nconst KEY_BLOCK_INTERVAL = 3;\n\n/**\n * Calculate the Base fee gas\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txType - The transaction type\n * @returns The base fee\n * @example\n * ```js\n * TX_FEE_BASE('channelForceProgress') => new BigNumber(30 * 15000)\n * ```\n */\nconst TX_FEE_BASE_GAS = (txType: Tag): BigNumber => {\n const feeFactors = {\n [Tag.ChannelForceProgressTx]: 30,\n [Tag.ChannelOffChainTx]: 0,\n [Tag.ChannelOffChainUpdateCallContract]: 0,\n [Tag.ChannelOffChainUpdateCreateContract]: 0,\n [Tag.ChannelOffChainUpdateDeposit]: 0,\n [Tag.ChannelOffChainUpdateWithdraw]: 0,\n [Tag.ChannelOffChainUpdateTransfer]: 0,\n [Tag.ContractCreateTx]: 5,\n [Tag.ContractCallTx]: 12,\n [Tag.GaAttachTx]: 5,\n [Tag.GaMetaTx]: 5,\n [Tag.PayingForTx]: 1 / 5,\n } as const;\n const factor = feeFactors[txType as keyof typeof feeFactors] ?? 1;\n return new BigNumber(factor * BASE_GAS);\n};\n\n/**\n * Calculate fee for Other types of transactions\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txType - The transaction type\n * @param txSize - The transaction size\n * @returns parameters - The transaction parameters\n * @returns parameters.relativeTtl - The relative ttl\n * @returns parameters.innerTxSize - The size of the inner transaction\n * @returns The Other fee\n * @example\n * ```js\n * TX_FEE_OTHER_GAS('oracleResponse',10, { relativeTtl: 10, innerTxSize: 10 })\n * => new BigNumber(10).times(20).plus(Math.ceil(32000 * 10 / Math.floor(60 * 24 * 365 / 2)))\n * ```\n */\nconst TX_FEE_OTHER_GAS = (\n txType: Tag,\n txSize: number,\n { relativeTtl, innerTxSize }: { relativeTtl: number; innerTxSize: number },\n): BigNumber => {\n switch (txType) {\n case Tag.OracleRegisterTx:\n case Tag.OracleExtendTx:\n case Tag.OracleQueryTx:\n case Tag.OracleResponseTx:\n return new BigNumber(txSize)\n .times(GAS_PER_BYTE)\n .plus(\n Math.ceil((32000 * relativeTtl) / Math.floor((60 * 24 * 365) / KEY_BLOCK_INTERVAL)),\n );\n case Tag.GaMetaTx:\n case Tag.PayingForTx:\n return new BigNumber(txSize).minus(innerTxSize).times(GAS_PER_BYTE);\n default:\n return new BigNumber(txSize).times(GAS_PER_BYTE);\n }\n};\n\nfunction getOracleRelativeTtl(params: any, txType: Tag): number {\n const ttlKeys = {\n [Tag.OracleRegisterTx]: 'oracleTtlValue',\n [Tag.OracleExtendTx]: 'oracleTtlValue',\n [Tag.OracleQueryTx]: 'queryTtlValue',\n [Tag.OracleResponseTx]: 'responseTtlValue',\n } as const;\n\n if (!isKeyOfObject(txType, ttlKeys)) return 1;\n return params[ttlKeys[txType]];\n}\n\n/**\n * Calculate fee based on tx type and params\n */\nexport function buildFee(txType: Tag, buildTx: any): BigNumber {\n const { rlpEncoded: { length }, txObject } = buildTx;\n\n return TX_FEE_BASE_GAS(txType)\n .plus(TX_FEE_OTHER_GAS(txType, length, {\n relativeTtl: getOracleRelativeTtl(txObject, txType),\n innerTxSize: [Tag.GaMetaTx, Tag.PayingForTx].includes(txType)\n ? txObject.tx.tx.encodedTx.rlpEncoded.length\n : 0,\n }))\n .times(MIN_GAS_PRICE);\n}\n\n/**\n * Calculate min fee\n * @category transaction builder\n * @param txType - Transaction type\n * @param rebuildTx - Callback to get built transaction with specific fee\n */\nfunction calculateMinFee(\n txType: Tag,\n rebuildTx: (value: BigNumber) => any,\n): BigNumber {\n let fee = new BigNumber(0);\n let previousFee;\n do {\n previousFee = fee;\n fee = buildFee(txType, rebuildTx(fee));\n } while (!fee.eq(previousFee));\n return fee;\n}\n\nexport default {\n ...coinAmount,\n\n serializeAettos(\n _value: string | undefined,\n { txType, rebuildTx, _computingMinFee }:\n { txType: Tag; rebuildTx: (params: any) => any; _computingMinFee?: string },\n ): string {\n if (_computingMinFee != null) return _computingMinFee;\n const minFee = calculateMinFee(txType, (fee) => rebuildTx({ _computingMinFee: fee }));\n const value = new BigNumber(_value ?? minFee);\n if (minFee.gt(value)) {\n throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger then ${minFee}`);\n }\n return value.toFixed();\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,oBAAoB;AAAA,SACpBC,aAAa,EAAEC,GAAG;AAAA,OACpBC,UAAU;AAAA,SACRC,aAAa;AAEtB,MAAMC,QAAQ,GAAG,KAAK;AACtB,MAAMC,YAAY,GAAG,EAAE;AACvB,MAAMC,kBAAkB,GAAG,CAAC;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAIC,MAAW,IAAgB;EAAA;EAClD,MAAMC,UAAU,GAAG;IACjB,CAACR,GAAG,CAACS,sBAAsB,GAAG,EAAE;IAChC,CAACT,GAAG,CAACU,iBAAiB,GAAG,CAAC;IAC1B,CAACV,GA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;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASgD,eAAe,CACtBxC,MAAW,EACXyC,SAAoC,EACzB;EACX,IAAIC,GAAG,GAAG,IAAIpD,SAAS,CAAC,CAAC,CAAC;EAC1B,IAAIqD,WAAW;EACf,GAAG;IACDA,WAAW,GAAGD,GAAG;IACjBA,GAAG,GAAGV,QAAQ,CAAChC,MAAM,EAAEyC,SAAS,CAACC,GAAG,CAAC,CAAC;EACxC,CAAC,QAAQ,CAACA,GAAG,CAACE,EAAE,CAACD,WAAW,CAAC;EAC7B,OAAOD,GAAG;AACZ;AAEA,eAAe;EACb,GAAGhD,UAAU;EAEbmD,eAAe,CACbC,MAA0B,SAGlB;IAAA,IAFR;MAAE9C,MAAM;MAAEyC,SAAS;MAAEM;IACqD,CAAC;IAE3E,IAAIA,gBAAgB,IAAI,IAAI,EAAE,OAAOA,gBAAgB;IACrD,MAAMC,MAAM,GAAGR,eAAe,CAACxC,MAAM,EAAG0C,GAAG,IAAKD,SAAS,CAAC;MAAEM,gBAAgB,EAAEL;IAAI,CAAC,CAAC,CAAC;IACrF,MAAMO,KAAK,GAAG,IAAI3D,SAAS,CAACwD,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIE,MAAM,CAAC;IAC7C,IAAIA,MAAM,CAACE,EAAE,CAACD,KAAK,CAAC,EAAE;MACpB,MAAM,IAAI1D,oBAAoB,CAAE,OAAM0D,KAAK,CAACE,QAAQ,EAAG,wBAAuBH,MAAO,EAAC,CAAC;IACzF;IACA,OAAOC,KAAK,CAACG,OAAO,EAAE;EACxB;AACF,CAAC"}
1
+ {"version":3,"file":"fee.mjs","names":["BigNumber","IllegalArgumentError","MIN_GAS_PRICE","Tag","coinAmount","isKeyOfObject","decode","BASE_GAS","GAS_PER_BYTE","KEY_BLOCK_INTERVAL","TX_FEE_BASE_GAS","txType","_feeFactors","feeFactors","ChannelForceProgressTx","ChannelOffChainTx","ChannelOffChainUpdateCallContract","ChannelOffChainUpdateCreateContract","ChannelOffChainUpdateDeposit","ChannelOffChainUpdateWithdraw","ChannelOffChainUpdateTransfer","ContractCreateTx","ContractCallTx","GaAttachTx","GaMetaTx","PayingForTx","factor","TX_FEE_OTHER_GAS","txSize","_ref","relativeTtl","innerTxSize","OracleRegisterTx","OracleExtendTx","OracleQueryTx","OracleResponseTx","times","plus","Math","ceil","floor","minus","getOracleRelativeTtl","params","ttlKeys","tag","buildFee","builtTx","unpackTx","buildTx","length","txObject","tx","encodedTx","calculateMinFee","rebuildTx","fee","previousFee","eq","serializeAettos","_value","_ref2","_computingMinFee","_pickBiggerFee","toFixed","minFee","value","gt","toString"],"sources":["../../../../src/tx/builder/field-types/fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE, Tag } from '../constants';\nimport coinAmount from './coin-amount';\nimport { isKeyOfObject } from '../../../utils/other';\nimport { decode, Encoded } from '../../../utils/encoder';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';\n\nconst BASE_GAS = 15000;\nconst GAS_PER_BYTE = 20;\nconst KEY_BLOCK_INTERVAL = 3;\n\n/**\n * Calculate the Base fee gas\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txType - The transaction type\n * @returns The base fee\n * @example\n * ```js\n * TX_FEE_BASE('channelForceProgress') => new BigNumber(30 * 15000)\n * ```\n */\nconst TX_FEE_BASE_GAS = (txType: Tag): BigNumber => {\n const feeFactors = {\n [Tag.ChannelForceProgressTx]: 30,\n [Tag.ChannelOffChainTx]: 0,\n [Tag.ChannelOffChainUpdateCallContract]: 0,\n [Tag.ChannelOffChainUpdateCreateContract]: 0,\n [Tag.ChannelOffChainUpdateDeposit]: 0,\n [Tag.ChannelOffChainUpdateWithdraw]: 0,\n [Tag.ChannelOffChainUpdateTransfer]: 0,\n [Tag.ContractCreateTx]: 5,\n [Tag.ContractCallTx]: 12,\n [Tag.GaAttachTx]: 5,\n [Tag.GaMetaTx]: 5,\n [Tag.PayingForTx]: 1 / 5,\n } as const;\n const factor = feeFactors[txType as keyof typeof feeFactors] ?? 1;\n return new BigNumber(factor * BASE_GAS);\n};\n\n/**\n * Calculate fee for Other types of transactions\n * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}\n * @param txType - The transaction type\n * @param txSize - The transaction size\n * @returns parameters - The transaction parameters\n * @returns parameters.relativeTtl - The relative ttl\n * @returns parameters.innerTxSize - The size of the inner transaction\n * @returns The Other fee\n * @example\n * ```js\n * TX_FEE_OTHER_GAS('oracleResponse',10, { relativeTtl: 10, innerTxSize: 10 })\n * => new BigNumber(10).times(20).plus(Math.ceil(32000 * 10 / Math.floor(60 * 24 * 365 / 2)))\n * ```\n */\nconst TX_FEE_OTHER_GAS = (\n txType: Tag,\n txSize: number,\n { relativeTtl, innerTxSize }: { relativeTtl: number; innerTxSize: number },\n): BigNumber => {\n switch (txType) {\n case Tag.OracleRegisterTx:\n case Tag.OracleExtendTx:\n case Tag.OracleQueryTx:\n case Tag.OracleResponseTx:\n return new BigNumber(txSize)\n .times(GAS_PER_BYTE)\n .plus(\n Math.ceil((32000 * relativeTtl) / Math.floor((60 * 24 * 365) / KEY_BLOCK_INTERVAL)),\n );\n case Tag.GaMetaTx:\n case Tag.PayingForTx:\n return new BigNumber(txSize).minus(innerTxSize).times(GAS_PER_BYTE);\n default:\n return new BigNumber(txSize).times(GAS_PER_BYTE);\n }\n};\n\nfunction getOracleRelativeTtl(params: any): number {\n const ttlKeys = {\n [Tag.OracleRegisterTx]: 'oracleTtlValue',\n [Tag.OracleExtendTx]: 'oracleTtlValue',\n [Tag.OracleQueryTx]: 'queryTtlValue',\n [Tag.OracleResponseTx]: 'responseTtlValue',\n } as const;\n\n const { tag } = params;\n if (!isKeyOfObject(tag, ttlKeys)) return 1;\n return params[ttlKeys[tag]];\n}\n\n/**\n * Calculate fee based on tx type and params\n */\nexport function buildFee(\n builtTx: Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n): BigNumber {\n const { length } = decode(builtTx);\n const txObject = unpackTx(builtTx);\n\n let innerTxSize = 0;\n if (txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx) {\n innerTxSize = decode(buildTx(txObject.tx.encodedTx)).length;\n }\n\n return TX_FEE_BASE_GAS(txObject.tag)\n .plus(TX_FEE_OTHER_GAS(txObject.tag, length, {\n relativeTtl: getOracleRelativeTtl(txObject), innerTxSize,\n }))\n .times(MIN_GAS_PRICE);\n}\n\n/**\n * Calculate min fee\n * @category transaction builder\n * @param rebuildTx - Callback to get built transaction with specific fee\n */\nfunction calculateMinFee(\n rebuildTx: (value: BigNumber) => Encoded.Transaction,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n): BigNumber {\n let fee = new BigNumber(0);\n let previousFee;\n do {\n previousFee = fee;\n fee = buildFee(rebuildTx(fee), unpackTx, buildTx);\n } while (!fee.eq(previousFee));\n return fee;\n}\n\nexport default {\n ...coinAmount,\n\n serializeAettos(\n _value: string | undefined,\n {\n rebuildTx, unpackTx, buildTx, _computingMinFee, _pickBiggerFee,\n }: {\n rebuildTx: (params: any) => Encoded.Transaction;\n unpackTx: typeof unpackTxType;\n buildTx: typeof buildTxType;\n _computingMinFee?: BigNumber;\n _pickBiggerFee?: boolean;\n },\n ): string {\n if (_computingMinFee != null) return _computingMinFee.toFixed();\n const minFee = calculateMinFee(\n (fee) => rebuildTx({ _computingMinFee: fee }),\n unpackTx,\n buildTx,\n );\n const value = new BigNumber(_value ?? minFee);\n if (minFee.gt(value)) {\n if (_pickBiggerFee === true) return minFee.toFixed();\n throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger then ${minFee}`);\n }\n return value.toFixed();\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,oBAAoB;AAAA,SACpBC,aAAa,EAAEC,GAAG;AAAA,OACpBC,UAAU;AAAA,SACRC,aAAa;AAAA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/D,MAAMC,MAAM,GAAGX,eAAe,CAC3BE,GAAG,IAAKD,SAAS,CAAC;MAAEO,gBAAgB,EAAEN;IAAI,CAAC,CAAC,EAC7CR,QAAQ,EACRC,OAAO,CACR;IACD,MAAMiB,KAAK,GAAG,IAAIlE,SAAS,CAAC4D,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIK,MAAM,CAAC;IAC7C,IAAIA,MAAM,CAACE,EAAE,CAACD,KAAK,CAAC,EAAE;MACpB,IAAIH,cAAc,KAAK,IAAI,EAAE,OAAOE,MAAM,CAACD,OAAO,EAAE;MACpD,MAAM,IAAI/D,oBAAoB,CAAE,OAAMiE,KAAK,CAACE,QAAQ,EAAG,wBAAuBH,MAAO,EAAC,CAAC;IACzF;IACA,OAAOC,KAAK,CAACF,OAAO,EAAE;EACxB;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"field.mjs","names":["serialize","value","from","deserialize","toString"],"sources":["../../../../src/tx/builder/field-types/field.ts"],"sourcesContent":["export default {\n serialize(value: string): Buffer {\n return Buffer.from(value);\n },\n\n deserialize(value: Buffer): string {\n return value.toString();\n },\n};\n"],"mappings":";;;;AAAA,eAAe;EACbA,SAAS,CAACC,KAAa,EAAU;IAC/B,OAAO,QAAOC,IAAI,CAACD,KAAK,CAAC;EAC3B,CAAC;EAEDE,WAAW,CAACF,KAAa,EAAU;IACjC,OAAOA,KAAK,CAACG,QAAQ,EAAE;EACzB;AACF,CAAC"}
1
+ {"version":3,"file":"field.mjs","names":["serialize","value","_Buffer","from","deserialize","toString"],"sources":["../../../../src/tx/builder/field-types/field.ts"],"sourcesContent":["export default {\n serialize(value: string): Buffer {\n return Buffer.from(value);\n },\n\n deserialize(value: Buffer): string {\n return value.toString();\n },\n};\n"],"mappings":";;;;AAAA,eAAe;EACbA,SAASA,CAACC,KAAa,EAAU;IAC/B,OAAOC,OAAA,CAAOC,IAAI,CAACF,KAAK,CAAC;EAC3B,CAAC;EAEDG,WAAWA,CAACH,KAAa,EAAU;IACjC,OAAOA,KAAK,CAACI,QAAQ,EAAE;EACzB;AACF,CAAC"}
@@ -1,11 +1,15 @@
1
1
  /// <reference types="node" />
2
2
  import { Tag } from '../constants';
3
+ import type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';
3
4
  declare const _default: {
4
- serialize(_value: number | undefined, { txType, rebuildTx, gasMax, _computingGasLimit, }: {
5
- txType: Tag;
5
+ serialize(_value: number | undefined, { tag, rebuildTx, unpackTx, buildTx, _computingGasLimit, }: {
6
+ tag: Tag;
6
7
  rebuildTx: (params: any) => any;
7
- gasMax: number;
8
+ unpackTx: typeof unpackTxType;
9
+ buildTx: typeof buildTxType;
8
10
  _computingGasLimit?: number | undefined;
11
+ }, { gasMax }: {
12
+ gasMax?: number | undefined;
9
13
  }): Buffer;
10
14
  deserialize(value: Buffer): number;
11
15
  };