@aeternity/aepp-sdk 11.0.1 → 12.0.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 (376) hide show
  1. package/LICENSE +1 -1
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +12 -19
  4. package/dist/aepp-sdk.browser-script.js.map +1 -1
  5. package/dist/aepp-sdk.browser.js +1 -1
  6. package/dist/aepp-sdk.browser.js.map +1 -1
  7. package/dist/aepp-sdk.js +1 -1
  8. package/dist/aepp-sdk.js.map +1 -1
  9. package/es/AeSdk.d.ts +37 -0
  10. package/es/AeSdk.mjs +81 -0
  11. package/es/AeSdk.mjs.map +1 -0
  12. package/es/AeSdkAepp.d.ts +69 -0
  13. package/es/AeSdkAepp.mjs +175 -0
  14. package/es/AeSdkAepp.mjs.map +1 -0
  15. package/es/AeSdkBase.d.ts +212 -0
  16. package/es/AeSdkBase.mjs +310 -0
  17. package/es/AeSdkBase.mjs.map +1 -0
  18. package/es/AeSdkWallet.d.ts +103 -0
  19. package/es/AeSdkWallet.mjs +322 -0
  20. package/es/AeSdkWallet.mjs.map +1 -0
  21. package/es/Node.d.ts +44 -0
  22. package/es/Node.mjs +141 -0
  23. package/es/Node.mjs.map +1 -0
  24. package/es/account/Base.d.ts +65 -0
  25. package/es/account/Base.mjs +123 -0
  26. package/es/account/Base.mjs.map +1 -0
  27. package/es/account/Memory.d.ts +25 -0
  28. package/es/account/Memory.mjs +81 -0
  29. package/es/account/Memory.mjs.map +1 -0
  30. package/es/account/Rpc.d.ts +27 -0
  31. package/es/account/Rpc.mjs +79 -0
  32. package/es/account/Rpc.mjs.map +1 -0
  33. package/es/aens.d.ts +209 -0
  34. package/es/aens.mjs +332 -0
  35. package/es/aens.mjs.map +1 -0
  36. package/es/aepp-wallet-communication/connection/Browser.d.ts +32 -0
  37. package/es/aepp-wallet-communication/connection/Browser.mjs +70 -0
  38. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
  39. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +17 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +57 -0
  41. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
  42. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +35 -0
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +142 -0
  44. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
  45. package/es/aepp-wallet-communication/connection-proxy.d.ts +10 -0
  46. package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +15 -11
  47. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
  48. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +33 -0
  49. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
  50. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
  51. package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
  52. package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
  53. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
  54. package/es/aepp-wallet-communication/schema.d.ts +90 -46
  55. package/es/aepp-wallet-communication/schema.mjs +214 -0
  56. package/es/aepp-wallet-communication/schema.mjs.map +1 -0
  57. package/es/aepp-wallet-communication/wallet-detector.d.ts +24 -0
  58. package/es/aepp-wallet-communication/wallet-detector.mjs +63 -0
  59. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  60. package/es/apis/compiler/compiler.d.ts +92 -0
  61. package/es/apis/compiler/compiler.mjs +576 -0
  62. package/es/apis/compiler/compiler.mjs.map +1 -0
  63. package/es/apis/compiler/index.d.ts +2 -0
  64. package/es/apis/compiler/index.mjs +3 -0
  65. package/es/apis/compiler/index.mjs.map +1 -0
  66. package/es/apis/compiler/models/index.d.ts +248 -0
  67. package/es/apis/compiler/models/index.mjs +48 -0
  68. package/es/apis/compiler/models/index.mjs.map +1 -0
  69. package/es/apis/compiler/models/mappers.d.ts +23 -0
  70. package/es/apis/compiler/models/mappers.mjs +585 -0
  71. package/es/apis/compiler/models/mappers.mjs.map +1 -0
  72. package/es/apis/compiler/models/parameters.d.ts +13 -0
  73. package/es/apis/compiler/models/parameters.mjs +71 -0
  74. package/es/apis/compiler/models/parameters.mjs.map +1 -0
  75. package/es/apis/node/index.d.ts +2 -0
  76. package/es/apis/node/index.mjs +3 -0
  77. package/es/apis/node/index.mjs.map +1 -0
  78. package/es/apis/node/models/index.d.ts +1061 -0
  79. package/es/apis/node/models/index.mjs +2 -0
  80. package/es/apis/node/models/index.mjs.map +1 -0
  81. package/es/apis/node/models/mappers.d.ts +95 -0
  82. package/es/apis/node/models/mappers.mjs +4164 -0
  83. package/es/apis/node/models/mappers.mjs.map +1 -0
  84. package/es/apis/node/models/parameters.d.ts +17 -0
  85. package/es/apis/node/models/parameters.mjs +165 -0
  86. package/es/apis/node/models/parameters.mjs.map +1 -0
  87. package/es/apis/node/node.d.ts +215 -0
  88. package/es/apis/node/node.mjs +1165 -0
  89. package/es/apis/node/node.mjs.map +1 -0
  90. package/es/chain.d.ts +220 -0
  91. package/es/chain.mjs +524 -0
  92. package/es/chain.mjs.map +1 -0
  93. package/es/channel/handlers.d.ts +34 -0
  94. package/es/channel/handlers.mjs +147 -112
  95. package/es/channel/handlers.mjs.map +1 -1
  96. package/es/channel/index.d.ts +634 -0
  97. package/es/channel/index.mjs +898 -900
  98. package/es/channel/index.mjs.map +1 -1
  99. package/es/channel/internal.d.ts +100 -0
  100. package/es/channel/internal.mjs +97 -51
  101. package/es/channel/internal.mjs.map +1 -1
  102. package/es/contract/Compiler.d.ts +17 -0
  103. package/es/contract/Compiler.mjs +67 -0
  104. package/es/contract/Compiler.mjs.map +1 -0
  105. package/es/contract/aci.d.ts +125 -0
  106. package/es/contract/aci.mjs +199 -180
  107. package/es/contract/aci.mjs.map +1 -1
  108. package/es/contract/ga.d.ts +68 -0
  109. package/es/contract/ga.mjs +190 -0
  110. package/es/contract/ga.mjs.map +1 -0
  111. package/es/contract/methods.d.ts +68 -0
  112. package/es/contract/methods.mjs +101 -0
  113. package/es/contract/methods.mjs.map +1 -0
  114. package/es/index.d.ts +32 -0
  115. package/es/index.mjs +32 -40
  116. package/es/index.mjs.map +1 -1
  117. package/es/oracle.d.ts +154 -0
  118. package/es/oracle.mjs +288 -0
  119. package/es/oracle.mjs.map +1 -0
  120. package/es/spend.d.ts +61 -0
  121. package/es/spend.mjs +122 -0
  122. package/es/spend.mjs.map +1 -0
  123. package/es/tx/builder/constants.d.ts +41 -0
  124. package/es/tx/builder/constants.mjs +11 -19
  125. package/es/tx/builder/constants.mjs.map +1 -1
  126. package/es/tx/builder/field-types.d.ts +62 -0
  127. package/es/tx/builder/field-types.mjs +62 -10
  128. package/es/tx/builder/field-types.mjs.map +1 -1
  129. package/es/tx/builder/helpers.d.ts +131 -0
  130. package/es/tx/builder/helpers.mjs +71 -169
  131. package/es/tx/builder/helpers.mjs.map +1 -1
  132. package/es/tx/builder/index.d.ts +75 -0
  133. package/es/tx/builder/index.mjs +141 -323
  134. package/es/tx/builder/index.mjs.map +1 -1
  135. package/es/tx/builder/schema.d.ts +350 -0
  136. package/es/tx/builder/schema.mjs +173 -510
  137. package/es/tx/builder/schema.mjs.map +1 -1
  138. package/es/tx/index.d.ts +63 -0
  139. package/es/tx/index.mjs +171 -265
  140. package/es/tx/index.mjs.map +1 -1
  141. package/es/tx/min-fee.d.ts +20 -0
  142. package/es/tx/min-fee.mjs +148 -0
  143. package/es/tx/min-fee.mjs.map +1 -0
  144. package/es/tx/validator.d.ts +19 -0
  145. package/es/tx/validator.mjs +64 -71
  146. package/es/tx/validator.mjs.map +1 -1
  147. package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
  148. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
  149. package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
  150. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
  151. package/es/typings/bip32-path/index.d.mjs +2 -0
  152. package/es/typings/bip32-path/index.d.mjs.map +1 -0
  153. package/es/typings/blakejs/index.d.mjs.map +1 -1
  154. package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
  155. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
  156. package/es/utils/amount-formatter.d.ts +42 -0
  157. package/es/utils/amount-formatter.mjs +28 -41
  158. package/es/utils/amount-formatter.mjs.map +1 -1
  159. package/es/utils/autorest.d.ts +6 -0
  160. package/es/utils/autorest.mjs +97 -0
  161. package/es/utils/autorest.mjs.map +1 -0
  162. package/es/utils/bignumber.d.ts +13 -0
  163. package/es/utils/bignumber.mjs +10 -8
  164. package/es/utils/bignumber.mjs.map +1 -1
  165. package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
  166. package/es/utils/bytes.mjs +10 -14
  167. package/es/utils/bytes.mjs.map +1 -1
  168. package/es/utils/crypto.d.ts +103 -0
  169. package/es/utils/crypto.mjs +60 -68
  170. package/es/utils/crypto.mjs.map +1 -1
  171. package/es/utils/encoder.d.ts +26 -0
  172. package/es/utils/encoder.mjs +47 -51
  173. package/es/utils/encoder.mjs.map +1 -1
  174. package/es/{errors.d.ts → utils/errors.d.ts} +254 -57
  175. package/es/utils/errors.mjs +318 -125
  176. package/es/utils/errors.mjs.map +1 -1
  177. package/es/utils/hd-wallet.d.ts +34 -0
  178. package/es/utils/hd-wallet.mjs +27 -16
  179. package/es/utils/hd-wallet.mjs.map +1 -1
  180. package/es/utils/json-big.d.ts +5 -0
  181. package/es/utils/json-big.mjs +10 -14
  182. package/es/utils/json-big.mjs.map +1 -1
  183. package/es/utils/keystore.d.ts +51 -0
  184. package/es/utils/keystore.mjs +98 -193
  185. package/es/utils/keystore.mjs.map +1 -1
  186. package/es/{mptree.d.ts → utils/mptree.d.ts} +5 -8
  187. package/es/utils/mptree.mjs +13 -14
  188. package/es/utils/mptree.mjs.map +1 -1
  189. package/es/utils/other.d.ts +14 -0
  190. package/es/utils/other.mjs +21 -36
  191. package/es/utils/other.mjs.map +1 -1
  192. package/es/{semver-satisfies.d.ts → utils/semver-satisfies.d.ts} +0 -0
  193. package/es/utils/semver-satisfies.mjs.map +1 -1
  194. package/es/utils/string.d.ts +24 -0
  195. package/es/utils/string.mjs +8 -10
  196. package/es/utils/string.mjs.map +1 -1
  197. package/package.json +49 -39
  198. package/src/AeSdk.ts +65 -0
  199. package/src/AeSdkAepp.ts +167 -0
  200. package/src/AeSdkBase.ts +320 -0
  201. package/src/AeSdkWallet.ts +332 -0
  202. package/src/Node.ts +167 -0
  203. package/src/account/Base.ts +114 -0
  204. package/src/account/Memory.ts +83 -0
  205. package/src/account/Rpc.ts +67 -0
  206. package/src/aens.ts +391 -0
  207. package/src/aepp-wallet-communication/connection/Browser.ts +68 -0
  208. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +58 -0
  209. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +111 -0
  210. package/{es/utils/crypto-ts.mjs → src/aepp-wallet-communication/connection-proxy.ts} +16 -17
  211. package/src/aepp-wallet-communication/rpc/RpcClient.ts +137 -0
  212. package/src/aepp-wallet-communication/rpc/types.ts +66 -0
  213. package/src/aepp-wallet-communication/schema.ts +181 -0
  214. package/src/aepp-wallet-communication/wallet-detector.ts +71 -0
  215. package/src/apis/compiler/code-model-v4.yaml +2649 -0
  216. package/src/apis/compiler/compiler.ts +585 -0
  217. package/src/apis/compiler/index.ts +2 -0
  218. package/src/apis/compiler/models/index.ts +301 -0
  219. package/src/apis/compiler/models/mappers.ts +583 -0
  220. package/src/apis/compiler/models/parameters.ts +93 -0
  221. package/src/apis/node/code-model-v4.yaml +10046 -0
  222. package/src/apis/node/index.ts +2 -0
  223. package/src/apis/node/models/index.ts +1253 -0
  224. package/src/apis/node/models/mappers.ts +4278 -0
  225. package/src/apis/node/models/parameters.ts +188 -0
  226. package/src/apis/node/node.ts +1299 -0
  227. package/src/chain.ts +444 -0
  228. package/src/channel/{handlers.js → handlers.ts} +220 -128
  229. package/src/channel/index.ts +991 -0
  230. package/src/channel/internal.ts +345 -0
  231. package/src/contract/Compiler.ts +66 -0
  232. package/src/contract/aci.ts +529 -0
  233. package/src/contract/ga.ts +178 -0
  234. package/src/contract/methods.ts +118 -0
  235. package/src/index.ts +51 -0
  236. package/src/oracle.ts +342 -0
  237. package/src/spend.ts +152 -0
  238. package/src/tx/builder/{constants.js → constants.ts} +12 -16
  239. package/src/tx/builder/field-types.ts +111 -0
  240. package/src/tx/builder/helpers.ts +253 -0
  241. package/src/tx/builder/index.ts +394 -0
  242. package/src/tx/builder/schema.ts +771 -0
  243. package/src/tx/index.ts +199 -0
  244. package/src/tx/min-fee.ts +136 -0
  245. package/src/tx/validator.ts +226 -0
  246. package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
  247. package/src/typings/@aeternity__uuid/index.d.ts +3 -0
  248. package/src/typings/bip32-path/index.d.ts +33 -0
  249. package/src/typings/tweetnacl-auth/index.d.ts +14 -0
  250. package/src/utils/amount-formatter.ts +29 -42
  251. package/src/utils/autorest.ts +90 -0
  252. package/src/utils/bignumber.ts +9 -11
  253. package/src/utils/bytes.ts +12 -14
  254. package/src/utils/crypto.ts +217 -0
  255. package/src/utils/encoder.ts +52 -55
  256. package/src/utils/errors.ts +268 -134
  257. package/src/utils/hd-wallet.ts +134 -0
  258. package/src/utils/json-big.ts +26 -0
  259. package/src/utils/keystore.ts +179 -0
  260. package/src/utils/mptree.ts +14 -14
  261. package/src/utils/other.ts +28 -43
  262. package/src/utils/string.ts +8 -10
  263. package/es/account/base.mjs +0 -179
  264. package/es/account/base.mjs.map +0 -1
  265. package/es/account/memory.mjs +0 -99
  266. package/es/account/memory.mjs.map +0 -1
  267. package/es/account/multiple.mjs +0 -179
  268. package/es/account/multiple.mjs.map +0 -1
  269. package/es/ae/aens.mjs +0 -404
  270. package/es/ae/aens.mjs.map +0 -1
  271. package/es/ae/aepp.mjs +0 -45
  272. package/es/ae/aepp.mjs.map +0 -1
  273. package/es/ae/contract.mjs +0 -159
  274. package/es/ae/contract.mjs.map +0 -1
  275. package/es/ae/index.mjs +0 -207
  276. package/es/ae/index.mjs.map +0 -1
  277. package/es/ae/oracle.mjs +0 -339
  278. package/es/ae/oracle.mjs.map +0 -1
  279. package/es/ae/universal.mjs +0 -45
  280. package/es/ae/universal.mjs.map +0 -1
  281. package/es/ae/wallet.mjs +0 -50
  282. package/es/ae/wallet.mjs.map +0 -1
  283. package/es/amount-formatter.d.ts +0 -58
  284. package/es/bignumber.d.ts +0 -18
  285. package/es/chain/index.mjs +0 -272
  286. package/es/chain/index.mjs.map +0 -1
  287. package/es/chain/node.mjs +0 -442
  288. package/es/chain/node.mjs.map +0 -1
  289. package/es/contract/compiler.mjs +0 -115
  290. package/es/contract/compiler.mjs.map +0 -1
  291. package/es/contract/ga/helpers.mjs +0 -30
  292. package/es/contract/ga/helpers.mjs.map +0 -1
  293. package/es/contract/ga/index.mjs +0 -178
  294. package/es/contract/ga/index.mjs.map +0 -1
  295. package/es/crypto-ts.d.ts +0 -9
  296. package/es/encoder.d.ts +0 -26
  297. package/es/node-pool/index.mjs +0 -188
  298. package/es/node-pool/index.mjs.map +0 -1
  299. package/es/node.mjs +0 -133
  300. package/es/node.mjs.map +0 -1
  301. package/es/other.d.ts +0 -31
  302. package/es/string.d.ts +0 -26
  303. package/es/tx/tx-object.mjs +0 -283
  304. package/es/tx/tx-object.mjs.map +0 -1
  305. package/es/tx/tx.mjs +0 -938
  306. package/es/tx/tx.mjs.map +0 -1
  307. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs +0 -132
  308. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +0 -1
  309. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +0 -183
  310. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +0 -1
  311. package/es/utils/aepp-wallet-communication/connection/index.mjs +0 -87
  312. package/es/utils/aepp-wallet-communication/connection/index.mjs.map +0 -1
  313. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs +0 -98
  314. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +0 -1
  315. package/es/utils/aepp-wallet-communication/helpers.mjs +0 -92
  316. package/es/utils/aepp-wallet-communication/helpers.mjs.map +0 -1
  317. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +0 -375
  318. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +0 -1
  319. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +0 -275
  320. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +0 -1
  321. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +0 -541
  322. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +0 -1
  323. package/es/utils/aepp-wallet-communication/schema.mjs +0 -102
  324. package/es/utils/aepp-wallet-communication/schema.mjs.map +0 -1
  325. package/es/utils/aepp-wallet-communication/wallet-detector.mjs +0 -110
  326. package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +0 -1
  327. package/es/utils/async-init.mjs +0 -64
  328. package/es/utils/async-init.mjs.map +0 -1
  329. package/es/utils/crypto-ts.mjs.map +0 -1
  330. package/es/utils/swagger.mjs +0 -164
  331. package/es/utils/swagger.mjs.map +0 -1
  332. package/src/account/base.js +0 -153
  333. package/src/account/memory.js +0 -83
  334. package/src/account/multiple.js +0 -162
  335. package/src/ae/aens.js +0 -361
  336. package/src/ae/aepp.js +0 -45
  337. package/src/ae/contract.js +0 -148
  338. package/src/ae/index.js +0 -168
  339. package/src/ae/oracle.js +0 -311
  340. package/src/ae/universal.js +0 -47
  341. package/src/ae/wallet.js +0 -50
  342. package/src/chain/index.js +0 -269
  343. package/src/chain/node.js +0 -320
  344. package/src/channel/index.js +0 -903
  345. package/src/channel/internal.js +0 -236
  346. package/src/contract/aci.js +0 -376
  347. package/src/contract/compiler.js +0 -100
  348. package/src/contract/ga/helpers.js +0 -19
  349. package/src/contract/ga/index.js +0 -150
  350. package/src/index.js +0 -89
  351. package/src/node-pool/index.js +0 -172
  352. package/src/node.js +0 -116
  353. package/src/tx/builder/field-types.js +0 -61
  354. package/src/tx/builder/helpers.js +0 -334
  355. package/src/tx/builder/index.js +0 -465
  356. package/src/tx/builder/schema.js +0 -1100
  357. package/src/tx/index.js +0 -301
  358. package/src/tx/tx-object.js +0 -187
  359. package/src/tx/tx.js +0 -631
  360. package/src/tx/validator.js +0 -181
  361. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -119
  362. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -165
  363. package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
  364. package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -86
  365. package/src/utils/aepp-wallet-communication/helpers.js +0 -60
  366. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -294
  367. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -232
  368. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -401
  369. package/src/utils/aepp-wallet-communication/schema.ts +0 -80
  370. package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -92
  371. package/src/utils/async-init.js +0 -45
  372. package/src/utils/crypto.js +0 -219
  373. package/src/utils/hd-wallet.js +0 -100
  374. package/src/utils/json-big.js +0 -26
  375. package/src/utils/keystore.js +0 -219
  376. package/src/utils/swagger.js +0 -156
@@ -0,0 +1,771 @@
1
+ /**
2
+ * Transaction Schema for TxBuilder
3
+ */
4
+ // # RLP version number
5
+ // # https://github.com/aeternity/protocol/blob/master/serializations.md#binary-serialization
6
+
7
+ import BigNumber from 'bignumber.js'
8
+ import { Name, NameId, NameFee, Deposit, Field, GasPrice } from './field-types'
9
+ import { EncodedData, EncodingType } from '../../utils/encoder'
10
+ import { Pointer } from './helpers'
11
+ import MPTree from '../../utils/mptree'
12
+
13
+ export * from './constants'
14
+
15
+ export enum ORACLE_TTL_TYPES {
16
+ delta = 0,
17
+ block = 1
18
+ }
19
+
20
+ // # TRANSACTION DEFAULT TTL
21
+ export const TX_TTL = 0
22
+ // # ORACLE
23
+ export const QUERY_FEE = 30000
24
+ export const ORACLE_TTL = { type: ORACLE_TTL_TYPES.delta, value: 500 }
25
+ export const QUERY_TTL = { type: ORACLE_TTL_TYPES.delta, value: 10 }
26
+ export const RESPONSE_TTL = { type: ORACLE_TTL_TYPES.delta, value: 10 }
27
+ // # CONTRACT
28
+ export const AMOUNT = 0
29
+ export const GAS_MAX = 1600000 - 21000
30
+ export const MAX_AUTH_FUN_GAS = 50000
31
+ export const DRY_RUN_ACCOUNT = {
32
+ pub: 'ak_11111111111111111111111111111111273Yts',
33
+ amount: 100000000000000000000000000000000000n
34
+ } as const
35
+
36
+ export type TxField = [
37
+ name: string,
38
+ type: FIELD_TYPES | typeof Field,
39
+ prefix?: EncodingType | EncodingType[]
40
+ ]
41
+
42
+ /**
43
+ * Enum with transaction types
44
+ * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/serializations.md#binary-serialization}
45
+ */
46
+ export enum TX_TYPE {
47
+ account = 10,
48
+ signed = 11,
49
+ spend = 12,
50
+ oracleRegister = 22,
51
+ oracleQuery = 23,
52
+ oracleResponse = 24,
53
+ oracleExtend = 25,
54
+ nameClaim = 32,
55
+ namePreClaim = 33,
56
+ nameUpdate = 34,
57
+ nameRevoke = 35,
58
+ nameTransfer = 36,
59
+ contract = 40,
60
+ contractCallResult = 41,
61
+ contractCreate = 42,
62
+ contractCall = 43,
63
+ channelCreate = 50,
64
+ channelDeposit = 51,
65
+ channelWithdraw = 52,
66
+ channelCloseMutual = 53,
67
+ channelCloseSolo = 54,
68
+ channelSlash = 55,
69
+ channelSettle = 56,
70
+ channelOffChain = 57,
71
+ channel = 58,
72
+ channelSnapshotSolo = 59,
73
+ proofOfInclusion = 60,
74
+ stateTrees = 62,
75
+ merklePatriciaTree = 63,
76
+ merklePatriciaTreeValue = 64,
77
+ sophiaByteCode = 70,
78
+ gaAttach = 80,
79
+ gaMeta = 81,
80
+ payingFor = 82,
81
+ channelForceProgress = 521,
82
+ channelOffChainUpdateTransfer = 570,
83
+ channelOffChainUpdateDeposit = 571,
84
+ channelOffChainUpdateWithdrawal = 572,
85
+ channelOffChainCreateContract = 573,
86
+ channelOffChainCallContract = 574,
87
+ channelReconnect = 575,
88
+ contractsTree = 621,
89
+ contractCallsTree = 622,
90
+ channelsTree = 623,
91
+ nameserviceTree = 624,
92
+ oraclesTree = 625,
93
+ accountsTree = 626
94
+ }
95
+
96
+ /**
97
+ * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}
98
+ */
99
+ export enum VM_VERSIONS {
100
+ NO_VM = 0,
101
+ SOPHIA = 1,
102
+ SOPHIA_IMPROVEMENTS_MINERVA = 3,
103
+ SOPHIA_IMPROVEMENTS_FORTUNA = 4,
104
+ FATE = 5,
105
+ SOPHIA_IMPROVEMENTS_LIMA = 6,
106
+ FATE_2 = 7
107
+ }
108
+
109
+ /**
110
+ * @see {@link https://github.com/aeternity/protocol/blob/0f6dee3d9d1e8e2469816798f5c7587a6c918f94/contracts/contract_vms.md#virtual-machines-on-the-%C3%A6ternity-blockchain}
111
+ */
112
+ export enum ABI_VERSIONS {
113
+ NO_ABI = 0,
114
+ SOPHIA = 1,
115
+ FATE = 3
116
+ }
117
+
118
+ export enum PROTOCOL_VERSIONS {
119
+ IRIS = 5
120
+ }
121
+
122
+ // First abi/vm by default
123
+ export const PROTOCOL_VM_ABI = {
124
+ [PROTOCOL_VERSIONS.IRIS]: {
125
+ [TX_TYPE.contractCreate]: {
126
+ vmVersion: [VM_VERSIONS.FATE_2], abiVersion: [ABI_VERSIONS.FATE]
127
+ },
128
+ // TODO: Ensure that AEVM (SOPHIA?) is still available here
129
+ [TX_TYPE.contractCall]: {
130
+ vmVersion: [], abiVersion: [ABI_VERSIONS.FATE, ABI_VERSIONS.SOPHIA]
131
+ },
132
+ [TX_TYPE.oracleRegister]: {
133
+ vmVersion: [], abiVersion: [ABI_VERSIONS.NO_ABI, ABI_VERSIONS.SOPHIA]
134
+ }
135
+ }
136
+ } as const
137
+
138
+ type PrefixType<Prefix> = Prefix extends EncodingType
139
+ ? EncodedData<Prefix>
140
+ : Prefix extends readonly EncodingType[]
141
+ ? EncodedData<Prefix[number]>
142
+ : EncodedData<any>
143
+
144
+ export interface CtVersion {
145
+ vmVersion: VM_VERSIONS
146
+ abiVersion: ABI_VERSIONS
147
+ }
148
+
149
+ export enum FIELD_TYPES {
150
+ int,
151
+ shortInt,
152
+ amount,
153
+ id,
154
+ ids,
155
+ string,
156
+ binary,
157
+ bool,
158
+ hex,
159
+ rlpBinary,
160
+ rlpBinaries,
161
+ rawBinary,
162
+ signatures,
163
+ pointers,
164
+ offChainUpdates,
165
+ callStack,
166
+ proofOfInclusion,
167
+ mptrees,
168
+ callReturnType,
169
+ ctVersion,
170
+ abiVersion,
171
+ ttlType,
172
+ sophiaCodeTypeInfo,
173
+ payload,
174
+ stateTree
175
+ }
176
+
177
+ interface BuildFieldTypes<Prefix extends undefined | EncodingType | readonly EncodingType[]>{
178
+ [FIELD_TYPES.int]: number | string | BigNumber
179
+ [FIELD_TYPES.shortInt]: number
180
+ [FIELD_TYPES.amount]: number | string | BigNumber
181
+ [FIELD_TYPES.id]: PrefixType<Prefix>
182
+ [FIELD_TYPES.ids]: Array<EncodedData<Prefix extends EncodingType[] ? Prefix : any>>
183
+ [FIELD_TYPES.string]: string
184
+ [FIELD_TYPES.binary]: PrefixType<Prefix>
185
+ [FIELD_TYPES.bool]: Boolean
186
+ [FIELD_TYPES.hex]: string
187
+ [FIELD_TYPES.rlpBinary]: any
188
+ [FIELD_TYPES.rlpBinaries]: any[]
189
+ [FIELD_TYPES.rawBinary]: Uint8Array
190
+ [FIELD_TYPES.signatures]: Uint8Array[]
191
+ [FIELD_TYPES.pointers]: Pointer[]
192
+ [FIELD_TYPES.offChainUpdates]: any
193
+ [FIELD_TYPES.callStack]: any
194
+ [FIELD_TYPES.proofOfInclusion]: any
195
+ [FIELD_TYPES.mptrees]: MPTree[]
196
+ [FIELD_TYPES.callReturnType]: any
197
+ [FIELD_TYPES.ctVersion]: CtVersion
198
+ [FIELD_TYPES.abiVersion]: ABI_VERSIONS
199
+ [FIELD_TYPES.ttlType]: ORACLE_TTL_TYPES
200
+ [FIELD_TYPES.sophiaCodeTypeInfo]: any
201
+ [FIELD_TYPES.payload]: string | undefined
202
+ [FIELD_TYPES.stateTree]: any
203
+ }
204
+
205
+ // based on https://stackoverflow.com/a/50375286/6176994
206
+ type UnionToIntersection<Union> =
207
+ (Union extends any ? (k: Union) => void : never) extends ((k: infer Intersection) => void)
208
+ ? Intersection : never
209
+
210
+ type TxElem = readonly [string, FIELD_TYPES | Field]
211
+ | readonly [string, FIELD_TYPES, EncodingType | readonly EncodingType[]]
212
+
213
+ type BuildTxArgBySchemaType<
214
+ Type extends FIELD_TYPES | Field,
215
+ Prefix extends undefined | EncodingType | readonly EncodingType[]
216
+ > =
217
+ Type extends typeof Field
218
+ ? Parameters<Type['serialize']>[0]
219
+ : Type extends FIELD_TYPES
220
+ ? BuildFieldTypes<Prefix>[Type]
221
+ : never
222
+
223
+ type NullablePartial<
224
+ T,
225
+ NK extends keyof T = { [K in keyof T]: undefined extends T[K] ? K : never }[keyof T]
226
+ > = Partial<Pick<T, NK>> & Omit<T, NK>
227
+
228
+ type BuildTxArgBySchema<SchemaLine> =
229
+ UnionToIntersection<
230
+ SchemaLine extends ReadonlyArray<infer Elem>
231
+ ? Elem extends TxElem
232
+ ? NullablePartial<{ [k in Elem[0]]: BuildTxArgBySchemaType<Elem[1], Elem[2]> }>
233
+ : never
234
+ : never
235
+ >
236
+
237
+ export type RawTxObject<Tx extends TxSchema> = {
238
+ [k in keyof Tx]: Tx[k] extends BigNumber ? string : Tx[k]
239
+ }
240
+
241
+ const BASE_TX = [
242
+ ['tag', FIELD_TYPES.shortInt],
243
+ ['VSN', FIELD_TYPES.shortInt]
244
+ ] as const
245
+
246
+ export const TX_SCHEMA = {
247
+ [TX_TYPE.account]: {
248
+ 2: [
249
+ ...BASE_TX,
250
+ ['flags', FIELD_TYPES.int],
251
+ ['nonce', FIELD_TYPES.shortInt],
252
+ ['balance', FIELD_TYPES.int],
253
+ ['gaContract', FIELD_TYPES.id, ['ct', 'nm']],
254
+ ['gaAuthFun', FIELD_TYPES.binary, 'cb']
255
+ ]
256
+ },
257
+ [TX_TYPE.signed]: {
258
+ 1: [
259
+ ...BASE_TX,
260
+ ['signatures', FIELD_TYPES.signatures],
261
+ ['encodedTx', FIELD_TYPES.rlpBinary]
262
+ ]
263
+ },
264
+ [TX_TYPE.spend]: {
265
+ 1: [
266
+ ...BASE_TX,
267
+ ['senderId', FIELD_TYPES.id, 'ak'],
268
+ ['recipientId', FIELD_TYPES.id, ['ak', 'nm']],
269
+ ['amount', FIELD_TYPES.amount],
270
+ ['fee', FIELD_TYPES.int],
271
+ ['ttl', FIELD_TYPES.shortInt],
272
+ ['nonce', FIELD_TYPES.shortInt],
273
+ ['payload', FIELD_TYPES.payload]
274
+ ]
275
+ },
276
+ [TX_TYPE.namePreClaim]: {
277
+ 1: [
278
+ ...BASE_TX,
279
+ ['accountId', FIELD_TYPES.id, 'ak'],
280
+ ['nonce', FIELD_TYPES.shortInt],
281
+ ['commitmentId', FIELD_TYPES.id, 'cm'],
282
+ ['fee', FIELD_TYPES.int],
283
+ ['ttl', FIELD_TYPES.shortInt]
284
+ ]
285
+ },
286
+ [TX_TYPE.nameClaim]: {
287
+ 2: [
288
+ ...BASE_TX,
289
+ ['accountId', FIELD_TYPES.id, 'ak'],
290
+ ['nonce', FIELD_TYPES.shortInt],
291
+ ['name', Name],
292
+ ['nameSalt', FIELD_TYPES.int],
293
+ ['nameFee', NameFee],
294
+ ['fee', FIELD_TYPES.int],
295
+ ['ttl', FIELD_TYPES.shortInt]
296
+ ]
297
+ },
298
+ [TX_TYPE.nameUpdate]: {
299
+ 1: [
300
+ ...BASE_TX,
301
+ ['accountId', FIELD_TYPES.id, 'ak'],
302
+ ['nonce', FIELD_TYPES.shortInt],
303
+ ['nameId', NameId],
304
+ ['nameTtl', FIELD_TYPES.int],
305
+ ['pointers', FIELD_TYPES.pointers],
306
+ ['clientTtl', FIELD_TYPES.shortInt],
307
+ ['fee', FIELD_TYPES.int],
308
+ ['ttl', FIELD_TYPES.shortInt]
309
+ ]
310
+ },
311
+ [TX_TYPE.nameTransfer]: {
312
+ 1: [
313
+ ...BASE_TX,
314
+ ['accountId', FIELD_TYPES.id, 'ak'],
315
+ ['nonce', FIELD_TYPES.shortInt],
316
+ ['nameId', NameId],
317
+ ['recipientId', FIELD_TYPES.id, ['ak', 'nm']],
318
+ ['fee', FIELD_TYPES.int],
319
+ ['ttl', FIELD_TYPES.shortInt]
320
+ ]
321
+ },
322
+ [TX_TYPE.nameRevoke]: {
323
+ 1: [
324
+ ...BASE_TX,
325
+ ['accountId', FIELD_TYPES.id, 'ak'],
326
+ ['nonce', FIELD_TYPES.shortInt],
327
+ ['nameId', NameId],
328
+ ['fee', FIELD_TYPES.int],
329
+ ['ttl', FIELD_TYPES.shortInt]
330
+ ]
331
+ },
332
+ [TX_TYPE.contract]: {
333
+ 1: [
334
+ ...BASE_TX,
335
+ ['owner', FIELD_TYPES.id, 'ak'],
336
+ ['ctVersion', FIELD_TYPES.ctVersion],
337
+ ['code', FIELD_TYPES.binary, 'cb'],
338
+ ['log', FIELD_TYPES.binary, 'cb'],
339
+ ['active', FIELD_TYPES.bool],
340
+ ['referers', FIELD_TYPES.ids, 'ak'],
341
+ ['deposit', Deposit]
342
+ ]
343
+ },
344
+ [TX_TYPE.contractCreate]: {
345
+ 1: [
346
+ ...BASE_TX,
347
+ ['ownerId', FIELD_TYPES.id, 'ak'],
348
+ ['nonce', FIELD_TYPES.shortInt],
349
+ ['code', FIELD_TYPES.binary, 'cb'],
350
+ ['ctVersion', FIELD_TYPES.ctVersion],
351
+ ['fee', FIELD_TYPES.int],
352
+ ['ttl', FIELD_TYPES.shortInt],
353
+ ['deposit', Deposit],
354
+ ['amount', FIELD_TYPES.amount],
355
+ ['gasLimit', FIELD_TYPES.shortInt],
356
+ ['gasPrice', GasPrice],
357
+ ['callData', FIELD_TYPES.binary, 'cb']
358
+ ]
359
+ },
360
+ [TX_TYPE.contractCall]: {
361
+ 1: [
362
+ ...BASE_TX,
363
+ ['callerId', FIELD_TYPES.id, 'ak'],
364
+ ['nonce', FIELD_TYPES.shortInt],
365
+ ['contractId', FIELD_TYPES.id, ['ct', 'nm']],
366
+ ['abiVersion', FIELD_TYPES.abiVersion],
367
+ ['fee', FIELD_TYPES.int],
368
+ ['ttl', FIELD_TYPES.shortInt],
369
+ ['amount', FIELD_TYPES.amount],
370
+ ['gasLimit', FIELD_TYPES.shortInt],
371
+ ['gasPrice', GasPrice],
372
+ ['callData', FIELD_TYPES.binary, 'cb']
373
+ ]
374
+ },
375
+ [TX_TYPE.contractCallResult]: {
376
+ 1: [
377
+ ...BASE_TX,
378
+ ['callerId', FIELD_TYPES.id, 'ak'],
379
+ ['callerNonce', FIELD_TYPES.shortInt],
380
+ ['height', FIELD_TYPES.shortInt],
381
+ ['contractId', FIELD_TYPES.id, 'ct'],
382
+ ['gasPrice', GasPrice],
383
+ ['gasUsed', FIELD_TYPES.shortInt],
384
+ ['returnValue', FIELD_TYPES.binary, 'cb'],
385
+ ['returnType', FIELD_TYPES.callReturnType],
386
+ // TODO: add serialization for
387
+ // <log> :: [ { <address> :: id, [ <topics> :: binary() ], <data> :: binary() } ]
388
+ ['log', FIELD_TYPES.rawBinary]
389
+ ]
390
+ },
391
+ [TX_TYPE.oracleRegister]: {
392
+ 1: [
393
+ ...BASE_TX,
394
+ ['accountId', FIELD_TYPES.id, 'ak'],
395
+ ['nonce', FIELD_TYPES.shortInt],
396
+ ['queryFormat', FIELD_TYPES.string],
397
+ ['responseFormat', FIELD_TYPES.string],
398
+ ['queryFee', FIELD_TYPES.amount],
399
+ ['oracleTtlType', FIELD_TYPES.ttlType],
400
+ ['oracleTtlValue', FIELD_TYPES.shortInt],
401
+ ['fee', FIELD_TYPES.int],
402
+ ['ttl', FIELD_TYPES.shortInt],
403
+ ['abiVersion', FIELD_TYPES.abiVersion]
404
+ ]
405
+ },
406
+ [TX_TYPE.oracleExtend]: {
407
+ 1: [
408
+ ...BASE_TX,
409
+ ['oracleId', FIELD_TYPES.id, ['ok', 'nm']],
410
+ ['nonce', FIELD_TYPES.shortInt],
411
+ ['oracleTtlType', FIELD_TYPES.ttlType],
412
+ ['oracleTtlValue', FIELD_TYPES.shortInt],
413
+ ['fee', FIELD_TYPES.int],
414
+ ['ttl', FIELD_TYPES.shortInt]
415
+ ]
416
+ },
417
+ [TX_TYPE.oracleQuery]: {
418
+ 1: [
419
+ ...BASE_TX,
420
+ ['senderId', FIELD_TYPES.id, 'ak'],
421
+ ['nonce', FIELD_TYPES.shortInt],
422
+ ['oracleId', FIELD_TYPES.id, ['ok', 'nm']],
423
+ ['query', FIELD_TYPES.string],
424
+ ['queryFee', FIELD_TYPES.amount],
425
+ ['queryTtlType', FIELD_TYPES.ttlType],
426
+ ['queryTtlValue', FIELD_TYPES.shortInt],
427
+ ['responseTtlType', FIELD_TYPES.ttlType],
428
+ ['responseTtlValue', FIELD_TYPES.shortInt],
429
+ ['fee', FIELD_TYPES.int],
430
+ ['ttl', FIELD_TYPES.shortInt]
431
+ ]
432
+ },
433
+ [TX_TYPE.oracleResponse]: {
434
+ 1: [
435
+ ...BASE_TX,
436
+ ['oracleId', FIELD_TYPES.id, 'ok'],
437
+ ['nonce', FIELD_TYPES.shortInt],
438
+ ['queryId', FIELD_TYPES.binary, 'oq'],
439
+ ['response', FIELD_TYPES.string],
440
+ ['responseTtlType', FIELD_TYPES.ttlType],
441
+ ['responseTtlValue', FIELD_TYPES.shortInt],
442
+ ['fee', FIELD_TYPES.int],
443
+ ['ttl', FIELD_TYPES.shortInt]
444
+ ]
445
+ },
446
+ [TX_TYPE.channelCreate]: {
447
+ 2: [
448
+ ...BASE_TX,
449
+ ['initiator', FIELD_TYPES.id, 'ak'],
450
+ ['initiatorAmount', FIELD_TYPES.int],
451
+ ['responder', FIELD_TYPES.id, 'ak'],
452
+ ['responderAmount', FIELD_TYPES.int],
453
+ ['channelReserve', FIELD_TYPES.int],
454
+ ['lockPeriod', FIELD_TYPES.int],
455
+ ['ttl', FIELD_TYPES.shortInt],
456
+ ['fee', FIELD_TYPES.int],
457
+ ['initiatorDelegateIds', FIELD_TYPES.string],
458
+ ['responderDelegateIds', FIELD_TYPES.string],
459
+ ['stateHash', FIELD_TYPES.binary, 'st'],
460
+ ['nonce', FIELD_TYPES.shortInt]
461
+ ]
462
+ },
463
+ [TX_TYPE.channelCloseMutual]: {
464
+ 1: [
465
+ ...BASE_TX,
466
+ ['channelId', FIELD_TYPES.id, 'ch'],
467
+ ['fromId', FIELD_TYPES.id, 'ak'],
468
+ ['initiatorAmountFinal', FIELD_TYPES.int],
469
+ ['responderAmountFinal', FIELD_TYPES.int],
470
+ ['ttl', FIELD_TYPES.shortInt],
471
+ ['fee', FIELD_TYPES.int],
472
+ ['nonce', FIELD_TYPES.shortInt]
473
+ ]
474
+ },
475
+ [TX_TYPE.channelCloseSolo]: {
476
+ 1: [
477
+ ...BASE_TX,
478
+ ['channelId', FIELD_TYPES.id, 'ch'],
479
+ ['fromId', FIELD_TYPES.id, 'ak'],
480
+ ['payload', FIELD_TYPES.binary, 'tx'],
481
+ ['poi', FIELD_TYPES.binary, 'pi'],
482
+ ['ttl', FIELD_TYPES.shortInt],
483
+ ['fee', FIELD_TYPES.int],
484
+ ['nonce', FIELD_TYPES.shortInt]
485
+ ]
486
+ },
487
+ [TX_TYPE.channelSlash]: {
488
+ 1: [
489
+ ...BASE_TX,
490
+ ['channelId', FIELD_TYPES.id, 'ch'],
491
+ ['fromId', FIELD_TYPES.id, 'ak'],
492
+ ['payload', FIELD_TYPES.binary, 'tx'],
493
+ ['poi', FIELD_TYPES.binary, 'pi'],
494
+ ['ttl', FIELD_TYPES.shortInt],
495
+ ['fee', FIELD_TYPES.int],
496
+ ['nonce', FIELD_TYPES.shortInt]
497
+ ]
498
+ },
499
+ [TX_TYPE.channelDeposit]: {
500
+ 1: [
501
+ ...BASE_TX,
502
+ ['channelId', FIELD_TYPES.id, 'ch'],
503
+ ['fromId', FIELD_TYPES.id, 'ak'],
504
+ ['amount', FIELD_TYPES.int],
505
+ ['ttl', FIELD_TYPES.shortInt],
506
+ ['fee', FIELD_TYPES.int],
507
+ ['stateHash', FIELD_TYPES.binary, 'st'],
508
+ ['round', FIELD_TYPES.int],
509
+ ['nonce', FIELD_TYPES.shortInt]
510
+ ]
511
+ },
512
+ [TX_TYPE.channelWithdraw]: {
513
+ 1: [
514
+ ...BASE_TX,
515
+ ['channelId', FIELD_TYPES.id, 'ch'],
516
+ ['toId', FIELD_TYPES.id, 'ak'],
517
+ ['amount', FIELD_TYPES.int],
518
+ ['ttl', FIELD_TYPES.shortInt],
519
+ ['fee', FIELD_TYPES.int],
520
+ ['stateHash', FIELD_TYPES.binary, 'st'],
521
+ ['round', FIELD_TYPES.int],
522
+ ['nonce', FIELD_TYPES.shortInt]
523
+ ]
524
+ },
525
+ [TX_TYPE.channelSettle]: {
526
+ 1: [
527
+ ...BASE_TX,
528
+ ['channelId', FIELD_TYPES.id, 'ch'],
529
+ ['fromId', FIELD_TYPES.id, 'ak'],
530
+ ['initiatorAmountFinal', FIELD_TYPES.int],
531
+ ['responderAmountFinal', FIELD_TYPES.int],
532
+ ['ttl', FIELD_TYPES.shortInt],
533
+ ['fee', FIELD_TYPES.int],
534
+ ['nonce', FIELD_TYPES.shortInt]
535
+ ]
536
+ },
537
+ [TX_TYPE.channelForceProgress]: {
538
+ 1: [
539
+ ...BASE_TX,
540
+ ['channelId', FIELD_TYPES.id, 'ch'],
541
+ ['fromId', FIELD_TYPES.id, 'ak'],
542
+ ['payload', FIELD_TYPES.binary, 'tx'],
543
+ ['round', FIELD_TYPES.int],
544
+ ['update', FIELD_TYPES.binary, 'cb'],
545
+ ['stateHash', FIELD_TYPES.binary, 'st'],
546
+ ['offChainTrees', FIELD_TYPES.stateTree],
547
+ ['ttl', FIELD_TYPES.shortInt],
548
+ ['fee', FIELD_TYPES.int],
549
+ ['nonce', FIELD_TYPES.shortInt]
550
+ ]
551
+ },
552
+ [TX_TYPE.channelOffChain]: {
553
+ 2: [
554
+ ...BASE_TX,
555
+ ['channelId', FIELD_TYPES.id, 'ch'],
556
+ ['round', FIELD_TYPES.int],
557
+ ['stateHash', FIELD_TYPES.binary, 'st']
558
+ ]
559
+ },
560
+ [TX_TYPE.channel]: {
561
+ 3: [
562
+ ...BASE_TX,
563
+ ['initiator', FIELD_TYPES.id, 'ak'],
564
+ ['responder', FIELD_TYPES.id, 'ak'],
565
+ ['channelAmount', FIELD_TYPES.int],
566
+ ['initiatorAmount', FIELD_TYPES.int],
567
+ ['responderAmount', FIELD_TYPES.int],
568
+ ['channelReserve', FIELD_TYPES.int],
569
+ ['initiatorDelegateIds', FIELD_TYPES.ids],
570
+ ['responderDelegateIds', FIELD_TYPES.ids],
571
+ ['stateHash', FIELD_TYPES.hex],
572
+ ['round', FIELD_TYPES.int],
573
+ ['soloRound', FIELD_TYPES.int],
574
+ ['lockPeriod', FIELD_TYPES.int],
575
+ ['lockedUntil', FIELD_TYPES.int],
576
+ ['initiatorAuth', FIELD_TYPES.binary, 'cb'],
577
+ ['responderAuth', FIELD_TYPES.binary, 'cb']
578
+ ]
579
+ },
580
+ [TX_TYPE.channelSnapshotSolo]: {
581
+ 1: [
582
+ ...BASE_TX,
583
+ ['channelId', FIELD_TYPES.id, 'ch'],
584
+ ['fromId', FIELD_TYPES.id, 'ak'],
585
+ ['payload', FIELD_TYPES.binary, 'tx'],
586
+ ['ttl', FIELD_TYPES.shortInt],
587
+ ['fee', FIELD_TYPES.int],
588
+ ['nonce', FIELD_TYPES.shortInt]
589
+ ]
590
+ },
591
+ [TX_TYPE.channelOffChainUpdateTransfer]: {
592
+ 1: [
593
+ ...BASE_TX,
594
+ ['from', FIELD_TYPES.id, 'ak'],
595
+ ['to', FIELD_TYPES.id, 'ak'],
596
+ ['amount', FIELD_TYPES.int]
597
+ ]
598
+ },
599
+ [TX_TYPE.channelOffChainUpdateDeposit]: {
600
+ 1: [
601
+ ...BASE_TX,
602
+ ['from', FIELD_TYPES.id, 'ak'],
603
+ ['amount', FIELD_TYPES.int]
604
+ ]
605
+ },
606
+ [TX_TYPE.channelOffChainUpdateWithdrawal]: {
607
+ 1: [
608
+ ...BASE_TX,
609
+ ['from', FIELD_TYPES.id, 'ak'],
610
+ ['amount', FIELD_TYPES.int]
611
+ ]
612
+ },
613
+ [TX_TYPE.channelOffChainCreateContract]: {
614
+ 1: [
615
+ ...BASE_TX,
616
+ ['owner', FIELD_TYPES.id, 'ak'],
617
+ ['ctVersion', FIELD_TYPES.ctVersion],
618
+ ['code', FIELD_TYPES.binary, 'cb'],
619
+ ['deposit', FIELD_TYPES.int],
620
+ ['callData', FIELD_TYPES.binary, 'cb']
621
+ ]
622
+ },
623
+ [TX_TYPE.channelOffChainCallContract]: {
624
+ 1: [
625
+ ...BASE_TX,
626
+ ['caller', FIELD_TYPES.id, 'ak'],
627
+ ['contract', FIELD_TYPES.id, 'ct'],
628
+ ['abiVersion', FIELD_TYPES.abiVersion],
629
+ ['amount', FIELD_TYPES.int],
630
+ ['callData', FIELD_TYPES.binary, 'cb'],
631
+ ['callStack', FIELD_TYPES.callStack],
632
+ ['gasPrice', GasPrice],
633
+ ['gasLimit', FIELD_TYPES.shortInt]
634
+ ]
635
+ },
636
+ [TX_TYPE.channelReconnect]: {
637
+ 1: [
638
+ ...BASE_TX,
639
+ ['channelId', FIELD_TYPES.id, 'ch'],
640
+ ['round', FIELD_TYPES.int],
641
+ ['role', FIELD_TYPES.string],
642
+ ['pubkey', FIELD_TYPES.id, 'ak']
643
+ ]
644
+ },
645
+ [TX_TYPE.proofOfInclusion]: {
646
+ 1: [
647
+ ...BASE_TX,
648
+ ['accounts', FIELD_TYPES.mptrees],
649
+ ['calls', FIELD_TYPES.mptrees],
650
+ ['channels', FIELD_TYPES.mptrees],
651
+ ['contracts', FIELD_TYPES.mptrees],
652
+ ['ns', FIELD_TYPES.mptrees],
653
+ ['oracles', FIELD_TYPES.mptrees]
654
+ ]
655
+ },
656
+ [TX_TYPE.stateTrees]: {
657
+ 1: [
658
+ ...BASE_TX,
659
+ ['contracts', FIELD_TYPES.rlpBinary],
660
+ ['calls', FIELD_TYPES.rlpBinary],
661
+ ['channels', FIELD_TYPES.rlpBinary],
662
+ ['ns', FIELD_TYPES.rlpBinary],
663
+ ['oracles', FIELD_TYPES.rlpBinary],
664
+ ['accounts', FIELD_TYPES.rlpBinary]
665
+ ]
666
+ },
667
+ [TX_TYPE.merklePatriciaTree]: {
668
+ 1: [
669
+ ...BASE_TX,
670
+ ['values', FIELD_TYPES.rlpBinaries]
671
+ ]
672
+ },
673
+ [TX_TYPE.merklePatriciaTreeValue]: {
674
+ 1: [
675
+ ...BASE_TX,
676
+ ['key', FIELD_TYPES.hex],
677
+ ['value', FIELD_TYPES.rawBinary]
678
+ ]
679
+ },
680
+ [TX_TYPE.contractsTree]: {
681
+ 1: [
682
+ ...BASE_TX,
683
+ ['contracts', FIELD_TYPES.rlpBinary]
684
+ ]
685
+ },
686
+ [TX_TYPE.contractCallsTree]: {
687
+ 1: [
688
+ ...BASE_TX,
689
+ ['calls', FIELD_TYPES.rlpBinary]
690
+ ]
691
+ },
692
+ [TX_TYPE.channelsTree]: {
693
+ 1: [
694
+ ...BASE_TX,
695
+ ['channels', FIELD_TYPES.rlpBinary]
696
+ ]
697
+ },
698
+ [TX_TYPE.nameserviceTree]: {
699
+ 1: [
700
+ ...BASE_TX,
701
+ ['mtree', FIELD_TYPES.rlpBinary]
702
+ ]
703
+ },
704
+ [TX_TYPE.oraclesTree]: {
705
+ 1: [
706
+ ...BASE_TX,
707
+ ['otree', FIELD_TYPES.rlpBinary]
708
+ ]
709
+ },
710
+ [TX_TYPE.accountsTree]: {
711
+ 1: [
712
+ ...BASE_TX,
713
+ ['accounts', FIELD_TYPES.rlpBinary]
714
+ ]
715
+ },
716
+ [TX_TYPE.gaAttach]: {
717
+ 1: [
718
+ ...BASE_TX,
719
+ ['ownerId', FIELD_TYPES.id, 'ak'],
720
+ ['nonce', FIELD_TYPES.shortInt],
721
+ ['code', FIELD_TYPES.binary, 'cb'],
722
+ ['authFun', FIELD_TYPES.rawBinary],
723
+ ['ctVersion', FIELD_TYPES.ctVersion],
724
+ ['fee', FIELD_TYPES.int],
725
+ ['ttl', FIELD_TYPES.shortInt],
726
+ ['gasLimit', FIELD_TYPES.shortInt],
727
+ ['gasPrice', GasPrice],
728
+ ['callData', FIELD_TYPES.binary, 'cb']
729
+ ]
730
+ },
731
+ [TX_TYPE.gaMeta]: {
732
+ 2: [
733
+ ...BASE_TX,
734
+ ['gaId', FIELD_TYPES.id, 'ak'],
735
+ ['authData', FIELD_TYPES.binary, 'cb'],
736
+ ['abiVersion', FIELD_TYPES.abiVersion],
737
+ ['fee', FIELD_TYPES.int],
738
+ ['gasLimit', FIELD_TYPES.shortInt],
739
+ ['gasPrice', GasPrice],
740
+ ['tx', FIELD_TYPES.rlpBinary]
741
+ ]
742
+ },
743
+ [TX_TYPE.payingFor]: {
744
+ 1: [
745
+ ...BASE_TX,
746
+ ['payerId', FIELD_TYPES.id, 'ak'],
747
+ ['nonce', FIELD_TYPES.shortInt],
748
+ ['fee', FIELD_TYPES.int],
749
+ ['tx', FIELD_TYPES.rlpBinary]
750
+ ]
751
+ },
752
+ [TX_TYPE.sophiaByteCode]: {
753
+ 3: [
754
+ ...BASE_TX,
755
+ ['sourceCodeHash', FIELD_TYPES.rawBinary],
756
+ ['typeInfo', FIELD_TYPES.sophiaCodeTypeInfo],
757
+ ['byteCode', FIELD_TYPES.rawBinary],
758
+ ['compilerVersion', FIELD_TYPES.string],
759
+ ['payable', FIELD_TYPES.bool]
760
+ ]
761
+ }
762
+ } as const
763
+
764
+ export type TxTypeSchemas = {
765
+ [key in TX_TYPE]: BuildTxArgBySchema<
766
+ typeof TX_SCHEMA[key][keyof typeof TX_SCHEMA[key]]
767
+ >
768
+ }
769
+
770
+ export type TxSchema = TxTypeSchemas[TX_TYPE]
771
+ export type TxParamsCommon = Partial<UnionToIntersection<TxSchema>>