@aeternity/aepp-sdk 13.0.0-alpha.0 → 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 (322) 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 +4206 -1127
  7. package/dist/aepp-sdk.js.map +1 -1
  8. package/es/AeSdkBase.d.ts +3 -3
  9. package/es/AeSdkBase.mjs +4 -0
  10. package/es/AeSdkBase.mjs.map +1 -1
  11. package/es/AeSdkMethods.d.ts +3 -4
  12. package/es/AeSdkMethods.mjs.map +1 -1
  13. package/es/Node.d.ts +4 -3
  14. package/es/Node.mjs +1 -1
  15. package/es/Node.mjs.map +1 -1
  16. package/es/account/Base.d.ts +2 -2
  17. package/es/account/Base.mjs.map +1 -1
  18. package/es/account/Generalized.mjs +5 -3
  19. package/es/account/Generalized.mjs.map +1 -1
  20. package/es/account/Ledger.mjs +2 -1
  21. package/es/account/Ledger.mjs.map +1 -1
  22. package/es/account/Memory.mjs +2 -1
  23. package/es/account/Memory.mjs.map +1 -1
  24. package/es/aens.d.ts +1 -1
  25. package/es/aens.mjs +5 -1
  26. package/es/aens.mjs.map +1 -1
  27. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  28. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +19 -4
  29. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  30. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +1 -1
  31. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  32. package/es/chain.d.ts +9 -1
  33. package/es/chain.mjs +4 -1
  34. package/es/chain.mjs.map +1 -1
  35. package/es/channel/Base.d.ts +6 -1
  36. package/es/channel/Base.mjs +9 -6
  37. package/es/channel/Base.mjs.map +1 -1
  38. package/es/channel/Contract.d.ts +8 -7
  39. package/es/channel/Contract.mjs +1 -1
  40. package/es/channel/Contract.mjs.map +1 -1
  41. package/es/channel/Spend.d.ts +3 -1
  42. package/es/channel/Spend.mjs +4 -2
  43. package/es/channel/Spend.mjs.map +1 -1
  44. package/es/channel/handlers.mjs +11 -9
  45. package/es/channel/handlers.mjs.map +1 -1
  46. package/es/channel/internal.mjs +3 -1
  47. package/es/channel/internal.mjs.map +1 -1
  48. package/es/contract/Contract.d.ts +21 -46
  49. package/es/contract/Contract.mjs +69 -52
  50. package/es/contract/Contract.mjs.map +1 -1
  51. package/es/contract/compiler/Base.d.ts +81 -0
  52. package/es/contract/compiler/Base.mjs +5 -0
  53. package/es/contract/compiler/Base.mjs.map +1 -0
  54. package/es/contract/compiler/Cli.d.ts +23 -0
  55. package/es/contract/compiler/Cli.mjs +155 -0
  56. package/es/contract/compiler/Cli.mjs.map +1 -0
  57. package/es/contract/compiler/Http.d.ts +32 -0
  58. package/es/contract/{CompilerHttp.mjs → compiler/Http.mjs} +64 -9
  59. package/es/contract/compiler/Http.mjs.map +1 -0
  60. package/es/contract/compiler/HttpNode.d.ts +17 -0
  61. package/es/contract/compiler/HttpNode.mjs +26 -0
  62. package/es/contract/compiler/HttpNode.mjs.map +1 -0
  63. package/es/contract/compiler/getFileSystem.d.ts +6 -0
  64. package/es/contract/compiler/getFileSystem.mjs +40 -0
  65. package/es/contract/compiler/getFileSystem.mjs.map +1 -0
  66. package/es/contract/ga.d.ts +5 -4
  67. package/es/contract/ga.mjs +11 -2
  68. package/es/contract/ga.mjs.map +1 -1
  69. package/es/index-browser.d.ts +39 -0
  70. package/es/index-browser.mjs +55 -0
  71. package/es/index-browser.mjs.map +1 -0
  72. package/es/index.d.ts +4 -38
  73. package/es/index.mjs +4 -53
  74. package/es/index.mjs.map +1 -1
  75. package/es/oracle.mjs +1 -1
  76. package/es/oracle.mjs.map +1 -1
  77. package/es/spend.mjs +1 -3
  78. package/es/spend.mjs.map +1 -1
  79. package/es/tx/builder/constants.d.ts +28 -1
  80. package/es/tx/builder/constants.mjs +32 -3
  81. package/es/tx/builder/constants.mjs.map +1 -1
  82. package/es/tx/builder/field-types/abi-version.d.ts +10 -0
  83. package/es/tx/builder/field-types/abi-version.mjs +20 -0
  84. package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
  85. package/es/tx/builder/field-types/address.d.ts +5 -6
  86. package/es/tx/builder/field-types/address.mjs +17 -8
  87. package/es/tx/builder/field-types/address.mjs.map +1 -1
  88. package/es/tx/builder/field-types/array.d.ts +7 -0
  89. package/es/tx/builder/field-types/array.mjs +11 -0
  90. package/es/tx/builder/field-types/array.mjs.map +1 -0
  91. package/es/tx/builder/field-types/boolean.d.ts +6 -0
  92. package/es/tx/builder/field-types/boolean.mjs +13 -0
  93. package/es/tx/builder/field-types/boolean.mjs.map +1 -0
  94. package/es/tx/builder/field-types/coin-amount.d.ts +1 -1
  95. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  96. package/es/tx/builder/field-types/ct-version.d.ts +30 -0
  97. package/es/tx/builder/field-types/ct-version.mjs +48 -0
  98. package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
  99. package/es/tx/builder/field-types/deposit.d.ts +1 -1
  100. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  101. package/es/tx/builder/field-types/encoded.d.ts +6 -0
  102. package/es/tx/builder/field-types/encoded.mjs +21 -0
  103. package/es/tx/builder/field-types/encoded.mjs.map +1 -0
  104. package/es/tx/builder/field-types/entry.d.ts +11 -0
  105. package/es/tx/builder/field-types/entry.mjs +31 -0
  106. package/es/tx/builder/field-types/entry.mjs.map +1 -0
  107. package/es/tx/builder/field-types/enumeration.d.ts +5 -3
  108. package/es/tx/builder/field-types/enumeration.mjs +11 -2
  109. package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
  110. package/es/tx/builder/field-types/fee.d.ts +10 -7
  111. package/es/tx/builder/field-types/fee.mjs +24 -20
  112. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  113. package/es/tx/builder/field-types/gas-limit.d.ts +5 -2
  114. package/es/tx/builder/field-types/gas-limit.mjs +9 -6
  115. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  116. package/es/tx/builder/field-types/gas-price.d.ts +1 -1
  117. package/es/tx/builder/field-types/index.d.ts +66 -28
  118. package/es/tx/builder/field-types/index.mjs +30 -12
  119. package/es/tx/builder/field-types/index.mjs.map +1 -1
  120. package/es/tx/builder/field-types/mptree.d.ts +37 -0
  121. package/es/tx/builder/field-types/mptree.mjs +268 -0
  122. package/es/tx/builder/field-types/mptree.mjs.map +1 -0
  123. package/es/tx/builder/field-types/name-fee.d.ts +1 -2
  124. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  125. package/es/tx/builder/field-types/name-id.mjs +2 -1
  126. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  127. package/es/tx/builder/field-types/pointers.mjs +2 -2
  128. package/es/tx/builder/field-types/pointers.mjs.map +1 -1
  129. package/es/tx/builder/field-types/raw.d.ts +6 -0
  130. package/es/tx/builder/field-types/raw.mjs +13 -0
  131. package/es/tx/builder/field-types/raw.mjs.map +1 -0
  132. package/es/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  133. package/es/tx/builder/field-types/short-u-int-const.mjs +16 -0
  134. package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
  135. package/es/tx/builder/field-types/string.d.ts +6 -0
  136. package/es/tx/builder/field-types/string.mjs +10 -0
  137. package/es/tx/builder/field-types/string.mjs.map +1 -0
  138. package/es/tx/builder/field-types/u-int.d.ts +1 -2
  139. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  140. package/es/tx/builder/index.d.ts +11 -29
  141. package/es/tx/builder/index.mjs +50 -211
  142. package/es/tx/builder/index.mjs.map +1 -1
  143. package/es/tx/builder/schema.d.ts +2111 -571
  144. package/es/tx/builder/schema.mjs +57 -125
  145. package/es/tx/builder/schema.mjs.map +1 -1
  146. package/es/tx/index.d.ts +5 -20
  147. package/es/tx/index.mjs +31 -88
  148. package/es/tx/index.mjs.map +1 -1
  149. package/es/tx/validator.d.ts +3 -5
  150. package/es/tx/validator.mjs +82 -95
  151. package/es/tx/validator.mjs.map +1 -1
  152. package/es/utils/bytes.mjs +1 -1
  153. package/es/utils/bytes.mjs.map +1 -1
  154. package/es/utils/errors.d.ts +3 -8
  155. package/es/utils/errors.mjs +1 -11
  156. package/es/utils/errors.mjs.map +1 -1
  157. package/es/utils/other.d.ts +1 -1
  158. package/package.json +35 -27
  159. package/src/AeSdkBase.ts +6 -3
  160. package/src/AeSdkMethods.ts +3 -4
  161. package/src/Node.ts +6 -3
  162. package/src/account/Base.ts +2 -2
  163. package/src/account/Generalized.ts +2 -2
  164. package/src/account/Ledger.ts +1 -1
  165. package/src/account/Memory.ts +1 -1
  166. package/src/aens.ts +3 -2
  167. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +18 -7
  168. package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
  169. package/src/chain.ts +5 -3
  170. package/src/channel/Base.ts +13 -5
  171. package/src/channel/Contract.ts +11 -10
  172. package/src/channel/Spend.ts +7 -2
  173. package/src/channel/handlers.ts +10 -9
  174. package/src/channel/internal.ts +1 -1
  175. package/src/contract/Contract.ts +69 -79
  176. package/src/contract/compiler/Base.ts +94 -0
  177. package/src/contract/compiler/Cli.ts +134 -0
  178. package/src/contract/compiler/Http.ts +124 -0
  179. package/src/contract/compiler/HttpNode.ts +26 -0
  180. package/src/contract/compiler/getFileSystem.ts +42 -0
  181. package/src/contract/ga.ts +9 -6
  182. package/src/index-browser.ts +58 -0
  183. package/src/index.ts +4 -56
  184. package/src/oracle.ts +1 -1
  185. package/src/spend.ts +1 -1
  186. package/src/tx/builder/constants.ts +32 -3
  187. package/src/tx/builder/field-types/abi-version.ts +21 -0
  188. package/src/tx/builder/field-types/address.ts +23 -13
  189. package/src/tx/builder/field-types/array.ts +19 -0
  190. package/src/tx/builder/field-types/boolean.ts +9 -0
  191. package/src/tx/builder/field-types/coin-amount.ts +2 -1
  192. package/src/tx/builder/field-types/ct-version.ts +50 -0
  193. package/src/tx/builder/field-types/deposit.ts +1 -1
  194. package/src/tx/builder/field-types/encoded.ts +27 -0
  195. package/src/tx/builder/field-types/entry.ts +31 -0
  196. package/src/tx/builder/field-types/enumeration.ts +15 -4
  197. package/src/tx/builder/field-types/fee.ts +38 -18
  198. package/src/tx/builder/field-types/gas-limit.ts +12 -7
  199. package/src/tx/builder/field-types/index.ts +46 -17
  200. package/src/tx/builder/field-types/mptree.ts +242 -0
  201. package/src/tx/builder/field-types/name-fee.ts +1 -2
  202. package/src/tx/builder/field-types/name-id.ts +1 -1
  203. package/src/tx/builder/field-types/pointers.ts +2 -2
  204. package/src/tx/builder/field-types/raw.ts +9 -0
  205. package/src/tx/builder/field-types/short-u-int-const.ts +20 -0
  206. package/src/tx/builder/field-types/string.ts +11 -0
  207. package/src/tx/builder/field-types/u-int.ts +1 -3
  208. package/src/tx/builder/index.ts +63 -247
  209. package/src/tx/builder/schema.ts +273 -323
  210. package/src/tx/index.ts +37 -104
  211. package/src/tx/validator.ts +72 -95
  212. package/src/utils/bytes.ts +1 -1
  213. package/src/utils/errors.ts +4 -13
  214. package/types-legacy/ts4.2/AeSdkBase.d.ts +3 -3
  215. package/types-legacy/ts4.2/AeSdkMethods.d.ts +3 -4
  216. package/types-legacy/ts4.2/Node.d.ts +3 -3
  217. package/types-legacy/ts4.2/account/Base.d.ts +2 -2
  218. package/types-legacy/ts4.2/aens.d.ts +1 -1
  219. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  220. package/types-legacy/ts4.2/chain.d.ts +9 -1
  221. package/types-legacy/ts4.2/channel/Base.d.ts +6 -1
  222. package/types-legacy/ts4.2/channel/Contract.d.ts +8 -7
  223. package/types-legacy/ts4.2/channel/Spend.d.ts +3 -1
  224. package/types-legacy/ts4.2/contract/Contract.d.ts +21 -46
  225. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +81 -0
  226. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
  227. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
  228. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
  229. package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
  230. package/types-legacy/ts4.2/contract/ga.d.ts +5 -4
  231. package/types-legacy/ts4.2/index-browser.d.ts +39 -0
  232. package/types-legacy/ts4.2/index.d.ts +4 -38
  233. package/types-legacy/ts4.2/tx/builder/constants.d.ts +28 -1
  234. package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +10 -0
  235. package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +11 -12
  236. package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
  237. package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
  238. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +1 -1
  239. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +42 -0
  240. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +1 -1
  241. package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
  242. package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
  243. package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -3
  244. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +10 -7
  245. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +5 -2
  246. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +1 -1
  247. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +72 -28
  248. package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +43 -0
  249. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +1 -2
  250. package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
  251. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  252. package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
  253. package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +1 -2
  254. package/types-legacy/ts4.2/tx/builder/index.d.ts +11 -29
  255. package/types-legacy/ts4.2/tx/builder/schema.d.ts +2380 -668
  256. package/types-legacy/ts4.2/tx/index.d.ts +5 -20
  257. package/types-legacy/ts4.2/tx/validator.d.ts +3 -5
  258. package/types-legacy/ts4.2/utils/errors.d.ts +3 -8
  259. package/types-legacy/ts4.2/utils/other.d.ts +1 -1
  260. package/types-legacy/ts4.5/AeSdkBase.d.ts +3 -3
  261. package/types-legacy/ts4.5/AeSdkMethods.d.ts +3 -4
  262. package/types-legacy/ts4.5/Node.d.ts +3 -3
  263. package/types-legacy/ts4.5/account/Base.d.ts +2 -2
  264. package/types-legacy/ts4.5/aens.d.ts +1 -1
  265. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  266. package/types-legacy/ts4.5/chain.d.ts +9 -1
  267. package/types-legacy/ts4.5/channel/Base.d.ts +6 -1
  268. package/types-legacy/ts4.5/channel/Contract.d.ts +8 -7
  269. package/types-legacy/ts4.5/channel/Spend.d.ts +3 -1
  270. package/types-legacy/ts4.5/contract/Contract.d.ts +21 -46
  271. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +81 -0
  272. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
  273. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
  274. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
  275. package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
  276. package/types-legacy/ts4.5/contract/ga.d.ts +5 -4
  277. package/types-legacy/ts4.5/index-browser.d.ts +39 -0
  278. package/types-legacy/ts4.5/index.d.ts +4 -38
  279. package/types-legacy/ts4.5/tx/builder/constants.d.ts +28 -1
  280. package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +10 -0
  281. package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +11 -12
  282. package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
  283. package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
  284. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +1 -1
  285. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +42 -0
  286. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +1 -1
  287. package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
  288. package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
  289. package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -3
  290. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +10 -7
  291. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +5 -2
  292. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +1 -1
  293. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +72 -28
  294. package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +43 -0
  295. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +1 -2
  296. package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
  297. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  298. package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
  299. package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +1 -2
  300. package/types-legacy/ts4.5/tx/builder/index.d.ts +11 -29
  301. package/types-legacy/ts4.5/tx/builder/schema.d.ts +2380 -668
  302. package/types-legacy/ts4.5/tx/index.d.ts +5 -20
  303. package/types-legacy/ts4.5/tx/validator.d.ts +3 -5
  304. package/types-legacy/ts4.5/utils/errors.d.ts +3 -8
  305. package/types-legacy/ts4.5/utils/other.d.ts +1 -1
  306. package/es/contract/CompilerHttp.d.ts +0 -18
  307. package/es/contract/CompilerHttp.mjs.map +0 -1
  308. package/es/tx/builder/field-types/addresses.d.ts +0 -6
  309. package/es/tx/builder/field-types/addresses.mjs +0 -13
  310. package/es/tx/builder/field-types/addresses.mjs.map +0 -1
  311. package/es/utils/mptree.d.ts +0 -26
  312. package/es/utils/mptree.mjs +0 -143
  313. package/es/utils/mptree.mjs.map +0 -1
  314. package/src/contract/CompilerHttp.ts +0 -67
  315. package/src/tx/builder/field-types/addresses.ts +0 -18
  316. package/src/utils/mptree.ts +0 -145
  317. package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +0 -18
  318. package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +0 -6
  319. package/types-legacy/ts4.2/utils/mptree.d.ts +0 -32
  320. package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +0 -18
  321. package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +0 -6
  322. package/types-legacy/ts4.5/utils/mptree.d.ts +0 -32
@@ -0,0 +1,48 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import { ConsensusProtocolVersion, VmVersion, AbiVersion } from "../constants.mjs"; // First abi/vm by default
6
+ export const ProtocolToVmAbi = {
7
+ [ConsensusProtocolVersion.Iris]: {
8
+ 'contract-create': {
9
+ vmVersion: [VmVersion.Fate2],
10
+ abiVersion: [AbiVersion.Fate]
11
+ },
12
+ // TODO: Ensure that AEVM (Sophia?) is still available here
13
+ 'contract-call': {
14
+ vmVersion: [],
15
+ abiVersion: [AbiVersion.Fate, AbiVersion.Sophia]
16
+ },
17
+ 'oracle-call': {
18
+ vmVersion: [],
19
+ abiVersion: [AbiVersion.NoAbi, AbiVersion.Sophia]
20
+ }
21
+ }
22
+ };
23
+ export function getProtocolDetails(protocolVersion, type) {
24
+ var _protocol$vmVersion$;
25
+ const protocol = ProtocolToVmAbi[protocolVersion][type];
26
+ return {
27
+ vmVersion: (_protocol$vmVersion$ = protocol.vmVersion[0]) !== null && _protocol$vmVersion$ !== void 0 ? _protocol$vmVersion$ : VmVersion.Fate2,
28
+ abiVersion: protocol.abiVersion[0]
29
+ };
30
+ }
31
+ export default {
32
+ serialize(value, _ref) {
33
+ var _value;
34
+ let {
35
+ consensusProtocolVersion = ConsensusProtocolVersion.Iris
36
+ } = _ref;
37
+ (_value = value) !== null && _value !== void 0 ? _value : value = getProtocolDetails(consensusProtocolVersion, 'contract-create');
38
+ return _Buffer.from([value.vmVersion, 0, value.abiVersion]);
39
+ },
40
+ deserialize(buffer) {
41
+ const [vm,, abi] = buffer;
42
+ return {
43
+ vmVersion: +vm,
44
+ abiVersion: +abi
45
+ };
46
+ }
47
+ };
48
+ //# 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","getProtocolDetails","protocolVersion","type","protocol","serialize","value","consensusProtocolVersion","from","deserialize","buffer","vm","abi"],"sources":["../../../../src/tx/builder/field-types/ct-version.ts"],"sourcesContent":["import { ConsensusProtocolVersion, VmVersion, AbiVersion } from '../constants';\n\n// First abi/vm by default\nexport const ProtocolToVmAbi = {\n [ConsensusProtocolVersion.Iris]: {\n 'contract-create': {\n vmVersion: [VmVersion.Fate2], abiVersion: [AbiVersion.Fate],\n },\n // TODO: Ensure that AEVM (Sophia?) is still available here\n 'contract-call': {\n vmVersion: [], abiVersion: [AbiVersion.Fate, AbiVersion.Sophia],\n },\n 'oracle-call': {\n vmVersion: [], abiVersion: [AbiVersion.NoAbi, AbiVersion.Sophia],\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 { 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 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,4BAExD;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;IACA,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,CAACO,MAAM;IACjE;EACF;AACF,CAAU;AAOV,OAAO,SAASE,kBAAkB,CAChCC,eAAyC,EACzCC,IAAyD,EAC9C;EAAA;EACX,MAAMC,QAAQ,GAAGX,eAAe,CAACS,eAAe,CAAC,CAACC,IAAI,CAAC;EACvD,OAAO;IACLR,SAAS,0BAAES,QAAQ,CAACT,SAAS,CAAC,CAAC,CAAC,uEAAIJ,SAAS,CAACK,KAAK;IACnDC,UAAU,EAAEO,QAAQ,CAACP,UAAU,CAAC,CAAC;EACnC,CAAC;AACH;AAEA,eAAe;EACbQ,SAAS,CACPC,KAA4B,QAGpB;IAAA;IAAA,IAFR;MAAEC,wBAAwB,GAAGjB,wBAAwB,CAACI;IACD,CAAC;IAEtD,UAAAY,KAAK,2CAALA,KAAK,GAAKL,kBAAkB,CAACM,wBAAwB,EAAE,iBAAiB,CAAC;IAEzE,OAAO,QAAOC,IAAI,CAAC,CAACF,KAAK,CAACX,SAAS,EAAE,CAAC,EAAEW,KAAK,CAACT,UAAU,CAAC,CAAC;EAC5D,CAAC;EAEDY,WAAW,CAACC,MAAc,EAAa;IACrC,MAAM,CAACC,EAAE,GAAIC,GAAG,CAAC,GAAGF,MAAM;IAC1B,OAAO;MAAEf,SAAS,EAAE,CAACgB,EAAE;MAAEd,UAAU,EAAE,CAACe;IAAI,CAAC;EAC7C;AACF,CAAC"}
@@ -1,6 +1,6 @@
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'.
@@ -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","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 * @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"}
@@ -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<Encoding>;
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","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<Encoding>;\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,eAAe,CACrCC,QAAW,EACXC,QAAmB,EAKjB;EACF,OAAO;IACLC,SAAS,CAACC,WAAgC,EAAE;MAC1C,IAAIA,WAAW,IAAI,IAAI,EAAE;QACvB,IAAIF,QAAQ,KAAK,IAAI,EAAE,OAAO,QAAOG,IAAI,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAIN,aAAa,CAAC,cAAc,EAAE,UAAU,EAAEK,WAAW,CAAC;MAClE;MACA,OAAOP,MAAM,CAACO,WAAW,CAAC;IAC5B,CAAC;IAEDE,WAAW,CAACC,MAAM,EAAE;MAClB,OAAOT,MAAM,CAACS,MAAM,EAAEN,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,31 @@
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
+ return decode(buildTx({
15
+ ...txParams,
16
+ ...(tag != null && {
17
+ tag
18
+ })
19
+ }));
20
+ },
21
+ deserialize(buf, _ref2) {
22
+ let {
23
+ unpackTx
24
+ } = _ref2;
25
+ const tx = unpackTx(encode(buf, Encoding.Transaction));
26
+ if (tag != null && tx.tag !== tag) throw new ArgumentError('Tag', tag, tx.tag);
27
+ return tx;
28
+ }
29
+ };
30
+ }
31
+ //# sourceMappingURL=entry.mjs.map
@@ -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"}
@@ -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","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,17 +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
+ 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, { denomination, ...options }: import("./coin-amount").Options): Buffer;
15
18
  deserialize(value: Buffer): string;
16
19
  };
17
20
  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,45 @@ 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
+ 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
97
99
  })).times(MIN_GAS_PRICE);
98
100
  }
99
101
 
100
102
  /**
101
103
  * Calculate min fee
102
104
  * @category transaction builder
103
- * @param txType - Transaction type
104
105
  * @param rebuildTx - Callback to get built transaction with specific fee
105
106
  */
106
- function calculateMinFee(txType, rebuildTx) {
107
+ function calculateMinFee(rebuildTx, unpackTx, buildTx) {
107
108
  let fee = new BigNumber(0);
108
109
  let previousFee;
109
110
  do {
110
111
  previousFee = fee;
111
- fee = buildFee(txType, rebuildTx(fee));
112
+ fee = buildFee(rebuildTx(fee), unpackTx, buildTx);
112
113
  } while (!fee.eq(previousFee));
113
114
  return fee;
114
115
  }
@@ -116,16 +117,19 @@ export default {
116
117
  ...coinAmount,
117
118
  serializeAettos(_value, _ref2) {
118
119
  let {
119
- txType,
120
120
  rebuildTx,
121
- _computingMinFee
121
+ unpackTx,
122
+ buildTx,
123
+ _computingMinFee,
124
+ _pickBiggerFee
122
125
  } = _ref2;
123
- if (_computingMinFee != null) return _computingMinFee;
124
- const minFee = calculateMinFee(txType, fee => rebuildTx({
126
+ if (_computingMinFee != null) return _computingMinFee.toFixed();
127
+ const minFee = calculateMinFee(fee => rebuildTx({
125
128
  _computingMinFee: fee
126
- }));
129
+ }), unpackTx, buildTx);
127
130
  const value = new BigNumber(_value !== null && _value !== void 0 ? _value : minFee);
128
131
  if (minFee.gt(value)) {
132
+ if (_pickBiggerFee === true) return minFee.toFixed();
129
133
  throw new IllegalArgumentError(`Fee ${value.toString()} must be bigger then ${minFee}`);
130
134
  }
131
135
  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,MAA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,GACzDoC,QAAQ,CAACE,EAAE,CAACA,EAAE,CAACC,SAAS,CAACL,UAAU,CAACC,MAAM,GAC1C;EACN,CAAC,CAAC,CAAC,CACFZ,KAAK,CAAC/B,aAAa,CAAC;AACzB;;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","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,cAA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M,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"}
@@ -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;
@@ -2,22 +2,25 @@ import { IllegalArgumentError } from "../../../utils/errors.mjs";
2
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
- function calculateGasLimitMax(txType, gasMax, rebuildTx) {
6
- 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);
7
7
  }
8
8
  export default {
9
9
  ...shortUInt,
10
10
  serialize(_value, _ref) {
11
11
  let {
12
- txType,
12
+ tag,
13
13
  rebuildTx,
14
+ unpackTx,
15
+ buildTx,
14
16
  gasMax = 6e6,
15
17
  _computingGasLimit
16
18
  } = _ref;
17
19
  if (_computingGasLimit != null) return shortUInt.serialize(_computingGasLimit);
18
- const gasLimitMax = txType === Tag.GaMetaTx ? MAX_AUTH_FUN_GAS : calculateGasLimitMax(txType, gasMax, gasLimit => rebuildTx({
19
- _computingGasLimit: gasLimit
20
- }));
20
+ const gasLimitMax = tag === Tag.GaMetaTx ? MAX_AUTH_FUN_GAS : calculateGasLimitMax(gasMax, gasLimit => rebuildTx({
21
+ _computingGasLimit: gasLimit,
22
+ _pickBiggerFee: true
23
+ }), unpackTx, buildTx);
21
24
  const value = _value !== null && _value !== void 0 ? _value : gasLimitMax;
22
25
  if (value > gasLimitMax) {
23
26
  throw new IllegalArgumentError(`Gas limit ${value} must be less or equal to ${gasLimitMax}`);
@@ -1 +1 @@
1
- {"version":3,"file":"gas-limit.mjs","names":["IllegalArgumentError","MIN_GAS_PRICE","Tag","MAX_AUTH_FUN_GAS","shortUInt","buildFee","calculateGasLimitMax","txType","gasMax","rebuildTx","dividedBy","serialize","_value","_computingGasLimit","gasLimitMax","GaMetaTx","gasLimit","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';\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 = txType === Tag.GaMetaTx ? MAX_AUTH_FUN_GAS : 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,oBAAoB;AAAA,SACpBC,aAAa,EAAEC,GAAG,EAAEC,gBAAgB;AAAA,OACtCC,SAAS;AAAA,SACPC,QAAQ;AAEjB,SAASC,oBAAoB,CAC3BC,MAAW,EACXC,MAAc,EACdC,SAAiC,EACzB;EACR,OAAOD,MAAM,GAAG,CAACH,QAAQ,CAACE,MAAM,EAAEE,SAAS,CAACD,MAAM,CAAC,CAAC,CAACE,SAAS,CAACT,aAAa,CAAC;AAC/E;AAEA,eAAe;EACb,GAAGG,SAAS;EAEZO,SAAS,CACPC,MAA0B,QASlB;IAAA,IARR;MACEL,MAAM;MAAEE,SAAS;MAAED,MAAM,GAAG,GAAG;MAAEK;IAMnC,CAAC;IAED,IAAIA,kBAAkB,IAAI,IAAI,EAAE,OAAOT,SAAS,CAACO,SAAS,CAACE,kBAAkB,CAAC;IAE9E,MAAMC,WAAW,GAAGP,MAAM,KAAKL,GAAG,CAACa,QAAQ,GAAGZ,gBAAgB,GAAGG,oBAAoB,CACnFC,MAAM,EACNC,MAAM,EACLQ,QAAQ,IAAKP,SAAS,CAAC;MAAEI,kBAAkB,EAAEG;IAAS,CAAC,CAAC,CAC1D;IACD,MAAMC,KAAK,GAAGL,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIE,WAAW;IACnC,IAAIG,KAAK,GAAGH,WAAW,EAAE;MACvB,MAAM,IAAId,oBAAoB,CAAE,aAAYiB,KAAM,6BAA4BH,WAAY,EAAC,CAAC;IAC9F;IACA,OAAOV,SAAS,CAACO,SAAS,CAACM,KAAK,CAAC;EACnC;AACF,CAAC"}
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,7 +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;
4
+ serialize(value: import("../constants").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
5
5
  deserialize(value: Buffer): string;
6
6
  };
7
7
  export default _default;
@@ -1,45 +1,64 @@
1
1
  /// <reference types="node" />
2
2
  import _address from './address';
3
- import _addresses from './addresses';
3
+ import _array from './array';
4
+ import _encoded from './encoded';
5
+ import _entry from './entry';
4
6
  import _enumeration from './enumeration';
5
- declare const field: {
6
- serialize(value: string): Buffer;
7
- deserialize(value: Buffer): string;
8
- };
9
- declare const uInt: {
10
- serialize(value: import("./u-int").Int): Buffer;
11
- deserialize(value: Buffer): string;
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;
12
15
  };
13
- declare const shortUInt: {
14
- serialize(value: number): Buffer;
15
- 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;
16
21
  };
17
22
  declare const coinAmount: {
18
23
  serializeAettos(value: string | undefined): string;
19
- serialize(value: import("./u-int").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
24
+ serialize(value: import("../constants").Int | undefined, { denomination, ...options }: import("./coin-amount").Options): Buffer;
20
25
  deserialize(value: Buffer): string;
21
26
  };
22
- declare const address: typeof _address;
23
- declare const addresses: typeof _addresses;
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
+ };
24
33
  declare const deposit: {
25
- 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;
26
35
  serializeAettos(value: string | undefined): string;
27
36
  deserialize(value: Buffer): string;
28
37
  };
38
+ declare const encoded: typeof _encoded;
39
+ declare const entry: typeof _entry;
29
40
  declare const enumeration: typeof _enumeration;
30
41
  declare const fee: {
31
- serializeAettos(_value: string | undefined, { txType, rebuildTx, _computingMinFee }: {
32
- txType: import("../constants").Tag;
33
- rebuildTx: (params: any) => any;
34
- _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;
35
48
  }): string;
36
- serialize(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;
37
54
  deserialize(value: Buffer): string;
38
55
  };
39
56
  declare const gasLimit: {
40
- serialize(_value: number | undefined, { txType, rebuildTx, gasMax, _computingGasLimit, }: {
41
- txType: import("../constants").Tag;
57
+ serialize(_value: number | undefined, { tag, rebuildTx, unpackTx, buildTx, gasMax, _computingGasLimit, }: {
58
+ tag: import("../constants").Tag;
42
59
  rebuildTx: (params: any) => any;
60
+ unpackTx: typeof import("..").unpackTx;
61
+ buildTx: typeof import("..").buildTx;
43
62
  gasMax: number;
44
63
  _computingGasLimit?: number | undefined;
45
64
  }): Buffer;
@@ -47,9 +66,10 @@ declare const gasLimit: {
47
66
  };
48
67
  declare const gasPrice: {
49
68
  serializeAettos(value?: string | undefined): string;
50
- serialize(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;
51
70
  deserialize(value: Buffer): string;
52
71
  };
72
+ declare const mptree: typeof _mptree;
53
73
  declare const name: {
54
74
  serialize(value: `${string}.chain`): Buffer;
55
75
  deserialize(value: Buffer): `${string}.chain`;
@@ -58,13 +78,13 @@ declare const nameFee: {
58
78
  serializeAettos(_value: string | undefined, txFields: {
59
79
  name: `${string}.chain`;
60
80
  }): string;
61
- serialize(value: import("./u-int").Int | undefined, txFields: {
81
+ serialize(value: import("../constants").Int | undefined, txFields: {
62
82
  name: `${string}.chain`;
63
83
  } & import("./coin-amount").Options): Buffer;
64
84
  deserialize(value: Buffer): string;
65
85
  };
66
86
  declare const nameId: {
67
- serialize(value: `nm_${string}` | `${string}.chain`): Buffer;
87
+ serialize(value: `${string}.chain` | `nm_${string}`): Buffer;
68
88
  deserialize: (value: Buffer) => `nm_${string}`;
69
89
  };
70
90
  declare const pointers: {
@@ -75,8 +95,26 @@ declare const pointers: {
75
95
  id: `ch_${string}` | `ct_${string}` | `ok_${string}` | `ak_${string}` | `cm_${string}` | `nm_${string}`;
76
96
  })[];
77
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;
114
+ };
115
+ export type BinaryData = Buffer | Buffer[] | Buffer[][] | Array<[Buffer, Array<[Buffer, Buffer[]]>]>;
78
116
  export interface Field {
79
- serialize: (value: any, options: any) => Buffer | Buffer[] | Buffer[][];
80
- deserialize: (value: Buffer | Buffer[] | Buffer[][]) => any;
117
+ serialize: (value: any, options: any) => BinaryData;
118
+ deserialize: (value: BinaryData, options: any) => any;
81
119
  }
82
- export { field, uInt, shortUInt, coinAmount, address, addresses, deposit, enumeration, fee, gasLimit, gasPrice, name, nameFee, nameId, pointers, };
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, };