@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
@@ -8,12 +8,12 @@ import BigNumber from 'bignumber.js';
8
8
  import { Tag } from './constants';
9
9
  import {
10
10
  Field, uInt, shortUInt, coinAmount, name, nameId, nameFee, deposit, gasLimit, gasPrice, fee,
11
- address, addresses, pointers, enumeration,
11
+ address, pointers, entry, enumeration, mptree, shortUIntConst, string, encoded, raw,
12
+ array, boolean, ctVersion, abiVersion,
12
13
  } from './field-types';
13
- import { Encoded, Encoding } from '../../utils/encoder';
14
- import MPTree from '../../utils/mptree';
14
+ import { Encoding } from '../../utils/encoder';
15
15
  import { UnionToIntersection } from '../../utils/other';
16
- import { AddressEncodings } from './field-types/address';
16
+ import { idTagToEncoding } from './field-types/address';
17
17
 
18
18
  export enum ORACLE_TTL_TYPES {
19
19
  delta = 0,
@@ -35,130 +35,18 @@ export const DRY_RUN_ACCOUNT = {
35
35
 
36
36
  export type TxField = [
37
37
  name: string,
38
- type: FIELD_TYPES | Field,
39
- prefix?: Encoding | Encoding[],
38
+ type: Field,
40
39
  ];
41
40
 
42
- /**
43
- * @category transaction builder
44
- * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}
45
- */
46
- export enum VM_VERSIONS {
47
- NO_VM = 0,
48
- SOPHIA = 1,
49
- SOPHIA_IMPROVEMENTS_MINERVA = 3,
50
- SOPHIA_IMPROVEMENTS_FORTUNA = 4,
51
- FATE = 5,
52
- SOPHIA_IMPROVEMENTS_LIMA = 6,
53
- FATE_2 = 7,
54
- }
55
-
56
- /**
57
- * @category transaction builder
58
- * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}
59
- */
60
- export enum ABI_VERSIONS {
61
- NO_ABI = 0,
62
- SOPHIA = 1,
63
- FATE = 3,
64
- }
65
-
66
41
  export enum CallReturnType {
67
42
  Ok = 0,
68
43
  Error = 1,
69
44
  Revert = 2,
70
45
  }
71
46
 
72
- /**
73
- * @category transaction builder
74
- */
75
- export enum PROTOCOL_VERSIONS {
76
- IRIS = 5,
77
- }
47
+ type TxElem = readonly [string, Field];
78
48
 
79
- // First abi/vm by default
80
- export const PROTOCOL_VM_ABI = {
81
- [PROTOCOL_VERSIONS.IRIS]: {
82
- [Tag.ContractCreateTx]: {
83
- vmVersion: [VM_VERSIONS.FATE_2], abiVersion: [ABI_VERSIONS.FATE],
84
- },
85
- // TODO: Ensure that AEVM (SOPHIA?) is still available here
86
- [Tag.ContractCallTx]: {
87
- vmVersion: [], abiVersion: [ABI_VERSIONS.FATE, ABI_VERSIONS.SOPHIA],
88
- },
89
- [Tag.OracleRegisterTx]: {
90
- vmVersion: [], abiVersion: [ABI_VERSIONS.NO_ABI, ABI_VERSIONS.SOPHIA],
91
- },
92
- },
93
- } as const;
94
-
95
- type PrefixType<Prefix> = Prefix extends Encoding
96
- ? Encoded.Generic<Prefix>
97
- : Prefix extends readonly Encoding[]
98
- ? Encoded.Generic<Prefix[number]>
99
- : Encoded.Generic<any>;
100
-
101
- /**
102
- * @category transaction builder
103
- */
104
- export interface CtVersion {
105
- vmVersion: VM_VERSIONS;
106
- abiVersion: ABI_VERSIONS;
107
- }
108
-
109
- /**
110
- * @category transaction builder
111
- */
112
- export enum FIELD_TYPES {
113
- string,
114
- binary,
115
- bool,
116
- hex,
117
- rlpBinary,
118
- rlpBinaries,
119
- rawBinary,
120
- signatures,
121
- offChainUpdates,
122
- callStack,
123
- proofOfInclusion,
124
- mptrees,
125
- ctVersion,
126
- sophiaCodeTypeInfo,
127
- payload,
128
- stateTree,
129
- }
130
-
131
- interface BuildFieldTypes<Prefix extends undefined | Encoding | readonly Encoding[]> {
132
- [FIELD_TYPES.string]: string;
133
- [FIELD_TYPES.binary]: PrefixType<Prefix>;
134
- [FIELD_TYPES.bool]: Boolean;
135
- [FIELD_TYPES.hex]: string;
136
- [FIELD_TYPES.rlpBinary]: any;
137
- [FIELD_TYPES.rlpBinaries]: any[];
138
- [FIELD_TYPES.rawBinary]: Uint8Array;
139
- [FIELD_TYPES.signatures]: Uint8Array[];
140
- [FIELD_TYPES.offChainUpdates]: any;
141
- [FIELD_TYPES.callStack]: any;
142
- [FIELD_TYPES.proofOfInclusion]: any;
143
- [FIELD_TYPES.mptrees]: MPTree[];
144
- [FIELD_TYPES.ctVersion]: CtVersion;
145
- [FIELD_TYPES.sophiaCodeTypeInfo]: any;
146
- [FIELD_TYPES.payload]: string | undefined;
147
- [FIELD_TYPES.stateTree]: any;
148
- }
149
-
150
- type TxElem = readonly [string, FIELD_TYPES | Field]
151
- | readonly [string, FIELD_TYPES, Encoding | readonly Encoding[]];
152
-
153
- type BuildTxArgBySchemaType<
154
- Type extends FIELD_TYPES | Field,
155
- Prefix extends undefined | Encoding | readonly Encoding[],
156
- > =
157
- Type extends Field
158
- ? Parameters<Type['serialize']>[0]
159
- : Type extends FIELD_TYPES
160
- ? BuildFieldTypes<Prefix>[Type]
161
- : never;
49
+ type BuildTxArgBySchemaType<Type extends Field> = Parameters<Type['serialize']>[0];
162
50
 
163
51
  type NullablePartial<
164
52
  T,
@@ -169,7 +57,7 @@ type BuildTxArgBySchema<SchemaLine> =
169
57
  UnionToIntersection<
170
58
  SchemaLine extends ReadonlyArray<infer Elem>
171
59
  ? Elem extends TxElem
172
- ? NullablePartial<{ [k in Elem[0]]: BuildTxArgBySchemaType<Elem[1], Elem[2]> }>
60
+ ? NullablePartial<{ [k in Elem[0]]: BuildTxArgBySchemaType<Elem[1]> }>
173
61
  : never
174
62
  : never
175
63
  >;
@@ -178,60 +66,75 @@ export type RawTxObject<Tx extends TxSchema> = {
178
66
  [k in keyof Tx]-?: Tx[k] extends BigNumber ? string : Tx[k]
179
67
  };
180
68
 
181
- const BASE_TX = [
182
- ['tag', shortUInt],
183
- ['VSN', shortUInt],
184
- ] as const;
185
-
69
+ /**
70
+ * @see {@link https://github.com/aeternity/protocol/blob/c007deeac4a01e401238412801ac7084ac72d60e/serializations.md#accounts-version-1-basic-accounts}
71
+ */
186
72
  export const TX_SCHEMA = {
187
73
  [Tag.Account]: {
188
74
  1: [
189
- ...BASE_TX,
75
+ ['tag', shortUIntConst(Tag.Account)],
76
+ ['version', shortUIntConst(1)],
190
77
  ['nonce', shortUInt],
191
78
  ['balance', uInt],
192
79
  ],
193
80
  2: [
194
- ...BASE_TX,
81
+ ['tag', shortUIntConst(Tag.Account)],
82
+ ['version', shortUIntConst(2)],
195
83
  ['flags', uInt],
196
84
  ['nonce', shortUInt],
197
85
  ['balance', uInt],
198
- ['gaContract', address<Encoding.ContractAddress | Encoding.Name>()],
199
- ['gaAuthFun', FIELD_TYPES.binary, Encoding.ContractBytearray],
86
+ ['gaContract', address(Encoding.ContractAddress, Encoding.Name)],
87
+ ['gaAuthFun', encoded(Encoding.ContractBytearray)],
200
88
  ],
201
89
  },
202
90
  [Tag.SignedTx]: {
203
91
  1: [
204
- ...BASE_TX,
205
- ['signatures', FIELD_TYPES.signatures],
206
- ['encodedTx', FIELD_TYPES.rlpBinary],
92
+ ['tag', shortUIntConst(Tag.SignedTx)],
93
+ ['version', shortUIntConst(1)],
94
+ ['signatures', array(raw)],
95
+ ['encodedTx', entry()],
207
96
  ],
208
97
  },
209
98
  [Tag.SpendTx]: {
210
99
  1: [
211
- ...BASE_TX,
212
- ['senderId', address<Encoding.AccountAddress>()],
213
- ['recipientId', address<Encoding.AccountAddress | Encoding.Name>()],
100
+ ['tag', shortUIntConst(Tag.SpendTx)],
101
+ ['version', shortUIntConst(1)],
102
+ ['senderId', address(Encoding.AccountAddress)],
103
+ ['recipientId', address(Encoding.AccountAddress, Encoding.Name)],
214
104
  ['amount', coinAmount],
215
105
  ['fee', fee],
216
106
  ['ttl', shortUInt],
217
107
  ['nonce', shortUInt],
218
- ['payload', FIELD_TYPES.payload],
108
+ ['payload', encoded(Encoding.Bytearray, true)],
109
+ ],
110
+ },
111
+ [Tag.Name]: {
112
+ 1: [
113
+ ['tag', shortUIntConst(Tag.Name)],
114
+ ['version', shortUIntConst(1)],
115
+ ['accountId', address(Encoding.AccountAddress)],
116
+ ['nameTtl', shortUInt],
117
+ ['status', raw],
118
+ ['clientTtl', shortUInt],
119
+ ['pointers', pointers],
219
120
  ],
220
121
  },
221
122
  [Tag.NamePreclaimTx]: {
222
123
  1: [
223
- ...BASE_TX,
224
- ['accountId', address<Encoding.AccountAddress>()],
124
+ ['tag', shortUIntConst(Tag.NamePreclaimTx)],
125
+ ['version', shortUIntConst(1)],
126
+ ['accountId', address(Encoding.AccountAddress)],
225
127
  ['nonce', shortUInt],
226
- ['commitmentId', address<Encoding.Commitment>()],
128
+ ['commitmentId', address(Encoding.Commitment)],
227
129
  ['fee', fee],
228
130
  ['ttl', shortUInt],
229
131
  ],
230
132
  },
231
133
  [Tag.NameClaimTx]: {
232
134
  2: [
233
- ...BASE_TX,
234
- ['accountId', address<Encoding.AccountAddress>()],
135
+ ['tag', shortUIntConst(Tag.NameClaimTx)],
136
+ ['version', shortUIntConst(2)],
137
+ ['accountId', address(Encoding.AccountAddress)],
235
138
  ['nonce', shortUInt],
236
139
  ['name', name],
237
140
  ['nameSalt', uInt],
@@ -242,8 +145,9 @@ export const TX_SCHEMA = {
242
145
  },
243
146
  [Tag.NameUpdateTx]: {
244
147
  1: [
245
- ...BASE_TX,
246
- ['accountId', address<Encoding.AccountAddress>()],
148
+ ['tag', shortUIntConst(Tag.NameUpdateTx)],
149
+ ['version', shortUIntConst(1)],
150
+ ['accountId', address(Encoding.AccountAddress)],
247
151
  ['nonce', shortUInt],
248
152
  ['nameId', nameId],
249
153
  ['nameTtl', shortUInt],
@@ -255,19 +159,21 @@ export const TX_SCHEMA = {
255
159
  },
256
160
  [Tag.NameTransferTx]: {
257
161
  1: [
258
- ...BASE_TX,
259
- ['accountId', address<Encoding.AccountAddress>()],
162
+ ['tag', shortUIntConst(Tag.NameTransferTx)],
163
+ ['version', shortUIntConst(1)],
164
+ ['accountId', address(Encoding.AccountAddress)],
260
165
  ['nonce', shortUInt],
261
166
  ['nameId', nameId],
262
- ['recipientId', address<Encoding.AccountAddress | Encoding.Name>()],
167
+ ['recipientId', address(Encoding.AccountAddress, Encoding.Name)],
263
168
  ['fee', fee],
264
169
  ['ttl', shortUInt],
265
170
  ],
266
171
  },
267
172
  [Tag.NameRevokeTx]: {
268
173
  1: [
269
- ...BASE_TX,
270
- ['accountId', address<Encoding.AccountAddress>()],
174
+ ['tag', shortUIntConst(Tag.NameRevokeTx)],
175
+ ['version', shortUIntConst(1)],
176
+ ['accountId', address(Encoding.AccountAddress)],
271
177
  ['nonce', shortUInt],
272
178
  ['nameId', nameId],
273
179
  ['fee', fee],
@@ -276,84 +182,102 @@ export const TX_SCHEMA = {
276
182
  },
277
183
  [Tag.Contract]: {
278
184
  1: [
279
- ...BASE_TX,
280
- ['owner', address<Encoding.AccountAddress>()],
281
- ['ctVersion', FIELD_TYPES.ctVersion],
282
- ['code', FIELD_TYPES.binary, Encoding.ContractBytearray],
283
- ['log', FIELD_TYPES.binary, Encoding.ContractBytearray],
284
- ['active', FIELD_TYPES.bool],
285
- ['referers', addresses<Encoding.AccountAddress>()],
185
+ ['tag', shortUIntConst(Tag.Contract)],
186
+ ['version', shortUIntConst(1)],
187
+ ['owner', address(Encoding.AccountAddress)],
188
+ ['ctVersion', ctVersion],
189
+ ['code', encoded(Encoding.ContractBytearray)],
190
+ ['log', encoded(Encoding.ContractBytearray)],
191
+ ['active', boolean],
192
+ ['referers', array(address(Encoding.AccountAddress))],
286
193
  ['deposit', deposit],
287
194
  ],
288
195
  },
289
196
  [Tag.ContractCreateTx]: {
290
197
  1: [
291
- ...BASE_TX,
292
- ['ownerId', address<Encoding.AccountAddress>()],
198
+ ['tag', shortUIntConst(Tag.ContractCreateTx)],
199
+ ['version', shortUIntConst(1)],
200
+ ['ownerId', address(Encoding.AccountAddress)],
293
201
  ['nonce', shortUInt],
294
- ['code', FIELD_TYPES.binary, Encoding.ContractBytearray],
295
- ['ctVersion', FIELD_TYPES.ctVersion],
202
+ ['code', encoded(Encoding.ContractBytearray)],
203
+ ['ctVersion', ctVersion],
296
204
  ['fee', fee],
297
205
  ['ttl', shortUInt],
298
206
  ['deposit', deposit],
299
207
  ['amount', coinAmount],
300
208
  ['gasLimit', gasLimit],
301
209
  ['gasPrice', gasPrice],
302
- ['callData', FIELD_TYPES.binary, Encoding.ContractBytearray],
210
+ ['callData', encoded(Encoding.ContractBytearray)],
303
211
  ],
304
212
  },
305
213
  [Tag.ContractCallTx]: {
306
214
  1: [
307
- ...BASE_TX,
308
- ['callerId', address<Encoding.AccountAddress>()],
215
+ ['tag', shortUIntConst(Tag.ContractCallTx)],
216
+ ['version', shortUIntConst(1)],
217
+ ['callerId', address(Encoding.AccountAddress)],
309
218
  ['nonce', shortUInt],
310
- ['contractId', address<Encoding.ContractAddress | Encoding.Name>()],
311
- ['abiVersion', enumeration<ABI_VERSIONS>()],
219
+ ['contractId', address(Encoding.ContractAddress, Encoding.Name)],
220
+ ['abiVersion', abiVersion],
312
221
  ['fee', fee],
313
222
  ['ttl', shortUInt],
314
223
  ['amount', coinAmount],
315
224
  ['gasLimit', gasLimit],
316
225
  ['gasPrice', gasPrice],
317
- ['callData', FIELD_TYPES.binary, Encoding.ContractBytearray],
226
+ ['callData', encoded(Encoding.ContractBytearray)],
318
227
  ],
319
228
  },
320
229
  [Tag.ContractCall]: {
321
230
  1: [
322
- ...BASE_TX,
323
- ['callerId', address<Encoding.AccountAddress>()],
231
+ ['tag', shortUIntConst(Tag.ContractCall)],
232
+ ['version', shortUIntConst(1)],
233
+ ['callerId', address(Encoding.AccountAddress)],
324
234
  ['callerNonce', shortUInt],
325
235
  ['height', shortUInt],
326
- ['contractId', address<Encoding.ContractAddress>()],
236
+ ['contractId', address(Encoding.ContractAddress)],
327
237
  ['gasPrice', gasPrice],
328
238
  ['gasUsed', shortUInt],
329
- ['returnValue', FIELD_TYPES.binary, Encoding.ContractBytearray],
330
- ['returnType', enumeration<CallReturnType>()],
239
+ ['returnValue', encoded(Encoding.ContractBytearray)],
240
+ ['returnType', enumeration(CallReturnType)],
331
241
  // TODO: add serialization for
332
242
  // <log> :: [ { <address> :: id, [ <topics> :: binary() ], <data> :: binary() } ]
333
- ['log', FIELD_TYPES.rawBinary],
243
+ ['log', raw],
244
+ ],
245
+ },
246
+ [Tag.Oracle]: {
247
+ 1: [
248
+ ['tag', shortUIntConst(Tag.Oracle)],
249
+ ['version', shortUIntConst(1)],
250
+ ['accountId', address(Encoding.AccountAddress)],
251
+ ['queryFormat', string],
252
+ ['responseFormat', string],
253
+ ['queryFee', coinAmount],
254
+ ['oracleTtlValue', shortUInt],
255
+ ['abiVersion', abiVersion],
334
256
  ],
335
257
  },
336
258
  [Tag.OracleRegisterTx]: {
337
259
  1: [
338
- ...BASE_TX,
339
- ['accountId', address<Encoding.AccountAddress>()],
260
+ ['tag', shortUIntConst(Tag.OracleRegisterTx)],
261
+ ['version', shortUIntConst(1)],
262
+ ['accountId', address(Encoding.AccountAddress)],
340
263
  ['nonce', shortUInt],
341
- ['queryFormat', FIELD_TYPES.string],
342
- ['responseFormat', FIELD_TYPES.string],
264
+ ['queryFormat', string],
265
+ ['responseFormat', string],
343
266
  ['queryFee', coinAmount],
344
- ['oracleTtlType', enumeration<ORACLE_TTL_TYPES>()],
267
+ ['oracleTtlType', enumeration(ORACLE_TTL_TYPES)],
345
268
  ['oracleTtlValue', shortUInt],
346
269
  ['fee', fee],
347
270
  ['ttl', shortUInt],
348
- ['abiVersion', enumeration<ABI_VERSIONS>()],
271
+ ['abiVersion', abiVersion],
349
272
  ],
350
273
  },
351
274
  [Tag.OracleExtendTx]: {
352
275
  1: [
353
- ...BASE_TX,
354
- ['oracleId', address<Encoding.OracleAddress | Encoding.Name>()],
276
+ ['tag', shortUIntConst(Tag.OracleExtendTx)],
277
+ ['version', shortUIntConst(1)],
278
+ ['oracleId', address(Encoding.OracleAddress, Encoding.Name)],
355
279
  ['nonce', shortUInt],
356
- ['oracleTtlType', enumeration<ORACLE_TTL_TYPES>()],
280
+ ['oracleTtlType', enumeration(ORACLE_TTL_TYPES)],
357
281
  ['oracleTtlValue', shortUInt],
358
282
  ['fee', fee],
359
283
  ['ttl', shortUInt],
@@ -361,15 +285,16 @@ export const TX_SCHEMA = {
361
285
  },
362
286
  [Tag.OracleQueryTx]: {
363
287
  1: [
364
- ...BASE_TX,
365
- ['senderId', address<Encoding.AccountAddress>()],
288
+ ['tag', shortUIntConst(Tag.OracleQueryTx)],
289
+ ['version', shortUIntConst(1)],
290
+ ['senderId', address(Encoding.AccountAddress)],
366
291
  ['nonce', shortUInt],
367
- ['oracleId', address<Encoding.OracleAddress | Encoding.Name>()],
368
- ['query', FIELD_TYPES.string],
292
+ ['oracleId', address(Encoding.OracleAddress, Encoding.Name)],
293
+ ['query', string],
369
294
  ['queryFee', coinAmount],
370
- ['queryTtlType', enumeration<ORACLE_TTL_TYPES>()],
295
+ ['queryTtlType', enumeration(ORACLE_TTL_TYPES)],
371
296
  ['queryTtlValue', shortUInt],
372
- ['responseTtlType', enumeration<ORACLE_TTL_TYPES>()],
297
+ ['responseTtlType', enumeration(ORACLE_TTL_TYPES)],
373
298
  ['responseTtlValue', shortUInt],
374
299
  ['fee', fee],
375
300
  ['ttl', shortUInt],
@@ -377,12 +302,13 @@ export const TX_SCHEMA = {
377
302
  },
378
303
  [Tag.OracleResponseTx]: {
379
304
  1: [
380
- ...BASE_TX,
381
- ['oracleId', address<Encoding.OracleAddress>()],
305
+ ['tag', shortUIntConst(Tag.OracleResponseTx)],
306
+ ['version', shortUIntConst(1)],
307
+ ['oracleId', address(Encoding.OracleAddress)],
382
308
  ['nonce', shortUInt],
383
- ['queryId', FIELD_TYPES.binary, Encoding.OracleQueryId],
384
- ['response', FIELD_TYPES.string],
385
- ['responseTtlType', enumeration<ORACLE_TTL_TYPES>()],
309
+ ['queryId', encoded(Encoding.OracleQueryId)],
310
+ ['response', string],
311
+ ['responseTtlType', enumeration(ORACLE_TTL_TYPES)],
386
312
  ['responseTtlValue', shortUInt],
387
313
  ['fee', fee],
388
314
  ['ttl', shortUInt],
@@ -390,26 +316,28 @@ export const TX_SCHEMA = {
390
316
  },
391
317
  [Tag.ChannelCreateTx]: {
392
318
  2: [
393
- ...BASE_TX,
394
- ['initiator', address<Encoding.AccountAddress>()],
319
+ ['tag', shortUIntConst(Tag.ChannelCreateTx)],
320
+ ['version', shortUIntConst(2)],
321
+ ['initiator', address(Encoding.AccountAddress)],
395
322
  ['initiatorAmount', uInt],
396
- ['responder', address<Encoding.AccountAddress>()],
323
+ ['responder', address(Encoding.AccountAddress)],
397
324
  ['responderAmount', uInt],
398
325
  ['channelReserve', uInt],
399
326
  ['lockPeriod', uInt],
400
327
  ['ttl', shortUInt],
401
328
  ['fee', fee],
402
- ['initiatorDelegateIds', FIELD_TYPES.string],
403
- ['responderDelegateIds', FIELD_TYPES.string],
404
- ['stateHash', FIELD_TYPES.binary, Encoding.State],
329
+ ['initiatorDelegateIds', array(address(...idTagToEncoding))],
330
+ ['responderDelegateIds', array(address(...idTagToEncoding))],
331
+ ['stateHash', encoded(Encoding.State)],
405
332
  ['nonce', shortUInt],
406
333
  ],
407
334
  },
408
335
  [Tag.ChannelCloseMutualTx]: {
409
336
  1: [
410
- ...BASE_TX,
411
- ['channelId', address<Encoding.Channel>()],
412
- ['fromId', address<Encoding.AccountAddress>()],
337
+ ['tag', shortUIntConst(Tag.ChannelCloseMutualTx)],
338
+ ['version', shortUIntConst(1)],
339
+ ['channelId', address(Encoding.Channel)],
340
+ ['fromId', address(Encoding.AccountAddress)],
413
341
  ['initiatorAmountFinal', uInt],
414
342
  ['responderAmountFinal', uInt],
415
343
  ['ttl', shortUInt],
@@ -419,11 +347,12 @@ export const TX_SCHEMA = {
419
347
  },
420
348
  [Tag.ChannelCloseSoloTx]: {
421
349
  1: [
422
- ...BASE_TX,
423
- ['channelId', address<Encoding.Channel>()],
424
- ['fromId', address<Encoding.AccountAddress>()],
425
- ['payload', FIELD_TYPES.binary, Encoding.Transaction],
426
- ['poi', FIELD_TYPES.binary, Encoding.Poi],
350
+ ['tag', shortUIntConst(Tag.ChannelCloseSoloTx)],
351
+ ['version', shortUIntConst(1)],
352
+ ['channelId', address(Encoding.Channel)],
353
+ ['fromId', address(Encoding.AccountAddress)],
354
+ ['payload', encoded(Encoding.Transaction)],
355
+ ['poi', entry(Tag.TreesPoi)],
427
356
  ['ttl', shortUInt],
428
357
  ['fee', fee],
429
358
  ['nonce', shortUInt],
@@ -431,11 +360,12 @@ export const TX_SCHEMA = {
431
360
  },
432
361
  [Tag.ChannelSlashTx]: {
433
362
  1: [
434
- ...BASE_TX,
435
- ['channelId', address<Encoding.Channel>()],
436
- ['fromId', address<Encoding.AccountAddress>()],
437
- ['payload', FIELD_TYPES.binary, Encoding.Transaction],
438
- ['poi', FIELD_TYPES.binary, Encoding.Poi],
363
+ ['tag', shortUIntConst(Tag.ChannelSlashTx)],
364
+ ['version', shortUIntConst(1)],
365
+ ['channelId', address(Encoding.Channel)],
366
+ ['fromId', address(Encoding.AccountAddress)],
367
+ ['payload', encoded(Encoding.Transaction)],
368
+ ['poi', entry(Tag.TreesPoi)],
439
369
  ['ttl', shortUInt],
440
370
  ['fee', fee],
441
371
  ['nonce', shortUInt],
@@ -443,35 +373,38 @@ export const TX_SCHEMA = {
443
373
  },
444
374
  [Tag.ChannelDepositTx]: {
445
375
  1: [
446
- ...BASE_TX,
447
- ['channelId', address<Encoding.Channel>()],
448
- ['fromId', address<Encoding.AccountAddress>()],
376
+ ['tag', shortUIntConst(Tag.ChannelDepositTx)],
377
+ ['version', shortUIntConst(1)],
378
+ ['channelId', address(Encoding.Channel)],
379
+ ['fromId', address(Encoding.AccountAddress)],
449
380
  ['amount', uInt],
450
381
  ['ttl', shortUInt],
451
382
  ['fee', fee],
452
- ['stateHash', FIELD_TYPES.binary, Encoding.State],
383
+ ['stateHash', encoded(Encoding.State)],
453
384
  ['round', shortUInt],
454
385
  ['nonce', shortUInt],
455
386
  ],
456
387
  },
457
388
  [Tag.ChannelWithdrawTx]: {
458
389
  1: [
459
- ...BASE_TX,
460
- ['channelId', address<Encoding.Channel>()],
461
- ['toId', address<Encoding.AccountAddress>()],
390
+ ['tag', shortUIntConst(Tag.ChannelWithdrawTx)],
391
+ ['version', shortUIntConst(1)],
392
+ ['channelId', address(Encoding.Channel)],
393
+ ['toId', address(Encoding.AccountAddress)],
462
394
  ['amount', uInt],
463
395
  ['ttl', shortUInt],
464
396
  ['fee', fee],
465
- ['stateHash', FIELD_TYPES.binary, Encoding.State],
397
+ ['stateHash', encoded(Encoding.State)],
466
398
  ['round', shortUInt],
467
399
  ['nonce', shortUInt],
468
400
  ],
469
401
  },
470
402
  [Tag.ChannelSettleTx]: {
471
403
  1: [
472
- ...BASE_TX,
473
- ['channelId', address<Encoding.Channel>()],
474
- ['fromId', address<Encoding.AccountAddress>()],
404
+ ['tag', shortUIntConst(Tag.ChannelSettleTx)],
405
+ ['version', shortUIntConst(1)],
406
+ ['channelId', address(Encoding.Channel)],
407
+ ['fromId', address(Encoding.AccountAddress)],
475
408
  ['initiatorAmountFinal', uInt],
476
409
  ['responderAmountFinal', uInt],
477
410
  ['ttl', shortUInt],
@@ -481,14 +414,15 @@ export const TX_SCHEMA = {
481
414
  },
482
415
  [Tag.ChannelForceProgressTx]: {
483
416
  1: [
484
- ...BASE_TX,
485
- ['channelId', address<Encoding.Channel>()],
486
- ['fromId', address<Encoding.AccountAddress>()],
487
- ['payload', FIELD_TYPES.binary, Encoding.Transaction],
417
+ ['tag', shortUIntConst(Tag.ChannelForceProgressTx)],
418
+ ['version', shortUIntConst(1)],
419
+ ['channelId', address(Encoding.Channel)],
420
+ ['fromId', address(Encoding.AccountAddress)],
421
+ ['payload', encoded(Encoding.Transaction)],
488
422
  ['round', shortUInt],
489
- ['update', FIELD_TYPES.binary, Encoding.ContractBytearray],
490
- ['stateHash', FIELD_TYPES.binary, Encoding.State],
491
- ['offChainTrees', FIELD_TYPES.stateTree],
423
+ ['update', encoded(Encoding.ContractBytearray)],
424
+ ['stateHash', encoded(Encoding.State)],
425
+ ['offChainTrees', encoded(Encoding.StateTrees)],
492
426
  ['ttl', shortUInt],
493
427
  ['fee', fee],
494
428
  ['nonce', shortUInt],
@@ -496,38 +430,41 @@ export const TX_SCHEMA = {
496
430
  },
497
431
  [Tag.ChannelOffChainTx]: {
498
432
  2: [
499
- ...BASE_TX,
500
- ['channelId', address<Encoding.Channel>()],
433
+ ['tag', shortUIntConst(Tag.ChannelOffChainTx)],
434
+ ['version', shortUIntConst(2)],
435
+ ['channelId', address(Encoding.Channel)],
501
436
  ['round', shortUInt],
502
- ['stateHash', FIELD_TYPES.binary, Encoding.State],
437
+ ['stateHash', encoded(Encoding.State)],
503
438
  ],
504
439
  },
505
440
  [Tag.Channel]: {
506
441
  3: [
507
- ...BASE_TX,
508
- ['initiator', address<Encoding.AccountAddress>()],
509
- ['responder', address<Encoding.AccountAddress>()],
442
+ ['tag', shortUIntConst(Tag.Channel)],
443
+ ['version', shortUIntConst(3)],
444
+ ['initiator', address(Encoding.AccountAddress)],
445
+ ['responder', address(Encoding.AccountAddress)],
510
446
  ['channelAmount', uInt],
511
447
  ['initiatorAmount', uInt],
512
448
  ['responderAmount', uInt],
513
449
  ['channelReserve', uInt],
514
- ['initiatorDelegateIds', addresses<AddressEncodings>()],
515
- ['responderDelegateIds', addresses<AddressEncodings>()],
516
- ['stateHash', FIELD_TYPES.hex],
450
+ ['initiatorDelegateIds', array(address(...idTagToEncoding))],
451
+ ['responderDelegateIds', array(address(...idTagToEncoding))],
452
+ ['stateHash', encoded(Encoding.State)],
517
453
  ['round', shortUInt],
518
454
  ['soloRound', uInt],
519
455
  ['lockPeriod', uInt],
520
456
  ['lockedUntil', uInt],
521
- ['initiatorAuth', FIELD_TYPES.binary, Encoding.ContractBytearray],
522
- ['responderAuth', FIELD_TYPES.binary, Encoding.ContractBytearray],
457
+ ['initiatorAuth', encoded(Encoding.ContractBytearray)],
458
+ ['responderAuth', encoded(Encoding.ContractBytearray)],
523
459
  ],
524
460
  },
525
461
  [Tag.ChannelSnapshotSoloTx]: {
526
462
  1: [
527
- ...BASE_TX,
528
- ['channelId', address<Encoding.Channel>()],
529
- ['fromId', address<Encoding.AccountAddress>()],
530
- ['payload', FIELD_TYPES.binary, Encoding.Transaction],
463
+ ['tag', shortUIntConst(Tag.ChannelSnapshotSoloTx)],
464
+ ['version', shortUIntConst(1)],
465
+ ['channelId', address(Encoding.Channel)],
466
+ ['fromId', address(Encoding.AccountAddress)],
467
+ ['payload', encoded(Encoding.Transaction)],
531
468
  ['ttl', shortUInt],
532
469
  ['fee', fee],
533
470
  ['nonce', shortUInt],
@@ -535,181 +472,194 @@ export const TX_SCHEMA = {
535
472
  },
536
473
  [Tag.ChannelOffChainUpdateTransfer]: {
537
474
  1: [
538
- ...BASE_TX,
539
- ['from', address<Encoding.AccountAddress>()],
540
- ['to', address<Encoding.AccountAddress>()],
475
+ ['tag', shortUIntConst(Tag.ChannelOffChainUpdateTransfer)],
476
+ ['version', shortUIntConst(1)],
477
+ ['from', address(Encoding.AccountAddress)],
478
+ ['to', address(Encoding.AccountAddress)],
541
479
  ['amount', uInt],
542
480
  ],
543
481
  },
544
482
  [Tag.ChannelOffChainUpdateDeposit]: {
545
483
  1: [
546
- ...BASE_TX,
547
- ['from', address<Encoding.AccountAddress>()],
484
+ ['tag', shortUIntConst(Tag.ChannelOffChainUpdateDeposit)],
485
+ ['version', shortUIntConst(1)],
486
+ ['from', address(Encoding.AccountAddress)],
548
487
  ['amount', uInt],
549
488
  ],
550
489
  },
551
490
  [Tag.ChannelOffChainUpdateWithdraw]: {
552
491
  1: [
553
- ...BASE_TX,
554
- ['from', address<Encoding.AccountAddress>()],
492
+ ['tag', shortUIntConst(Tag.ChannelOffChainUpdateWithdraw)],
493
+ ['version', shortUIntConst(1)],
494
+ ['from', address(Encoding.AccountAddress)],
555
495
  ['amount', uInt],
556
496
  ],
557
497
  },
558
498
  [Tag.ChannelOffChainUpdateCreateContract]: {
559
499
  1: [
560
- ...BASE_TX,
561
- ['owner', address<Encoding.AccountAddress>()],
562
- ['ctVersion', FIELD_TYPES.ctVersion],
563
- ['code', FIELD_TYPES.binary, Encoding.ContractBytearray],
500
+ ['tag', shortUIntConst(Tag.ChannelOffChainUpdateCreateContract)],
501
+ ['version', shortUIntConst(1)],
502
+ ['owner', address(Encoding.AccountAddress)],
503
+ ['ctVersion', ctVersion],
504
+ ['code', encoded(Encoding.ContractBytearray)],
564
505
  ['deposit', uInt],
565
- ['callData', FIELD_TYPES.binary, Encoding.ContractBytearray],
506
+ ['callData', encoded(Encoding.ContractBytearray)],
566
507
  ],
567
508
  },
568
509
  [Tag.ChannelOffChainUpdateCallContract]: {
569
510
  1: [
570
- ...BASE_TX,
571
- ['caller', address<Encoding.AccountAddress>()],
572
- ['contract', address<Encoding.ContractAddress>()],
573
- ['abiVersion', enumeration<ABI_VERSIONS>()],
511
+ ['tag', shortUIntConst(Tag.ChannelOffChainUpdateCallContract)],
512
+ ['version', shortUIntConst(1)],
513
+ ['caller', address(Encoding.AccountAddress)],
514
+ ['contract', address(Encoding.ContractAddress)],
515
+ ['abiVersion', abiVersion],
574
516
  ['amount', uInt],
575
- ['callData', FIELD_TYPES.binary, Encoding.ContractBytearray],
576
- ['callStack', FIELD_TYPES.callStack],
517
+ ['callData', encoded(Encoding.ContractBytearray)],
518
+ ['callStack', raw],
577
519
  ['gasPrice', gasPrice],
578
520
  ['gasLimit', gasLimit],
579
521
  ],
580
522
  },
581
523
  [Tag.ChannelClientReconnectTx]: {
582
524
  1: [
583
- ...BASE_TX,
584
- ['channelId', address<Encoding.Channel>()],
525
+ ['tag', shortUIntConst(Tag.ChannelClientReconnectTx)],
526
+ ['version', shortUIntConst(1)],
527
+ ['channelId', address(Encoding.Channel)],
585
528
  ['round', shortUInt],
586
- ['role', FIELD_TYPES.string],
587
- ['pubkey', address<Encoding.AccountAddress>()],
529
+ ['role', string],
530
+ ['pubkey', address(Encoding.AccountAddress)],
588
531
  ],
589
532
  },
590
533
  [Tag.TreesPoi]: {
591
534
  1: [
592
- ...BASE_TX,
593
- ['accounts', FIELD_TYPES.mptrees],
594
- ['calls', FIELD_TYPES.mptrees],
595
- ['channels', FIELD_TYPES.mptrees],
596
- ['contracts', FIELD_TYPES.mptrees],
597
- ['ns', FIELD_TYPES.mptrees],
598
- ['oracles', FIELD_TYPES.mptrees],
535
+ ['tag', shortUIntConst(Tag.TreesPoi)],
536
+ ['version', shortUIntConst(1)],
537
+ ['accounts', array(mptree(Encoding.AccountAddress, Tag.Account))],
538
+ ['calls', array(mptree(Encoding.Bytearray, Tag.ContractCall))],
539
+ ['channels', array(mptree(Encoding.Channel, Tag.Channel))],
540
+ ['contracts', array(mptree(Encoding.ContractAddress, Tag.Contract))],
541
+ ['ns', array(mptree(Encoding.Name, Tag.Name))],
542
+ ['oracles', array(mptree(Encoding.OracleAddress, Tag.Oracle))],
599
543
  ],
600
544
  },
601
545
  [Tag.StateTrees]: {
602
546
  1: [
603
- ...BASE_TX,
604
- ['contracts', FIELD_TYPES.rlpBinary],
605
- ['calls', FIELD_TYPES.rlpBinary],
606
- ['channels', FIELD_TYPES.rlpBinary],
607
- ['ns', FIELD_TYPES.rlpBinary],
608
- ['oracles', FIELD_TYPES.rlpBinary],
609
- ['accounts', FIELD_TYPES.rlpBinary],
547
+ ['tag', shortUIntConst(Tag.StateTrees)],
548
+ ['version', shortUIntConst(1)],
549
+ ['contracts', entry()],
550
+ ['calls', entry()],
551
+ ['channels', entry()],
552
+ ['ns', entry()],
553
+ ['oracles', entry()],
554
+ ['accounts', entry()],
610
555
  ],
611
556
  },
612
557
  [Tag.Mtree]: {
613
558
  1: [
614
- ...BASE_TX,
615
- ['values', FIELD_TYPES.rlpBinaries],
559
+ ['tag', shortUIntConst(Tag.Mtree)],
560
+ ['version', shortUIntConst(1)],
561
+ ['values', array(entry())],
616
562
  ],
617
563
  },
618
564
  [Tag.MtreeValue]: {
619
565
  1: [
620
- ...BASE_TX,
621
- ['key', FIELD_TYPES.hex],
622
- ['value', FIELD_TYPES.rawBinary],
566
+ ['tag', shortUIntConst(Tag.MtreeValue)],
567
+ ['version', shortUIntConst(1)],
568
+ ['key', raw],
569
+ ['value', raw],
623
570
  ],
624
571
  },
625
572
  [Tag.ContractsMtree]: {
626
573
  1: [
627
- ...BASE_TX,
628
- ['contracts', FIELD_TYPES.rlpBinary],
574
+ ['tag', shortUIntConst(Tag.ContractsMtree)],
575
+ ['version', shortUIntConst(1)],
576
+ ['contracts', entry()],
629
577
  ],
630
578
  },
631
579
  [Tag.CallsMtree]: {
632
580
  1: [
633
- ...BASE_TX,
634
- ['calls', FIELD_TYPES.rlpBinary],
581
+ ['tag', shortUIntConst(Tag.CallsMtree)],
582
+ ['version', shortUIntConst(1)],
583
+ ['calls', entry()],
635
584
  ],
636
585
  },
637
586
  [Tag.ChannelsMtree]: {
638
587
  1: [
639
- ...BASE_TX,
640
- ['channels', FIELD_TYPES.rlpBinary],
588
+ ['tag', shortUIntConst(Tag.ChannelsMtree)],
589
+ ['version', shortUIntConst(1)],
590
+ ['channels', entry()],
641
591
  ],
642
592
  },
643
593
  [Tag.NameserviceMtree]: {
644
594
  1: [
645
- ...BASE_TX,
646
- ['mtree', FIELD_TYPES.rlpBinary],
595
+ ['tag', shortUIntConst(Tag.NameserviceMtree)],
596
+ ['version', shortUIntConst(1)],
597
+ ['mtree', entry()],
647
598
  ],
648
599
  },
649
600
  [Tag.OraclesMtree]: {
650
601
  1: [
651
- ...BASE_TX,
652
- ['otree', FIELD_TYPES.rlpBinary],
602
+ ['tag', shortUIntConst(Tag.OraclesMtree)],
603
+ ['version', shortUIntConst(1)],
604
+ ['otree', entry()],
653
605
  ],
654
606
  },
655
607
  [Tag.AccountsMtree]: {
656
608
  1: [
657
- ...BASE_TX,
658
- ['accounts', FIELD_TYPES.rlpBinary],
609
+ ['tag', shortUIntConst(Tag.AccountsMtree)],
610
+ ['version', shortUIntConst(1)],
611
+ ['accounts', entry()],
659
612
  ],
660
613
  },
661
614
  [Tag.GaAttachTx]: {
662
615
  1: [
663
- ...BASE_TX,
664
- ['ownerId', address<Encoding.AccountAddress>()],
616
+ ['tag', shortUIntConst(Tag.GaAttachTx)],
617
+ ['version', shortUIntConst(1)],
618
+ ['ownerId', address(Encoding.AccountAddress)],
665
619
  ['nonce', shortUInt],
666
- ['code', FIELD_TYPES.binary, Encoding.ContractBytearray],
667
- ['authFun', FIELD_TYPES.rawBinary],
668
- ['ctVersion', FIELD_TYPES.ctVersion],
620
+ ['code', encoded(Encoding.ContractBytearray)],
621
+ ['authFun', raw],
622
+ ['ctVersion', ctVersion],
669
623
  ['fee', fee],
670
624
  ['ttl', shortUInt],
671
625
  ['gasLimit', gasLimit],
672
626
  ['gasPrice', gasPrice],
673
- ['callData', FIELD_TYPES.binary, Encoding.ContractBytearray],
627
+ ['callData', encoded(Encoding.ContractBytearray)],
674
628
  ],
675
629
  },
676
630
  [Tag.GaMetaTx]: {
677
631
  2: [
678
- ...BASE_TX,
679
- ['gaId', address<Encoding.AccountAddress>()],
680
- ['authData', FIELD_TYPES.binary, Encoding.ContractBytearray],
681
- ['abiVersion', enumeration<ABI_VERSIONS>()],
632
+ ['tag', shortUIntConst(Tag.GaMetaTx)],
633
+ ['version', shortUIntConst(2)],
634
+ ['gaId', address(Encoding.AccountAddress)],
635
+ ['authData', encoded(Encoding.ContractBytearray)],
636
+ ['abiVersion', abiVersion],
682
637
  ['fee', fee],
683
638
  ['gasLimit', gasLimit],
684
639
  ['gasPrice', gasPrice],
685
- ['tx', FIELD_TYPES.rlpBinary],
640
+ ['tx', entry()],
686
641
  ],
687
642
  },
688
643
  [Tag.PayingForTx]: {
689
644
  1: [
690
- ...BASE_TX,
691
- ['payerId', address<Encoding.AccountAddress>()],
645
+ ['tag', shortUIntConst(Tag.PayingForTx)],
646
+ ['version', shortUIntConst(1)],
647
+ ['payerId', address(Encoding.AccountAddress)],
692
648
  ['nonce', shortUInt],
693
649
  ['fee', fee],
694
- ['tx', FIELD_TYPES.rlpBinary],
695
- ],
696
- },
697
- [Tag.CompilerSophia]: {
698
- 3: [
699
- ...BASE_TX,
700
- ['sourceCodeHash', FIELD_TYPES.rawBinary],
701
- ['typeInfo', FIELD_TYPES.sophiaCodeTypeInfo],
702
- ['byteCode', FIELD_TYPES.rawBinary],
703
- ['compilerVersion', FIELD_TYPES.string],
704
- ['payable', FIELD_TYPES.bool],
650
+ ['tx', entry()],
705
651
  ],
706
652
  },
707
653
  } as const;
708
654
 
655
+ type TxTypeSchemasNotCombined = {
656
+ [tag in Tag]: {
657
+ [ver in keyof typeof TX_SCHEMA[tag]]: BuildTxArgBySchema<typeof TX_SCHEMA[tag][ver]>
658
+ }
659
+ };
660
+
709
661
  export type TxTypeSchemas = {
710
- [key in Tag]: BuildTxArgBySchema<
711
- typeof TX_SCHEMA[key][keyof typeof TX_SCHEMA[key]]
712
- >
662
+ [key in Tag]: TxTypeSchemasNotCombined[key][keyof TxTypeSchemasNotCombined[key]]
713
663
  };
714
664
 
715
665
  export type TxSchema = TxTypeSchemas[Tag];