@aeternity/aepp-sdk 12.1.3 → 13.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (565) 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 +12031 -11231
  7. package/dist/aepp-sdk.js.map +1 -1
  8. package/es/AeSdk.d.ts +7 -3
  9. package/es/AeSdk.mjs +17 -22
  10. package/es/AeSdk.mjs.map +1 -1
  11. package/es/AeSdkAepp.d.ts +6 -5
  12. package/es/AeSdkAepp.mjs +7 -30
  13. package/es/AeSdkAepp.mjs.map +1 -1
  14. package/es/AeSdkBase.d.ts +18 -140
  15. package/es/AeSdkBase.mjs +30 -184
  16. package/es/AeSdkBase.mjs.map +1 -1
  17. package/es/AeSdkMethods.d.ts +123 -0
  18. package/es/AeSdkMethods.mjs +122 -0
  19. package/es/AeSdkMethods.mjs.map +1 -0
  20. package/es/AeSdkWallet.d.ts +7 -21
  21. package/es/AeSdkWallet.mjs +38 -86
  22. package/es/AeSdkWallet.mjs.map +1 -1
  23. package/es/Node.d.ts +11 -15
  24. package/es/Node.mjs +35 -48
  25. package/es/Node.mjs.map +1 -1
  26. package/es/account/Base.d.ts +24 -40
  27. package/es/account/Base.mjs +1 -101
  28. package/es/account/Base.mjs.map +1 -1
  29. package/es/account/Generalized.d.ts +16 -0
  30. package/es/account/Generalized.mjs +113 -0
  31. package/es/account/Generalized.mjs.map +1 -0
  32. package/es/account/Ledger.d.ts +28 -0
  33. package/es/account/Ledger.mjs +102 -0
  34. package/es/account/Ledger.mjs.map +1 -0
  35. package/es/account/LedgerFactory.d.ts +39 -0
  36. package/es/account/LedgerFactory.mjs +81 -0
  37. package/es/account/LedgerFactory.mjs.map +1 -0
  38. package/es/account/Memory.d.ts +13 -17
  39. package/es/account/Memory.mjs +43 -64
  40. package/es/account/Memory.mjs.map +1 -1
  41. package/es/account/Rpc.d.ts +6 -8
  42. package/es/account/Rpc.mjs +14 -32
  43. package/es/account/Rpc.mjs.map +1 -1
  44. package/es/aens.d.ts +4 -4
  45. package/es/aens.mjs +46 -41
  46. package/es/aens.mjs.map +1 -1
  47. package/es/aepp-wallet-communication/connection/Browser.mjs +9 -13
  48. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  49. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  50. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +22 -11
  51. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  52. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -1
  53. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -31
  54. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  55. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  56. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +3 -3
  57. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -42
  58. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  59. package/es/aepp-wallet-communication/rpc/types.d.ts +7 -1
  60. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  61. package/es/aepp-wallet-communication/schema.mjs +14 -68
  62. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  63. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
  64. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  65. package/es/apis/compiler/compiler.d.ts +23 -29
  66. package/es/apis/compiler/compiler.mjs +128 -189
  67. package/es/apis/compiler/compiler.mjs.map +1 -1
  68. package/es/apis/compiler/index.mjs.map +1 -1
  69. package/es/apis/compiler/models/index.d.ts +82 -135
  70. package/es/apis/compiler/models/index.mjs +1 -47
  71. package/es/apis/compiler/models/index.mjs.map +1 -1
  72. package/es/apis/compiler/models/mappers.d.ts +8 -8
  73. package/es/apis/compiler/models/mappers.mjs +165 -183
  74. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  75. package/es/apis/compiler/models/parameters.d.ts +0 -1
  76. package/es/apis/compiler/models/parameters.mjs +5 -9
  77. package/es/apis/compiler/models/parameters.mjs.map +1 -1
  78. package/es/apis/node/index.mjs.map +1 -1
  79. package/es/apis/node/models/index.d.ts +48 -48
  80. package/es/apis/node/models/mappers.mjs +12 -6
  81. package/es/apis/node/models/mappers.mjs.map +1 -1
  82. package/es/apis/node/models/parameters.mjs.map +1 -1
  83. package/es/apis/node/node.mjs +43 -84
  84. package/es/apis/node/node.mjs.map +1 -1
  85. package/es/chain.d.ts +10 -2
  86. package/es/chain.mjs +37 -59
  87. package/es/chain.mjs.map +1 -1
  88. package/es/channel/Base.d.ts +200 -0
  89. package/es/channel/Base.mjs +293 -0
  90. package/es/channel/Base.mjs.map +1 -0
  91. package/es/channel/Contract.d.ts +248 -0
  92. package/es/channel/Contract.mjs +420 -0
  93. package/es/channel/Contract.mjs.map +1 -0
  94. package/es/channel/Spend.d.ts +219 -0
  95. package/es/channel/Spend.mjs +385 -0
  96. package/es/channel/Spend.mjs.map +1 -0
  97. package/es/channel/handlers.d.ts +8 -21
  98. package/es/channel/handlers.mjs +151 -899
  99. package/es/channel/handlers.mjs.map +1 -1
  100. package/es/channel/internal.d.ts +27 -21
  101. package/es/channel/internal.mjs +101 -191
  102. package/es/channel/internal.mjs.map +1 -1
  103. package/es/contract/Contract.d.ts +210 -0
  104. package/es/contract/Contract.mjs +551 -0
  105. package/es/contract/Contract.mjs.map +1 -0
  106. package/es/contract/compiler/Base.d.ts +81 -0
  107. package/es/contract/compiler/Base.mjs +5 -0
  108. package/es/contract/compiler/Base.mjs.map +1 -0
  109. package/es/contract/compiler/Cli.d.ts +23 -0
  110. package/es/contract/compiler/Cli.mjs +155 -0
  111. package/es/contract/compiler/Cli.mjs.map +1 -0
  112. package/es/contract/compiler/Http.d.ts +32 -0
  113. package/es/contract/compiler/Http.mjs +118 -0
  114. package/es/contract/compiler/Http.mjs.map +1 -0
  115. package/es/contract/compiler/HttpNode.d.ts +17 -0
  116. package/es/contract/compiler/HttpNode.mjs +26 -0
  117. package/es/contract/compiler/HttpNode.mjs.map +1 -0
  118. package/es/contract/compiler/getFileSystem.d.ts +6 -0
  119. package/es/contract/compiler/getFileSystem.mjs +40 -0
  120. package/es/contract/compiler/getFileSystem.mjs.map +1 -0
  121. package/es/contract/ga.d.ts +9 -34
  122. package/es/contract/ga.mjs +29 -112
  123. package/es/contract/ga.mjs.map +1 -1
  124. package/es/index-browser.d.ts +39 -0
  125. package/es/index-browser.mjs +55 -0
  126. package/es/index-browser.mjs.map +1 -0
  127. package/es/index.d.ts +4 -35
  128. package/es/index.mjs +4 -51
  129. package/es/index.mjs.map +1 -1
  130. package/es/oracle.d.ts +5 -5
  131. package/es/oracle.mjs +34 -40
  132. package/es/oracle.mjs.map +1 -1
  133. package/es/spend.d.ts +3 -3
  134. package/es/spend.mjs +18 -23
  135. package/es/spend.mjs.map +1 -1
  136. package/es/tx/builder/constants.d.ts +30 -2
  137. package/es/tx/builder/constants.mjs +43 -14
  138. package/es/tx/builder/constants.mjs.map +1 -1
  139. package/es/tx/builder/field-types/abi-version.d.ts +10 -0
  140. package/es/tx/builder/field-types/abi-version.mjs +20 -0
  141. package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
  142. package/es/tx/builder/field-types/address.d.ts +14 -0
  143. package/es/tx/builder/field-types/address.mjs +51 -0
  144. package/es/tx/builder/field-types/address.mjs.map +1 -0
  145. package/es/tx/builder/field-types/array.d.ts +7 -0
  146. package/es/tx/builder/field-types/array.mjs +11 -0
  147. package/es/tx/builder/field-types/array.mjs.map +1 -0
  148. package/es/tx/builder/field-types/boolean.d.ts +6 -0
  149. package/es/tx/builder/field-types/boolean.mjs +13 -0
  150. package/es/tx/builder/field-types/boolean.mjs.map +1 -0
  151. package/es/tx/builder/field-types/coin-amount.d.ts +2 -3
  152. package/es/tx/builder/field-types/coin-amount.mjs +4 -12
  153. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  154. package/es/tx/builder/field-types/ct-version.d.ts +30 -0
  155. package/es/tx/builder/field-types/ct-version.mjs +48 -0
  156. package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
  157. package/es/tx/builder/field-types/deposit.d.ts +1 -2
  158. package/es/tx/builder/field-types/deposit.mjs +2 -4
  159. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  160. package/es/tx/builder/field-types/encoded.d.ts +6 -0
  161. package/es/tx/builder/field-types/encoded.mjs +21 -0
  162. package/es/tx/builder/field-types/encoded.mjs.map +1 -0
  163. package/es/tx/builder/field-types/entry.d.ts +11 -0
  164. package/es/tx/builder/field-types/entry.mjs +31 -0
  165. package/es/tx/builder/field-types/entry.mjs.map +1 -0
  166. package/es/tx/builder/field-types/enumeration.d.ts +7 -0
  167. package/es/tx/builder/field-types/enumeration.mjs +30 -0
  168. package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
  169. package/es/tx/builder/field-types/fee.d.ts +10 -15
  170. package/es/tx/builder/field-types/fee.mjs +31 -43
  171. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  172. package/es/tx/builder/field-types/field.mjs +0 -2
  173. package/es/tx/builder/field-types/field.mjs.map +1 -1
  174. package/es/tx/builder/field-types/gas-limit.d.ts +5 -2
  175. package/es/tx/builder/field-types/gas-limit.mjs +12 -14
  176. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  177. package/es/tx/builder/field-types/gas-price.d.ts +1 -2
  178. package/es/tx/builder/field-types/gas-price.mjs +3 -7
  179. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  180. package/es/tx/builder/field-types/index.d.ts +80 -30
  181. package/es/tx/builder/field-types/index.mjs +34 -9
  182. package/es/tx/builder/field-types/index.mjs.map +1 -1
  183. package/es/tx/builder/field-types/mptree.d.ts +37 -0
  184. package/es/tx/builder/field-types/mptree.mjs +268 -0
  185. package/es/tx/builder/field-types/mptree.mjs.map +1 -0
  186. package/es/tx/builder/field-types/name-fee.d.ts +1 -3
  187. package/es/tx/builder/field-types/name-fee.mjs +3 -5
  188. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  189. package/es/tx/builder/field-types/name-id.d.ts +1 -4
  190. package/es/tx/builder/field-types/name-id.mjs +5 -10
  191. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  192. package/es/tx/builder/field-types/name.mjs +0 -2
  193. package/es/tx/builder/field-types/name.mjs.map +1 -1
  194. package/es/tx/builder/field-types/pointers.d.ts +23 -0
  195. package/es/tx/builder/field-types/pointers.mjs +36 -0
  196. package/es/tx/builder/field-types/pointers.mjs.map +1 -0
  197. package/es/tx/builder/field-types/raw.d.ts +6 -0
  198. package/es/tx/builder/field-types/raw.mjs +13 -0
  199. package/es/tx/builder/field-types/raw.mjs.map +1 -0
  200. package/es/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  201. package/es/tx/builder/field-types/short-u-int-const.mjs +16 -0
  202. package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
  203. package/es/tx/builder/field-types/short-u-int.mjs +0 -2
  204. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  205. package/es/tx/builder/field-types/string.d.ts +6 -0
  206. package/es/tx/builder/field-types/string.mjs +10 -0
  207. package/es/tx/builder/field-types/string.mjs.map +1 -0
  208. package/es/tx/builder/field-types/u-int.d.ts +1 -2
  209. package/es/tx/builder/field-types/u-int.mjs +3 -4
  210. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  211. package/es/tx/builder/helpers.d.ts +2 -32
  212. package/es/tx/builder/helpers.mjs +19 -71
  213. package/es/tx/builder/helpers.mjs.map +1 -1
  214. package/es/tx/builder/index.d.ts +11 -49
  215. package/es/tx/builder/index.mjs +57 -337
  216. package/es/tx/builder/index.mjs.map +1 -1
  217. package/es/tx/builder/schema.d.ts +2367 -667
  218. package/es/tx/builder/schema.mjs +70 -145
  219. package/es/tx/builder/schema.mjs.map +1 -1
  220. package/es/tx/index.d.ts +4 -49
  221. package/es/tx/index.mjs +38 -112
  222. package/es/tx/index.mjs.map +1 -1
  223. package/es/tx/validator.d.ts +4 -6
  224. package/es/tx/validator.mjs +104 -90
  225. package/es/tx/validator.mjs.map +1 -1
  226. package/es/typings/{@aeternity__argon2-browser → @aeternity__aepp-calldata}/index.d.mjs +0 -0
  227. package/es/typings/@aeternity__aepp-calldata/index.d.mjs.map +1 -0
  228. package/es/utils/amount-formatter.mjs +4 -10
  229. package/es/utils/amount-formatter.mjs.map +1 -1
  230. package/es/utils/autorest.d.ts +1 -0
  231. package/es/utils/autorest.mjs +17 -19
  232. package/es/utils/autorest.mjs.map +1 -1
  233. package/es/utils/bignumber.mjs +4 -7
  234. package/es/utils/bignumber.mjs.map +1 -1
  235. package/es/utils/bytes.d.ts +0 -17
  236. package/es/utils/bytes.mjs +6 -35
  237. package/es/utils/bytes.mjs.map +1 -1
  238. package/es/utils/crypto.d.ts +15 -8
  239. package/es/utils/crypto.mjs +40 -40
  240. package/es/utils/crypto.mjs.map +1 -1
  241. package/es/utils/encoder-types.d.ts +28 -28
  242. package/es/utils/encoder-types.mjs +0 -1
  243. package/es/utils/encoder-types.mjs.map +1 -1
  244. package/es/utils/encoder.d.ts +0 -1
  245. package/es/utils/encoder.mjs +7 -15
  246. package/es/utils/encoder.mjs.map +1 -1
  247. package/es/utils/errors.d.ts +15 -14
  248. package/es/utils/errors.mjs +86 -172
  249. package/es/utils/errors.mjs.map +1 -1
  250. package/es/utils/hd-wallet.d.ts +27 -19
  251. package/es/utils/hd-wallet.mjs +42 -26
  252. package/es/utils/hd-wallet.mjs.map +1 -1
  253. package/es/utils/json-big.mjs +0 -8
  254. package/es/utils/json-big.mjs.map +1 -1
  255. package/es/utils/keystore.d.ts +2 -0
  256. package/es/utils/keystore.mjs +37 -36
  257. package/es/utils/keystore.mjs.map +1 -1
  258. package/es/utils/other.d.ts +4 -2
  259. package/es/utils/other.mjs +11 -7
  260. package/es/utils/other.mjs.map +1 -1
  261. package/es/utils/semver-satisfies.mjs +0 -3
  262. package/es/utils/semver-satisfies.mjs.map +1 -1
  263. package/es/utils/string.d.ts +0 -12
  264. package/es/utils/string.mjs +1 -21
  265. package/es/utils/string.mjs.map +1 -1
  266. package/package.json +98 -51
  267. package/src/AeSdk.ts +15 -11
  268. package/src/AeSdkAepp.ts +9 -7
  269. package/src/AeSdkBase.ts +31 -202
  270. package/src/AeSdkMethods.ts +169 -0
  271. package/src/AeSdkWallet.ts +16 -47
  272. package/src/Node.ts +17 -18
  273. package/src/account/Base.ts +29 -75
  274. package/src/account/Generalized.ts +98 -0
  275. package/src/account/Ledger.ts +131 -0
  276. package/src/account/LedgerFactory.ts +86 -0
  277. package/src/account/Memory.ts +46 -60
  278. package/src/account/Rpc.ts +17 -26
  279. package/src/aens.ts +13 -11
  280. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +21 -9
  281. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
  282. package/src/aepp-wallet-communication/rpc/RpcClient.ts +4 -4
  283. package/src/aepp-wallet-communication/rpc/types.ts +11 -1
  284. package/src/aepp-wallet-communication/schema.ts +18 -18
  285. package/src/apis/compiler/code-model-v4.yaml +681 -888
  286. package/src/apis/compiler/compiler.ts +113 -154
  287. package/src/apis/compiler/models/index.ts +80 -140
  288. package/src/apis/compiler/models/mappers.ts +165 -183
  289. package/src/apis/compiler/models/parameters.ts +6 -12
  290. package/src/chain.ts +11 -6
  291. package/src/channel/Base.ts +335 -0
  292. package/src/channel/Contract.ts +488 -0
  293. package/src/channel/Spend.ts +408 -0
  294. package/src/channel/handlers.ts +164 -582
  295. package/src/channel/internal.ts +114 -143
  296. package/src/contract/Contract.ts +610 -0
  297. package/src/contract/compiler/Base.ts +94 -0
  298. package/src/contract/compiler/Cli.ts +134 -0
  299. package/src/contract/compiler/Http.ts +124 -0
  300. package/src/contract/compiler/HttpNode.ts +26 -0
  301. package/src/contract/compiler/getFileSystem.ts +42 -0
  302. package/src/contract/ga.ts +23 -106
  303. package/src/index-browser.ts +58 -0
  304. package/src/index.ts +4 -55
  305. package/src/oracle.ts +8 -8
  306. package/src/spend.ts +6 -14
  307. package/src/tx/builder/constants.ts +33 -3
  308. package/src/tx/builder/field-types/abi-version.ts +21 -0
  309. package/src/tx/builder/field-types/address.ts +62 -0
  310. package/src/tx/builder/field-types/array.ts +19 -0
  311. package/src/tx/builder/field-types/boolean.ts +9 -0
  312. package/src/tx/builder/field-types/coin-amount.ts +4 -9
  313. package/src/tx/builder/field-types/ct-version.ts +50 -0
  314. package/src/tx/builder/field-types/deposit.ts +1 -1
  315. package/src/tx/builder/field-types/encoded.ts +27 -0
  316. package/src/tx/builder/field-types/entry.ts +31 -0
  317. package/src/tx/builder/field-types/enumeration.ts +32 -0
  318. package/src/tx/builder/field-types/fee.ts +39 -21
  319. package/src/tx/builder/field-types/gas-limit.ts +13 -8
  320. package/src/tx/builder/field-types/gas-price.ts +0 -2
  321. package/src/tx/builder/field-types/index.ts +54 -15
  322. package/src/tx/builder/field-types/mptree.ts +242 -0
  323. package/src/tx/builder/field-types/name-fee.ts +2 -3
  324. package/src/tx/builder/field-types/name-id.ts +7 -10
  325. package/src/tx/builder/field-types/pointers.ts +41 -0
  326. package/src/tx/builder/field-types/raw.ts +9 -0
  327. package/src/tx/builder/field-types/short-u-int-const.ts +20 -0
  328. package/src/tx/builder/field-types/string.ts +11 -0
  329. package/src/tx/builder/field-types/u-int.ts +4 -5
  330. package/src/tx/builder/helpers.ts +10 -60
  331. package/src/tx/builder/index.ts +65 -308
  332. package/src/tx/builder/schema.ts +280 -341
  333. package/src/tx/index.ts +40 -103
  334. package/src/tx/validator.ts +91 -96
  335. package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
  336. package/src/utils/autorest.ts +16 -1
  337. package/src/utils/bytes.ts +6 -34
  338. package/src/utils/crypto.ts +23 -16
  339. package/src/utils/encoder.ts +0 -1
  340. package/src/utils/errors.ts +22 -25
  341. package/src/utils/hd-wallet.ts +30 -9
  342. package/src/utils/keystore.ts +24 -21
  343. package/src/utils/other.ts +16 -1
  344. package/src/utils/string.ts +0 -20
  345. package/types-legacy/ts4.2/AeSdk.d.ts +41 -0
  346. package/types-legacy/ts4.2/AeSdkAepp.d.ts +71 -0
  347. package/types-legacy/ts4.2/AeSdkBase.d.ts +91 -0
  348. package/types-legacy/ts4.2/AeSdkMethods.d.ts +140 -0
  349. package/types-legacy/ts4.2/AeSdkWallet.d.ts +90 -0
  350. package/types-legacy/ts4.2/Node.d.ts +78 -0
  351. package/types-legacy/ts4.2/account/Base.d.ts +52 -0
  352. package/types-legacy/ts4.2/account/Generalized.d.ts +16 -0
  353. package/types-legacy/ts4.2/account/Ledger.d.ts +28 -0
  354. package/types-legacy/ts4.2/account/LedgerFactory.d.ts +39 -0
  355. package/types-legacy/ts4.2/account/Memory.d.ts +22 -0
  356. package/types-legacy/ts4.2/account/Rpc.d.ts +25 -0
  357. package/types-legacy/ts4.2/aens.d.ts +222 -0
  358. package/types-legacy/ts4.2/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  359. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +19 -0
  360. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  361. package/types-legacy/ts4.2/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  362. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  363. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +83 -0
  364. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +133 -0
  365. package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  366. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +86 -0
  367. package/types-legacy/ts4.2/apis/compiler/index.d.ts +2 -0
  368. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +195 -0
  369. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +23 -0
  370. package/types-legacy/ts4.2/apis/compiler/models/parameters.d.ts +12 -0
  371. package/types-legacy/ts4.2/apis/node/index.d.ts +2 -0
  372. package/types-legacy/ts4.2/apis/node/models/index.d.ts +1065 -0
  373. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +95 -0
  374. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +17 -0
  375. package/types-legacy/ts4.2/apis/node/node.d.ts +215 -0
  376. package/types-legacy/ts4.2/chain.d.ts +256 -0
  377. package/types-legacy/ts4.2/channel/Base.d.ts +199 -0
  378. package/types-legacy/ts4.2/channel/Contract.d.ts +248 -0
  379. package/types-legacy/ts4.2/channel/Spend.d.ts +219 -0
  380. package/types-legacy/ts4.2/channel/handlers.d.ts +21 -0
  381. package/types-legacy/ts4.2/channel/internal.d.ts +107 -0
  382. package/types-legacy/ts4.2/contract/Contract.d.ts +212 -0
  383. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +81 -0
  384. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
  385. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
  386. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
  387. package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
  388. package/types-legacy/ts4.2/contract/ga.d.ts +44 -0
  389. package/types-legacy/ts4.2/globals.d.ts +16 -0
  390. package/types-legacy/ts4.2/index-browser.d.ts +39 -0
  391. package/types-legacy/ts4.2/index.d.ts +5 -0
  392. package/types-legacy/ts4.2/oracle.d.ts +161 -0
  393. package/types-legacy/ts4.2/spend.d.ts +62 -0
  394. package/types-legacy/ts4.2/tx/builder/constants.d.ts +98 -0
  395. package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +10 -0
  396. package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +21 -0
  397. package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
  398. package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
  399. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +12 -0
  400. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +42 -0
  401. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +14 -0
  402. package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
  403. package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
  404. package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +7 -0
  405. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +20 -0
  406. package/types-legacy/ts4.2/tx/builder/field-types/field.d.ts +6 -0
  407. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +15 -0
  408. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +7 -0
  409. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +129 -0
  410. package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +43 -0
  411. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +18 -0
  412. package/types-legacy/ts4.2/tx/builder/field-types/name-id.d.ts +11 -0
  413. package/types-legacy/ts4.2/tx/builder/field-types/name.d.ts +13 -0
  414. package/types-legacy/ts4.2/tx/builder/field-types/pointers.d.ts +26 -0
  415. package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
  416. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  417. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int.d.ts +6 -0
  418. package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
  419. package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +7 -0
  420. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
  421. package/types-legacy/ts4.2/tx/builder/index.d.ts +50 -0
  422. package/types-legacy/ts4.2/tx/builder/schema.d.ts +4675 -0
  423. package/types-legacy/ts4.2/tx/index.d.ts +19 -0
  424. package/types-legacy/ts4.2/tx/validator.d.ts +18 -0
  425. package/types-legacy/ts4.2/utils/amount-formatter.d.ts +42 -0
  426. package/types-legacy/ts4.2/utils/autorest.d.ts +7 -0
  427. package/types-legacy/ts4.2/utils/bignumber.d.ts +13 -0
  428. package/types-legacy/ts4.2/utils/bytes.d.ts +9 -0
  429. package/types-legacy/ts4.2/utils/crypto.d.ts +95 -0
  430. package/types-legacy/ts4.2/utils/encoder-types.d.ts +61 -0
  431. package/types-legacy/ts4.2/utils/encoder.d.ts +24 -0
  432. package/types-legacy/ts4.2/utils/errors.d.ts +475 -0
  433. package/types-legacy/ts4.2/utils/hd-wallet.d.ts +65 -0
  434. package/types-legacy/ts4.2/utils/json-big.d.ts +5 -0
  435. package/types-legacy/ts4.2/utils/keystore.d.ts +53 -0
  436. package/types-legacy/ts4.2/utils/other.d.ts +31 -0
  437. package/types-legacy/ts4.2/utils/semver-satisfies.d.ts +1 -0
  438. package/types-legacy/ts4.2/utils/string.d.ts +12 -0
  439. package/types-legacy/ts4.5/AeSdk.d.ts +41 -0
  440. package/types-legacy/ts4.5/AeSdkAepp.d.ts +71 -0
  441. package/types-legacy/ts4.5/AeSdkBase.d.ts +91 -0
  442. package/types-legacy/ts4.5/AeSdkMethods.d.ts +140 -0
  443. package/types-legacy/ts4.5/AeSdkWallet.d.ts +90 -0
  444. package/types-legacy/ts4.5/Node.d.ts +78 -0
  445. package/types-legacy/ts4.5/account/Base.d.ts +52 -0
  446. package/types-legacy/ts4.5/account/Generalized.d.ts +16 -0
  447. package/types-legacy/ts4.5/account/Ledger.d.ts +28 -0
  448. package/types-legacy/ts4.5/account/LedgerFactory.d.ts +39 -0
  449. package/types-legacy/ts4.5/account/Memory.d.ts +22 -0
  450. package/types-legacy/ts4.5/account/Rpc.d.ts +25 -0
  451. package/types-legacy/ts4.5/aens.d.ts +222 -0
  452. package/types-legacy/ts4.5/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  453. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +19 -0
  454. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  455. package/types-legacy/ts4.5/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  456. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  457. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +83 -0
  458. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +133 -0
  459. package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  460. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +86 -0
  461. package/types-legacy/ts4.5/apis/compiler/index.d.ts +2 -0
  462. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +195 -0
  463. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +23 -0
  464. package/types-legacy/ts4.5/apis/compiler/models/parameters.d.ts +12 -0
  465. package/types-legacy/ts4.5/apis/node/index.d.ts +2 -0
  466. package/types-legacy/ts4.5/apis/node/models/index.d.ts +1065 -0
  467. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +95 -0
  468. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +17 -0
  469. package/types-legacy/ts4.5/apis/node/node.d.ts +215 -0
  470. package/types-legacy/ts4.5/chain.d.ts +256 -0
  471. package/types-legacy/ts4.5/channel/Base.d.ts +199 -0
  472. package/types-legacy/ts4.5/channel/Contract.d.ts +248 -0
  473. package/types-legacy/ts4.5/channel/Spend.d.ts +219 -0
  474. package/types-legacy/ts4.5/channel/handlers.d.ts +21 -0
  475. package/types-legacy/ts4.5/channel/internal.d.ts +107 -0
  476. package/types-legacy/ts4.5/contract/Contract.d.ts +212 -0
  477. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +81 -0
  478. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
  479. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
  480. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
  481. package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
  482. package/types-legacy/ts4.5/contract/ga.d.ts +44 -0
  483. package/types-legacy/ts4.5/index-browser.d.ts +39 -0
  484. package/types-legacy/ts4.5/index.d.ts +4 -0
  485. package/types-legacy/ts4.5/oracle.d.ts +161 -0
  486. package/types-legacy/ts4.5/spend.d.ts +62 -0
  487. package/types-legacy/ts4.5/tx/builder/constants.d.ts +98 -0
  488. package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +10 -0
  489. package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +21 -0
  490. package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
  491. package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
  492. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +12 -0
  493. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +42 -0
  494. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +14 -0
  495. package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
  496. package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
  497. package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +7 -0
  498. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +20 -0
  499. package/types-legacy/ts4.5/tx/builder/field-types/field.d.ts +6 -0
  500. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +15 -0
  501. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +7 -0
  502. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +129 -0
  503. package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +43 -0
  504. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +18 -0
  505. package/types-legacy/ts4.5/tx/builder/field-types/name-id.d.ts +11 -0
  506. package/types-legacy/ts4.5/tx/builder/field-types/name.d.ts +13 -0
  507. package/types-legacy/ts4.5/tx/builder/field-types/pointers.d.ts +26 -0
  508. package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
  509. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  510. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int.d.ts +6 -0
  511. package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
  512. package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +7 -0
  513. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
  514. package/types-legacy/ts4.5/tx/builder/index.d.ts +50 -0
  515. package/types-legacy/ts4.5/tx/builder/schema.d.ts +4675 -0
  516. package/types-legacy/ts4.5/tx/index.d.ts +19 -0
  517. package/types-legacy/ts4.5/tx/validator.d.ts +18 -0
  518. package/types-legacy/ts4.5/utils/amount-formatter.d.ts +42 -0
  519. package/types-legacy/ts4.5/utils/autorest.d.ts +7 -0
  520. package/types-legacy/ts4.5/utils/bignumber.d.ts +13 -0
  521. package/types-legacy/ts4.5/utils/bytes.d.ts +9 -0
  522. package/types-legacy/ts4.5/utils/crypto.d.ts +95 -0
  523. package/types-legacy/ts4.5/utils/encoder-types.d.ts +61 -0
  524. package/types-legacy/ts4.5/utils/encoder.d.ts +24 -0
  525. package/types-legacy/ts4.5/utils/errors.d.ts +475 -0
  526. package/types-legacy/ts4.5/utils/hd-wallet.d.ts +65 -0
  527. package/types-legacy/ts4.5/utils/json-big.d.ts +5 -0
  528. package/types-legacy/ts4.5/utils/keystore.d.ts +53 -0
  529. package/types-legacy/ts4.5/utils/other.d.ts +31 -0
  530. package/types-legacy/ts4.5/utils/semver-satisfies.d.ts +1 -0
  531. package/types-legacy/ts4.5/utils/string.d.ts +12 -0
  532. package/es/channel/index.d.ts +0 -625
  533. package/es/channel/index.mjs +0 -975
  534. package/es/channel/index.mjs.map +0 -1
  535. package/es/contract/Compiler.d.ts +0 -18
  536. package/es/contract/Compiler.mjs +0 -68
  537. package/es/contract/Compiler.mjs.map +0 -1
  538. package/es/contract/aci.d.ts +0 -127
  539. package/es/contract/aci.mjs +0 -508
  540. package/es/contract/aci.mjs.map +0 -1
  541. package/es/contract/methods.d.ts +0 -71
  542. package/es/contract/methods.mjs +0 -104
  543. package/es/contract/methods.mjs.map +0 -1
  544. package/es/deprecated/index.d.ts +0 -143
  545. package/es/deprecated/index.mjs +0 -162
  546. package/es/deprecated/index.mjs.map +0 -1
  547. package/es/deprecated/methods.d.ts +0 -18
  548. package/es/deprecated/methods.mjs +0 -26
  549. package/es/deprecated/methods.mjs.map +0 -1
  550. package/es/tx/builder/address.d.ts +0 -25
  551. package/es/tx/builder/address.mjs +0 -45
  552. package/es/tx/builder/address.mjs.map +0 -1
  553. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +0 -1
  554. package/es/utils/mptree.d.ts +0 -26
  555. package/es/utils/mptree.mjs +0 -165
  556. package/es/utils/mptree.mjs.map +0 -1
  557. package/src/channel/index.ts +0 -1025
  558. package/src/contract/Compiler.ts +0 -67
  559. package/src/contract/aci.ts +0 -537
  560. package/src/contract/methods.ts +0 -123
  561. package/src/deprecated/index.ts +0 -172
  562. package/src/deprecated/methods.ts +0 -25
  563. package/src/tx/builder/address.ts +0 -50
  564. package/src/typings/@aeternity__argon2-browser/index.d.ts +0 -3
  565. package/src/utils/mptree.ts +0 -145
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.mjs","names":["decode","encode","Encoding","ArgumentError","genEntryField","tag","serialize","txParams","buildTx","ArrayBuffer","isView","from","deserialize","buf","unpackTx","tx","Transaction"],"sources":["../../../../src/tx/builder/field-types/entry.ts"],"sourcesContent":["import { decode, encode, Encoding } 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 `Parameters<typeof buildTxType<T>>[0]`,\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 `ReturnType<typeof unpackTxType<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 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":";;;;SAASA,MAAM,EAAEC,MAAM,EAAEC,QAAQ;AAAA,SAExBC,aAAa;AAGtB,eAAe,SAASC,aAAa,CAAsBC,GAAO,EAYhE;EACA,OAAO;IACLC,SAAS,CAACC,QAAQ,QAAe;MAAA,IAAb;QAAEC;MAAQ,CAAC;MAC7B,IAAIC,WAAW,CAACC,MAAM,CAACH,QAAQ,CAAC,EAAE,OAAO,QAAOI,IAAI,CAACJ,QAAQ,CAAQ;MACrE,OAAOP,MAAM,CAACQ,OAAO,CAAC;QAAE,GAAGD,QAAQ;QAAE,IAAGF,GAAG,IAAI,IAAI,IAAI;UAAEA;QAAI,CAAC;MAAC,CAAC,CAAC,CAAC;IACpE,CAAC;IAEDO,WAAW,CAACC,GAAG,SAAgB;MAAA,IAAd;QAAEC;MAAS,CAAC;MAC3B,MAAMC,EAAE,GAAGD,QAAQ,CAACb,MAAM,CAACY,GAAG,EAAEX,QAAQ,CAACc,WAAW,CAAC,CAAC;MACtD,IAAIX,GAAG,IAAI,IAAI,IAAIU,EAAE,CAACV,GAAG,KAAKA,GAAG,EAAE,MAAM,IAAIF,aAAa,CAAC,KAAK,EAAEE,GAAG,EAAEU,EAAE,CAACV,GAAG,CAAC;MAC9E,OAAOU,EAAE;IACX;EACF,CAAC;AACH"}
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" />
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];
7
+ };
@@ -0,0 +1,30 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import { ArgumentError } from "../../../utils/errors.mjs";
6
+ import { isItemOfArray } from "../../../utils/other.mjs";
7
+ export default function genEnumerationField(enm) {
8
+ const values = Object.values(enm).filter(v => typeof v === 'number');
9
+ return {
10
+ serialize(value) {
11
+ if (typeof value !== 'number') throw new ArgumentError('value', 'to be a number', value);
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
+ }
16
+ return _Buffer.from([value]);
17
+ },
18
+ deserialize(buffer) {
19
+ if (buffer.length !== 1) {
20
+ throw new ArgumentError('buffer', 'to have single element', buffer.length);
21
+ }
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;
27
+ }
28
+ };
29
+ }
30
+ //# sourceMappingURL=enumeration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enumeration.mjs","names":["ArgumentError","isItemOfArray","genEnumerationField","enm","values","Object","filter","v","serialize","value","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,mBAAmB,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,SAAS,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,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,IAAIb,aAAa,CAAC,QAAQ,EAAE,wBAAwB,EAAEY,MAAM,CAACC,MAAM,CAAC;MAC5E;MACA,MAAMJ,KAAK,GAAGG,MAAM,CAAC,CAAC,CAAC;MACvB,IAAI,CAACX,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,25 +1,20 @@
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
- /**
9
- * Calculate min fee
10
- * @category transaction builder
11
- * @param txType - Transaction type
12
- * @param rebuildTx - Callback to get built transaction with specific fee
13
- */
14
- export declare function calculateMinFee(txType: Tag, rebuildTx: (value: BigNumber) => any): BigNumber;
8
+ export declare function buildFee(builtTx: Encoded.Transaction, unpackTx: typeof unpackTxType, buildTx: typeof buildTxType): BigNumber;
15
9
  declare const _default: {
16
- serializeAettos(_value: string | undefined, { txType, rebuildTx, _computingMinFee }: {
17
- txType: Tag;
18
- rebuildTx: (params: any) => any;
19
- _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;
20
16
  }): string;
21
- serialize: (value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options) => Buffer;
22
- serializeOptional(value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
17
+ serialize(value: import("../constants").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
23
18
  deserialize(value: Buffer): string;
24
19
  };
25
20
  export default _default;
@@ -1,12 +1,13 @@
1
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
2
1
  import BigNumber from 'bignumber.js';
3
2
  import { IllegalArgumentError } from "../../../utils/errors.mjs";
4
3
  import { MIN_GAS_PRICE, Tag } from "../constants.mjs";
5
4
  import coinAmount from "./coin-amount.mjs";
6
5
  import { isKeyOfObject } from "../../../utils/other.mjs";
6
+ import { decode } from "../../../utils/encoder.mjs";
7
7
  const BASE_GAS = 15000;
8
8
  const GAS_PER_BYTE = 20;
9
9
  const KEY_BLOCK_INTERVAL = 3;
10
+
10
11
  /**
11
12
  * Calculate the Base fee gas
12
13
  * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}
@@ -17,10 +18,8 @@ const KEY_BLOCK_INTERVAL = 3;
17
18
  * TX_FEE_BASE('channelForceProgress') => new BigNumber(30 * 15000)
18
19
  * ```
19
20
  */
20
-
21
21
  const TX_FEE_BASE_GAS = txType => {
22
22
  var _feeFactors;
23
-
24
23
  const feeFactors = {
25
24
  [Tag.ChannelForceProgressTx]: 30,
26
25
  [Tag.ChannelOffChainTx]: 0,
@@ -38,6 +37,7 @@ const TX_FEE_BASE_GAS = txType => {
38
37
  const factor = (_feeFactors = feeFactors[txType]) !== null && _feeFactors !== void 0 ? _feeFactors : 1;
39
38
  return new BigNumber(factor * BASE_GAS);
40
39
  };
40
+
41
41
  /**
42
42
  * Calculate fee for Other types of transactions
43
43
  * @see {@link https://github.com/aeternity/protocol/blob/master/consensus/README.md#gas}
@@ -53,98 +53,86 @@ const TX_FEE_BASE_GAS = txType => {
53
53
  * => new BigNumber(10).times(20).plus(Math.ceil(32000 * 10 / Math.floor(60 * 24 * 365 / 2)))
54
54
  * ```
55
55
  */
56
-
57
-
58
56
  const TX_FEE_OTHER_GAS = (txType, txSize, _ref) => {
59
57
  let {
60
58
  relativeTtl,
61
59
  innerTxSize
62
60
  } = _ref;
63
-
64
61
  switch (txType) {
65
62
  case Tag.OracleRegisterTx:
66
63
  case Tag.OracleExtendTx:
67
64
  case Tag.OracleQueryTx:
68
65
  case Tag.OracleResponseTx:
69
66
  return new BigNumber(txSize).times(GAS_PER_BYTE).plus(Math.ceil(32000 * relativeTtl / Math.floor(60 * 24 * 365 / KEY_BLOCK_INTERVAL)));
70
-
71
67
  case Tag.GaMetaTx:
72
68
  case Tag.PayingForTx:
73
69
  return new BigNumber(txSize).minus(innerTxSize).times(GAS_PER_BYTE);
74
-
75
70
  default:
76
71
  return new BigNumber(txSize).times(GAS_PER_BYTE);
77
72
  }
78
73
  };
79
-
80
- function getOracleRelativeTtl(params, txType) {
74
+ function getOracleRelativeTtl(params) {
81
75
  const ttlKeys = {
82
76
  [Tag.OracleRegisterTx]: 'oracleTtlValue',
83
77
  [Tag.OracleExtendTx]: 'oracleTtlValue',
84
78
  [Tag.OracleQueryTx]: 'queryTtlValue',
85
79
  [Tag.OracleResponseTx]: 'responseTtlValue'
86
80
  };
87
- if (!isKeyOfObject(txType, ttlKeys)) return 1;
88
- return params[ttlKeys[txType]];
81
+ const {
82
+ tag
83
+ } = params;
84
+ if (!isKeyOfObject(tag, ttlKeys)) return 1;
85
+ return params[ttlKeys[tag]];
89
86
  }
87
+
90
88
  /**
91
89
  * Calculate fee based on tx type and params
92
90
  */
93
-
94
-
95
- export function buildFee(txType, buildTx) {
96
- var _context;
97
-
91
+ export function buildFee(builtTx, unpackTx, buildTx) {
98
92
  const {
99
- rlpEncoded: {
100
- length
101
- },
102
- txObject
103
- } = buildTx;
104
- return TX_FEE_BASE_GAS(txType).plus(TX_FEE_OTHER_GAS(txType, length, {
105
- relativeTtl: getOracleRelativeTtl(txObject, txType),
106
- innerTxSize: _includesInstanceProperty(_context = [Tag.GaMetaTx, Tag.PayingForTx]).call(_context, txType) ? txObject.tx.tx.encodedTx.rlpEncoded.length : 0
93
+ length
94
+ } = decode(builtTx);
95
+ const txObject = unpackTx(builtTx);
96
+ return TX_FEE_BASE_GAS(txObject.tag).plus(TX_FEE_OTHER_GAS(txObject.tag, length, {
97
+ relativeTtl: getOracleRelativeTtl(txObject),
98
+ innerTxSize: txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx ? decode(buildTx(txObject.tx.encodedTx)).length : 0
107
99
  })).times(MIN_GAS_PRICE);
108
100
  }
101
+
109
102
  /**
110
103
  * Calculate min fee
111
104
  * @category transaction builder
112
- * @param txType - Transaction type
113
105
  * @param rebuildTx - Callback to get built transaction with specific fee
114
106
  */
115
-
116
- export function calculateMinFee(txType, rebuildTx) {
107
+ function calculateMinFee(rebuildTx, unpackTx, buildTx) {
117
108
  let fee = new BigNumber(0);
118
109
  let previousFee;
119
-
120
110
  do {
121
111
  previousFee = fee;
122
- fee = buildFee(txType, rebuildTx(fee));
112
+ fee = buildFee(rebuildTx(fee), unpackTx, buildTx);
123
113
  } while (!fee.eq(previousFee));
124
-
125
114
  return fee;
126
115
  }
127
- export default { ...coinAmount,
128
-
116
+ export default {
117
+ ...coinAmount,
129
118
  serializeAettos(_value, _ref2) {
130
119
  let {
131
- txType,
132
120
  rebuildTx,
133
- _computingMinFee
121
+ unpackTx,
122
+ buildTx,
123
+ _computingMinFee,
124
+ _pickBiggerFee
134
125
  } = _ref2;
135
- if (_computingMinFee != null) return _computingMinFee;
136
- const minFee = calculateMinFee(txType, fee => rebuildTx({
126
+ if (_computingMinFee != null) return _computingMinFee.toFixed();
127
+ const minFee = calculateMinFee(fee => rebuildTx({
137
128
  _computingMinFee: fee
138
- }));
129
+ }), unpackTx, buildTx);
139
130
  const value = new BigNumber(_value !== null && _value !== void 0 ? _value : minFee);
140
-
141
131
  if (minFee.gt(value)) {
132
+ if (_pickBiggerFee === true) return minFee.toFixed();
142
133
  throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger then ${minFee}`);
143
134
  }
144
-
145
135
  return value.toFixed();
146
- },
147
-
148
- serialize: coinAmount.serializeOptional
136
+ }
149
137
  };
150
138
  //# sourceMappingURL=fee.mjs.map
@@ -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","tx","encodedTx","calculateMinFee","rebuildTx","fee","previousFee","eq","serializeAettos","_value","_computingMinFee","minFee","value","gt","toString","toFixed","serialize","serializeOptional"],"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 */\nexport function 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 serialize: coinAmount.serializeOptional,\n};\n"],"mappings":";AAAA,OAAOA,SAAP,MAAsB,cAAtB;SACSC,oB;SACAC,a,EAAeC,G;OACjBC,U;SACEC,a;AAET,MAAMC,QAAQ,GAAG,KAAjB;AACA,MAAMC,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,EAAP;EACD,CAfY;;EAiBbC,SAAS,EAAE1D,UAAU,CAAC2D;AAjBT,CAAf"}
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","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","tag","buildFee","builtTx","unpackTx","buildTx","length","txObject","tx","encodedTx","calculateMinFee","rebuildTx","fee","previousFee","eq","serializeAettos","_value","_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 return TX_FEE_BASE_GAS(txObject.tag)\n .plus(TX_FEE_OTHER_GAS(txObject.tag, length, {\n relativeTtl: getOracleRelativeTtl(txObject),\n innerTxSize: txObject.tag === Tag.GaMetaTx || txObject.tag === Tag.PayingForTx\n ? decode(buildTx(txObject.tx.encodedTx)).length\n : 0,\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,SACbC,MAAM;AAGf,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,CAACT,GAAG,CAACU,sBAAsB,GAAG,EAAE;IAChC,CAACV,GAAG,CAACW,iBAAiB,GAAG,CAAC;IAC1B,CAACX,GAAG,CAACY,iCAAiC,GAAG,CAAC;IAC1C,CAACZ,GAAG,CAACa,mCAAmC,GAAG,CAAC;IAC5C,CAACb,GAAG,CAACc,4BAA4B,GAAG,CAAC;IACrC,CAACd,GAAG,CAACe,6BAA6B,GAAG,CAAC;IACtC,CAACf,GAAG,CAACgB,6BAA6B,GAAG,CAAC;IACtC,CAAChB,GAAG,CAACiB,gBAAgB,GAAG,CAAC;IACzB,CAACjB,GAAG,CAACkB,cAAc,GAAG,EAAE;IACxB,CAAClB,GAAG,CAACmB,UAAU,GAAG,CAAC;IACnB,CAACnB,GAAG,CAACoB,QAAQ,GAAG,CAAC;IACjB,CAACpB,GAAG,CAACqB,WAAW,GAAG,CAAC,GAAG;EACzB,CAAU;EACV,MAAMC,MAAM,kBAAGb,UAAU,CAACD,MAAM,CAA4B,qDAAI,CAAC;EACjE,OAAO,IAAIX,SAAS,CAACyB,MAAM,GAAGlB,QAAQ,CAAC;AACzC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA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gBAAgB;MAAEC;IAOlD,CAAC;IAED,IAAID,gBAAgB,IAAI,IAAI,EAAE,OAAOA,gBAAgB,CAACE,OAAO,EAAE;IAC/D,MAAMC,MAAM,GAAGV,eAAe,CAC3BE,GAAG,IAAKD,SAAS,CAAC;MAAEM,gBAAgB,EAAEL;IAAI,CAAC,CAAC,EAC7CR,QAAQ,EACRC,OAAO,CACR;IACD,MAAMgB,KAAK,GAAG,IAAI/D,SAAS,CAAC0D,MAAM,aAANA,MAAM,cAANA,MAAM,GAAII,MAAM,CAAC;IAC7C,IAAIA,MAAM,CAACE,EAAE,CAACD,KAAK,CAAC,EAAE;MACpB,IAAIH,cAAc,KAAK,IAAI,EAAE,OAAOE,MAAM,CAACD,OAAO,EAAE;MACpD,MAAM,IAAI5D,oBAAoB,CAAE,OAAM8D,KAAK,CAACE,QAAQ,EAAG,wBAAuBH,MAAO,EAAC,CAAC;IACzF;IACA,OAAOC,KAAK,CAACF,OAAO,EAAE;EACxB;AACF,CAAC"}
@@ -6,10 +6,8 @@ export default {
6
6
  serialize(value) {
7
7
  return _Buffer.from(value);
8
8
  },
9
-
10
9
  deserialize(value) {
11
10
  return value.toString();
12
11
  }
13
-
14
12
  };
15
13
  //# sourceMappingURL=field.mjs.map
@@ -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,KAAD,EAAwB;IAC/B,OAAO,QAAOC,IAAP,CAAYD,KAAZ,CAAP;EACD,CAHY;;EAKbE,WAAW,CAACF,KAAD,EAAwB;IACjC,OAAOA,KAAK,CAACG,QAAN,EAAP;EACD;;AAPY,CAAf"}
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,9 +1,12 @@
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, gasMax, _computingGasLimit, }: {
6
+ tag: Tag;
6
7
  rebuildTx: (params: any) => any;
8
+ unpackTx: typeof unpackTxType;
9
+ buildTx: typeof buildTxType;
7
10
  gasMax: number;
8
11
  _computingGasLimit?: number | undefined;
9
12
  }): Buffer;
@@ -1,33 +1,31 @@
1
1
  import { IllegalArgumentError } from "../../../utils/errors.mjs";
2
- import { MIN_GAS_PRICE } from "../constants.mjs";
2
+ import { MIN_GAS_PRICE, Tag, MAX_AUTH_FUN_GAS } from "../constants.mjs";
3
3
  import shortUInt from "./short-u-int.mjs";
4
4
  import { buildFee } from "./fee.mjs";
5
-
6
- function calculateGasLimitMax(txType, gasMax, rebuildTx) {
7
- return gasMax - +buildFee(txType, rebuildTx(gasMax)).dividedBy(MIN_GAS_PRICE);
5
+ function calculateGasLimitMax(gasMax, rebuildTx, unpackTx, buildTx) {
6
+ return gasMax - +buildFee(rebuildTx(gasMax), unpackTx, buildTx).dividedBy(MIN_GAS_PRICE);
8
7
  }
9
-
10
- export default { ...shortUInt,
11
-
8
+ export default {
9
+ ...shortUInt,
12
10
  serialize(_value, _ref) {
13
11
  let {
14
- txType,
12
+ tag,
15
13
  rebuildTx,
14
+ unpackTx,
15
+ buildTx,
16
16
  gasMax = 6e6,
17
17
  _computingGasLimit
18
18
  } = _ref;
19
19
  if (_computingGasLimit != null) return shortUInt.serialize(_computingGasLimit);
20
- const gasLimitMax = calculateGasLimitMax(txType, gasMax, gasLimit => rebuildTx({
21
- _computingGasLimit: gasLimit
22
- }));
20
+ const gasLimitMax = tag === Tag.GaMetaTx ? MAX_AUTH_FUN_GAS : calculateGasLimitMax(gasMax, gasLimit => rebuildTx({
21
+ _computingGasLimit: gasLimit,
22
+ _pickBiggerFee: true
23
+ }), unpackTx, buildTx);
23
24
  const value = _value !== null && _value !== void 0 ? _value : gasLimitMax;
24
-
25
25
  if (value > gasLimitMax) {
26
26
  throw new IllegalArgumentError(`Gas limit ${value} must be less or equal to ${gasLimitMax}`);
27
27
  }
28
-
29
28
  return shortUInt.serialize(value);
30
29
  }
31
-
32
30
  };
33
31
  //# sourceMappingURL=gas-limit.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"gas-limit.mjs","names":["IllegalArgumentError","MIN_GAS_PRICE","shortUInt","buildFee","calculateGasLimitMax","txType","gasMax","rebuildTx","dividedBy","serialize","_value","_computingGasLimit","gasLimitMax","gasLimit","value"],"sources":["../../../../src/tx/builder/field-types/gas-limit.ts"],"sourcesContent":["import { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE, Tag } from '../constants';\nimport shortUInt from './short-u-int';\nimport { buildFee } from './fee';\n\nfunction calculateGasLimitMax(\n txType: Tag,\n gasMax: number,\n rebuildTx: (value: number) => any,\n): number {\n return gasMax - +buildFee(txType, rebuildTx(gasMax)).dividedBy(MIN_GAS_PRICE);\n}\n\nexport default {\n ...shortUInt,\n\n serialize(\n _value: number | undefined,\n {\n txType, rebuildTx, gasMax = 6e6, _computingGasLimit,\n }: {\n txType: Tag;\n rebuildTx: (params: any) => any;\n gasMax: number;\n _computingGasLimit?: number;\n },\n ): Buffer {\n if (_computingGasLimit != null) return shortUInt.serialize(_computingGasLimit);\n\n const gasLimitMax = calculateGasLimitMax(\n txType,\n gasMax,\n (gasLimit) => rebuildTx({ _computingGasLimit: gasLimit }),\n );\n const value = _value ?? gasLimitMax;\n if (value > gasLimitMax) {\n throw new IllegalArgumentError(`Gas limit ${value} must be less or equal to ${gasLimitMax}`);\n }\n return shortUInt.serialize(value);\n },\n};\n"],"mappings":"SAASA,oB;SACAC,a;OACFC,S;SACEC,Q;;AAET,SAASC,oBAAT,CACEC,MADF,EAEEC,MAFF,EAGEC,SAHF,EAIU;EACR,OAAOD,MAAM,GAAG,CAACH,QAAQ,CAACE,MAAD,EAASE,SAAS,CAACD,MAAD,CAAlB,CAAR,CAAoCE,SAApC,CAA8CP,aAA9C,CAAjB;AACD;;AAED,eAAe,EACb,GAAGC,SADU;;EAGbO,SAAS,CACPC,MADO,QAUC;IAAA,IARR;MACEL,MADF;MACUE,SADV;MACqBD,MAAM,GAAG,GAD9B;MACmCK;IADnC,CAQQ;IACR,IAAIA,kBAAkB,IAAI,IAA1B,EAAgC,OAAOT,SAAS,CAACO,SAAV,CAAoBE,kBAApB,CAAP;IAEhC,MAAMC,WAAW,GAAGR,oBAAoB,CACtCC,MADsC,EAEtCC,MAFsC,EAGrCO,QAAD,IAAcN,SAAS,CAAC;MAAEI,kBAAkB,EAAEE;IAAtB,CAAD,CAHe,CAAxC;IAKA,MAAMC,KAAK,GAAGJ,MAAH,aAAGA,MAAH,cAAGA,MAAH,GAAaE,WAAxB;;IACA,IAAIE,KAAK,GAAGF,WAAZ,EAAyB;MACvB,MAAM,IAAIZ,oBAAJ,CAA0B,aAAYc,KAAM,6BAA4BF,WAAY,EAApF,CAAN;IACD;;IACD,OAAOV,SAAS,CAACO,SAAV,CAAoBK,KAApB,CAAP;EACD;;AA1BY,CAAf"}
1
+ {"version":3,"file":"gas-limit.mjs","names":["IllegalArgumentError","MIN_GAS_PRICE","Tag","MAX_AUTH_FUN_GAS","shortUInt","buildFee","calculateGasLimitMax","gasMax","rebuildTx","unpackTx","buildTx","dividedBy","serialize","_value","tag","_computingGasLimit","gasLimitMax","GaMetaTx","gasLimit","_pickBiggerFee","value"],"sources":["../../../../src/tx/builder/field-types/gas-limit.ts"],"sourcesContent":["import { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE, Tag, MAX_AUTH_FUN_GAS } from '../constants';\nimport shortUInt from './short-u-int';\nimport { buildFee } from './fee';\nimport type { unpackTx as unpackTxType, buildTx as buildTxType } from '../index';\n\nfunction calculateGasLimitMax(\n gasMax: number,\n rebuildTx: (value: number) => any,\n unpackTx: typeof unpackTxType,\n buildTx: typeof buildTxType,\n): number {\n return gasMax - +buildFee(rebuildTx(gasMax), unpackTx, buildTx).dividedBy(MIN_GAS_PRICE);\n}\n\nexport default {\n ...shortUInt,\n\n serialize(\n _value: number | undefined,\n {\n tag, rebuildTx, unpackTx, buildTx, gasMax = 6e6, _computingGasLimit,\n }: {\n tag: Tag;\n rebuildTx: (params: any) => any;\n unpackTx: typeof unpackTxType;\n buildTx: typeof buildTxType;\n gasMax: number;\n _computingGasLimit?: number;\n },\n ): Buffer {\n if (_computingGasLimit != null) return shortUInt.serialize(_computingGasLimit);\n\n const gasLimitMax = tag === Tag.GaMetaTx ? MAX_AUTH_FUN_GAS : calculateGasLimitMax(\n gasMax,\n (gasLimit) => rebuildTx({ _computingGasLimit: gasLimit, _pickBiggerFee: true }),\n unpackTx,\n buildTx,\n );\n const value = _value ?? gasLimitMax;\n if (value > gasLimitMax) {\n throw new IllegalArgumentError(`Gas limit ${value} must be less or equal to ${gasLimitMax}`);\n }\n return shortUInt.serialize(value);\n },\n};\n"],"mappings":"SAASA,oBAAoB;AAAA,SACpBC,aAAa,EAAEC,GAAG,EAAEC,gBAAgB;AAAA,OACtCC,SAAS;AAAA,SACPC,QAAQ;AAGjB,SAASC,oBAAoB,CAC3BC,MAAc,EACdC,SAAiC,EACjCC,QAA6B,EAC7BC,OAA2B,EACnB;EACR,OAAOH,MAAM,GAAG,CAACF,QAAQ,CAACG,SAAS,CAACD,MAAM,CAAC,EAAEE,QAAQ,EAAEC,OAAO,CAAC,CAACC,SAAS,CAACV,aAAa,CAAC;AAC1F;AAEA,eAAe;EACb,GAAGG,SAAS;EAEZQ,SAAS,CACPC,MAA0B,QAWlB;IAAA,IAVR;MACEC,GAAG;MAAEN,SAAS;MAAEC,QAAQ;MAAEC,OAAO;MAAEH,MAAM,GAAG,GAAG;MAAEQ;IAQnD,CAAC;IAED,IAAIA,kBAAkB,IAAI,IAAI,EAAE,OAAOX,SAAS,CAACQ,SAAS,CAACG,kBAAkB,CAAC;IAE9E,MAAMC,WAAW,GAAGF,GAAG,KAAKZ,GAAG,CAACe,QAAQ,GAAGd,gBAAgB,GAAGG,oBAAoB,CAChFC,MAAM,EACLW,QAAQ,IAAKV,SAAS,CAAC;MAAEO,kBAAkB,EAAEG,QAAQ;MAAEC,cAAc,EAAE;IAAK,CAAC,CAAC,EAC/EV,QAAQ,EACRC,OAAO,CACR;IACD,MAAMU,KAAK,GAAGP,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIG,WAAW;IACnC,IAAII,KAAK,GAAGJ,WAAW,EAAE;MACvB,MAAM,IAAIhB,oBAAoB,CAAE,aAAYoB,KAAM,6BAA4BJ,WAAY,EAAC,CAAC;IAC9F;IACA,OAAOZ,SAAS,CAACQ,SAAS,CAACQ,KAAK,CAAC;EACnC;AACF,CAAC"}
@@ -1,8 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  declare const _default: {
3
3
  serializeAettos(value?: string | undefined): string;
4
- serialize: (value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options) => Buffer;
5
- serializeOptional(value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
4
+ serialize(value: import("../constants").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
6
5
  deserialize(value: Buffer): string;
7
6
  };
8
7
  export default _default;
@@ -1,18 +1,14 @@
1
1
  import coinAmount from "./coin-amount.mjs";
2
2
  import { IllegalArgumentError } from "../../../utils/errors.mjs";
3
3
  import { MIN_GAS_PRICE } from "../constants.mjs";
4
- export default { ...coinAmount,
5
-
4
+ export default {
5
+ ...coinAmount,
6
6
  serializeAettos() {
7
7
  let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MIN_GAS_PRICE.toString();
8
-
9
8
  if (+value < MIN_GAS_PRICE) {
10
9
  throw new IllegalArgumentError(`Gas price ${value.toString()} must be bigger then ${MIN_GAS_PRICE}`);
11
10
  }
12
-
13
11
  return value;
14
- },
15
-
16
- serialize: coinAmount.serializeOptional
12
+ }
17
13
  };
18
14
  //# sourceMappingURL=gas-price.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"gas-price.mjs","names":["coinAmount","IllegalArgumentError","MIN_GAS_PRICE","serializeAettos","value","toString","serialize","serializeOptional"],"sources":["../../../../src/tx/builder/field-types/gas-price.ts"],"sourcesContent":["import coinAmount from './coin-amount';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE } from '../constants';\n\nexport default {\n ...coinAmount,\n\n serializeAettos(value: string | undefined = MIN_GAS_PRICE.toString()): string {\n if (+value < MIN_GAS_PRICE) {\n throw new IllegalArgumentError(`Gas price ${value.toString()} must be bigger then ${MIN_GAS_PRICE}`);\n }\n return value;\n },\n\n serialize: coinAmount.serializeOptional,\n};\n"],"mappings":"OAAOA,U;SACEC,oB;SACAC,a;AAET,eAAe,EACb,GAAGF,UADU;;EAGbG,eAAe,GAA+D;IAAA,IAA9DC,KAA8D,uEAAlCF,aAAa,CAACG,QAAd,EAAkC;;IAC5E,IAAI,CAACD,KAAD,GAASF,aAAb,EAA4B;MAC1B,MAAM,IAAID,oBAAJ,CAA0B,aAAYG,KAAK,CAACC,QAAN,EAAiB,wBAAuBH,aAAc,EAA5F,CAAN;IACD;;IACD,OAAOE,KAAP;EACD,CARY;;EAUbE,SAAS,EAAEN,UAAU,CAACO;AAVT,CAAf"}
1
+ {"version":3,"file":"gas-price.mjs","names":["coinAmount","IllegalArgumentError","MIN_GAS_PRICE","serializeAettos","value","toString"],"sources":["../../../../src/tx/builder/field-types/gas-price.ts"],"sourcesContent":["import coinAmount from './coin-amount';\nimport { IllegalArgumentError } from '../../../utils/errors';\nimport { MIN_GAS_PRICE } from '../constants';\n\nexport default {\n ...coinAmount,\n\n serializeAettos(value: string | undefined = MIN_GAS_PRICE.toString()): string {\n if (+value < MIN_GAS_PRICE) {\n throw new IllegalArgumentError(`Gas price ${value.toString()} must be bigger then ${MIN_GAS_PRICE}`);\n }\n return value;\n },\n};\n"],"mappings":"OAAOA,UAAU;AAAA,SACRC,oBAAoB;AAAA,SACpBC,aAAa;AAEtB,eAAe;EACb,GAAGF,UAAU;EAEbG,eAAe,GAA+D;IAAA,IAA9DC,KAAyB,uEAAGF,aAAa,CAACG,QAAQ,EAAE;IAClE,IAAI,CAACD,KAAK,GAAGF,aAAa,EAAE;MAC1B,MAAM,IAAID,oBAAoB,CAAE,aAAYG,KAAK,CAACC,QAAQ,EAAG,wBAAuBH,aAAc,EAAC,CAAC;IACtG;IACA,OAAOE,KAAK;EACd;AACF,CAAC"}
@@ -1,42 +1,64 @@
1
1
  /// <reference types="node" />
2
- declare const field: {
3
- serialize(value: string): Buffer;
4
- deserialize(value: Buffer): string;
5
- };
6
- declare const uInt: {
7
- serialize(value: import("./u-int").Int): Buffer;
8
- deserialize(value: Buffer): string;
2
+ import _address from './address';
3
+ import _array from './array';
4
+ import _encoded from './encoded';
5
+ import _entry from './entry';
6
+ import _enumeration from './enumeration';
7
+ import _mptree from './mptree';
8
+ import _shortUIntConst from './short-u-int-const';
9
+ declare const abiVersion: {
10
+ serialize(value: import("../constants").AbiVersion | undefined, { tag, consensusProtocolVersion }: {
11
+ tag: import("../constants").Tag;
12
+ consensusProtocolVersion: import("../constants").ConsensusProtocolVersion;
13
+ }): Buffer;
14
+ deserialize(buffer: Buffer): import("../constants").AbiVersion;
9
15
  };
10
- declare const shortUInt: {
11
- serialize(value: number): Buffer;
12
- deserialize(value: Buffer): number;
16
+ declare const address: typeof _address;
17
+ declare const array: typeof _array;
18
+ declare const boolean: {
19
+ serialize(value: boolean): Buffer;
20
+ deserialize(buffer: Buffer): boolean;
13
21
  };
14
22
  declare const coinAmount: {
15
23
  serializeAettos(value: string | undefined): string;
16
- serializeOptional(value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
17
- serialize(value: import("./u-int").Int, options: import("./coin-amount").Options): Buffer;
24
+ serialize(value: import("../constants").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
18
25
  deserialize(value: Buffer): string;
19
26
  };
27
+ declare const ctVersion: {
28
+ serialize(value: import("./ct-version").CtVersion | undefined, { consensusProtocolVersion }: {
29
+ consensusProtocolVersion: import("../constants").ConsensusProtocolVersion;
30
+ }): Buffer;
31
+ deserialize(buffer: Buffer): import("./ct-version").CtVersion;
32
+ };
20
33
  declare const deposit: {
21
- serialize(value: import("./u-int").Int | undefined, options: import("./coin-amount").Options): Buffer;
34
+ serialize(value: import("../constants").Int | undefined, options: import("./coin-amount").Options): Buffer;
22
35
  serializeAettos(value: string | undefined): string;
23
- serializeOptional(value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
24
36
  deserialize(value: Buffer): string;
25
37
  };
38
+ declare const encoded: typeof _encoded;
39
+ declare const entry: typeof _entry;
40
+ declare const enumeration: typeof _enumeration;
26
41
  declare const fee: {
27
- serializeAettos(_value: string | undefined, { txType, rebuildTx, _computingMinFee }: {
28
- txType: import("../constants").Tag;
29
- rebuildTx: (params: any) => any;
30
- _computingMinFee?: string | undefined;
42
+ serializeAettos(_value: string | undefined, { rebuildTx, unpackTx, buildTx, _computingMinFee, _pickBiggerFee, }: {
43
+ rebuildTx: (params: any) => `tx_${string}`;
44
+ unpackTx: typeof import("..").unpackTx;
45
+ buildTx: typeof import("..").buildTx;
46
+ _computingMinFee?: import("bignumber.js").BigNumber | undefined;
47
+ _pickBiggerFee?: boolean | undefined;
31
48
  }): string;
32
- serialize: (value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options) => Buffer;
33
- serializeOptional(value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
49
+ serialize(value: import("../constants").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
50
+ deserialize(value: Buffer): string;
51
+ };
52
+ declare const field: {
53
+ serialize(value: string): Buffer;
34
54
  deserialize(value: Buffer): string;
35
55
  };
36
56
  declare const gasLimit: {
37
- serialize(_value: number | undefined, { txType, rebuildTx, gasMax, _computingGasLimit, }: {
38
- txType: import("../constants").Tag;
57
+ serialize(_value: number | undefined, { tag, rebuildTx, unpackTx, buildTx, gasMax, _computingGasLimit, }: {
58
+ tag: import("../constants").Tag;
39
59
  rebuildTx: (params: any) => any;
60
+ unpackTx: typeof import("..").unpackTx;
61
+ buildTx: typeof import("..").buildTx;
40
62
  gasMax: number;
41
63
  _computingGasLimit?: number | undefined;
42
64
  }): Buffer;
@@ -44,10 +66,10 @@ declare const gasLimit: {
44
66
  };
45
67
  declare const gasPrice: {
46
68
  serializeAettos(value?: string | undefined): string;
47
- serialize: (value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options) => Buffer;
48
- serializeOptional(value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
69
+ serialize(value: import("../constants").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
49
70
  deserialize(value: Buffer): string;
50
71
  };
72
+ declare const mptree: typeof _mptree;
51
73
  declare const name: {
52
74
  serialize(value: `${string}.chain`): Buffer;
53
75
  deserialize(value: Buffer): `${string}.chain`;
@@ -56,15 +78,43 @@ declare const nameFee: {
56
78
  serializeAettos(_value: string | undefined, txFields: {
57
79
  name: `${string}.chain`;
58
80
  }): string;
59
- serialize(value: import("./u-int").Int | undefined, txFields: {
81
+ serialize(value: import("../constants").Int | undefined, txFields: {
60
82
  name: `${string}.chain`;
61
83
  } & import("./coin-amount").Options): Buffer;
62
- serializeOptional(value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
63
84
  deserialize(value: Buffer): string;
64
85
  };
65
86
  declare const nameId: {
66
- serialize(value: `nm_${string}` | `${string}.chain`): Buffer;
67
- deserialize(value: Buffer): `nm_${string}`;
87
+ serialize(value: `${string}.chain` | `nm_${string}`): Buffer;
88
+ deserialize: (value: Buffer) => `nm_${string}`;
89
+ };
90
+ declare const pointers: {
91
+ serialize(pointers: (import("../../../apis/node").NamePointer & {
92
+ id: `ch_${string}` | `ct_${string}` | `ok_${string}` | `ak_${string}` | `cm_${string}` | `nm_${string}`;
93
+ })[]): Buffer[][];
94
+ deserialize(pointers: [key: Buffer, id: Buffer][]): (import("../../../apis/node").NamePointer & {
95
+ id: `ch_${string}` | `ct_${string}` | `ok_${string}` | `ak_${string}` | `cm_${string}` | `nm_${string}`;
96
+ })[];
97
+ };
98
+ declare const raw: {
99
+ serialize(buffer: Uint8Array): Buffer;
100
+ deserialize(buffer: Buffer): Buffer;
101
+ };
102
+ declare const shortUInt: {
103
+ serialize(value: number): Buffer;
104
+ deserialize(value: Buffer): number;
105
+ };
106
+ declare const shortUIntConst: typeof _shortUIntConst;
107
+ declare const string: {
108
+ serialize(string: string): Buffer;
109
+ deserialize(buffer: Buffer): string;
110
+ };
111
+ declare const uInt: {
112
+ serialize(value: import("../constants").Int): Buffer;
113
+ deserialize(value: Buffer): string;
68
114
  };
69
- export declare type Field = typeof field | typeof uInt | typeof shortUInt | typeof coinAmount | typeof deposit | typeof fee | typeof gasLimit | typeof gasPrice | typeof name | typeof nameFee | typeof nameId;
70
- export { field, uInt, shortUInt, coinAmount, deposit, fee, gasLimit, gasPrice, name, nameFee, nameId, };
115
+ export type BinaryData = Buffer | Buffer[] | Buffer[][] | Array<[Buffer, Array<[Buffer, Buffer[]]>]>;
116
+ export interface Field {
117
+ serialize: (value: any, options: any) => BinaryData;
118
+ deserialize: (value: BinaryData, options: any) => any;
119
+ }
120
+ export { abiVersion, address, array, boolean, coinAmount, ctVersion, deposit, encoded, entry, enumeration, fee, field, gasLimit, gasPrice, mptree, name, nameFee, nameId, pointers, raw, shortUInt, shortUIntConst, string, uInt, };