@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
@@ -1,34 +1,19 @@
1
- /**
2
- * Transaction methods
3
- *
4
- * This is implementation of [Tx](api/tx.md) relays
5
- * the creation of transactions to {@link Node}.
6
- * These methods provide ability to create native transactions.
7
- */
8
- import BigNumber from 'bignumber.js';
9
- import { ABI_VERSIONS, CtVersion } from './builder/schema';
10
1
  import { Tag } from './builder/constants';
11
2
  import Node from '../Node';
12
3
  import { Encoded } from '../utils/encoder';
13
4
  import { buildTx as syncBuildTx } from './builder/index';
14
5
  import { AE_AMOUNT_FORMATS } from '../utils/amount-formatter';
15
- type Int = number | string | BigNumber;
16
6
  export type BuildTxOptions<TxType extends Tag, OmitFields extends string> = Omit<Parameters<any>[1], OmitFields>;
17
7
  /**
18
8
  * @category transaction builder
19
9
  */
20
- export declare function _buildTx<TxType extends Tag>(txType: TxType, { denomination, absoluteTtl, ..._params }: Omit<Parameters<any>[0], 'fee' | 'nonce' | 'ttl' | 'ctVersion' | 'abiVersion'> & {
21
- onNode: Node;
22
- fee?: Int;
23
- nonce?: number;
24
- ttl?: number;
10
+ export declare function _buildTx<TxType extends Tag>(txType: TxType, { denomination, absoluteTtl, strategy, onNode, ..._params }: Omit<Parameters<any>[0], 'tag' | 'nonce' | 'ttl'> & {
25
11
  denomination?: AE_AMOUNT_FORMATS;
26
12
  absoluteTtl?: boolean;
13
+ strategy?: 'continuity' | 'max';
14
+ onNode: Node;
15
+ ttl?: number;
16
+ nonce?: number;
27
17
  } & (TxType extends Tag.OracleExtendTx | Tag.OracleResponseTx ? {
28
18
  callerId: Encoded.AccountAddress;
29
- } : {}) & (TxType extends Tag.ContractCreateTx | Tag.GaAttachTx ? {
30
- ctVersion?: CtVersion;
31
- } : {}) & (TxType extends Tag.ContractCallTx | Tag.OracleRegisterTx ? {
32
- abiVersion?: ABI_VERSIONS;
33
19
  } : {})): Promise<Encoded.Transaction>;
34
- export {};
@@ -1,5 +1,4 @@
1
- import { Tag } from './builder/constants';
2
- import { Encoded } from '../utils/encoder';
1
+ import { unpackTx } from './builder';
3
2
  import Node from '../Node';
4
3
  export interface ValidatorResult {
5
4
  message: string;
@@ -8,13 +7,12 @@ export interface ValidatorResult {
8
7
  }
9
8
  /**
10
9
  * Transaction Validator
11
- * This function validates some of transaction properties,
10
+ * This function validates some transaction properties,
12
11
  * to make sure it can be posted it to the chain
13
12
  * @category transaction builder
14
13
  * @param transaction - Base64Check-encoded transaction
15
14
  * @param nodeNotCached - Node to validate transaction against
16
- * @param parentTxTypes - Types of parent transactions
17
15
  * @returns Array with verification errors
18
16
  * @example const errors = await verifyTransaction(transaction, node)
19
17
  */
20
- export default function verifyTransaction(transaction: Encoded.Transaction | Encoded.Poi, nodeNotCached: Node, parentTxTypes?: Tag[]): Promise<ValidatorResult[]>;
18
+ export default function verifyTransaction(transaction: Parameters<typeof unpackTx>[0], nodeNotCached: Node): Promise<ValidatorResult[]>;
@@ -1,4 +1,5 @@
1
1
  import BigNumber from 'bignumber.js';
2
+ import { Int } from '../tx/builder/constants';
2
3
  /**
3
4
  * aepp-sdk originated error
4
5
  * @category exception
@@ -70,7 +71,7 @@ export declare class WalletError extends BaseError {
70
71
  * @category exception
71
72
  */
72
73
  export declare class ArgumentError extends BaseError {
73
- constructor(argumentName: string, requirement: string, argumentValue: any);
74
+ constructor(argumentName: string, requirement: unknown, argumentValue: unknown);
74
75
  }
75
76
  /**
76
77
  * @category exception
@@ -317,7 +318,7 @@ export declare class NoSuchContractFunctionError extends ContractError {
317
318
  * @category exception
318
319
  */
319
320
  export declare class NotPayableFunctionError extends ContractError {
320
- constructor(amount: string, fn: string);
321
+ constructor(amount: Int, fn: string);
321
322
  }
322
323
  /**
323
324
  * @category exception
@@ -442,12 +443,6 @@ export declare class TagNotFoundError extends TransactionError {
442
443
  export declare class TxNotInChainError extends TransactionError {
443
444
  constructor(txHash: string);
444
445
  }
445
- /**
446
- * @category exception
447
- */
448
- export declare class UnknownTxError extends TransactionError {
449
- constructor(message: string);
450
- }
451
446
  /**
452
447
  * @category exception
453
448
  */
@@ -14,7 +14,7 @@ export declare const mapObject: <InputV, OutputV>(object: {
14
14
  ]) => {
15
15
  [k: string]: OutputV;
16
16
  };
17
- export declare const concatBuffers: (list: readonly Uint8Array[], totalLength?: number | undefined) => Buffer;
17
+ export declare const concatBuffers: typeof Buffer.concat;
18
18
  /**
19
19
  * Object key type guard
20
20
  * @param key - Maybe object key
@@ -1,18 +0,0 @@
1
- import { Compiler as CompilerApi } from '../apis/compiler';
2
- /**
3
- * Contract Compiler over HTTP
4
- *
5
- * This class include api call's related to contract compiler functionality.
6
- * @category contract
7
- * @example CompilerHttp('COMPILER_URL')
8
- */
9
- export default class CompilerHttp extends CompilerApi {
10
- /**
11
- * @param compilerUrl - Url for compiler API
12
- * @param options - Options
13
- * @param options.ignoreVersion - Don't check compiler version
14
- */
15
- constructor(compilerUrl: string, { ignoreVersion }?: {
16
- ignoreVersion?: boolean;
17
- });
18
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"CompilerHttp.mjs","names":["Compiler","CompilerApi","genErrorFormatterPolicy","genVersionCheckPolicy","CompilerHttp","constructor","compilerUrl","ignoreVersion","allowInsecureConnection","additionalPolicies","body","message","reason","parameter","info","JSON","stringify","Array","isArray","map","e","type","pos","line","col","context","trim","join","versionPromise","apiVersion","then","pipeline","addPolicy"],"sources":["../../src/contract/CompilerHttp.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2022 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\nimport { Compiler as CompilerApi, ErrorModel, CompilerError } from '../apis/compiler';\nimport { genErrorFormatterPolicy, genVersionCheckPolicy } from '../utils/autorest';\n\ntype GeneralCompilerError = ErrorModel & {\n info?: object;\n parameter?: string;\n};\n\n/**\n * Contract Compiler over HTTP\n *\n * This class include api call's related to contract compiler functionality.\n * @category contract\n * @example CompilerHttp('COMPILER_URL')\n */\nexport default class CompilerHttp extends CompilerApi {\n /**\n * @param compilerUrl - Url for compiler API\n * @param options - Options\n * @param options.ignoreVersion - Don't check compiler version\n */\n constructor(compilerUrl: string, { ignoreVersion }: { ignoreVersion?: boolean } = {}) {\n super(compilerUrl, {\n allowInsecureConnection: true,\n additionalPolicies: [\n genErrorFormatterPolicy((body: GeneralCompilerError | CompilerError[]) => {\n let message = '';\n if ('reason' in body) {\n message += ` ${body.reason\n }${body.parameter != null ? ` in ${body.parameter}` : ''\n // TODO: revising after improving documentation https://github.com/aeternity/aesophia_http/issues/78\n }${body.info != null ? ` (${JSON.stringify(body.info)})` : ''}`;\n }\n if (Array.isArray(body)) {\n message += `\\n${body\n .map((e) => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context != null ? `(${e.context})` : ''}`)\n .map((e) => e.trim()) // TODO: remove after fixing https://github.com/aeternity/aesophia_http/issues/80\n .join('\\n')}`;\n }\n return message;\n }),\n ],\n });\n if (ignoreVersion !== true) {\n const versionPromise = this.apiVersion().then(({ apiVersion }) => apiVersion);\n this.pipeline.addPolicy(\n genVersionCheckPolicy('compiler', '/api-version', versionPromise, '7.0.1', '8.0.0'),\n );\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAfA,SAgBSA,QAAQ,IAAIC,WAAW;AAAA,SACvBC,uBAAuB,EAAEC,qBAAqB;AAOvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,YAAY,SAASH,WAAW,CAAC;EACpD;AACF;AACA;AACA;AACA;EACEI,WAAW,CAACC,WAAmB,EAAuD;IAAA,IAArD;MAAEC;IAA2C,CAAC,uEAAG,CAAC,CAAC;IAClF,KAAK,CAACD,WAAW,EAAE;MACjBE,uBAAuB,EAAE,IAAI;MAC7BC,kBAAkB,EAAE,CAClBP,uBAAuB,CAAEQ,IAA4C,IAAK;QACxE,IAAIC,OAAO,GAAG,EAAE;QAChB,IAAI,QAAQ,IAAID,IAAI,EAAE;UACpBC,OAAO,IAAK,IAAGD,IAAI,CAACE,MACnB,GAAEF,IAAI,CAACG,SAAS,IAAI,IAAI,GAAI,OAAMH,IAAI,CAACG,SAAU,EAAC,GAAG;UACpD;UACD,GAAEH,IAAI,CAACI,IAAI,IAAI,IAAI,GAAI,KAAIC,IAAI,CAACC,SAAS,CAACN,IAAI,CAACI,IAAI,CAAE,GAAE,GAAG,EAAG,EAAC;QACjE;QACA,IAAIG,KAAK,CAACC,OAAO,CAACR,IAAI,CAAC,EAAE;UACvBC,OAAO,IAAK,KAAID,IAAI,CACjBS,GAAG,CAAEC,CAAC,IAAM,GAAEA,CAAC,CAACC,IAAK,IAAGD,CAAC,CAACE,GAAG,CAACC,IAAK,IAAGH,CAAC,CAACE,GAAG,CAACE,GAAI,KAAIJ,CAAC,CAACT,OAAQ,GAAES,CAAC,CAACK,OAAO,IAAI,IAAI,GAAI,IAAGL,CAAC,CAACK,OAAQ,GAAE,GAAG,EAAG,EAAC,CAAC,CAC5GN,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACM,IAAI,EAAE,CAAC,CAAC;UAAA,CACrBC,IAAI,CAAC,IAAI,CAAE,EAAC;QACjB;QACA,OAAOhB,OAAO;MAChB,CAAC,CAAC;IAEN,CAAC,CAAC;IACF,IAAIJ,aAAa,KAAK,IAAI,EAAE;MAC1B,MAAMqB,cAAc,GAAG,IAAI,CAACC,UAAU,EAAE,CAACC,IAAI,CAAC;QAAA,IAAC;UAAED;QAAW,CAAC;QAAA,OAAKA,UAAU;MAAA,EAAC;MAC7E,IAAI,CAACE,QAAQ,CAACC,SAAS,CACrB7B,qBAAqB,CAAC,UAAU,EAAE,cAAc,EAAEyB,cAAc,EAAE,OAAO,EAAE,OAAO,CAAC,CACpF;IACH;EACF;AACF"}
@@ -1,6 +0,0 @@
1
- /// <reference types="node" />
2
- import { AddressEncodings } from './address';
3
- export default function genAddressesField<Encoding extends AddressEncodings>(): {
4
- serialize: (value: Array<`${Encoding}_${string}`>) => Buffer[];
5
- deserialize: (value: Buffer[]) => Array<`${Encoding}_${string}`>;
6
- };
@@ -1,13 +0,0 @@
1
- import genAddressField from "./address.mjs";
2
- export default function genAddressesField() {
3
- const address = genAddressField();
4
- return {
5
- serialize(addresses) {
6
- return addresses.map(address.serialize);
7
- },
8
- deserialize(addresses) {
9
- return addresses.map(address.deserialize);
10
- }
11
- };
12
- }
13
- //# sourceMappingURL=addresses.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addresses.mjs","names":["genAddressField","genAddressesField","address","serialize","addresses","map","deserialize"],"sources":["../../../../src/tx/builder/field-types/addresses.ts"],"sourcesContent":["import genAddressField, { AddressEncodings } from './address';\n\nexport default function genAddressesField<Encoding extends AddressEncodings>(): {\n serialize: (value: Array<`${Encoding}_${string}`>) => Buffer[];\n deserialize: (value: Buffer[]) => Array<`${Encoding}_${string}`>;\n} {\n const address = genAddressField<Encoding>();\n\n return {\n serialize(addresses) {\n return addresses.map(address.serialize);\n },\n\n deserialize(addresses) {\n return addresses.map(address.deserialize);\n },\n };\n}\n"],"mappings":"OAAOA,eAAe;AAEtB,eAAe,SAASC,iBAAiB,GAGvC;EACA,MAAMC,OAAO,GAAGF,eAAe,EAAY;EAE3C,OAAO;IACLG,SAAS,CAACC,SAAS,EAAE;MACnB,OAAOA,SAAS,CAACC,GAAG,CAACH,OAAO,CAACC,SAAS,CAAC;IACzC,CAAC;IAEDG,WAAW,CAACF,SAAS,EAAE;MACrB,OAAOA,SAAS,CAACC,GAAG,CAACH,OAAO,CAACI,WAAW,CAAC;IAC3C;EACF,CAAC;AACH"}
@@ -1,26 +0,0 @@
1
- /// <reference types="node" />
2
- export type MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>];
3
- export default class MPTree {
4
- private readonly rootHash;
5
- private readonly nodes;
6
- private static nodeHash;
7
- /**
8
- * Deserialize Merkle Patricia Tree
9
- * @param binary - Binary
10
- * @returns Merkle Patricia Tree
11
- */
12
- constructor(binary: MPTreeBinary);
13
- isEqual(tree: MPTree): boolean;
14
- private static parseNode;
15
- /**
16
- * Serialize Merkle Patricia Tree
17
- * @returns Binary
18
- */
19
- serialize(): MPTreeBinary;
20
- /**
21
- * Retrieve value from Merkle Patricia Tree
22
- * @param _key - The key of the element to retrieve
23
- * @returns Value associated to the specified key
24
- */
25
- get(_key: string): Buffer | undefined;
26
- }
@@ -1,143 +0,0 @@
1
- import _buffer from "buffer";
2
- const {
3
- Buffer: _Buffer
4
- } = _buffer;
5
- /*
6
- * ISC License (ISC)
7
- * Copyright (c) 2021 aeternity developers
8
- *
9
- * Permission to use, copy, modify, and/or distribute this software for any
10
- * purpose with or without fee is hereby granted, provided that the above
11
- * copyright notice and this permission notice appear in all copies.
12
- *
13
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- * PERFORMANCE OF THIS SOFTWARE.
20
- */
21
-
22
- /* eslint-disable default-case */
23
- import _rlp from 'rlp';
24
- const {
25
- encode: rlpEncode
26
- } = _rlp;
27
- import { hash } from "./crypto.mjs";
28
- import { MerkleTreeHashMismatchError, MissingNodeInTreeError, UnknownPathNibbleError, UnknownNodeLengthError } from "./errors.mjs";
29
- var NodeType;
30
- (function (NodeType) {
31
- NodeType[NodeType["Branch"] = 0] = "Branch";
32
- NodeType[NodeType["Extension"] = 1] = "Extension";
33
- NodeType[NodeType["Leaf"] = 2] = "Leaf";
34
- })(NodeType || (NodeType = {}));
35
- export default class MPTree {
36
- static nodeHash(node) {
37
- return _Buffer.from(hash(rlpEncode(node))).toString('hex');
38
- }
39
-
40
- /**
41
- * Deserialize Merkle Patricia Tree
42
- * @param binary - Binary
43
- * @returns Merkle Patricia Tree
44
- */
45
- constructor(binary) {
46
- this.rootHash = binary[0].toString('hex');
47
- this.nodes = Object.fromEntries(binary[1].map(node => [node[0].toString('hex'), node[1]]));
48
- if (this.nodes[this.rootHash] === undefined) throw new MissingNodeInTreeError('Can\'t find a node by root hash');
49
- Object.entries(this.nodes).forEach(_ref => {
50
- let [key, node] = _ref;
51
- if (MPTree.nodeHash(node) !== key) throw new MerkleTreeHashMismatchError();
52
- const {
53
- type,
54
- payload
55
- } = MPTree.parseNode(node);
56
- switch (type) {
57
- case NodeType.Branch:
58
- payload.slice(0, 16).filter(n => n.length).forEach(n => {
59
- if (this.nodes[n.toString('hex')] === undefined) {
60
- throw new MissingNodeInTreeError('Can\'t find a node by hash in branch node');
61
- }
62
- });
63
- break;
64
- case NodeType.Extension:
65
- if (this.nodes[payload[0].toString('hex')] === undefined) {
66
- throw new MissingNodeInTreeError('Can\'t find a node by hash in extension node');
67
- }
68
- }
69
- });
70
- }
71
- isEqual(tree) {
72
- return this.rootHash === tree.rootHash;
73
- }
74
- static parseNode(node) {
75
- switch (node.length) {
76
- case 17:
77
- return {
78
- type: NodeType.Branch,
79
- payload: node,
80
- path: null
81
- };
82
- case 2:
83
- {
84
- const nibble = node[0][0] >> 4; // eslint-disable-line no-bitwise
85
- if (nibble > 3) throw new UnknownPathNibbleError(nibble);
86
- const type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf;
87
- const slice = [0, 2].includes(nibble) ? 2 : 1;
88
- return {
89
- type,
90
- payload: [node[1]],
91
- path: node[0].toString('hex').slice(slice)
92
- };
93
- }
94
- default:
95
- throw new UnknownNodeLengthError(node.length);
96
- }
97
- }
98
-
99
- /**
100
- * Serialize Merkle Patricia Tree
101
- * @returns Binary
102
- */
103
- serialize() {
104
- return [_Buffer.from(this.rootHash, 'hex'), Object.entries(this.nodes).map(_ref2 => {
105
- let [mptHash, value] = _ref2;
106
- return [_Buffer.from(mptHash, 'hex'), value];
107
- })];
108
- }
109
-
110
- /**
111
- * Retrieve value from Merkle Patricia Tree
112
- * @param _key - The key of the element to retrieve
113
- * @returns Value associated to the specified key
114
- */
115
- get(_key) {
116
- let searchFrom = this.rootHash;
117
- let key = _key;
118
- while (true) {
119
- // eslint-disable-line no-constant-condition
120
- const {
121
- type,
122
- payload,
123
- path
124
- } = MPTree.parseNode(this.nodes[searchFrom]);
125
- switch (type) {
126
- case NodeType.Branch:
127
- if (key.length === 0) return payload[16];
128
- searchFrom = payload[+`0x${key[0]}`].toString('hex');
129
- key = key.substring(1);
130
- break;
131
- case NodeType.Extension:
132
- if (key.substring(0, path === null || path === void 0 ? void 0 : path.length) !== path) return undefined;
133
- searchFrom = payload[0].toString('hex');
134
- key = key.substring(path.length);
135
- break;
136
- case NodeType.Leaf:
137
- if (path !== key) return undefined;
138
- return payload[0];
139
- }
140
- }
141
- }
142
- }
143
- //# sourceMappingURL=mptree.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mptree.mjs","names":["hash","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownPathNibbleError","UnknownNodeLengthError","NodeType","MPTree","nodeHash","node","from","rlpEncode","toString","constructor","binary","rootHash","nodes","Object","fromEntries","map","undefined","entries","forEach","key","type","payload","parseNode","Branch","slice","filter","n","length","Extension","isEqual","tree","path","nibble","Leaf","includes","serialize","mptHash","value","get","_key","searchFrom","substring"],"sources":["../../src/utils/mptree.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2021 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/* eslint-disable default-case */\nimport { encode as rlpEncode } from 'rlp';\nimport type { Input } from 'rlp';\nimport { hash } from './crypto';\nimport {\n MerkleTreeHashMismatchError,\n MissingNodeInTreeError,\n UnknownPathNibbleError,\n UnknownNodeLengthError,\n} from './errors';\n\nenum NodeType {\n Branch,\n Extension,\n Leaf,\n}\n\nexport type MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>];\n\nexport default class MPTree {\n private readonly rootHash: string;\n\n private readonly nodes: { [key: string]: Buffer[] };\n\n private static nodeHash(node: Input): string {\n return Buffer.from(hash(rlpEncode(node))).toString('hex');\n }\n\n /**\n * Deserialize Merkle Patricia Tree\n * @param binary - Binary\n * @returns Merkle Patricia Tree\n */\n constructor(binary: MPTreeBinary) {\n this.rootHash = binary[0].toString('hex');\n this.nodes = Object.fromEntries(\n binary[1].map((node) => [node[0].toString('hex'), node[1]]),\n );\n\n if (this.nodes[this.rootHash] === undefined) throw new MissingNodeInTreeError('Can\\'t find a node by root hash');\n Object.entries(this.nodes).forEach(([key, node]) => {\n if (MPTree.nodeHash(node) !== key) throw new MerkleTreeHashMismatchError();\n const { type, payload } = MPTree.parseNode(node);\n switch (type) {\n case NodeType.Branch:\n payload\n .slice(0, 16)\n .filter((n) => n.length)\n .forEach((n) => {\n if (this.nodes[n.toString('hex')] === undefined) {\n throw new MissingNodeInTreeError('Can\\'t find a node by hash in branch node');\n }\n });\n break;\n case NodeType.Extension:\n if (this.nodes[payload[0].toString('hex')] === undefined) {\n throw new MissingNodeInTreeError('Can\\'t find a node by hash in extension node');\n }\n }\n });\n }\n\n isEqual(tree: MPTree): boolean {\n return this.rootHash === tree.rootHash;\n }\n\n private static parseNode(node: Buffer[]): {\n type: NodeType;\n payload: Buffer[];\n path: string | null;\n } {\n switch (node.length) {\n case 17:\n return { type: NodeType.Branch, payload: node, path: null };\n case 2: {\n const nibble = node[0][0] >> 4; // eslint-disable-line no-bitwise\n if (nibble > 3) throw new UnknownPathNibbleError(nibble);\n const type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf;\n const slice = [0, 2].includes(nibble) ? 2 : 1;\n return { type, payload: [node[1]], path: node[0].toString('hex').slice(slice) };\n }\n default:\n throw new UnknownNodeLengthError(node.length);\n }\n }\n\n /**\n * Serialize Merkle Patricia Tree\n * @returns Binary\n */\n serialize(): MPTreeBinary {\n return [\n Buffer.from(this.rootHash, 'hex'),\n Object.entries(this.nodes).map(([mptHash, value]) => ([\n Buffer.from(mptHash, 'hex'),\n value,\n ])),\n ];\n }\n\n /**\n * Retrieve value from Merkle Patricia Tree\n * @param _key - The key of the element to retrieve\n * @returns Value associated to the specified key\n */\n get(_key: string): Buffer | undefined {\n let searchFrom = this.rootHash;\n let key = _key;\n while (true) { // eslint-disable-line no-constant-condition\n const { type, payload, path } = MPTree.parseNode(this.nodes[searchFrom]);\n switch (type) {\n case NodeType.Branch:\n if (key.length === 0) return payload[16];\n searchFrom = payload[+`0x${key[0]}`].toString('hex');\n key = key.substring(1);\n break;\n case NodeType.Extension:\n if (key.substring(0, path?.length) !== path) return undefined;\n searchFrom = payload[0].toString('hex');\n key = key.substring(path.length);\n break;\n case NodeType.Leaf:\n if (path !== key) return undefined;\n return payload[0];\n }\n }\n }\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iBAAoC,KAAK;AAAC;EAAA;AAAA;AAAA,SAEjCA,IAAI;AAAA,SAEXC,2BAA2B,EAC3BC,sBAAsB,EACtBC,sBAAsB,EACtBC,sBAAsB;AAAA,IAGnBC,QA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,SAAS,CAAC,CAAC,CAAC;UACtB;QACF,KAAKvC,QAAQ,CAAC0B,SAAS;UACrB,IAAIT,GAAG,CAACsB,SAAS,CAAC,CAAC,EAAEV,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEJ,MAAM,CAAC,KAAKI,IAAI,EAAE,OAAOf,SAAS;UAC7DwB,UAAU,GAAGnB,OAAO,CAAC,CAAC,CAAC,CAACb,QAAQ,CAAC,KAAK,CAAC;UACvCW,GAAG,GAAGA,GAAG,CAACsB,SAAS,CAACV,IAAI,CAACJ,MAAM,CAAC;UAChC;QACF,KAAKzB,QAAQ,CAAC+B,IAAI;UAChB,IAAIF,IAAI,KAAKZ,GAAG,EAAE,OAAOH,SAAS;UAClC,OAAOK,OAAO,CAAC,CAAC,CAAC;MAAC;IAExB;EACF;AACF"}
@@ -1,67 +0,0 @@
1
- /*
2
- * ISC License (ISC)
3
- * Copyright (c) 2022 aeternity developers
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
8
- *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- * PERFORMANCE OF THIS SOFTWARE.
16
- */
17
- import { Compiler as CompilerApi, ErrorModel, CompilerError } from '../apis/compiler';
18
- import { genErrorFormatterPolicy, genVersionCheckPolicy } from '../utils/autorest';
19
-
20
- type GeneralCompilerError = ErrorModel & {
21
- info?: object;
22
- parameter?: string;
23
- };
24
-
25
- /**
26
- * Contract Compiler over HTTP
27
- *
28
- * This class include api call's related to contract compiler functionality.
29
- * @category contract
30
- * @example CompilerHttp('COMPILER_URL')
31
- */
32
- export default class CompilerHttp extends CompilerApi {
33
- /**
34
- * @param compilerUrl - Url for compiler API
35
- * @param options - Options
36
- * @param options.ignoreVersion - Don't check compiler version
37
- */
38
- constructor(compilerUrl: string, { ignoreVersion }: { ignoreVersion?: boolean } = {}) {
39
- super(compilerUrl, {
40
- allowInsecureConnection: true,
41
- additionalPolicies: [
42
- genErrorFormatterPolicy((body: GeneralCompilerError | CompilerError[]) => {
43
- let message = '';
44
- if ('reason' in body) {
45
- message += ` ${body.reason
46
- }${body.parameter != null ? ` in ${body.parameter}` : ''
47
- // TODO: revising after improving documentation https://github.com/aeternity/aesophia_http/issues/78
48
- }${body.info != null ? ` (${JSON.stringify(body.info)})` : ''}`;
49
- }
50
- if (Array.isArray(body)) {
51
- message += `\n${body
52
- .map((e) => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context != null ? `(${e.context})` : ''}`)
53
- .map((e) => e.trim()) // TODO: remove after fixing https://github.com/aeternity/aesophia_http/issues/80
54
- .join('\n')}`;
55
- }
56
- return message;
57
- }),
58
- ],
59
- });
60
- if (ignoreVersion !== true) {
61
- const versionPromise = this.apiVersion().then(({ apiVersion }) => apiVersion);
62
- this.pipeline.addPolicy(
63
- genVersionCheckPolicy('compiler', '/api-version', versionPromise, '7.0.1', '8.0.0'),
64
- );
65
- }
66
- }
67
- }
@@ -1,18 +0,0 @@
1
- import genAddressField, { AddressEncodings } from './address';
2
-
3
- export default function genAddressesField<Encoding extends AddressEncodings>(): {
4
- serialize: (value: Array<`${Encoding}_${string}`>) => Buffer[];
5
- deserialize: (value: Buffer[]) => Array<`${Encoding}_${string}`>;
6
- } {
7
- const address = genAddressField<Encoding>();
8
-
9
- return {
10
- serialize(addresses) {
11
- return addresses.map(address.serialize);
12
- },
13
-
14
- deserialize(addresses) {
15
- return addresses.map(address.deserialize);
16
- },
17
- };
18
- }
@@ -1,145 +0,0 @@
1
- /*
2
- * ISC License (ISC)
3
- * Copyright (c) 2021 aeternity developers
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
8
- *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- * PERFORMANCE OF THIS SOFTWARE.
16
- */
17
-
18
- /* eslint-disable default-case */
19
- import { encode as rlpEncode } from 'rlp';
20
- import type { Input } from 'rlp';
21
- import { hash } from './crypto';
22
- import {
23
- MerkleTreeHashMismatchError,
24
- MissingNodeInTreeError,
25
- UnknownPathNibbleError,
26
- UnknownNodeLengthError,
27
- } from './errors';
28
-
29
- enum NodeType {
30
- Branch,
31
- Extension,
32
- Leaf,
33
- }
34
-
35
- export type MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>];
36
-
37
- export default class MPTree {
38
- private readonly rootHash: string;
39
-
40
- private readonly nodes: { [key: string]: Buffer[] };
41
-
42
- private static nodeHash(node: Input): string {
43
- return Buffer.from(hash(rlpEncode(node))).toString('hex');
44
- }
45
-
46
- /**
47
- * Deserialize Merkle Patricia Tree
48
- * @param binary - Binary
49
- * @returns Merkle Patricia Tree
50
- */
51
- constructor(binary: MPTreeBinary) {
52
- this.rootHash = binary[0].toString('hex');
53
- this.nodes = Object.fromEntries(
54
- binary[1].map((node) => [node[0].toString('hex'), node[1]]),
55
- );
56
-
57
- if (this.nodes[this.rootHash] === undefined) throw new MissingNodeInTreeError('Can\'t find a node by root hash');
58
- Object.entries(this.nodes).forEach(([key, node]) => {
59
- if (MPTree.nodeHash(node) !== key) throw new MerkleTreeHashMismatchError();
60
- const { type, payload } = MPTree.parseNode(node);
61
- switch (type) {
62
- case NodeType.Branch:
63
- payload
64
- .slice(0, 16)
65
- .filter((n) => n.length)
66
- .forEach((n) => {
67
- if (this.nodes[n.toString('hex')] === undefined) {
68
- throw new MissingNodeInTreeError('Can\'t find a node by hash in branch node');
69
- }
70
- });
71
- break;
72
- case NodeType.Extension:
73
- if (this.nodes[payload[0].toString('hex')] === undefined) {
74
- throw new MissingNodeInTreeError('Can\'t find a node by hash in extension node');
75
- }
76
- }
77
- });
78
- }
79
-
80
- isEqual(tree: MPTree): boolean {
81
- return this.rootHash === tree.rootHash;
82
- }
83
-
84
- private static parseNode(node: Buffer[]): {
85
- type: NodeType;
86
- payload: Buffer[];
87
- path: string | null;
88
- } {
89
- switch (node.length) {
90
- case 17:
91
- return { type: NodeType.Branch, payload: node, path: null };
92
- case 2: {
93
- const nibble = node[0][0] >> 4; // eslint-disable-line no-bitwise
94
- if (nibble > 3) throw new UnknownPathNibbleError(nibble);
95
- const type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf;
96
- const slice = [0, 2].includes(nibble) ? 2 : 1;
97
- return { type, payload: [node[1]], path: node[0].toString('hex').slice(slice) };
98
- }
99
- default:
100
- throw new UnknownNodeLengthError(node.length);
101
- }
102
- }
103
-
104
- /**
105
- * Serialize Merkle Patricia Tree
106
- * @returns Binary
107
- */
108
- serialize(): MPTreeBinary {
109
- return [
110
- Buffer.from(this.rootHash, 'hex'),
111
- Object.entries(this.nodes).map(([mptHash, value]) => ([
112
- Buffer.from(mptHash, 'hex'),
113
- value,
114
- ])),
115
- ];
116
- }
117
-
118
- /**
119
- * Retrieve value from Merkle Patricia Tree
120
- * @param _key - The key of the element to retrieve
121
- * @returns Value associated to the specified key
122
- */
123
- get(_key: string): Buffer | undefined {
124
- let searchFrom = this.rootHash;
125
- let key = _key;
126
- while (true) { // eslint-disable-line no-constant-condition
127
- const { type, payload, path } = MPTree.parseNode(this.nodes[searchFrom]);
128
- switch (type) {
129
- case NodeType.Branch:
130
- if (key.length === 0) return payload[16];
131
- searchFrom = payload[+`0x${key[0]}`].toString('hex');
132
- key = key.substring(1);
133
- break;
134
- case NodeType.Extension:
135
- if (key.substring(0, path?.length) !== path) return undefined;
136
- searchFrom = payload[0].toString('hex');
137
- key = key.substring(path.length);
138
- break;
139
- case NodeType.Leaf:
140
- if (path !== key) return undefined;
141
- return payload[0];
142
- }
143
- }
144
- }
145
- }
@@ -1,18 +0,0 @@
1
- import { Compiler as CompilerApi } from '../apis/compiler';
2
- /**
3
- * Contract Compiler over HTTP
4
- *
5
- * This class include api call's related to contract compiler functionality.
6
- * @category contract
7
- * @example CompilerHttp('COMPILER_URL')
8
- */
9
- export default class CompilerHttp extends CompilerApi {
10
- /**
11
- * @param compilerUrl - Url for compiler API
12
- * @param options - Options
13
- * @param options.ignoreVersion - Don't check compiler version
14
- */
15
- constructor(compilerUrl: string, { ignoreVersion }?: {
16
- ignoreVersion?: boolean;
17
- });
18
- }
@@ -1,6 +0,0 @@
1
- /// <reference types="node" />
2
- import { AddressEncodings } from './address';
3
- export default function genAddressesField<Encoding extends AddressEncodings>(): {
4
- serialize: (value: Array<`${Encoding}_${string}`>) => Buffer[];
5
- deserialize: (value: Buffer[]) => Array<`${Encoding}_${string}`>;
6
- };
@@ -1,32 +0,0 @@
1
- /// <reference types="node" />
2
- export type MPTreeBinary = [
3
- Buffer,
4
- Array<[
5
- Buffer,
6
- Buffer[]
7
- ]>
8
- ];
9
- export default class MPTree {
10
- private readonly rootHash;
11
- private readonly nodes;
12
- private static nodeHash;
13
- /**
14
- * Deserialize Merkle Patricia Tree
15
- * @param binary - Binary
16
- * @returns Merkle Patricia Tree
17
- */
18
- constructor(binary: MPTreeBinary);
19
- isEqual(tree: MPTree): boolean;
20
- private static parseNode;
21
- /**
22
- * Serialize Merkle Patricia Tree
23
- * @returns Binary
24
- */
25
- serialize(): MPTreeBinary;
26
- /**
27
- * Retrieve value from Merkle Patricia Tree
28
- * @param _key - The key of the element to retrieve
29
- * @returns Value associated to the specified key
30
- */
31
- get(_key: string): Buffer | undefined;
32
- }