@aeternity/aepp-sdk 13.0.0-alpha.0 → 13.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (481) hide show
  1. package/bin/aesophia_cli +0 -0
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.map +1 -1
  4. package/dist/aepp-sdk.browser.js +1 -1
  5. package/dist/aepp-sdk.browser.js.map +1 -1
  6. package/dist/aepp-sdk.js +5595 -2249
  7. package/dist/aepp-sdk.js.map +1 -1
  8. package/es/AeSdk.mjs.map +1 -1
  9. package/es/AeSdkAepp.mjs.map +1 -1
  10. package/es/AeSdkBase.d.ts +3 -3
  11. package/es/AeSdkBase.mjs +4 -0
  12. package/es/AeSdkBase.mjs.map +1 -1
  13. package/es/AeSdkMethods.d.ts +12 -14
  14. package/es/AeSdkMethods.mjs +6 -8
  15. package/es/AeSdkMethods.mjs.map +1 -1
  16. package/es/AeSdkWallet.mjs +1 -1
  17. package/es/AeSdkWallet.mjs.map +1 -1
  18. package/es/Node.d.ts +9 -4
  19. package/es/Node.mjs +12 -6
  20. package/es/Node.mjs.map +1 -1
  21. package/es/account/Base.d.ts +13 -8
  22. package/es/account/Base.mjs +0 -17
  23. package/es/account/Base.mjs.map +1 -1
  24. package/es/account/Generalized.mjs +14 -25
  25. package/es/account/Generalized.mjs.map +1 -1
  26. package/es/account/Ledger.mjs +2 -1
  27. package/es/account/Ledger.mjs.map +1 -1
  28. package/es/account/LedgerFactory.mjs.map +1 -1
  29. package/es/account/Memory.d.ts +2 -1
  30. package/es/account/Memory.mjs +11 -22
  31. package/es/account/Memory.mjs.map +1 -1
  32. package/es/account/Rpc.mjs.map +1 -1
  33. package/es/aens.d.ts +12 -14
  34. package/es/aens.mjs +22 -32
  35. package/es/aens.mjs.map +1 -1
  36. package/es/aepp-wallet-communication/connection/Browser.mjs +0 -16
  37. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  38. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  39. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +19 -20
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  41. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -16
  42. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  43. package/es/aepp-wallet-communication/connection-proxy.mjs +0 -17
  44. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  45. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -6
  46. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  47. package/es/aepp-wallet-communication/rpc/types.d.ts +6 -2
  48. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  49. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  50. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -16
  51. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  52. package/es/apis/compiler/compiler.d.ts +1 -1
  53. package/es/apis/compiler/compiler.mjs +4 -20
  54. package/es/apis/compiler/compiler.mjs.map +1 -1
  55. package/es/apis/compiler/models/index.d.ts +3 -2
  56. package/es/apis/compiler/models/index.mjs.map +1 -1
  57. package/es/apis/compiler/models/mappers.d.ts +1 -1
  58. package/es/apis/compiler/models/mappers.mjs +19 -2
  59. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  60. package/es/apis/node/models/index.d.ts +15 -15
  61. package/es/apis/node/models/index.mjs.map +1 -1
  62. package/es/apis/node/models/mappers.d.ts +1 -1
  63. package/es/apis/node/models/mappers.mjs +2 -1
  64. package/es/apis/node/models/mappers.mjs.map +1 -1
  65. package/es/apis/node/models/parameters.d.ts +2 -2
  66. package/es/apis/node/models/parameters.mjs +2 -2
  67. package/es/apis/node/models/parameters.mjs.map +1 -1
  68. package/es/apis/node/node.mjs +3 -19
  69. package/es/apis/node/node.mjs.map +1 -1
  70. package/es/chain.d.ts +17 -9
  71. package/es/chain.mjs +23 -23
  72. package/es/chain.mjs.map +1 -1
  73. package/es/channel/Base.d.ts +27 -9
  74. package/es/channel/Base.mjs +27 -27
  75. package/es/channel/Base.mjs.map +1 -1
  76. package/es/channel/Contract.d.ts +8 -7
  77. package/es/channel/Contract.mjs +8 -21
  78. package/es/channel/Contract.mjs.map +1 -1
  79. package/es/channel/Spend.d.ts +5 -1
  80. package/es/channel/Spend.mjs +4 -18
  81. package/es/channel/Spend.mjs.map +1 -1
  82. package/es/channel/handlers.mjs +16 -26
  83. package/es/channel/handlers.mjs.map +1 -1
  84. package/es/channel/internal.d.ts +19 -2
  85. package/es/channel/internal.mjs +22 -20
  86. package/es/channel/internal.mjs.map +1 -1
  87. package/es/contract/Contract.d.ts +43 -123
  88. package/es/contract/Contract.mjs +230 -250
  89. package/es/contract/Contract.mjs.map +1 -1
  90. package/es/contract/compiler/Base.d.ts +74 -0
  91. package/es/contract/compiler/Base.mjs +5 -0
  92. package/es/contract/compiler/Base.mjs.map +1 -0
  93. package/es/contract/compiler/Cli.d.ts +23 -0
  94. package/es/contract/compiler/Cli.mjs +149 -0
  95. package/es/contract/compiler/Cli.mjs.map +1 -0
  96. package/es/contract/compiler/Http.d.ts +32 -0
  97. package/es/contract/compiler/Http.mjs +94 -0
  98. package/es/contract/compiler/Http.mjs.map +1 -0
  99. package/es/contract/compiler/HttpNode.d.ts +17 -0
  100. package/es/contract/compiler/HttpNode.mjs +26 -0
  101. package/es/contract/compiler/HttpNode.mjs.map +1 -0
  102. package/es/contract/compiler/getFileSystem.d.ts +6 -0
  103. package/es/contract/compiler/getFileSystem.mjs +40 -0
  104. package/es/contract/compiler/getFileSystem.mjs.map +1 -0
  105. package/es/contract/delegation-signature.d.ts +43 -0
  106. package/es/contract/delegation-signature.mjs +45 -0
  107. package/es/contract/delegation-signature.mjs.map +1 -0
  108. package/es/contract/ga.d.ts +27 -10
  109. package/es/contract/ga.mjs +63 -29
  110. package/es/contract/ga.mjs.map +1 -1
  111. package/es/index-browser.d.ts +40 -0
  112. package/es/index-browser.mjs +41 -0
  113. package/es/index-browser.mjs.map +1 -0
  114. package/es/index.d.ts +4 -38
  115. package/es/index.mjs +4 -53
  116. package/es/index.mjs.map +1 -1
  117. package/es/oracle.d.ts +12 -17
  118. package/es/oracle.mjs +29 -49
  119. package/es/oracle.mjs.map +1 -1
  120. package/es/spend.d.ts +19 -27
  121. package/es/spend.mjs +21 -46
  122. package/es/spend.mjs.map +1 -1
  123. package/es/tx/builder/SchemaTypes.d.ts +37 -0
  124. package/es/tx/builder/SchemaTypes.mjs +2 -0
  125. package/es/tx/builder/SchemaTypes.mjs.map +1 -0
  126. package/es/tx/builder/constants.d.ts +31 -2
  127. package/es/tx/builder/constants.mjs +34 -3
  128. package/es/tx/builder/constants.mjs.map +1 -1
  129. package/es/tx/builder/field-types/abi-version.d.ts +19 -0
  130. package/es/tx/builder/field-types/abi-version.mjs +40 -0
  131. package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
  132. package/es/tx/builder/field-types/address.d.ts +5 -6
  133. package/es/tx/builder/field-types/address.mjs +17 -8
  134. package/es/tx/builder/field-types/address.mjs.map +1 -1
  135. package/es/tx/builder/field-types/array.d.ts +7 -0
  136. package/es/tx/builder/field-types/array.mjs +11 -0
  137. package/es/tx/builder/field-types/array.mjs.map +1 -0
  138. package/es/tx/builder/field-types/boolean.d.ts +6 -0
  139. package/es/tx/builder/field-types/boolean.mjs +13 -0
  140. package/es/tx/builder/field-types/boolean.mjs.map +1 -0
  141. package/es/tx/builder/field-types/coin-amount.d.ts +4 -5
  142. package/es/tx/builder/field-types/coin-amount.mjs +4 -5
  143. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  144. package/es/tx/builder/field-types/ct-version.d.ts +49 -0
  145. package/es/tx/builder/field-types/ct-version.mjs +76 -0
  146. package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
  147. package/es/tx/builder/field-types/deposit.d.ts +3 -2
  148. package/es/tx/builder/field-types/deposit.mjs +3 -2
  149. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  150. package/es/tx/builder/field-types/encoded.d.ts +6 -0
  151. package/es/tx/builder/field-types/encoded.mjs +21 -0
  152. package/es/tx/builder/field-types/encoded.mjs.map +1 -0
  153. package/es/tx/builder/field-types/entry.d.ts +11 -0
  154. package/es/tx/builder/field-types/entry.mjs +34 -0
  155. package/es/tx/builder/field-types/entry.mjs.map +1 -0
  156. package/es/tx/builder/field-types/enumeration.d.ts +5 -3
  157. package/es/tx/builder/field-types/enumeration.mjs +11 -2
  158. package/es/tx/builder/field-types/enumeration.mjs.map +1 -1
  159. package/es/tx/builder/field-types/fee.d.ts +12 -7
  160. package/es/tx/builder/field-types/fee.mjs +28 -20
  161. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  162. package/es/tx/builder/field-types/field.mjs.map +1 -1
  163. package/es/tx/builder/field-types/gas-limit.d.ts +7 -3
  164. package/es/tx/builder/field-types/gas-limit.mjs +13 -8
  165. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  166. package/es/tx/builder/field-types/gas-price.d.ts +3 -1
  167. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  168. package/es/tx/builder/field-types/index.d.ts +107 -30
  169. package/es/tx/builder/field-types/index.mjs +38 -12
  170. package/es/tx/builder/field-types/index.mjs.map +1 -1
  171. package/es/tx/builder/field-types/map.d.ts +13 -0
  172. package/es/tx/builder/field-types/map.mjs +49 -0
  173. package/es/tx/builder/field-types/map.mjs.map +1 -0
  174. package/es/tx/builder/field-types/mptree.d.ts +42 -0
  175. package/es/tx/builder/field-types/mptree.mjs +266 -0
  176. package/es/tx/builder/field-types/mptree.mjs.map +1 -0
  177. package/es/tx/builder/field-types/name-fee.d.ts +2 -3
  178. package/es/tx/builder/field-types/name-fee.mjs +2 -2
  179. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  180. package/es/tx/builder/field-types/name-id.mjs +2 -1
  181. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  182. package/es/tx/builder/field-types/name.mjs.map +1 -1
  183. package/es/tx/builder/field-types/nonce.d.ts +14 -0
  184. package/es/tx/builder/field-types/nonce.mjs +29 -0
  185. package/es/tx/builder/field-types/nonce.mjs.map +1 -0
  186. package/es/tx/builder/field-types/pointers.mjs +2 -2
  187. package/es/tx/builder/field-types/pointers.mjs.map +1 -1
  188. package/es/tx/builder/field-types/raw.d.ts +6 -0
  189. package/es/tx/builder/field-types/raw.mjs +13 -0
  190. package/es/tx/builder/field-types/raw.mjs.map +1 -0
  191. package/es/tx/builder/field-types/short-u-int-const.d.ts +7 -0
  192. package/es/tx/builder/field-types/short-u-int-const.mjs +20 -0
  193. package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
  194. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  195. package/es/tx/builder/field-types/string.d.ts +6 -0
  196. package/es/tx/builder/field-types/string.mjs +10 -0
  197. package/es/tx/builder/field-types/string.mjs.map +1 -0
  198. package/es/tx/builder/field-types/ttl.d.ts +11 -0
  199. package/es/tx/builder/field-types/ttl.mjs +21 -0
  200. package/es/tx/builder/field-types/ttl.mjs.map +1 -0
  201. package/es/tx/builder/field-types/u-int.d.ts +1 -2
  202. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  203. package/es/tx/builder/field-types/wrapped.d.ts +14 -0
  204. package/es/tx/builder/field-types/wrapped.mjs +22 -0
  205. package/es/tx/builder/field-types/wrapped.mjs.map +1 -0
  206. package/es/tx/builder/helpers.mjs.map +1 -1
  207. package/es/tx/builder/index.d.ts +18 -36
  208. package/es/tx/builder/index.mjs +65 -236
  209. package/es/tx/builder/index.mjs.map +1 -1
  210. package/es/tx/builder/schema.d.ts +2734 -1324
  211. package/es/tx/builder/schema.generated.d.ts +2011 -0
  212. package/es/tx/builder/schema.generated.mjs +2 -0
  213. package/es/tx/builder/schema.generated.mjs.map +1 -0
  214. package/es/tx/builder/schema.mjs +459 -223
  215. package/es/tx/builder/schema.mjs.map +1 -1
  216. package/es/tx/execution-cost.d.ts +35 -0
  217. package/es/tx/execution-cost.mjs +123 -0
  218. package/es/tx/execution-cost.mjs.map +1 -0
  219. package/es/tx/transaction-signer.d.ts +6 -0
  220. package/es/tx/transaction-signer.mjs +27 -0
  221. package/es/tx/transaction-signer.mjs.map +1 -0
  222. package/es/tx/validator.d.ts +3 -5
  223. package/es/tx/validator.mjs +91 -153
  224. package/es/tx/validator.mjs.map +1 -1
  225. package/es/utils/amount-formatter.mjs +0 -16
  226. package/es/utils/amount-formatter.mjs.map +1 -1
  227. package/es/utils/autorest.d.ts +3 -2
  228. package/es/utils/autorest.mjs +43 -11
  229. package/es/utils/autorest.mjs.map +1 -1
  230. package/es/utils/bytes.mjs +1 -17
  231. package/es/utils/bytes.mjs.map +1 -1
  232. package/es/utils/crypto.mjs +0 -16
  233. package/es/utils/crypto.mjs.map +1 -1
  234. package/es/utils/encoder.mjs.map +1 -1
  235. package/es/utils/errors.d.ts +16 -38
  236. package/es/utils/errors.mjs +3 -43
  237. package/es/utils/errors.mjs.map +1 -1
  238. package/es/utils/hd-wallet.mjs.map +1 -1
  239. package/es/utils/json-big.mjs.map +1 -1
  240. package/es/utils/keystore.mjs.map +1 -1
  241. package/es/utils/other.mjs.map +1 -1
  242. package/es/utils/semver-satisfies.mjs.map +1 -1
  243. package/es/utils/string.mjs +0 -17
  244. package/es/utils/string.mjs.map +1 -1
  245. package/package.json +52 -40
  246. package/src/AeSdkBase.ts +6 -3
  247. package/src/AeSdkMethods.ts +12 -18
  248. package/src/AeSdkWallet.ts +1 -1
  249. package/src/Node.ts +23 -9
  250. package/src/account/Base.ts +13 -24
  251. package/src/account/Generalized.ts +9 -24
  252. package/src/account/Ledger.ts +1 -1
  253. package/src/account/Memory.ts +15 -22
  254. package/src/aens.ts +34 -49
  255. package/src/aepp-wallet-communication/connection/Browser.ts +0 -17
  256. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +18 -24
  257. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +0 -17
  258. package/src/aepp-wallet-communication/connection-proxy.ts +0 -17
  259. package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
  260. package/src/aepp-wallet-communication/rpc/types.ts +6 -2
  261. package/src/aepp-wallet-communication/wallet-detector.ts +0 -17
  262. package/src/apis/compiler/compiler.ts +3 -27
  263. package/src/apis/compiler/models/index.ts +3 -2
  264. package/src/apis/compiler/models/mappers.ts +15 -2
  265. package/src/apis/node/models/index.ts +16 -15
  266. package/src/apis/node/models/mappers.ts +2 -1
  267. package/src/apis/node/models/parameters.ts +2 -2
  268. package/src/apis/node/node.ts +3 -27
  269. package/src/chain.ts +33 -30
  270. package/src/channel/Base.ts +39 -31
  271. package/src/channel/Contract.ts +18 -32
  272. package/src/channel/Spend.ts +8 -18
  273. package/src/channel/handlers.ts +14 -26
  274. package/src/channel/internal.ts +41 -23
  275. package/src/contract/Contract.ts +188 -228
  276. package/src/contract/compiler/Base.ts +87 -0
  277. package/src/contract/compiler/Cli.ts +128 -0
  278. package/src/contract/compiler/Http.ts +105 -0
  279. package/src/contract/compiler/HttpNode.ts +26 -0
  280. package/src/contract/compiler/getFileSystem.ts +42 -0
  281. package/src/contract/delegation-signature.ts +56 -0
  282. package/src/contract/ga.ts +61 -37
  283. package/src/index-browser.ts +50 -0
  284. package/src/index.ts +4 -56
  285. package/src/oracle.ts +47 -57
  286. package/src/spend.ts +34 -68
  287. package/src/tx/builder/SchemaTypes.ts +79 -0
  288. package/src/tx/builder/constants.ts +34 -3
  289. package/src/tx/builder/field-types/abi-version.ts +44 -0
  290. package/src/tx/builder/field-types/address.ts +23 -13
  291. package/src/tx/builder/field-types/array.ts +19 -0
  292. package/src/tx/builder/field-types/boolean.ts +9 -0
  293. package/src/tx/builder/field-types/coin-amount.ts +8 -5
  294. package/src/tx/builder/field-types/ct-version.ts +83 -0
  295. package/src/tx/builder/field-types/deposit.ts +4 -2
  296. package/src/tx/builder/field-types/encoded.ts +27 -0
  297. package/src/tx/builder/field-types/entry.ts +36 -0
  298. package/src/tx/builder/field-types/enumeration.ts +15 -4
  299. package/src/tx/builder/field-types/fee.ts +41 -19
  300. package/src/tx/builder/field-types/gas-limit.ts +13 -8
  301. package/src/tx/builder/field-types/index.ts +60 -17
  302. package/src/tx/builder/field-types/map.ts +45 -0
  303. package/src/tx/builder/field-types/mptree.ts +243 -0
  304. package/src/tx/builder/field-types/name-fee.ts +3 -3
  305. package/src/tx/builder/field-types/name-id.ts +1 -1
  306. package/src/tx/builder/field-types/nonce.ts +40 -0
  307. package/src/tx/builder/field-types/pointers.ts +2 -2
  308. package/src/tx/builder/field-types/raw.ts +9 -0
  309. package/src/tx/builder/field-types/short-u-int-const.ts +30 -0
  310. package/src/tx/builder/field-types/string.ts +11 -0
  311. package/src/tx/builder/field-types/ttl.ts +24 -0
  312. package/src/tx/builder/field-types/u-int.ts +1 -3
  313. package/src/tx/builder/field-types/wrapped.ts +32 -0
  314. package/src/tx/builder/index.ts +82 -280
  315. package/src/tx/builder/schema.generated.ts +2013 -0
  316. package/src/tx/builder/schema.ts +536 -666
  317. package/src/tx/execution-cost.ts +146 -0
  318. package/src/tx/transaction-signer.ts +27 -0
  319. package/src/tx/validator.ts +100 -154
  320. package/src/utils/amount-formatter.ts +0 -16
  321. package/src/utils/autorest.ts +52 -11
  322. package/src/utils/bytes.ts +1 -17
  323. package/src/utils/crypto.ts +0 -16
  324. package/src/utils/errors.ts +18 -56
  325. package/src/utils/string.ts +0 -17
  326. package/types-legacy/ts4.2/AeSdkBase.d.ts +3 -3
  327. package/types-legacy/ts4.2/AeSdkMethods.d.ts +12 -14
  328. package/types-legacy/ts4.2/Node.d.ts +8 -4
  329. package/types-legacy/ts4.2/account/Base.d.ts +13 -8
  330. package/types-legacy/ts4.2/account/Memory.d.ts +2 -1
  331. package/types-legacy/ts4.2/aens.d.ts +12 -14
  332. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  333. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +6 -2
  334. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +1 -1
  335. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +3 -2
  336. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +1 -1
  337. package/types-legacy/ts4.2/apis/node/models/index.d.ts +15 -15
  338. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +1 -1
  339. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +2 -2
  340. package/types-legacy/ts4.2/chain.d.ts +17 -9
  341. package/types-legacy/ts4.2/channel/Base.d.ts +27 -9
  342. package/types-legacy/ts4.2/channel/Contract.d.ts +8 -7
  343. package/types-legacy/ts4.2/channel/Spend.d.ts +5 -1
  344. package/types-legacy/ts4.2/channel/internal.d.ts +22 -2
  345. package/types-legacy/ts4.2/contract/Contract.d.ts +42 -122
  346. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +74 -0
  347. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
  348. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
  349. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
  350. package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
  351. package/types-legacy/ts4.2/contract/delegation-signature.d.ts +43 -0
  352. package/types-legacy/ts4.2/contract/ga.d.ts +27 -10
  353. package/types-legacy/ts4.2/index-browser.d.ts +40 -0
  354. package/types-legacy/ts4.2/index.d.ts +4 -38
  355. package/types-legacy/ts4.2/oracle.d.ts +12 -17
  356. package/types-legacy/ts4.2/spend.d.ts +19 -27
  357. package/types-legacy/ts4.2/tx/builder/SchemaTypes.d.ts +37 -0
  358. package/types-legacy/ts4.2/tx/builder/constants.d.ts +31 -2
  359. package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +19 -0
  360. package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +11 -12
  361. package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
  362. package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
  363. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +4 -5
  364. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +72 -0
  365. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +3 -2
  366. package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
  367. package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
  368. package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -3
  369. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +12 -7
  370. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +7 -3
  371. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +3 -1
  372. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +113 -30
  373. package/types-legacy/ts4.2/tx/builder/field-types/map.d.ts +13 -0
  374. package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +48 -0
  375. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +2 -3
  376. package/types-legacy/ts4.2/tx/builder/field-types/nonce.d.ts +14 -0
  377. package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
  378. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +7 -0
  379. package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
  380. package/types-legacy/ts4.2/tx/builder/field-types/ttl.d.ts +11 -0
  381. package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +1 -2
  382. package/types-legacy/ts4.2/tx/builder/field-types/wrapped.d.ts +14 -0
  383. package/types-legacy/ts4.2/tx/builder/index.d.ts +21 -36
  384. package/types-legacy/ts4.2/tx/builder/schema.d.ts +2971 -2926
  385. package/types-legacy/ts4.2/tx/builder/schema.generated.d.ts +2011 -0
  386. package/types-legacy/ts4.2/tx/execution-cost.d.ts +35 -0
  387. package/types-legacy/ts4.2/tx/transaction-signer.d.ts +6 -0
  388. package/types-legacy/ts4.2/tx/validator.d.ts +3 -5
  389. package/types-legacy/ts4.2/utils/autorest.d.ts +3 -2
  390. package/types-legacy/ts4.2/utils/errors.d.ts +16 -38
  391. package/types-legacy/ts4.5/AeSdkBase.d.ts +3 -3
  392. package/types-legacy/ts4.5/AeSdkMethods.d.ts +12 -14
  393. package/types-legacy/ts4.5/Node.d.ts +8 -4
  394. package/types-legacy/ts4.5/account/Base.d.ts +13 -8
  395. package/types-legacy/ts4.5/account/Memory.d.ts +2 -1
  396. package/types-legacy/ts4.5/aens.d.ts +12 -14
  397. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  398. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +6 -2
  399. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +1 -1
  400. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +3 -2
  401. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +1 -1
  402. package/types-legacy/ts4.5/apis/node/models/index.d.ts +15 -15
  403. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +1 -1
  404. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +2 -2
  405. package/types-legacy/ts4.5/chain.d.ts +17 -9
  406. package/types-legacy/ts4.5/channel/Base.d.ts +27 -9
  407. package/types-legacy/ts4.5/channel/Contract.d.ts +8 -7
  408. package/types-legacy/ts4.5/channel/Spend.d.ts +5 -1
  409. package/types-legacy/ts4.5/channel/internal.d.ts +22 -2
  410. package/types-legacy/ts4.5/contract/Contract.d.ts +42 -122
  411. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +74 -0
  412. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
  413. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
  414. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
  415. package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
  416. package/types-legacy/ts4.5/contract/delegation-signature.d.ts +43 -0
  417. package/types-legacy/ts4.5/contract/ga.d.ts +27 -10
  418. package/types-legacy/ts4.5/index-browser.d.ts +40 -0
  419. package/types-legacy/ts4.5/index.d.ts +4 -38
  420. package/types-legacy/ts4.5/oracle.d.ts +12 -17
  421. package/types-legacy/ts4.5/spend.d.ts +19 -27
  422. package/types-legacy/ts4.5/tx/builder/SchemaTypes.d.ts +37 -0
  423. package/types-legacy/ts4.5/tx/builder/constants.d.ts +31 -2
  424. package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +19 -0
  425. package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +11 -12
  426. package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
  427. package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
  428. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +4 -5
  429. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +72 -0
  430. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +3 -2
  431. package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
  432. package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
  433. package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -3
  434. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +12 -7
  435. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +7 -3
  436. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +3 -1
  437. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +113 -30
  438. package/types-legacy/ts4.5/tx/builder/field-types/map.d.ts +13 -0
  439. package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +48 -0
  440. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +2 -3
  441. package/types-legacy/ts4.5/tx/builder/field-types/nonce.d.ts +14 -0
  442. package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
  443. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +7 -0
  444. package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
  445. package/types-legacy/ts4.5/tx/builder/field-types/ttl.d.ts +11 -0
  446. package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +1 -2
  447. package/types-legacy/ts4.5/tx/builder/field-types/wrapped.d.ts +14 -0
  448. package/types-legacy/ts4.5/tx/builder/index.d.ts +21 -36
  449. package/types-legacy/ts4.5/tx/builder/schema.d.ts +2971 -2926
  450. package/types-legacy/ts4.5/tx/builder/schema.generated.d.ts +2011 -0
  451. package/types-legacy/ts4.5/tx/execution-cost.d.ts +35 -0
  452. package/types-legacy/ts4.5/tx/transaction-signer.d.ts +6 -0
  453. package/types-legacy/ts4.5/tx/validator.d.ts +3 -5
  454. package/types-legacy/ts4.5/utils/autorest.d.ts +3 -2
  455. package/types-legacy/ts4.5/utils/errors.d.ts +16 -38
  456. package/es/contract/CompilerHttp.d.ts +0 -18
  457. package/es/contract/CompilerHttp.mjs +0 -63
  458. package/es/contract/CompilerHttp.mjs.map +0 -1
  459. package/es/tx/builder/field-types/addresses.d.ts +0 -6
  460. package/es/tx/builder/field-types/addresses.mjs +0 -13
  461. package/es/tx/builder/field-types/addresses.mjs.map +0 -1
  462. package/es/tx/index.d.ts +0 -34
  463. package/es/tx/index.mjs +0 -172
  464. package/es/tx/index.mjs.map +0 -1
  465. package/es/utils/mptree.d.ts +0 -26
  466. package/es/utils/mptree.mjs +0 -143
  467. package/es/utils/mptree.mjs.map +0 -1
  468. package/src/apis/compiler/code-model-v4.yaml +0 -2442
  469. package/src/apis/node/code-model-v4.yaml +0 -10080
  470. package/src/contract/CompilerHttp.ts +0 -67
  471. package/src/tx/builder/field-types/addresses.ts +0 -18
  472. package/src/tx/index.ts +0 -196
  473. package/src/utils/mptree.ts +0 -145
  474. package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +0 -18
  475. package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +0 -6
  476. package/types-legacy/ts4.2/tx/index.d.ts +0 -34
  477. package/types-legacy/ts4.2/utils/mptree.d.ts +0 -32
  478. package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +0 -18
  479. package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +0 -6
  480. package/types-legacy/ts4.5/tx/index.d.ts +0 -34
  481. package/types-legacy/ts4.5/utils/mptree.d.ts +0 -32
package/es/spend.mjs CHANGED
@@ -1,44 +1,8 @@
1
- /*
2
- * ISC License (ISC)
3
- * Copyright (c) 2022 aeternity developers
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
8
- *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- * PERFORMANCE OF THIS SOFTWARE.
16
- */
17
1
  import BigNumber from 'bignumber.js';
18
2
  import { sendTransaction, getBalance, resolveName } from "./chain.mjs";
19
- import { _buildTx } from "./tx/index.mjs";
20
- import { buildTxHash, unpackTx } from "./tx/builder/index.mjs";
3
+ import { buildTxAsync, unpackTx } from "./tx/builder/index.mjs";
21
4
  import { ArgumentError } from "./utils/errors.mjs";
22
5
  import { Tag } from "./tx/builder/constants.mjs";
23
- /**
24
- * Sign and post a transaction to the chain
25
- * @category chain
26
- * @param tx - Transaction
27
- * @param options - Options
28
- * @param options.verify - Verify transaction before broadcast, throw error if not
29
- * valid
30
- * @returns Transaction
31
- */
32
- export async function send(tx, options) {
33
- const signed = await options.onAccount.signTransaction(tx, {
34
- ...options,
35
- networkId: await options.onNode.getNetworkId()
36
- });
37
- return options.innerTx === true ? {
38
- hash: buildTxHash(signed),
39
- rawTx: signed
40
- } : sendTransaction(signed, options);
41
- }
42
6
  /**
43
7
  * Send coins to another account
44
8
  * @category chain
@@ -48,8 +12,9 @@ export async function send(tx, options) {
48
12
  * @returns Transaction
49
13
  */
50
14
  export async function spend(amount, recipientIdOrName, options) {
51
- return send(await _buildTx(Tag.SpendTx, {
15
+ return sendTransaction(await buildTxAsync({
52
16
  ...options,
17
+ tag: Tag.SpendTx,
53
18
  senderId: options.onAccount.address,
54
19
  recipientId: await resolveName(recipientIdOrName, 'account_pubkey', options),
55
20
  amount
@@ -57,12 +22,21 @@ export async function spend(amount, recipientIdOrName, options) {
57
22
  }
58
23
  // TODO: Rename to spendFraction
59
24
  /**
60
- * Send a fraction of coin balance to another account
25
+ * Spend a fraction of coin balance to another account. Useful if needed to drain account balance
26
+ * completely, sending funds to another account (with fraction set to 1).
61
27
  * @category chain
62
28
  * @param fraction - Fraction of balance to spend (between 0 and 1)
63
29
  * @param recipientIdOrName - Address or name of recipient account
64
30
  * @param options - Options
65
- * @returns Transaction
31
+ * @example
32
+ * ```js
33
+ * // `fraction` * 100 = % of AE to be transferred (e.g. `0.42` for 42% or `1` for 100%)
34
+ * const { blockHeight } = await aeSdk.transferFunds(
35
+ * 0.42,
36
+ * 'ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E',
37
+ * );
38
+ * console.log('Transaction mined at', blockHeight);
39
+ * ```
66
40
  */
67
41
  export async function transferFunds(fraction, recipientIdOrName, options) {
68
42
  if (fraction < 0 || fraction > 1) {
@@ -73,19 +47,19 @@ export async function transferFunds(fraction, recipientIdOrName, options) {
73
47
  const balance = new BigNumber(await getBalance.bind(options.onAccount)(senderId, options));
74
48
  const desiredAmount = balance.times(fraction).integerValue(BigNumber.ROUND_HALF_UP);
75
49
  const {
76
- tx: {
77
- fee
78
- }
79
- } = unpackTx(await _buildTx(Tag.SpendTx, {
50
+ fee
51
+ } = unpackTx(await buildTxAsync({
80
52
  ...options,
53
+ tag: Tag.SpendTx,
81
54
  senderId,
82
55
  recipientId,
83
56
  amount: desiredAmount
84
57
  }), Tag.SpendTx);
85
58
  // Reducing of the amount may reduce transaction fee, so this is not completely accurate
86
59
  const amount = desiredAmount.plus(fee).gt(balance) ? balance.minus(fee) : desiredAmount;
87
- return send(await _buildTx(Tag.SpendTx, {
60
+ return sendTransaction(await buildTxAsync({
88
61
  ...options,
62
+ tag: Tag.SpendTx,
89
63
  senderId,
90
64
  recipientId,
91
65
  amount
@@ -99,8 +73,9 @@ export async function transferFunds(fraction, recipientIdOrName, options) {
99
73
  * @returns Object Transaction
100
74
  */
101
75
  export async function payForTransaction(transaction, options) {
102
- return send(await _buildTx(Tag.PayingForTx, {
76
+ return sendTransaction(await buildTxAsync({
103
77
  ...options,
78
+ tag: Tag.PayingForTx,
104
79
  payerId: options.onAccount.address,
105
80
  tx: transaction
106
81
  }), options);
package/es/spend.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"spend.mjs","names":["BigNumber","sendTransaction","getBalance","resolveName","_buildTx","buildTxHash","unpackTx","ArgumentError","Tag","send","tx","options","signed","onAccount","signTransaction","networkId","onNode","getNetworkId","innerTx","hash","rawTx","spend","amount","recipientIdOrName","SpendTx","senderId","address","recipientId","transferFunds","fraction","balance","bind","desiredAmount","times","integerValue","ROUND_HALF_UP","fee","plus","gt","minus","payForTransaction","transaction","PayingForTx","payerId"],"sources":["../src/spend.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport BigNumber from 'bignumber.js';\nimport { sendTransaction, getBalance, resolveName } from './chain';\nimport { _buildTx, BuildTxOptions } from './tx';\nimport { buildTxHash, unpackTx } from './tx/builder';\nimport { ArgumentError } from './utils/errors';\nimport { Encoded, Encoding } from './utils/encoder';\nimport { Tag, AensName } from './tx/builder/constants';\nimport AccountBase from './account/Base';\n\n/**\n * Sign and post a transaction to the chain\n * @category chain\n * @param tx - Transaction\n * @param options - Options\n * @param options.verify - Verify transaction before broadcast, throw error if not\n * valid\n * @returns Transaction\n */\nexport async function send(\n tx: Encoded.Transaction,\n options: SendOptions,\n): Promise<SendReturnType> {\n const signed = await options.onAccount.signTransaction(tx, {\n ...options,\n networkId: await options.onNode.getNetworkId(),\n });\n\n return options.innerTx === true\n ? { hash: buildTxHash(signed), rawTx: signed }\n : sendTransaction(signed, options);\n}\n\ntype SendOptionsType = Parameters<AccountBase['signTransaction']>[1]\n& Parameters<typeof sendTransaction>[1] & { onAccount: AccountBase };\nexport interface SendOptions extends SendOptionsType {}\ninterface SendReturnType extends Awaited<ReturnType<typeof sendTransaction>> {}\n\n/**\n * Send coins to another account\n * @category chain\n * @param amount - Amount to spend\n * @param recipientIdOrName - Address or name of recipient account\n * @param options - Options\n * @returns Transaction\n */\nexport async function spend(\n amount: number | string,\n recipientIdOrName: Encoded.AccountAddress | AensName,\n options: SpendOptions,\n): ReturnType<typeof send> {\n return send(\n await _buildTx(Tag.SpendTx, {\n ...options,\n senderId: options.onAccount.address,\n recipientId: await resolveName<Encoding.AccountAddress>(\n recipientIdOrName,\n 'account_pubkey',\n options,\n ),\n amount,\n }),\n options,\n );\n}\n\ntype SpendOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'>\n& Parameters<typeof resolveName>[2] & { onAccount: AccountBase } & SendOptions;\ninterface SpendOptions extends SpendOptionsType {}\n\n// TODO: Rename to spendFraction\n/**\n * Send a fraction of coin balance to another account\n * @category chain\n * @param fraction - Fraction of balance to spend (between 0 and 1)\n * @param recipientIdOrName - Address or name of recipient account\n * @param options - Options\n * @returns Transaction\n */\nexport async function transferFunds(\n fraction: number | string,\n recipientIdOrName: AensName | Encoded.AccountAddress,\n options: TransferFundsOptions,\n): ReturnType<typeof send> {\n if (fraction < 0 || fraction > 1) {\n throw new ArgumentError('fraction', 'a number between 0 and 1', fraction);\n }\n const recipientId = await resolveName<Encoding.AccountAddress>(\n recipientIdOrName,\n 'account_pubkey',\n options,\n );\n const senderId = options.onAccount.address;\n const balance = new BigNumber(\n await getBalance.bind(options.onAccount)(senderId, options),\n );\n const desiredAmount = balance.times(fraction).integerValue(BigNumber.ROUND_HALF_UP);\n const { tx: { fee } } = unpackTx(\n await _buildTx(Tag.SpendTx, {\n ...options, senderId, recipientId, amount: desiredAmount,\n }),\n Tag.SpendTx,\n );\n // Reducing of the amount may reduce transaction fee, so this is not completely accurate\n const amount = desiredAmount.plus(fee).gt(balance) ? balance.minus(fee) : desiredAmount;\n return send(\n await _buildTx(Tag.SpendTx, {\n ...options, senderId, recipientId, amount,\n }),\n options,\n );\n}\n\ntype TransferFundsOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'>\n& Parameters<typeof resolveName>[2] & { onAccount: AccountBase } & SendOptions;\ninterface TransferFundsOptions extends TransferFundsOptionsType {}\n\n/**\n * Submit transaction of another account paying for it (fee and gas)\n * @category chain\n * @param transaction - tx_<base64>-encoded transaction\n * @param options - Options\n * @returns Object Transaction\n */\nexport async function payForTransaction(\n transaction: Encoded.Transaction,\n options: PayForTransactionOptions,\n): ReturnType<typeof send> {\n return send(\n await _buildTx(\n Tag.PayingForTx,\n { ...options, payerId: options.onAccount.address, tx: transaction },\n ),\n options,\n );\n}\n\ninterface PayForTransactionOptions extends\n BuildTxOptions<Tag.PayingForTx, 'payerId' | 'tx'>, SendOptions {\n onAccount: AccountBase;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,eAAe,EAAEC,UAAU,EAAEC,WAAW;AAAA,SACxCC,QAAQ;AAAA,SACRC,WAAW,EAAEC,QAAQ;AAAA,SACrBC,aAAa;AAAA,SAEbC,GAAG;AAGZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,IAAI,CACxBC,EAAuB,EACvBC,OAAoB,EACK;EACzB,MAAMC,MAAM,GAAG,MAAMD,OAAO,CAACE,SAAS,CAACC,eAAe,CAACJ,EAAE,EAAE;IACzD,GAAGC,OAAO;IACVI,SAAS,EAAE,MAAMJ,OAAO,CAACK,MAAM,CAACC,YAAY;EAC9C,CAAC,CAAC;EAEF,OAAON,OAAO,CAACO,OAAO,KAAK,IAAI,GAC3B;IAAEC,IAAI,EAAEd,WAAW,CAACO,MAAM,CAAC;IAAEQ,KAAK,EAAER;EAAO,CAAC,GAC5CX,eAAe,CAACW,MAAM,EAAED,OAAO,CAAC;AACtC;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeU,KAAK,CACzBC,MAAuB,EACvBC,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MAAM,GAAGU,aAAa,CAACK,IAAI,CAACD,GAAG,CAAC,CAACE,EAAE,CAACR,OAAO,CAAC,GAAGA,OAAO,CAACS,KAAK,CAACH,GAAG,CAAC,GAAGJ,aAAa;EACvF,OAAOvB,IAAI,CACT,MAAML,QAAQ,CAACI,GAAG,CAACgB,OAAO,EAAE;IAC1B,GAAGb,OAAO;IAAEc,QAAQ;IAAEE,WAAW;IAAEL;EACrC,CAAC,CAAC,EACFX,OAAO,CACR;AACH;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe6B,iBAAiB,CACrCC,WAAgC,EAChC9B,OAAiC,EACR;EACzB,OAAOF,IAAI,CACT,MAAML,QAAQ,CACZI,GAAG,CAACkC,WAAW,EACf;IAAE,GAAG/B,OAAO;IAAEgC,OAAO,EAAEhC,OAAO,CAACE,SAAS,CAACa,OAAO;IAAEhB,EAAE,EAAE+B;EAAY,CAAC,CACpE,EACD9B,OAAO,CACR;AACH"}
1
+ {"version":3,"file":"spend.mjs","names":["BigNumber","sendTransaction","getBalance","resolveName","buildTxAsync","unpackTx","ArgumentError","Tag","spend","amount","recipientIdOrName","options","tag","SpendTx","senderId","onAccount","address","recipientId","transferFunds","fraction","balance","bind","desiredAmount","times","integerValue","ROUND_HALF_UP","fee","plus","gt","minus","payForTransaction","transaction","PayingForTx","payerId","tx"],"sources":["../src/spend.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport {\n sendTransaction, getBalance, resolveName, SendTransactionOptions,\n} from './chain';\nimport { buildTxAsync, BuildTxOptions, unpackTx } from './tx/builder';\nimport { ArgumentError } from './utils/errors';\nimport { Encoded, Encoding } from './utils/encoder';\nimport { Tag, AensName } from './tx/builder/constants';\nimport AccountBase from './account/Base';\n\n/**\n * Send coins to another account\n * @category chain\n * @param amount - Amount to spend\n * @param recipientIdOrName - Address or name of recipient account\n * @param options - Options\n * @returns Transaction\n */\nexport async function spend(\n amount: number | string,\n recipientIdOrName: Encoded.AccountAddress | AensName,\n options: SpendOptions,\n): ReturnType<typeof sendTransaction> {\n return sendTransaction(\n await buildTxAsync({\n ...options,\n tag: Tag.SpendTx,\n senderId: options.onAccount.address,\n recipientId: await resolveName<Encoding.AccountAddress>(\n recipientIdOrName,\n 'account_pubkey',\n options,\n ),\n amount,\n }),\n options,\n );\n}\n\ntype SpendOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'>\n& Parameters<typeof resolveName>[2] & { onAccount: AccountBase } & SendTransactionOptions;\ninterface SpendOptions extends SpendOptionsType {}\n\n// TODO: Rename to spendFraction\n/**\n * Spend a fraction of coin balance to another account. Useful if needed to drain account balance\n * completely, sending funds to another account (with fraction set to 1).\n * @category chain\n * @param fraction - Fraction of balance to spend (between 0 and 1)\n * @param recipientIdOrName - Address or name of recipient account\n * @param options - Options\n * @example\n * ```js\n * // `fraction` * 100 = % of AE to be transferred (e.g. `0.42` for 42% or `1` for 100%)\n * const { blockHeight } = await aeSdk.transferFunds(\n * 0.42,\n * 'ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E',\n * );\n * console.log('Transaction mined at', blockHeight);\n * ```\n */\nexport async function transferFunds(\n fraction: number | string,\n recipientIdOrName: AensName | Encoded.AccountAddress,\n options: TransferFundsOptions,\n): ReturnType<typeof sendTransaction> {\n if (fraction < 0 || fraction > 1) {\n throw new ArgumentError('fraction', 'a number between 0 and 1', fraction);\n }\n const recipientId = await resolveName<Encoding.AccountAddress>(\n recipientIdOrName,\n 'account_pubkey',\n options,\n );\n const senderId = options.onAccount.address;\n const balance = new BigNumber(\n await getBalance.bind(options.onAccount)(senderId, options),\n );\n const desiredAmount = balance.times(fraction).integerValue(BigNumber.ROUND_HALF_UP);\n const { fee } = unpackTx(\n await buildTxAsync({\n ...options, tag: Tag.SpendTx, senderId, recipientId, amount: desiredAmount,\n }),\n Tag.SpendTx,\n );\n // Reducing of the amount may reduce transaction fee, so this is not completely accurate\n const amount = desiredAmount.plus(fee).gt(balance) ? balance.minus(fee) : desiredAmount;\n return sendTransaction(\n await buildTxAsync({\n ...options, tag: Tag.SpendTx, senderId, recipientId, amount,\n }),\n options,\n );\n}\n\ntype TransferFundsOptionsType = BuildTxOptions<Tag.SpendTx, 'senderId' | 'recipientId' | 'amount'>\n& Parameters<typeof resolveName>[2] & { onAccount: AccountBase } & SendTransactionOptions;\ninterface TransferFundsOptions extends TransferFundsOptionsType {}\n\n/**\n * Submit transaction of another account paying for it (fee and gas)\n * @category chain\n * @param transaction - tx_<base64>-encoded transaction\n * @param options - Options\n * @returns Object Transaction\n */\nexport async function payForTransaction(\n transaction: Encoded.Transaction,\n options: PayForTransactionOptions,\n): ReturnType<typeof sendTransaction> {\n return sendTransaction(\n await buildTxAsync({\n ...options, tag: Tag.PayingForTx, payerId: options.onAccount.address, tx: transaction,\n }),\n options,\n );\n}\n\ninterface PayForTransactionOptions extends\n BuildTxOptions<Tag.PayingForTx, 'payerId' | 'tx' | 'onNode'>, SendTransactionOptions {\n onAccount: AccountBase;\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAEnCC,eAAe,EAAEC,UAAU,EAAEC,WAAW;AAAA,SAEjCC,YAAY,EAAkBC,QAAQ;AAAA,SACtCC,aAAa;AAAA,SAEbC,GAAG;AAGZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,KAAKA,CACzBC,MAAuB,EACvBC,iBAAoD,EACpDC,OAAqB,EACe;EACpC,OAAOV,eAAe,CACpB,MAAMG,YAAY,CAAC;IACjB,GAAGO,OAAO;IACVC,GAAG,EAAEL,GAAG,CAACM,OAAO;IAChBC,QAAQ,EAAEH,OAAO,CAACI,SAAS,CAACC,OAAO;IACnCC,WAAW,EAAE,MAAMd,WAAW,CAC5BO,iBAAiB,EACjB,gBAAgB,EAChBC,OAAO,CACR;IACDF;EACF,CAAC,CAAC,EACFE,OAAO,CACR;AACH;AAMA;AACA;AACA;AACA;AAC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AACH;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAemB,iBAAiBA,CACrCC,WAAgC,EAChCpB,OAAiC,EACG;EACpC,OAAOV,eAAe,CACpB,MAAMG,YAAY,CAAC;IACjB,GAAGO,OAAO;IAAEC,GAAG,EAAEL,GAAG,CAACyB,WAAW;IAAEC,OAAO,EAAEtB,OAAO,CAACI,SAAS,CAACC,OAAO;IAAEkB,EAAE,EAAEH;EAC5E,CAAC,CAAC,EACFpB,OAAO,CACR;AACH"}
@@ -0,0 +1,37 @@
1
+ import { Field as OriginalField } from './field-types';
2
+ import { UnionToIntersection } from '../../utils/other';
3
+ export interface Field extends OriginalField {
4
+ serialize: (...args: any[]) => any;
5
+ }
6
+ type NullablePartial<T, NK extends keyof T = {
7
+ [K in keyof T]: undefined extends T[K] ? K : never;
8
+ }[keyof T]> = Partial<Pick<T, NK>> & Omit<T, NK>;
9
+ type Or<A, B> = A extends undefined ? B : A;
10
+ type TxParamsBySchemaInternal<SchemaItem> = {
11
+ -readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field ? Parameters<SchemaItem[key]['serialize']>[0] : never;
12
+ };
13
+ type TxParamsBySchemaInternalParams<SchemaItem, SchemaItemValues = SchemaItem[keyof SchemaItem]> = UnionToIntersection<SchemaItemValues extends Field ? Or<Parameters<SchemaItemValues['serialize']>[2], {}> : never>;
14
+ type PickIsRec<SchemaItem, Recursive extends boolean> = {
15
+ [Key in keyof SchemaItem as SchemaItem[Key] extends Field & {
16
+ recursiveType: true;
17
+ } ? (Recursive extends true ? Key : never) : (Recursive extends true ? never : Key)]: SchemaItem[Key];
18
+ };
19
+ type TxParamsBySchema<SchemaItem> = SchemaItem extends Object ? TxParamsBySchemaInternal<PickIsRec<SchemaItem, true>> & NullablePartial<TxParamsBySchemaInternal<PickIsRec<SchemaItem, false>>> & TxParamsBySchemaInternalParams<PickIsRec<SchemaItem, false>> : never;
20
+ type TxParamsAsyncBySchemaInternal<SchemaItem> = {
21
+ -readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field & {
22
+ prepare: Function;
23
+ } ? Parameters<SchemaItem[key]['prepare']>[0] : SchemaItem[key] extends Field ? Parameters<SchemaItem[key]['serialize']>[0] : never;
24
+ };
25
+ type TxParamsAsyncBySchemaInternalParams<SchemaItem, SchemaItemValues = SchemaItem[keyof SchemaItem]> = UnionToIntersection<SchemaItemValues extends Field & {
26
+ prepare: Function;
27
+ } ? Or<Parameters<SchemaItemValues['prepare']>[2], {}> : {}>;
28
+ type TxParamsAsyncBySchema<SchemaItem> = SchemaItem extends Object ? TxParamsAsyncBySchemaInternal<PickIsRec<SchemaItem, true>> & NullablePartial<TxParamsAsyncBySchemaInternal<PickIsRec<SchemaItem, false>>> & TxParamsAsyncBySchemaInternalParams<PickIsRec<SchemaItem, false>> & TxParamsBySchemaInternalParams<PickIsRec<SchemaItem, false>> : never;
29
+ type TxUnpackedBySchema<SchemaItem> = {
30
+ -readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field ? ReturnType<SchemaItem[key]['deserialize']> : never;
31
+ };
32
+ export default interface SchemaTypes<Schema extends readonly any[], SchemaItems = Schema[number]> {
33
+ TxParams: TxParamsBySchema<SchemaItems>;
34
+ TxParamsAsync: TxParamsAsyncBySchema<SchemaItems>;
35
+ TxUnpacked: TxUnpackedBySchema<SchemaItems>;
36
+ }
37
+ export {};
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=SchemaTypes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaTypes.mjs","names":[],"sources":["../../../src/tx/builder/SchemaTypes.ts"],"sourcesContent":["import { Field as OriginalField } from './field-types';\nimport { UnionToIntersection } from '../../utils/other';\n\n// TODO: figure out why this override is necessary\nexport interface Field extends OriginalField {\n serialize: (...args: any[]) => any;\n}\n\ntype NullablePartial<\n T,\n NK extends keyof T = { [K in keyof T]: undefined extends T[K] ? K : never }[keyof T],\n> = Partial<Pick<T, NK>> & Omit<T, NK>;\n\ntype Or<A, B> = A extends undefined ? B : A;\n\ntype TxParamsBySchemaInternal<SchemaItem> = {\n -readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field\n ? Parameters<SchemaItem[key]['serialize']>[0]\n : never;\n};\n\ntype TxParamsBySchemaInternalParams<\n SchemaItem,\n SchemaItemValues = SchemaItem[keyof SchemaItem],\n> = UnionToIntersection<\nSchemaItemValues extends Field\n ? Or<Parameters<SchemaItemValues['serialize']>[2], {}> : never\n>;\n\ntype PickIsRec<SchemaItem, Recursive extends boolean> = {\n [Key in keyof SchemaItem\n as SchemaItem[Key] extends Field & { recursiveType: true }\n ? (Recursive extends true ? Key : never)\n : (Recursive extends true ? never : Key)]: SchemaItem[Key];\n};\n\ntype TxParamsBySchema<SchemaItem> = SchemaItem extends Object\n ? TxParamsBySchemaInternal<PickIsRec<SchemaItem, true>> &\n NullablePartial<TxParamsBySchemaInternal<PickIsRec<SchemaItem, false>>> &\n TxParamsBySchemaInternalParams<PickIsRec<SchemaItem, false>>\n : never;\n\ntype TxParamsAsyncBySchemaInternal<SchemaItem> = {\n -readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field & { prepare: Function }\n ? Parameters<SchemaItem[key]['prepare']>[0]\n : SchemaItem[key] extends Field\n ? Parameters<SchemaItem[key]['serialize']>[0]\n : never;\n};\n\ntype TxParamsAsyncBySchemaInternalParams<\n SchemaItem,\n SchemaItemValues = SchemaItem[keyof SchemaItem],\n> = UnionToIntersection<\nSchemaItemValues extends Field & { prepare: Function }\n ? Or<Parameters<SchemaItemValues['prepare']>[2], {}> : {}\n>;\n\ntype TxParamsAsyncBySchema<SchemaItem> = SchemaItem extends Object\n ? TxParamsAsyncBySchemaInternal<PickIsRec<SchemaItem, true>>\n & NullablePartial<TxParamsAsyncBySchemaInternal<PickIsRec<SchemaItem, false>>>\n & TxParamsAsyncBySchemaInternalParams<PickIsRec<SchemaItem, false>>\n & TxParamsBySchemaInternalParams<PickIsRec<SchemaItem, false>>\n : never;\n\ntype TxUnpackedBySchema<SchemaItem> = {\n -readonly [key in keyof SchemaItem]: SchemaItem[key] extends Field\n ? ReturnType<SchemaItem[key]['deserialize']>\n : never;\n};\n\nexport default interface SchemaTypes<\n Schema extends readonly any[],\n SchemaItems = Schema[number],\n> {\n TxParams: TxParamsBySchema<SchemaItems>;\n TxParamsAsync: TxParamsAsyncBySchema<SchemaItems>;\n TxUnpacked: TxUnpackedBySchema<SchemaItems>;\n}\n"],"mappings":""}
@@ -1,5 +1,6 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  export declare const MAX_AUTH_FUN_GAS = 50000;
3
+ export type Int = number | string | BigNumber;
3
4
  export type AensName = `${string}.chain`;
4
5
  export declare const NAME_TTL = 180000;
5
6
  export declare const NAME_MAX_TTL = 36000;
@@ -14,6 +15,32 @@ export declare const NAME_BID_MAX_LENGTH = 12;
14
15
  export declare const NAME_BID_RANGES: {
15
16
  [k: string]: BigNumber;
16
17
  };
18
+ export declare enum ConsensusProtocolVersion {
19
+ Iris = 5,
20
+ Ceres = 6
21
+ }
22
+ /**
23
+ * @category transaction builder
24
+ * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}
25
+ */
26
+ export declare enum VmVersion {
27
+ NoVm = 0,
28
+ Sophia = 1,
29
+ SophiaImprovementsMinerva = 3,
30
+ SophiaImprovementsFortuna = 4,
31
+ Fate = 5,
32
+ SophiaImprovementsLima = 6,
33
+ Fate2 = 7
34
+ }
35
+ /**
36
+ * @category transaction builder
37
+ * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}
38
+ */
39
+ export declare enum AbiVersion {
40
+ NoAbi = 0,
41
+ Sophia = 1,
42
+ Fate = 3
43
+ }
17
44
  /**
18
45
  * Enum with tag types
19
46
  * @category transaction builder
@@ -24,10 +51,12 @@ export declare enum Tag {
24
51
  Account = 10,
25
52
  SignedTx = 11,
26
53
  SpendTx = 12,
54
+ Oracle = 20,
27
55
  OracleRegisterTx = 22,
28
56
  OracleQueryTx = 23,
29
57
  OracleResponseTx = 24,
30
58
  OracleExtendTx = 25,
59
+ Name = 30,
31
60
  NameClaimTx = 32,
32
61
  NamePreclaimTx = 33,
33
62
  NameUpdateTx = 34,
@@ -64,8 +93,8 @@ export declare enum Tag {
64
93
  NameserviceMtree = 624,
65
94
  OraclesMtree = 625,
66
95
  AccountsMtree = 626,
67
- CompilerSophia = 70,
68
96
  GaAttachTx = 80,
69
97
  GaMetaTx = 81,
70
- PayingForTx = 82
98
+ PayingForTx = 82,
99
+ GaMetaTxAuthData = 810
71
100
  }
@@ -1,8 +1,6 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { mapObject } from "../../utils/other.mjs";
3
3
  export const MAX_AUTH_FUN_GAS = 50000;
4
- // # AENS
5
-
6
4
  export const NAME_TTL = 180000;
7
5
  // # max number of block into the future that the name is going to be available
8
6
  // # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update
@@ -58,6 +56,32 @@ export const NAME_BID_RANGES = mapObject({
58
56
  let [key, value] = _ref;
59
57
  return [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)];
60
58
  });
59
+ export let ConsensusProtocolVersion;
60
+
61
+ /**
62
+ * @category transaction builder
63
+ * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}
64
+ */
65
+ (function (ConsensusProtocolVersion) {
66
+ ConsensusProtocolVersion[ConsensusProtocolVersion["Iris"] = 5] = "Iris";
67
+ ConsensusProtocolVersion[ConsensusProtocolVersion["Ceres"] = 6] = "Ceres";
68
+ })(ConsensusProtocolVersion || (ConsensusProtocolVersion = {}));
69
+ export let VmVersion;
70
+
71
+ /**
72
+ * @category transaction builder
73
+ * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}
74
+ */
75
+ (function (VmVersion) {
76
+ VmVersion[VmVersion["NoVm"] = 0] = "NoVm";
77
+ VmVersion[VmVersion["Sophia"] = 1] = "Sophia";
78
+ VmVersion[VmVersion["SophiaImprovementsMinerva"] = 3] = "SophiaImprovementsMinerva";
79
+ VmVersion[VmVersion["SophiaImprovementsFortuna"] = 4] = "SophiaImprovementsFortuna";
80
+ VmVersion[VmVersion["Fate"] = 5] = "Fate";
81
+ VmVersion[VmVersion["SophiaImprovementsLima"] = 6] = "SophiaImprovementsLima";
82
+ VmVersion[VmVersion["Fate2"] = 7] = "Fate2";
83
+ })(VmVersion || (VmVersion = {}));
84
+ export let AbiVersion;
61
85
 
62
86
  /**
63
87
  * Enum with tag types
@@ -66,6 +90,11 @@ export const NAME_BID_RANGES = mapObject({
66
90
  * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_chain_objects.erl#L39-L97}
67
91
  */
68
92
  // TODO: implement serialisation for commented-out tags
93
+ (function (AbiVersion) {
94
+ AbiVersion[AbiVersion["NoAbi"] = 0] = "NoAbi";
95
+ AbiVersion[AbiVersion["Sophia"] = 1] = "Sophia";
96
+ AbiVersion[AbiVersion["Fate"] = 3] = "Fate";
97
+ })(AbiVersion || (AbiVersion = {}));
69
98
  export let Tag; // KeyBlock = 100,
70
99
  // MicroBlock = 101,
71
100
  // LightMicroBlock = 102,
@@ -74,10 +103,12 @@ export let Tag; // KeyBlock = 100,
74
103
  Tag[Tag["Account"] = 10] = "Account";
75
104
  Tag[Tag["SignedTx"] = 11] = "SignedTx";
76
105
  Tag[Tag["SpendTx"] = 12] = "SpendTx";
106
+ Tag[Tag["Oracle"] = 20] = "Oracle";
77
107
  Tag[Tag["OracleRegisterTx"] = 22] = "OracleRegisterTx";
78
108
  Tag[Tag["OracleQueryTx"] = 23] = "OracleQueryTx";
79
109
  Tag[Tag["OracleResponseTx"] = 24] = "OracleResponseTx";
80
110
  Tag[Tag["OracleExtendTx"] = 25] = "OracleExtendTx";
111
+ Tag[Tag["Name"] = 30] = "Name";
81
112
  Tag[Tag["NameClaimTx"] = 32] = "NameClaimTx";
82
113
  Tag[Tag["NamePreclaimTx"] = 33] = "NamePreclaimTx";
83
114
  Tag[Tag["NameUpdateTx"] = 34] = "NameUpdateTx";
@@ -114,9 +145,9 @@ export let Tag; // KeyBlock = 100,
114
145
  Tag[Tag["NameserviceMtree"] = 624] = "NameserviceMtree";
115
146
  Tag[Tag["OraclesMtree"] = 625] = "OraclesMtree";
116
147
  Tag[Tag["AccountsMtree"] = 626] = "AccountsMtree";
117
- Tag[Tag["CompilerSophia"] = 70] = "CompilerSophia";
118
148
  Tag[Tag["GaAttachTx"] = 80] = "GaAttachTx";
119
149
  Tag[Tag["GaMetaTx"] = 81] = "GaMetaTx";
120
150
  Tag[Tag["PayingForTx"] = 82] = "PayingForTx";
151
+ Tag[Tag["GaMetaTxAuthData"] = 810] = "GaMetaTxAuthData";
121
152
  })(Tag || (Tag = {}));
122
153
  //# sourceMappingURL=constants.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","names":["BigNumber","mapObject","MAX_AUTH_FUN_GAS","NAME_TTL","NAME_MAX_TTL","NAME_MAX_CLIENT_TTL","CLIENT_TTL","MIN_GAS_PRICE","NAME_FEE_MULTIPLIER","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUT_BLOCKS","NAME_MAX_LENGTH_FEE","NAME_BID_MAX_LENGTH","NAME_BID_RANGES","key","value","times","Tag"],"sources":["../../../src/tx/builder/constants.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { mapObject } from '../../utils/other';\n\nexport const MAX_AUTH_FUN_GAS = 50000;\n// # AENS\nexport type AensName = `${string}.chain`;\nexport const NAME_TTL = 180000;\n// # max number of block into the future that the name is going to be available\n// # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update\n// # https://github.com/aeternity/protocol/blob/44a93d3aab957ca820183c3520b9daf6b0fedff4/AENS.md#aens-entry\nexport const NAME_MAX_TTL = 36000;\nexport const NAME_MAX_CLIENT_TTL = 84600;\nexport const CLIENT_TTL = NAME_MAX_CLIENT_TTL;\nexport const MIN_GAS_PRICE = 1e9;\n// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67\nexport const NAME_FEE_MULTIPLIER = 1e14; // 100000000000000\nexport const NAME_FEE_BID_INCREMENT = 0.05; // # the increment is in percentage\n// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L272\nexport const NAME_BID_TIMEOUT_BLOCKS = 480; // # ~1 day\n// # this is the max length for a domain that requires a base fee to be paid\nexport const NAME_MAX_LENGTH_FEE = 31;\nexport const NAME_BID_MAX_LENGTH = 12; // # this is the max length for a domain to be part of a bid\n// # https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290\n// # https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times\n// # bid ranges:\nexport const NAME_BID_RANGES = mapObject({\n 31: 3,\n 30: 5,\n 29: 8,\n 28: 13,\n 27: 21,\n 26: 34,\n 25: 55,\n 24: 89,\n 23: 144,\n 22: 233,\n 21: 377,\n 20: 610,\n 19: 987,\n 18: 1597,\n 17: 2584,\n 16: 4181,\n 15: 6765,\n 14: 10946,\n 13: 17711,\n 12: 28657,\n 11: 46368,\n 10: 75025,\n 9: 121393,\n 8: 196418,\n 7: 317811,\n 6: 514229,\n 5: 832040,\n 4: 1346269,\n 3: 2178309,\n 2: 3524578,\n 1: 5702887,\n}, ([key, value]) => [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)]);\n\n/**\n * Enum with tag types\n * @category transaction builder\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/serializations.md#binary-serialization}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_chain_objects.erl#L39-L97}\n */\n// TODO: implement serialisation for commented-out tags\nexport enum Tag {\n Account = 10,\n SignedTx = 11,\n SpendTx = 12,\n // Oracle = 20,\n // OracleQuery = 21,\n OracleRegisterTx = 22,\n OracleQueryTx = 23,\n OracleResponseTx = 24,\n OracleExtendTx = 25,\n // Name = 30,\n // NameCommitment = 31,\n NameClaimTx = 32,\n NamePreclaimTx = 33,\n NameUpdateTx = 34,\n NameRevokeTx = 35,\n NameTransferTx = 36,\n // NameAuction = 37,\n Contract = 40,\n ContractCall = 41,\n ContractCreateTx = 42,\n ContractCallTx = 43,\n ChannelCreateTx = 50,\n // ChannelSetDelegatesTx = 501,\n ChannelDepositTx = 51,\n ChannelWithdrawTx = 52,\n ChannelForceProgressTx = 521,\n ChannelCloseMutualTx = 53,\n ChannelCloseSoloTx = 54,\n ChannelSlashTx = 55,\n ChannelSettleTx = 56,\n ChannelOffChainTx = 57,\n ChannelOffChainUpdateTransfer = 570,\n ChannelOffChainUpdateDeposit = 571,\n ChannelOffChainUpdateWithdraw = 572,\n ChannelOffChainUpdateCreateContract = 573,\n ChannelOffChainUpdateCallContract = 574,\n // ChannelOffChainUpdateMeta = 576,\n ChannelClientReconnectTx = 575,\n Channel = 58,\n ChannelSnapshotSoloTx = 59,\n TreesPoi = 60,\n // TreesDb = 61,\n StateTrees = 62,\n Mtree = 63,\n MtreeValue = 64,\n ContractsMtree = 621,\n CallsMtree = 622,\n ChannelsMtree = 623,\n NameserviceMtree = 624,\n OraclesMtree = 625,\n AccountsMtree = 626,\n CompilerSophia = 70,\n GaAttachTx = 80,\n GaMetaTx = 81,\n PayingForTx = 82,\n // KeyBlock = 100,\n // MicroBlock = 101,\n // LightMicroBlock = 102,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CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;AAAA,GAAHA,GAAG,KAAHA,GAAG"}
1
+ {"version":3,"file":"constants.mjs","names":["BigNumber","mapObject","MAX_AUTH_FUN_GAS","NAME_TTL","NAME_MAX_TTL","NAME_MAX_CLIENT_TTL","CLIENT_TTL","MIN_GAS_PRICE","NAME_FEE_MULTIPLIER","NAME_FEE_BID_INCREMENT","NAME_BID_TIMEOUT_BLOCKS","NAME_MAX_LENGTH_FEE","NAME_BID_MAX_LENGTH","NAME_BID_RANGES","_ref","key","value","times","ConsensusProtocolVersion","VmVersion","AbiVersion","Tag"],"sources":["../../../src/tx/builder/constants.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { mapObject } from '../../utils/other';\n\nexport const MAX_AUTH_FUN_GAS = 50000;\nexport type Int = number | string | BigNumber;\n// # AENS\nexport type AensName = `${string}.chain`;\nexport const NAME_TTL = 180000;\n// # max number of block into the future that the name is going to be available\n// # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update\n// # https://github.com/aeternity/protocol/blob/44a93d3aab957ca820183c3520b9daf6b0fedff4/AENS.md#aens-entry\nexport const NAME_MAX_TTL = 36000;\nexport const NAME_MAX_CLIENT_TTL = 84600;\nexport const CLIENT_TTL = NAME_MAX_CLIENT_TTL;\nexport const MIN_GAS_PRICE = 1e9;\n// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67\nexport const NAME_FEE_MULTIPLIER = 1e14; // 100000000000000\nexport const NAME_FEE_BID_INCREMENT = 0.05; // # the increment is in percentage\n// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L272\nexport const NAME_BID_TIMEOUT_BLOCKS = 480; // # ~1 day\n// # this is the max length for a domain that requires a base fee to be paid\nexport const NAME_MAX_LENGTH_FEE = 31;\nexport const NAME_BID_MAX_LENGTH = 12; // # this is the max length for a domain to be part of a bid\n// # https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290\n// # https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times\n// # bid ranges:\nexport const NAME_BID_RANGES = mapObject({\n 31: 3,\n 30: 5,\n 29: 8,\n 28: 13,\n 27: 21,\n 26: 34,\n 25: 55,\n 24: 89,\n 23: 144,\n 22: 233,\n 21: 377,\n 20: 610,\n 19: 987,\n 18: 1597,\n 17: 2584,\n 16: 4181,\n 15: 6765,\n 14: 10946,\n 13: 17711,\n 12: 28657,\n 11: 46368,\n 10: 75025,\n 9: 121393,\n 8: 196418,\n 7: 317811,\n 6: 514229,\n 5: 832040,\n 4: 1346269,\n 3: 2178309,\n 2: 3524578,\n 1: 5702887,\n}, ([key, value]) => [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)]);\n\nexport enum ConsensusProtocolVersion {\n Iris = 5,\n Ceres = 6,\n}\n\n/**\n * @category transaction builder\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}\n */\nexport enum VmVersion {\n NoVm = 0,\n Sophia = 1,\n SophiaImprovementsMinerva = 3,\n SophiaImprovementsFortuna = 4,\n Fate = 5,\n SophiaImprovementsLima = 6,\n Fate2 = 7,\n}\n\n/**\n * @category transaction builder\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}\n */\nexport enum AbiVersion {\n NoAbi = 0,\n Sophia = 1,\n Fate = 3,\n}\n\n/**\n * Enum with tag types\n * @category transaction builder\n * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/serializations.md#binary-serialization}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_chain_objects.erl#L39-L97}\n */\n// TODO: implement serialisation for commented-out tags\nexport enum Tag {\n Account = 10,\n SignedTx = 11,\n SpendTx = 12,\n Oracle = 20,\n // OracleQuery = 21,\n OracleRegisterTx = 22,\n OracleQueryTx = 23,\n OracleResponseTx = 24,\n OracleExtendTx = 25,\n Name = 30,\n // NameCommitment = 31,\n NameClaimTx = 32,\n NamePreclaimTx = 33,\n NameUpdateTx = 34,\n NameRevokeTx = 35,\n NameTransferTx = 36,\n // NameAuction = 37,\n Contract = 40,\n ContractCall = 41,\n ContractCreateTx = 42,\n ContractCallTx = 43,\n ChannelCreateTx = 50,\n // ChannelSetDelegatesTx = 501,\n ChannelDepositTx = 51,\n ChannelWithdrawTx = 52,\n ChannelForceProgressTx = 521,\n ChannelCloseMutualTx = 53,\n ChannelCloseSoloTx = 54,\n ChannelSlashTx = 55,\n ChannelSettleTx = 56,\n ChannelOffChainTx = 57,\n ChannelOffChainUpdateTransfer = 570,\n ChannelOffChainUpdateDeposit = 571,\n ChannelOffChainUpdateWithdraw = 572,\n ChannelOffChainUpdateCreateContract = 573,\n ChannelOffChainUpdateCallContract = 574,\n // ChannelOffChainUpdateMeta = 576,\n ChannelClientReconnectTx = 575,\n Channel = 58,\n ChannelSnapshotSoloTx = 59,\n TreesPoi = 60,\n // TreesDb = 61,\n StateTrees = 62,\n Mtree = 63,\n MtreeValue = 64,\n ContractsMtree = 621,\n CallsMtree = 622,\n ChannelsMtree = 623,\n NameserviceMtree = 624,\n OraclesMtree = 625,\n AccountsMtree = 626,\n // CompilerSophia = 70,\n GaAttachTx = 80,\n GaMetaTx = 81,\n PayingForTx = 82,\n GaMetaTxAuthData = 810,\n // KeyBlock = 100,\n // MicroBlock = 101,\n // LightMicroBlock = 102,\n // Pof = 200,\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AAAC,SAC5BC,SAAS;AAElB,OAAO,MAAMC,gBAAgB,GAAG,KAAK;AAIrC,OAAO,MAAMC,QAAQ,GAAG,MAAM;AAC9B;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAG,KAAK;AACjC,OAAO,MAAMC,mBAAmB,GAAG,KAAK;AACxC,OAAO,MAAMC,UAAU,GAAGD,mBAAmB;AAC7C,OAAO,MAAME,aAAa,GAAG,GAAG;AAChC;AACA,OAAO,MAAMC,mBAAmB,GAAG,IAAI,CAAC,CAAC;AACzC,OAAO,MAAMC,sBAAsB,GAAG,IAAI,CAAC,CAAC;AAC5C;AACA,OAAO,MAAMC,uBAAuB,GAAG,GAAG,CAAC,CAAC;AAC5C;AACA,OAAO,MAAMC,mBAAmB,GAAG,EAAE;AACrC,OAAO,MAAMC,mBAAmB,GAAG,EAAE,CAAC,CAAC;AACvC;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGZ,SAAS,CAAC;EACvC,EAAE,EAAE,CAAC;EACL,EAAE,EAAE,CAAC;EACL,EAAE,EAAE,CAAC;EACL,EAAE,EAAE,EAAE;EACN,EAAE,EAAE,EAAE;EACN,EAAE,EAAE,EAAE;EACN,EAAE,EAAE,EAAE;EACN,EAAE,EAAE,EAAE;EACN,EAAE,EAAE,GAAG;EACP,EAAE,EAAE,GAAG;EACP,EAAE,EAAE,GAAG;EACP,EAAE,EAAE,GAAG;EACP,EAAE,EAAE,GAAG;EACP,EAAE,EAAE,IAAI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CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;EAAHA,GAAG,CAAHA,GAAG;AAAA,GAAHA,GAAG,KAAHA,GAAG"}
@@ -0,0 +1,19 @@
1
+ /// <reference types="node" />
2
+ import { Tag, ConsensusProtocolVersion, AbiVersion } from '../constants';
3
+ import Node from '../../../Node';
4
+ declare const _default: {
5
+ _getProtocolDetails(c: ConsensusProtocolVersion, tag: Tag): AbiVersion;
6
+ serialize(value: AbiVersion | undefined, { tag }: {
7
+ tag: Tag;
8
+ }, { consensusProtocolVersion }: {
9
+ consensusProtocolVersion?: ConsensusProtocolVersion | undefined;
10
+ }): Buffer;
11
+ prepare(value: AbiVersion | undefined, { tag }: {
12
+ tag: Tag;
13
+ }, options: {
14
+ consensusProtocolVersion?: ConsensusProtocolVersion;
15
+ onNode?: Node;
16
+ }): Promise<AbiVersion | undefined>;
17
+ deserialize(buffer: Buffer): AbiVersion;
18
+ };
19
+ export default _default;
@@ -0,0 +1,40 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import { Tag, ConsensusProtocolVersion } from "../constants.mjs";
6
+ import { getProtocolDetails } from "./ct-version.mjs";
7
+ export default {
8
+ _getProtocolDetails(c, tag) {
9
+ const kind = Tag.ContractCallTx === tag || Tag.GaMetaTx === tag ? 'contract-call' : 'oracle-call';
10
+ return getProtocolDetails(c, kind).abiVersion;
11
+ },
12
+ serialize(value, _ref, _ref2) {
13
+ let {
14
+ tag
15
+ } = _ref;
16
+ let {
17
+ consensusProtocolVersion = ConsensusProtocolVersion.Iris
18
+ } = _ref2;
19
+ const result = value !== null && value !== void 0 ? value : this._getProtocolDetails(consensusProtocolVersion, tag);
20
+ return _Buffer.from([result]);
21
+ },
22
+ async prepare(value, _ref3,
23
+ // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}
24
+ options) {
25
+ let {
26
+ tag
27
+ } = _ref3;
28
+ if (value != null) return value;
29
+ if (options.consensusProtocolVersion != null) return undefined;
30
+ if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;
31
+ if (options.onNode != null) {
32
+ return this._getProtocolDetails((await options.onNode.getNodeInfo()).consensusProtocolVersion, tag);
33
+ }
34
+ return undefined;
35
+ },
36
+ deserialize(buffer) {
37
+ return buffer[0];
38
+ }
39
+ };
40
+ //# sourceMappingURL=abi-version.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi-version.mjs","names":["Tag","ConsensusProtocolVersion","getProtocolDetails","_getProtocolDetails","c","tag","kind","ContractCallTx","GaMetaTx","abiVersion","serialize","value","_ref","_ref2","consensusProtocolVersion","Iris","result","_Buffer","from","prepare","_ref3","options","undefined","Object","keys","length","onNode","getNodeInfo","deserialize","buffer"],"sources":["../../../../src/tx/builder/field-types/abi-version.ts"],"sourcesContent":["import { Tag, ConsensusProtocolVersion, AbiVersion } from '../constants';\nimport { getProtocolDetails } from './ct-version';\nimport Node from '../../../Node';\n\nexport default {\n _getProtocolDetails(c: ConsensusProtocolVersion, tag: Tag): AbiVersion {\n const kind = Tag.ContractCallTx === tag || Tag.GaMetaTx === tag\n ? 'contract-call' : 'oracle-call';\n return getProtocolDetails(c, kind).abiVersion;\n },\n\n serialize(\n value: AbiVersion | undefined,\n { tag }: { tag: Tag },\n { consensusProtocolVersion = ConsensusProtocolVersion.Iris }:\n { consensusProtocolVersion?: ConsensusProtocolVersion },\n ): Buffer {\n const result = value ?? this._getProtocolDetails(consensusProtocolVersion, tag);\n\n return Buffer.from([result]);\n },\n\n async prepare(\n value: AbiVersion | undefined,\n { tag }: { tag: Tag },\n // TODO: { consensusProtocolVersion: ConsensusProtocolVersion } | { onNode: Node } | {}\n options: { consensusProtocolVersion?: ConsensusProtocolVersion; onNode?: Node },\n ): Promise<AbiVersion | undefined> {\n if (value != null) return value;\n if (options.consensusProtocolVersion != null) return undefined;\n if (Object.keys(ConsensusProtocolVersion).length === 2) return undefined;\n if (options.onNode != null) {\n return this._getProtocolDetails(\n (await options.onNode.getNodeInfo()).consensusProtocolVersion,\n tag,\n );\n }\n return undefined;\n },\n\n deserialize(buffer: Buffer): AbiVersion {\n return buffer[0];\n },\n};\n"],"mappings":";;;;SAASA,GAAG,EAAEC,wBAAwB;AAAA,SAC7BC,kBAAkB;AAG3B,eAAe;EACbC,mBAAmBA,CAACC,CAA2B,EAAEC,GAAQ,EAAc;IACrE,MAAMC,IAAI,GAAGN,GAAG,CAACO,cAAc,KAAKF,GAAG,IAAIL,GAAG,CAACQ,QAAQ,KAAKH,GAAG,GAC3D,eAAe,GAAG,aAAa;IACnC,OAAOH,kBAAkB,CAACE,CAAC,EAAEE,IAAI,CAAC,CAACG,UAAU;EAC/C,CAAC;EAEDC,SAASA,CACPC,KAA6B,EAAAC,IAAA,EAAAC,KAAA,EAIrB;IAAA,IAHR;MAAER;IAAkB,CAAC,GAAAO,IAAA;IAAA,IACrB;MAAEE,wBAAwB,GAAGb,wBAAwB,CAACc;IACA,CAAC,GAAAF,KAAA;IAEvD,MAAMG,MAAM,GAAGL,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,IAAI,CAACR,mBAAmB,CAACW,wBAAwB,EAAET,GAAG,CAAC;IAE/E,OAAOY,OAAA,CAAOC,IAAI,CAAC,CAACF,MAAM,CAAC,CAAC;EAC9B,CAAC;EAED,MAAMG,OAAOA,CACXR,KAA6B,EAAAS,KAAA;EAE7B;EACAC,OAA+E,EAC9C;IAAA,IAHjC;MAAEhB;IAAkB,CAAC,GAAAe,KAAA;IAIrB,IAAIT,KAAK,IAAI,IAAI,EAAE,OAAOA,KAAK;IAC/B,IAAIU,OAAO,CAACP,wBAAwB,IAAI,IAAI,EAAE,OAAOQ,SAAS;IAC9D,IAAIC,MAAM,CAACC,IAAI,CAACvB,wBAAwB,CAAC,CAACwB,MAAM,KAAK,CAAC,EAAE,OAAOH,SAAS;IACxE,IAAID,OAAO,CAACK,MAAM,IAAI,IAAI,EAAE;MAC1B,OAAO,IAAI,CAACvB,mBAAmB,CAC7B,CAAC,MAAMkB,OAAO,CAACK,MAAM,CAACC,WAAW,EAAE,EAAEb,wBAAwB,EAC7DT,GAAG,CACJ;IACH;IACA,OAAOiB,SAAS;EAClB,CAAC;EAEDM,WAAWA,CAACC,MAAc,EAAc;IACtC,OAAOA,MAAM,CAAC,CAAC,CAAC;EAClB;AACF,CAAC"}
@@ -1,15 +1,14 @@
1
1
  /// <reference types="node" />
2
- import { Encoding } from '../../../utils/encoder';
2
+ import { Encoded } from '../../../utils/encoder';
3
3
  /**
4
4
  * Map of prefix to ID tag constant
5
5
  * @see {@link https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type}
6
6
  * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_id.erl#L97-L102}
7
7
  * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L163-L168}
8
8
  */
9
- declare const idTagToEncoding: readonly [Encoding.AccountAddress, Encoding.Name, Encoding.Commitment, Encoding.OracleAddress, Encoding.ContractAddress, Encoding.Channel];
9
+ export declare const idTagToEncoding: readonly [Encoded.Encoding.AccountAddress, Encoded.Encoding.Name, Encoded.Encoding.Commitment, Encoded.Encoding.OracleAddress, Encoded.Encoding.ContractAddress, Encoded.Encoding.Channel];
10
10
  export type AddressEncodings = typeof idTagToEncoding[number];
11
- export default function genAddressField<Encoding extends AddressEncodings>(): {
12
- serialize: (value: `${Encoding}_${string}`) => Buffer;
13
- deserialize: (value: Buffer) => `${Encoding}_${string}`;
11
+ export default function genAddressField<Encoding extends AddressEncodings>(...encodings: Encoding[]): {
12
+ serialize: (value: Encoded.Generic<Encoding>) => Buffer;
13
+ deserialize: (value: Buffer) => Encoded.Generic<Encoding>;
14
14
  };
15
- export {};
@@ -2,7 +2,7 @@ import _buffer from "buffer";
2
2
  const {
3
3
  Buffer: _Buffer
4
4
  } = _buffer;
5
- import { PrefixNotFoundError, TagNotFoundError } from "../../../utils/errors.mjs";
5
+ import { ArgumentError, PrefixNotFoundError, TagNotFoundError } from "../../../utils/errors.mjs";
6
6
  import { toBytes } from "../../../utils/bytes.mjs";
7
7
  import { decode, encode, Encoding } from "../../../utils/encoder.mjs";
8
8
  import { isItemOfArray } from "../../../utils/other.mjs";
@@ -12,8 +12,11 @@ import { isItemOfArray } from "../../../utils/other.mjs";
12
12
  * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_id.erl#L97-L102}
13
13
  * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L163-L168}
14
14
  */
15
- const idTagToEncoding = [Encoding.AccountAddress, Encoding.Name, Encoding.Commitment, Encoding.OracleAddress, Encoding.ContractAddress, Encoding.Channel];
15
+ export const idTagToEncoding = [Encoding.AccountAddress, Encoding.Name, Encoding.Commitment, Encoding.OracleAddress, Encoding.ContractAddress, Encoding.Channel];
16
16
  export default function genAddressField() {
17
+ for (var _len = arguments.length, encodings = new Array(_len), _key = 0; _key < _len; _key++) {
18
+ encodings[_key] = arguments[_key];
19
+ }
17
20
  return {
18
21
  /**
19
22
  * Utility function to create and _id type
@@ -21,9 +24,12 @@ export default function genAddressField() {
21
24
  * @returns Buffer Buffer with ID tag and decoded HASh
22
25
  */
23
26
  serialize(hashId) {
24
- const encoding = hashId.slice(0, 2);
25
- if (!isItemOfArray(encoding, idTagToEncoding)) throw new TagNotFoundError(encoding);
26
- const idTag = idTagToEncoding.indexOf(encoding) + 1;
27
+ const enc = hashId.slice(0, 2);
28
+ if (!isItemOfArray(enc, idTagToEncoding)) throw new TagNotFoundError(enc);
29
+ if (!isItemOfArray(enc, encodings)) {
30
+ throw new ArgumentError('Address encoding', encodings.join(', '), enc);
31
+ }
32
+ const idTag = idTagToEncoding.indexOf(enc) + 1;
27
33
  return _Buffer.from([...toBytes(idTag), ...decode(hashId)]);
28
34
  },
29
35
  /**
@@ -33,9 +39,12 @@ export default function genAddressField() {
33
39
  */
34
40
  deserialize(buf) {
35
41
  const idTag = _Buffer.from(buf).readUIntBE(0, 1);
36
- const encoding = idTagToEncoding[idTag - 1];
37
- if (encoding == null) throw new PrefixNotFoundError(idTag);
38
- return encode(buf.subarray(1), encoding);
42
+ const enc = idTagToEncoding[idTag - 1];
43
+ if (enc == null) throw new PrefixNotFoundError(idTag);
44
+ if (!isItemOfArray(enc, encodings)) {
45
+ throw new ArgumentError('Address encoding', encodings.join(', '), enc);
46
+ }
47
+ return encode(buf.subarray(1), enc);
39
48
  }
40
49
  };
41
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"address.mjs","names":["PrefixNotFoundError","TagNotFoundError","toBytes","decode","encode","Encoding","isItemOfArray","idTagToEncoding","AccountAddress","Name","Commitment","OracleAddress","ContractAddress","Channel","genAddressField","serialize","hashId","encoding","slice","idTag","indexOf","from","deserialize","buf","readUIntBE","subarray"],"sources":["../../../../src/tx/builder/field-types/address.ts"],"sourcesContent":["import { PrefixNotFoundError, TagNotFoundError } from '../../../utils/errors';\nimport { toBytes } from '../../../utils/bytes';\nimport { decode, encode, Encoding } from '../../../utils/encoder';\nimport { isItemOfArray } from '../../../utils/other';\n\n/**\n * Map of prefix to ID tag constant\n * @see {@link https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_id.erl#L97-L102}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L163-L168}\n */\nconst idTagToEncoding = [\n Encoding.AccountAddress,\n Encoding.Name,\n Encoding.Commitment,\n Encoding.OracleAddress,\n Encoding.ContractAddress,\n Encoding.Channel,\n] as const;\n\nexport type AddressEncodings = typeof idTagToEncoding[number];\n\nexport default function genAddressField<Encoding extends AddressEncodings>(): {\n serialize: (value: `${Encoding}_${string}`) => Buffer;\n deserialize: (value: Buffer) => `${Encoding}_${string}`;\n} {\n return {\n /**\n * Utility function to create and _id type\n * @param hashId - Encoded hash\n * @returns Buffer Buffer with ID tag and decoded HASh\n */\n serialize(hashId) {\n const encoding = hashId.slice(0, 2);\n if (!isItemOfArray(encoding, idTagToEncoding)) throw new TagNotFoundError(encoding);\n const idTag = idTagToEncoding.indexOf(encoding) + 1;\n return Buffer.from([...toBytes(idTag), ...decode(hashId)]);\n },\n\n /**\n * Utility function to read and _id type\n * @param buf - Data\n * @returns Encoded hash string with prefix\n */\n deserialize(buf) {\n const idTag = Buffer.from(buf).readUIntBE(0, 1);\n const encoding = idTagToEncoding[idTag - 1];\n if (encoding == null) throw new PrefixNotFoundError(idTag);\n return encode(buf.subarray(1), encoding) as `${Encoding}_${string}`;\n },\n };\n}\n"],"mappings":";;;;SAASA,mBAAmB,EAAEC,gBAAgB;AAAA,SACrCC,OAAO;AAAA,SACPC,MAAM,EAAEC,MAAM,EAAEC,QAAQ;AAAA,SACxBC,aAAa;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAG,CACtBF,QAAQ,CAACG,cAAc,EACvBH,QAAQ,CAACI,IAAI,EACbJ,QAAQ,CAACK,UAAU,EACnBL,QAAQ,CAACM,aAAa,EACtBN,QAAQ,CAACO,eAAe,EACxBP,QAAQ,CAACQ,OAAO,CACR;AAIV,eAAe,SAASC,eAAe,GAGrC;EACA,OAAO;IACL;AACJ;AACA;AACA;AACA;IACIC,SAAS,CAACC,MAAM,EAAE;MAChB,MAAMC,QAAQ,GAAGD,MAAM,CAACE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;MACnC,IAAI,CAACZ,aAAa,CAACW,QAAQ,EAAEV,eAAe,CAAC,EAAE,MAAM,IAAIN,gBAAgB,CAACgB,QAAQ,CAAC;MACnF,MAAME,KAAK,GAAGZ,eAAe,CAACa,OAAO,CAACH,QAAQ,CAAC,GAAG,CAAC;MACnD,OAAO,QAAOI,IAAI,CAAC,CAAC,GAAGnB,OAAO,CAACiB,KAAK,CAAC,EAAE,GAAGhB,MAAM,CAACa,MAAM,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED;AACJ;AACA;AACA;AACA;IACIM,WAAW,CAACC,GAAG,EAAE;MACf,MAAMJ,KAAK,GAAG,QAAOE,IAAI,CAACE,GAAG,CAAC,CAACC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;MAC/C,MAAMP,QAAQ,GAAGV,eAAe,CAACY,KAAK,GAAG,CAAC,CAAC;MAC3C,IAAIF,QAAQ,IAAI,IAAI,EAAE,MAAM,IAAIjB,mBAAmB,CAACmB,KAAK,CAAC;MAC1D,OAAOf,MAAM,CAACmB,GAAG,CAACE,QAAQ,CAAC,CAAC,CAAC,EAAER,QAAQ,CAAC;IAC1C;EACF,CAAC;AACH"}
1
+ {"version":3,"file":"address.mjs","names":["ArgumentError","PrefixNotFoundError","TagNotFoundError","toBytes","decode","encode","Encoding","isItemOfArray","idTagToEncoding","AccountAddress","Name","Commitment","OracleAddress","ContractAddress","Channel","genAddressField","_len","arguments","length","encodings","Array","_key","serialize","hashId","enc","slice","join","idTag","indexOf","_Buffer","from","deserialize","buf","readUIntBE","subarray"],"sources":["../../../../src/tx/builder/field-types/address.ts"],"sourcesContent":["import { ArgumentError, PrefixNotFoundError, TagNotFoundError } from '../../../utils/errors';\nimport { toBytes } from '../../../utils/bytes';\nimport {\n decode, encode, Encoded, Encoding,\n} from '../../../utils/encoder';\nimport { isItemOfArray } from '../../../utils/other';\n\n/**\n * Map of prefix to ID tag constant\n * @see {@link https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_id.erl#L97-L102}\n * @see {@link https://github.com/aeternity/aeserialization/blob/eb68fe331bd476910394966b7f5ede7a74d37e35/src/aeser_api_encoder.erl#L163-L168}\n */\nexport const idTagToEncoding = [\n Encoding.AccountAddress,\n Encoding.Name,\n Encoding.Commitment,\n Encoding.OracleAddress,\n Encoding.ContractAddress,\n Encoding.Channel,\n] as const;\n\nexport type AddressEncodings = typeof idTagToEncoding[number];\n\nexport default function genAddressField<Encoding extends AddressEncodings>(\n ...encodings: Encoding[]\n): {\n serialize: (value: Encoded.Generic<Encoding>) => Buffer;\n deserialize: (value: Buffer) => Encoded.Generic<Encoding>;\n } {\n return {\n /**\n * Utility function to create and _id type\n * @param hashId - Encoded hash\n * @returns Buffer Buffer with ID tag and decoded HASh\n */\n serialize(hashId) {\n const enc = hashId.slice(0, 2);\n if (!isItemOfArray(enc, idTagToEncoding)) throw new TagNotFoundError(enc);\n if (!isItemOfArray(enc, encodings)) {\n throw new ArgumentError('Address encoding', encodings.join(', '), enc);\n }\n const idTag = idTagToEncoding.indexOf(enc) + 1;\n return Buffer.from([...toBytes(idTag), ...decode(hashId)]);\n },\n\n /**\n * Utility function to read and _id type\n * @param buf - Data\n * @returns Encoded hash string with prefix\n */\n deserialize(buf) {\n const idTag = Buffer.from(buf).readUIntBE(0, 1);\n const enc = idTagToEncoding[idTag - 1];\n if (enc == null) throw new PrefixNotFoundError(idTag);\n if (!isItemOfArray(enc, encodings)) {\n throw new ArgumentError('Address encoding', encodings.join(', '), enc);\n }\n return encode(buf.subarray(1), enc) as Encoded.Generic<Encoding>;\n },\n };\n}\n"],"mappings":";;;;SAASA,aAAa,EAAEC,mBAAmB,EAAEC,gBAAgB;AAAA,SACpDC,OAAO;AAAA,SAEdC,MAAM,EAAEC,MAAM,EAAWC,QAAQ;AAAA,SAE1BC,aAAa;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG,CAC7BF,QAAQ,CAACG,cAAc,EACvBH,QAAQ,CAACI,IAAI,EACbJ,QAAQ,CAACK,UAAU,EACnBL,QAAQ,CAACM,aAAa,EACtBN,QAAQ,CAACO,eAAe,EACxBP,QAAQ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a,CAACiB,GAAG,EAAEL,SAAS,CAAC,EAAE;QAClC,MAAM,IAAInB,aAAa,CAAC,kBAAkB,EAAEmB,SAAS,CAACO,IAAI,CAAC,IAAI,CAAC,EAAEF,GAAG,CAAC;MACxE;MACA,OAAOnB,MAAM,CAAC2B,GAAG,CAACE,QAAQ,CAAC,CAAC,CAAC,EAAEV,GAAG,CAAC;IACrC;EACF,CAAC;AACH"}
@@ -0,0 +1,7 @@
1
+ export default function genArrayField<Input, Output, Binary>(itemHandler: {
2
+ serialize: (value: Input, params: unknown) => Binary;
3
+ deserialize: (value: Binary, params: unknown) => Output;
4
+ }): {
5
+ serialize: (value: readonly Input[], params: unknown) => Binary[];
6
+ deserialize: (value: Binary[], params: unknown) => Output[];
7
+ };
@@ -0,0 +1,11 @@
1
+ export default function genArrayField(itemHandler) {
2
+ return {
3
+ serialize(items, params) {
4
+ return items.map(item => itemHandler.serialize(item, params));
5
+ },
6
+ deserialize(buffers, params) {
7
+ return buffers.map(buffer => itemHandler.deserialize(buffer, params));
8
+ }
9
+ };
10
+ }
11
+ //# sourceMappingURL=array.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.mjs","names":["genArrayField","itemHandler","serialize","items","params","map","item","deserialize","buffers","buffer"],"sources":["../../../../src/tx/builder/field-types/array.ts"],"sourcesContent":["export default function genArrayField<Input, Output, Binary>(\n itemHandler: {\n serialize: (value: Input, params: unknown) => Binary;\n deserialize: (value: Binary, params: unknown) => Output;\n },\n): {\n serialize: (value: readonly Input[], params: unknown) => Binary[];\n deserialize: (value: Binary[], params: unknown) => Output[];\n } {\n return {\n serialize(items, params) {\n return items.map((item) => itemHandler.serialize(item, params));\n },\n\n deserialize(buffers, params) {\n return buffers.map((buffer) => itemHandler.deserialize(buffer, params));\n },\n };\n}\n"],"mappings":"AAAA,eAAe,SAASA,aAAaA,CACnCC,WAGC,EAIC;EACF,OAAO;IACLC,SAASA,CAACC,KAAK,EAAEC,MAAM,EAAE;MACvB,OAAOD,KAAK,CAACE,GAAG,CAAEC,IAAI,IAAKL,WAAW,CAACC,SAAS,CAACI,IAAI,EAAEF,MAAM,CAAC,CAAC;IACjE,CAAC;IAEDG,WAAWA,CAACC,OAAO,EAAEJ,MAAM,EAAE;MAC3B,OAAOI,OAAO,CAACH,GAAG,CAAEI,MAAM,IAAKR,WAAW,CAACM,WAAW,CAACE,MAAM,EAAEL,MAAM,CAAC,CAAC;IACzE;EACF,CAAC;AACH"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="node" />
2
+ declare const _default: {
3
+ serialize(value: boolean): Buffer;
4
+ deserialize(buffer: Buffer): boolean;
5
+ };
6
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ export default {
6
+ serialize(value) {
7
+ return _Buffer.from([value ? 1 : 0]);
8
+ },
9
+ deserialize(buffer) {
10
+ return buffer[0] === 1;
11
+ }
12
+ };
13
+ //# sourceMappingURL=boolean.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.mjs","names":["serialize","value","_Buffer","from","deserialize","buffer"],"sources":["../../../../src/tx/builder/field-types/boolean.ts"],"sourcesContent":["export default {\n serialize(value: boolean): Buffer {\n return Buffer.from([value ? 1 : 0]);\n },\n\n deserialize(buffer: Buffer): boolean {\n return buffer[0] === 1;\n },\n};\n"],"mappings":";;;;AAAA,eAAe;EACbA,SAASA,CAACC,KAAc,EAAU;IAChC,OAAOC,OAAA,CAAOC,IAAI,CAAC,CAACF,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;EACrC,CAAC;EAEDG,WAAWA,CAACC,MAAc,EAAW;IACnC,OAAOA,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;EACxB;AACF,CAAC"}