@aeternity/aepp-sdk 12.1.3 → 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 (565) 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 +12031 -11231
  7. package/dist/aepp-sdk.js.map +1 -1
  8. package/es/AeSdk.d.ts +7 -3
  9. package/es/AeSdk.mjs +17 -22
  10. package/es/AeSdk.mjs.map +1 -1
  11. package/es/AeSdkAepp.d.ts +6 -5
  12. package/es/AeSdkAepp.mjs +7 -30
  13. package/es/AeSdkAepp.mjs.map +1 -1
  14. package/es/AeSdkBase.d.ts +18 -140
  15. package/es/AeSdkBase.mjs +30 -184
  16. package/es/AeSdkBase.mjs.map +1 -1
  17. package/es/AeSdkMethods.d.ts +123 -0
  18. package/es/AeSdkMethods.mjs +122 -0
  19. package/es/AeSdkMethods.mjs.map +1 -0
  20. package/es/AeSdkWallet.d.ts +7 -21
  21. package/es/AeSdkWallet.mjs +38 -86
  22. package/es/AeSdkWallet.mjs.map +1 -1
  23. package/es/Node.d.ts +11 -15
  24. package/es/Node.mjs +35 -48
  25. package/es/Node.mjs.map +1 -1
  26. package/es/account/Base.d.ts +24 -40
  27. package/es/account/Base.mjs +1 -101
  28. package/es/account/Base.mjs.map +1 -1
  29. package/es/account/Generalized.d.ts +16 -0
  30. package/es/account/Generalized.mjs +113 -0
  31. package/es/account/Generalized.mjs.map +1 -0
  32. package/es/account/Ledger.d.ts +28 -0
  33. package/es/account/Ledger.mjs +102 -0
  34. package/es/account/Ledger.mjs.map +1 -0
  35. package/es/account/LedgerFactory.d.ts +39 -0
  36. package/es/account/LedgerFactory.mjs +81 -0
  37. package/es/account/LedgerFactory.mjs.map +1 -0
  38. package/es/account/Memory.d.ts +13 -17
  39. package/es/account/Memory.mjs +43 -64
  40. package/es/account/Memory.mjs.map +1 -1
  41. package/es/account/Rpc.d.ts +6 -8
  42. package/es/account/Rpc.mjs +14 -32
  43. package/es/account/Rpc.mjs.map +1 -1
  44. package/es/aens.d.ts +4 -4
  45. package/es/aens.mjs +46 -41
  46. package/es/aens.mjs.map +1 -1
  47. package/es/aepp-wallet-communication/connection/Browser.mjs +9 -13
  48. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  49. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  50. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +22 -11
  51. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  52. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -1
  53. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -31
  54. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  55. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  56. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +3 -3
  57. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -42
  58. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  59. package/es/aepp-wallet-communication/rpc/types.d.ts +7 -1
  60. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  61. package/es/aepp-wallet-communication/schema.mjs +14 -68
  62. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  63. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
  64. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  65. package/es/apis/compiler/compiler.d.ts +23 -29
  66. package/es/apis/compiler/compiler.mjs +128 -189
  67. package/es/apis/compiler/compiler.mjs.map +1 -1
  68. package/es/apis/compiler/index.mjs.map +1 -1
  69. package/es/apis/compiler/models/index.d.ts +82 -135
  70. package/es/apis/compiler/models/index.mjs +1 -47
  71. package/es/apis/compiler/models/index.mjs.map +1 -1
  72. package/es/apis/compiler/models/mappers.d.ts +8 -8
  73. package/es/apis/compiler/models/mappers.mjs +165 -183
  74. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  75. package/es/apis/compiler/models/parameters.d.ts +0 -1
  76. package/es/apis/compiler/models/parameters.mjs +5 -9
  77. package/es/apis/compiler/models/parameters.mjs.map +1 -1
  78. package/es/apis/node/index.mjs.map +1 -1
  79. package/es/apis/node/models/index.d.ts +48 -48
  80. package/es/apis/node/models/mappers.mjs +12 -6
  81. package/es/apis/node/models/mappers.mjs.map +1 -1
  82. package/es/apis/node/models/parameters.mjs.map +1 -1
  83. package/es/apis/node/node.mjs +43 -84
  84. package/es/apis/node/node.mjs.map +1 -1
  85. package/es/chain.d.ts +10 -2
  86. package/es/chain.mjs +37 -59
  87. package/es/chain.mjs.map +1 -1
  88. package/es/channel/Base.d.ts +200 -0
  89. package/es/channel/Base.mjs +293 -0
  90. package/es/channel/Base.mjs.map +1 -0
  91. package/es/channel/Contract.d.ts +248 -0
  92. package/es/channel/Contract.mjs +420 -0
  93. package/es/channel/Contract.mjs.map +1 -0
  94. package/es/channel/Spend.d.ts +219 -0
  95. package/es/channel/Spend.mjs +385 -0
  96. package/es/channel/Spend.mjs.map +1 -0
  97. package/es/channel/handlers.d.ts +8 -21
  98. package/es/channel/handlers.mjs +151 -899
  99. package/es/channel/handlers.mjs.map +1 -1
  100. package/es/channel/internal.d.ts +27 -21
  101. package/es/channel/internal.mjs +101 -191
  102. package/es/channel/internal.mjs.map +1 -1
  103. package/es/contract/Contract.d.ts +210 -0
  104. package/es/contract/Contract.mjs +551 -0
  105. package/es/contract/Contract.mjs.map +1 -0
  106. package/es/contract/compiler/Base.d.ts +81 -0
  107. package/es/contract/compiler/Base.mjs +5 -0
  108. package/es/contract/compiler/Base.mjs.map +1 -0
  109. package/es/contract/compiler/Cli.d.ts +23 -0
  110. package/es/contract/compiler/Cli.mjs +155 -0
  111. package/es/contract/compiler/Cli.mjs.map +1 -0
  112. package/es/contract/compiler/Http.d.ts +32 -0
  113. package/es/contract/compiler/Http.mjs +118 -0
  114. package/es/contract/compiler/Http.mjs.map +1 -0
  115. package/es/contract/compiler/HttpNode.d.ts +17 -0
  116. package/es/contract/compiler/HttpNode.mjs +26 -0
  117. package/es/contract/compiler/HttpNode.mjs.map +1 -0
  118. package/es/contract/compiler/getFileSystem.d.ts +6 -0
  119. package/es/contract/compiler/getFileSystem.mjs +40 -0
  120. package/es/contract/compiler/getFileSystem.mjs.map +1 -0
  121. package/es/contract/ga.d.ts +9 -34
  122. package/es/contract/ga.mjs +29 -112
  123. package/es/contract/ga.mjs.map +1 -1
  124. package/es/index-browser.d.ts +39 -0
  125. package/es/index-browser.mjs +55 -0
  126. package/es/index-browser.mjs.map +1 -0
  127. package/es/index.d.ts +4 -35
  128. package/es/index.mjs +4 -51
  129. package/es/index.mjs.map +1 -1
  130. package/es/oracle.d.ts +5 -5
  131. package/es/oracle.mjs +34 -40
  132. package/es/oracle.mjs.map +1 -1
  133. package/es/spend.d.ts +3 -3
  134. package/es/spend.mjs +18 -23
  135. package/es/spend.mjs.map +1 -1
  136. package/es/tx/builder/constants.d.ts +30 -2
  137. package/es/tx/builder/constants.mjs +43 -14
  138. package/es/tx/builder/constants.mjs.map +1 -1
  139. package/es/tx/builder/field-types/abi-version.d.ts +10 -0
  140. package/es/tx/builder/field-types/abi-version.mjs +20 -0
  141. package/es/tx/builder/field-types/abi-version.mjs.map +1 -0
  142. package/es/tx/builder/field-types/address.d.ts +14 -0
  143. package/es/tx/builder/field-types/address.mjs +51 -0
  144. package/es/tx/builder/field-types/address.mjs.map +1 -0
  145. package/es/tx/builder/field-types/array.d.ts +7 -0
  146. package/es/tx/builder/field-types/array.mjs +11 -0
  147. package/es/tx/builder/field-types/array.mjs.map +1 -0
  148. package/es/tx/builder/field-types/boolean.d.ts +6 -0
  149. package/es/tx/builder/field-types/boolean.mjs +13 -0
  150. package/es/tx/builder/field-types/boolean.mjs.map +1 -0
  151. package/es/tx/builder/field-types/coin-amount.d.ts +2 -3
  152. package/es/tx/builder/field-types/coin-amount.mjs +4 -12
  153. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  154. package/es/tx/builder/field-types/ct-version.d.ts +30 -0
  155. package/es/tx/builder/field-types/ct-version.mjs +48 -0
  156. package/es/tx/builder/field-types/ct-version.mjs.map +1 -0
  157. package/es/tx/builder/field-types/deposit.d.ts +1 -2
  158. package/es/tx/builder/field-types/deposit.mjs +2 -4
  159. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  160. package/es/tx/builder/field-types/encoded.d.ts +6 -0
  161. package/es/tx/builder/field-types/encoded.mjs +21 -0
  162. package/es/tx/builder/field-types/encoded.mjs.map +1 -0
  163. package/es/tx/builder/field-types/entry.d.ts +11 -0
  164. package/es/tx/builder/field-types/entry.mjs +31 -0
  165. package/es/tx/builder/field-types/entry.mjs.map +1 -0
  166. package/es/tx/builder/field-types/enumeration.d.ts +7 -0
  167. package/es/tx/builder/field-types/enumeration.mjs +30 -0
  168. package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
  169. package/es/tx/builder/field-types/fee.d.ts +10 -15
  170. package/es/tx/builder/field-types/fee.mjs +31 -43
  171. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  172. package/es/tx/builder/field-types/field.mjs +0 -2
  173. package/es/tx/builder/field-types/field.mjs.map +1 -1
  174. package/es/tx/builder/field-types/gas-limit.d.ts +5 -2
  175. package/es/tx/builder/field-types/gas-limit.mjs +12 -14
  176. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  177. package/es/tx/builder/field-types/gas-price.d.ts +1 -2
  178. package/es/tx/builder/field-types/gas-price.mjs +3 -7
  179. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  180. package/es/tx/builder/field-types/index.d.ts +80 -30
  181. package/es/tx/builder/field-types/index.mjs +34 -9
  182. package/es/tx/builder/field-types/index.mjs.map +1 -1
  183. package/es/tx/builder/field-types/mptree.d.ts +37 -0
  184. package/es/tx/builder/field-types/mptree.mjs +268 -0
  185. package/es/tx/builder/field-types/mptree.mjs.map +1 -0
  186. package/es/tx/builder/field-types/name-fee.d.ts +1 -3
  187. package/es/tx/builder/field-types/name-fee.mjs +3 -5
  188. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  189. package/es/tx/builder/field-types/name-id.d.ts +1 -4
  190. package/es/tx/builder/field-types/name-id.mjs +5 -10
  191. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  192. package/es/tx/builder/field-types/name.mjs +0 -2
  193. package/es/tx/builder/field-types/name.mjs.map +1 -1
  194. package/es/tx/builder/field-types/pointers.d.ts +23 -0
  195. package/es/tx/builder/field-types/pointers.mjs +36 -0
  196. package/es/tx/builder/field-types/pointers.mjs.map +1 -0
  197. package/es/tx/builder/field-types/raw.d.ts +6 -0
  198. package/es/tx/builder/field-types/raw.mjs +13 -0
  199. package/es/tx/builder/field-types/raw.mjs.map +1 -0
  200. package/es/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  201. package/es/tx/builder/field-types/short-u-int-const.mjs +16 -0
  202. package/es/tx/builder/field-types/short-u-int-const.mjs.map +1 -0
  203. package/es/tx/builder/field-types/short-u-int.mjs +0 -2
  204. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  205. package/es/tx/builder/field-types/string.d.ts +6 -0
  206. package/es/tx/builder/field-types/string.mjs +10 -0
  207. package/es/tx/builder/field-types/string.mjs.map +1 -0
  208. package/es/tx/builder/field-types/u-int.d.ts +1 -2
  209. package/es/tx/builder/field-types/u-int.mjs +3 -4
  210. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  211. package/es/tx/builder/helpers.d.ts +2 -32
  212. package/es/tx/builder/helpers.mjs +19 -71
  213. package/es/tx/builder/helpers.mjs.map +1 -1
  214. package/es/tx/builder/index.d.ts +11 -49
  215. package/es/tx/builder/index.mjs +57 -337
  216. package/es/tx/builder/index.mjs.map +1 -1
  217. package/es/tx/builder/schema.d.ts +2367 -667
  218. package/es/tx/builder/schema.mjs +70 -145
  219. package/es/tx/builder/schema.mjs.map +1 -1
  220. package/es/tx/index.d.ts +4 -49
  221. package/es/tx/index.mjs +38 -112
  222. package/es/tx/index.mjs.map +1 -1
  223. package/es/tx/validator.d.ts +4 -6
  224. package/es/tx/validator.mjs +104 -90
  225. package/es/tx/validator.mjs.map +1 -1
  226. package/es/typings/{@aeternity__argon2-browser → @aeternity__aepp-calldata}/index.d.mjs +0 -0
  227. package/es/typings/@aeternity__aepp-calldata/index.d.mjs.map +1 -0
  228. package/es/utils/amount-formatter.mjs +4 -10
  229. package/es/utils/amount-formatter.mjs.map +1 -1
  230. package/es/utils/autorest.d.ts +1 -0
  231. package/es/utils/autorest.mjs +17 -19
  232. package/es/utils/autorest.mjs.map +1 -1
  233. package/es/utils/bignumber.mjs +4 -7
  234. package/es/utils/bignumber.mjs.map +1 -1
  235. package/es/utils/bytes.d.ts +0 -17
  236. package/es/utils/bytes.mjs +6 -35
  237. package/es/utils/bytes.mjs.map +1 -1
  238. package/es/utils/crypto.d.ts +15 -8
  239. package/es/utils/crypto.mjs +40 -40
  240. package/es/utils/crypto.mjs.map +1 -1
  241. package/es/utils/encoder-types.d.ts +28 -28
  242. package/es/utils/encoder-types.mjs +0 -1
  243. package/es/utils/encoder-types.mjs.map +1 -1
  244. package/es/utils/encoder.d.ts +0 -1
  245. package/es/utils/encoder.mjs +7 -15
  246. package/es/utils/encoder.mjs.map +1 -1
  247. package/es/utils/errors.d.ts +15 -14
  248. package/es/utils/errors.mjs +86 -172
  249. package/es/utils/errors.mjs.map +1 -1
  250. package/es/utils/hd-wallet.d.ts +27 -19
  251. package/es/utils/hd-wallet.mjs +42 -26
  252. package/es/utils/hd-wallet.mjs.map +1 -1
  253. package/es/utils/json-big.mjs +0 -8
  254. package/es/utils/json-big.mjs.map +1 -1
  255. package/es/utils/keystore.d.ts +2 -0
  256. package/es/utils/keystore.mjs +37 -36
  257. package/es/utils/keystore.mjs.map +1 -1
  258. package/es/utils/other.d.ts +4 -2
  259. package/es/utils/other.mjs +11 -7
  260. package/es/utils/other.mjs.map +1 -1
  261. package/es/utils/semver-satisfies.mjs +0 -3
  262. package/es/utils/semver-satisfies.mjs.map +1 -1
  263. package/es/utils/string.d.ts +0 -12
  264. package/es/utils/string.mjs +1 -21
  265. package/es/utils/string.mjs.map +1 -1
  266. package/package.json +98 -51
  267. package/src/AeSdk.ts +15 -11
  268. package/src/AeSdkAepp.ts +9 -7
  269. package/src/AeSdkBase.ts +31 -202
  270. package/src/AeSdkMethods.ts +169 -0
  271. package/src/AeSdkWallet.ts +16 -47
  272. package/src/Node.ts +17 -18
  273. package/src/account/Base.ts +29 -75
  274. package/src/account/Generalized.ts +98 -0
  275. package/src/account/Ledger.ts +131 -0
  276. package/src/account/LedgerFactory.ts +86 -0
  277. package/src/account/Memory.ts +46 -60
  278. package/src/account/Rpc.ts +17 -26
  279. package/src/aens.ts +13 -11
  280. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +21 -9
  281. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
  282. package/src/aepp-wallet-communication/rpc/RpcClient.ts +4 -4
  283. package/src/aepp-wallet-communication/rpc/types.ts +11 -1
  284. package/src/aepp-wallet-communication/schema.ts +18 -18
  285. package/src/apis/compiler/code-model-v4.yaml +681 -888
  286. package/src/apis/compiler/compiler.ts +113 -154
  287. package/src/apis/compiler/models/index.ts +80 -140
  288. package/src/apis/compiler/models/mappers.ts +165 -183
  289. package/src/apis/compiler/models/parameters.ts +6 -12
  290. package/src/chain.ts +11 -6
  291. package/src/channel/Base.ts +335 -0
  292. package/src/channel/Contract.ts +488 -0
  293. package/src/channel/Spend.ts +408 -0
  294. package/src/channel/handlers.ts +164 -582
  295. package/src/channel/internal.ts +114 -143
  296. package/src/contract/Contract.ts +610 -0
  297. package/src/contract/compiler/Base.ts +94 -0
  298. package/src/contract/compiler/Cli.ts +134 -0
  299. package/src/contract/compiler/Http.ts +124 -0
  300. package/src/contract/compiler/HttpNode.ts +26 -0
  301. package/src/contract/compiler/getFileSystem.ts +42 -0
  302. package/src/contract/ga.ts +23 -106
  303. package/src/index-browser.ts +58 -0
  304. package/src/index.ts +4 -55
  305. package/src/oracle.ts +8 -8
  306. package/src/spend.ts +6 -14
  307. package/src/tx/builder/constants.ts +33 -3
  308. package/src/tx/builder/field-types/abi-version.ts +21 -0
  309. package/src/tx/builder/field-types/address.ts +62 -0
  310. package/src/tx/builder/field-types/array.ts +19 -0
  311. package/src/tx/builder/field-types/boolean.ts +9 -0
  312. package/src/tx/builder/field-types/coin-amount.ts +4 -9
  313. package/src/tx/builder/field-types/ct-version.ts +50 -0
  314. package/src/tx/builder/field-types/deposit.ts +1 -1
  315. package/src/tx/builder/field-types/encoded.ts +27 -0
  316. package/src/tx/builder/field-types/entry.ts +31 -0
  317. package/src/tx/builder/field-types/enumeration.ts +32 -0
  318. package/src/tx/builder/field-types/fee.ts +39 -21
  319. package/src/tx/builder/field-types/gas-limit.ts +13 -8
  320. package/src/tx/builder/field-types/gas-price.ts +0 -2
  321. package/src/tx/builder/field-types/index.ts +54 -15
  322. package/src/tx/builder/field-types/mptree.ts +242 -0
  323. package/src/tx/builder/field-types/name-fee.ts +2 -3
  324. package/src/tx/builder/field-types/name-id.ts +7 -10
  325. package/src/tx/builder/field-types/pointers.ts +41 -0
  326. package/src/tx/builder/field-types/raw.ts +9 -0
  327. package/src/tx/builder/field-types/short-u-int-const.ts +20 -0
  328. package/src/tx/builder/field-types/string.ts +11 -0
  329. package/src/tx/builder/field-types/u-int.ts +4 -5
  330. package/src/tx/builder/helpers.ts +10 -60
  331. package/src/tx/builder/index.ts +65 -308
  332. package/src/tx/builder/schema.ts +280 -341
  333. package/src/tx/index.ts +40 -103
  334. package/src/tx/validator.ts +91 -96
  335. package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
  336. package/src/utils/autorest.ts +16 -1
  337. package/src/utils/bytes.ts +6 -34
  338. package/src/utils/crypto.ts +23 -16
  339. package/src/utils/encoder.ts +0 -1
  340. package/src/utils/errors.ts +22 -25
  341. package/src/utils/hd-wallet.ts +30 -9
  342. package/src/utils/keystore.ts +24 -21
  343. package/src/utils/other.ts +16 -1
  344. package/src/utils/string.ts +0 -20
  345. package/types-legacy/ts4.2/AeSdk.d.ts +41 -0
  346. package/types-legacy/ts4.2/AeSdkAepp.d.ts +71 -0
  347. package/types-legacy/ts4.2/AeSdkBase.d.ts +91 -0
  348. package/types-legacy/ts4.2/AeSdkMethods.d.ts +140 -0
  349. package/types-legacy/ts4.2/AeSdkWallet.d.ts +90 -0
  350. package/types-legacy/ts4.2/Node.d.ts +78 -0
  351. package/types-legacy/ts4.2/account/Base.d.ts +52 -0
  352. package/types-legacy/ts4.2/account/Generalized.d.ts +16 -0
  353. package/types-legacy/ts4.2/account/Ledger.d.ts +28 -0
  354. package/types-legacy/ts4.2/account/LedgerFactory.d.ts +39 -0
  355. package/types-legacy/ts4.2/account/Memory.d.ts +22 -0
  356. package/types-legacy/ts4.2/account/Rpc.d.ts +25 -0
  357. package/types-legacy/ts4.2/aens.d.ts +222 -0
  358. package/types-legacy/ts4.2/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  359. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +19 -0
  360. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  361. package/types-legacy/ts4.2/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  362. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  363. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +83 -0
  364. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +133 -0
  365. package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  366. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +86 -0
  367. package/types-legacy/ts4.2/apis/compiler/index.d.ts +2 -0
  368. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +195 -0
  369. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +23 -0
  370. package/types-legacy/ts4.2/apis/compiler/models/parameters.d.ts +12 -0
  371. package/types-legacy/ts4.2/apis/node/index.d.ts +2 -0
  372. package/types-legacy/ts4.2/apis/node/models/index.d.ts +1065 -0
  373. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +95 -0
  374. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +17 -0
  375. package/types-legacy/ts4.2/apis/node/node.d.ts +215 -0
  376. package/types-legacy/ts4.2/chain.d.ts +256 -0
  377. package/types-legacy/ts4.2/channel/Base.d.ts +199 -0
  378. package/types-legacy/ts4.2/channel/Contract.d.ts +248 -0
  379. package/types-legacy/ts4.2/channel/Spend.d.ts +219 -0
  380. package/types-legacy/ts4.2/channel/handlers.d.ts +21 -0
  381. package/types-legacy/ts4.2/channel/internal.d.ts +107 -0
  382. package/types-legacy/ts4.2/contract/Contract.d.ts +212 -0
  383. package/types-legacy/ts4.2/contract/compiler/Base.d.ts +81 -0
  384. package/types-legacy/ts4.2/contract/compiler/Cli.d.ts +23 -0
  385. package/types-legacy/ts4.2/contract/compiler/Http.d.ts +32 -0
  386. package/types-legacy/ts4.2/contract/compiler/HttpNode.d.ts +17 -0
  387. package/types-legacy/ts4.2/contract/compiler/getFileSystem.d.ts +6 -0
  388. package/types-legacy/ts4.2/contract/ga.d.ts +44 -0
  389. package/types-legacy/ts4.2/globals.d.ts +16 -0
  390. package/types-legacy/ts4.2/index-browser.d.ts +39 -0
  391. package/types-legacy/ts4.2/index.d.ts +5 -0
  392. package/types-legacy/ts4.2/oracle.d.ts +161 -0
  393. package/types-legacy/ts4.2/spend.d.ts +62 -0
  394. package/types-legacy/ts4.2/tx/builder/constants.d.ts +98 -0
  395. package/types-legacy/ts4.2/tx/builder/field-types/abi-version.d.ts +10 -0
  396. package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +21 -0
  397. package/types-legacy/ts4.2/tx/builder/field-types/array.d.ts +7 -0
  398. package/types-legacy/ts4.2/tx/builder/field-types/boolean.d.ts +6 -0
  399. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +12 -0
  400. package/types-legacy/ts4.2/tx/builder/field-types/ct-version.d.ts +42 -0
  401. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +14 -0
  402. package/types-legacy/ts4.2/tx/builder/field-types/encoded.d.ts +6 -0
  403. package/types-legacy/ts4.2/tx/builder/field-types/entry.d.ts +11 -0
  404. package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +7 -0
  405. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +20 -0
  406. package/types-legacy/ts4.2/tx/builder/field-types/field.d.ts +6 -0
  407. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +15 -0
  408. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +7 -0
  409. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +129 -0
  410. package/types-legacy/ts4.2/tx/builder/field-types/mptree.d.ts +43 -0
  411. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +18 -0
  412. package/types-legacy/ts4.2/tx/builder/field-types/name-id.d.ts +11 -0
  413. package/types-legacy/ts4.2/tx/builder/field-types/name.d.ts +13 -0
  414. package/types-legacy/ts4.2/tx/builder/field-types/pointers.d.ts +26 -0
  415. package/types-legacy/ts4.2/tx/builder/field-types/raw.d.ts +6 -0
  416. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  417. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int.d.ts +6 -0
  418. package/types-legacy/ts4.2/tx/builder/field-types/string.d.ts +6 -0
  419. package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +7 -0
  420. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
  421. package/types-legacy/ts4.2/tx/builder/index.d.ts +50 -0
  422. package/types-legacy/ts4.2/tx/builder/schema.d.ts +4675 -0
  423. package/types-legacy/ts4.2/tx/index.d.ts +19 -0
  424. package/types-legacy/ts4.2/tx/validator.d.ts +18 -0
  425. package/types-legacy/ts4.2/utils/amount-formatter.d.ts +42 -0
  426. package/types-legacy/ts4.2/utils/autorest.d.ts +7 -0
  427. package/types-legacy/ts4.2/utils/bignumber.d.ts +13 -0
  428. package/types-legacy/ts4.2/utils/bytes.d.ts +9 -0
  429. package/types-legacy/ts4.2/utils/crypto.d.ts +95 -0
  430. package/types-legacy/ts4.2/utils/encoder-types.d.ts +61 -0
  431. package/types-legacy/ts4.2/utils/encoder.d.ts +24 -0
  432. package/types-legacy/ts4.2/utils/errors.d.ts +475 -0
  433. package/types-legacy/ts4.2/utils/hd-wallet.d.ts +65 -0
  434. package/types-legacy/ts4.2/utils/json-big.d.ts +5 -0
  435. package/types-legacy/ts4.2/utils/keystore.d.ts +53 -0
  436. package/types-legacy/ts4.2/utils/other.d.ts +31 -0
  437. package/types-legacy/ts4.2/utils/semver-satisfies.d.ts +1 -0
  438. package/types-legacy/ts4.2/utils/string.d.ts +12 -0
  439. package/types-legacy/ts4.5/AeSdk.d.ts +41 -0
  440. package/types-legacy/ts4.5/AeSdkAepp.d.ts +71 -0
  441. package/types-legacy/ts4.5/AeSdkBase.d.ts +91 -0
  442. package/types-legacy/ts4.5/AeSdkMethods.d.ts +140 -0
  443. package/types-legacy/ts4.5/AeSdkWallet.d.ts +90 -0
  444. package/types-legacy/ts4.5/Node.d.ts +78 -0
  445. package/types-legacy/ts4.5/account/Base.d.ts +52 -0
  446. package/types-legacy/ts4.5/account/Generalized.d.ts +16 -0
  447. package/types-legacy/ts4.5/account/Ledger.d.ts +28 -0
  448. package/types-legacy/ts4.5/account/LedgerFactory.d.ts +39 -0
  449. package/types-legacy/ts4.5/account/Memory.d.ts +22 -0
  450. package/types-legacy/ts4.5/account/Rpc.d.ts +25 -0
  451. package/types-legacy/ts4.5/aens.d.ts +222 -0
  452. package/types-legacy/ts4.5/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  453. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +19 -0
  454. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  455. package/types-legacy/ts4.5/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  456. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  457. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +83 -0
  458. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +133 -0
  459. package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  460. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +86 -0
  461. package/types-legacy/ts4.5/apis/compiler/index.d.ts +2 -0
  462. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +195 -0
  463. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +23 -0
  464. package/types-legacy/ts4.5/apis/compiler/models/parameters.d.ts +12 -0
  465. package/types-legacy/ts4.5/apis/node/index.d.ts +2 -0
  466. package/types-legacy/ts4.5/apis/node/models/index.d.ts +1065 -0
  467. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +95 -0
  468. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +17 -0
  469. package/types-legacy/ts4.5/apis/node/node.d.ts +215 -0
  470. package/types-legacy/ts4.5/chain.d.ts +256 -0
  471. package/types-legacy/ts4.5/channel/Base.d.ts +199 -0
  472. package/types-legacy/ts4.5/channel/Contract.d.ts +248 -0
  473. package/types-legacy/ts4.5/channel/Spend.d.ts +219 -0
  474. package/types-legacy/ts4.5/channel/handlers.d.ts +21 -0
  475. package/types-legacy/ts4.5/channel/internal.d.ts +107 -0
  476. package/types-legacy/ts4.5/contract/Contract.d.ts +212 -0
  477. package/types-legacy/ts4.5/contract/compiler/Base.d.ts +81 -0
  478. package/types-legacy/ts4.5/contract/compiler/Cli.d.ts +23 -0
  479. package/types-legacy/ts4.5/contract/compiler/Http.d.ts +32 -0
  480. package/types-legacy/ts4.5/contract/compiler/HttpNode.d.ts +17 -0
  481. package/types-legacy/ts4.5/contract/compiler/getFileSystem.d.ts +6 -0
  482. package/types-legacy/ts4.5/contract/ga.d.ts +44 -0
  483. package/types-legacy/ts4.5/index-browser.d.ts +39 -0
  484. package/types-legacy/ts4.5/index.d.ts +4 -0
  485. package/types-legacy/ts4.5/oracle.d.ts +161 -0
  486. package/types-legacy/ts4.5/spend.d.ts +62 -0
  487. package/types-legacy/ts4.5/tx/builder/constants.d.ts +98 -0
  488. package/types-legacy/ts4.5/tx/builder/field-types/abi-version.d.ts +10 -0
  489. package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +21 -0
  490. package/types-legacy/ts4.5/tx/builder/field-types/array.d.ts +7 -0
  491. package/types-legacy/ts4.5/tx/builder/field-types/boolean.d.ts +6 -0
  492. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +12 -0
  493. package/types-legacy/ts4.5/tx/builder/field-types/ct-version.d.ts +42 -0
  494. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +14 -0
  495. package/types-legacy/ts4.5/tx/builder/field-types/encoded.d.ts +6 -0
  496. package/types-legacy/ts4.5/tx/builder/field-types/entry.d.ts +11 -0
  497. package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +7 -0
  498. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +20 -0
  499. package/types-legacy/ts4.5/tx/builder/field-types/field.d.ts +6 -0
  500. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +15 -0
  501. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +7 -0
  502. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +129 -0
  503. package/types-legacy/ts4.5/tx/builder/field-types/mptree.d.ts +43 -0
  504. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +18 -0
  505. package/types-legacy/ts4.5/tx/builder/field-types/name-id.d.ts +11 -0
  506. package/types-legacy/ts4.5/tx/builder/field-types/name.d.ts +13 -0
  507. package/types-legacy/ts4.5/tx/builder/field-types/pointers.d.ts +26 -0
  508. package/types-legacy/ts4.5/tx/builder/field-types/raw.d.ts +6 -0
  509. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int-const.d.ts +5 -0
  510. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int.d.ts +6 -0
  511. package/types-legacy/ts4.5/tx/builder/field-types/string.d.ts +6 -0
  512. package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +7 -0
  513. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
  514. package/types-legacy/ts4.5/tx/builder/index.d.ts +50 -0
  515. package/types-legacy/ts4.5/tx/builder/schema.d.ts +4675 -0
  516. package/types-legacy/ts4.5/tx/index.d.ts +19 -0
  517. package/types-legacy/ts4.5/tx/validator.d.ts +18 -0
  518. package/types-legacy/ts4.5/utils/amount-formatter.d.ts +42 -0
  519. package/types-legacy/ts4.5/utils/autorest.d.ts +7 -0
  520. package/types-legacy/ts4.5/utils/bignumber.d.ts +13 -0
  521. package/types-legacy/ts4.5/utils/bytes.d.ts +9 -0
  522. package/types-legacy/ts4.5/utils/crypto.d.ts +95 -0
  523. package/types-legacy/ts4.5/utils/encoder-types.d.ts +61 -0
  524. package/types-legacy/ts4.5/utils/encoder.d.ts +24 -0
  525. package/types-legacy/ts4.5/utils/errors.d.ts +475 -0
  526. package/types-legacy/ts4.5/utils/hd-wallet.d.ts +65 -0
  527. package/types-legacy/ts4.5/utils/json-big.d.ts +5 -0
  528. package/types-legacy/ts4.5/utils/keystore.d.ts +53 -0
  529. package/types-legacy/ts4.5/utils/other.d.ts +31 -0
  530. package/types-legacy/ts4.5/utils/semver-satisfies.d.ts +1 -0
  531. package/types-legacy/ts4.5/utils/string.d.ts +12 -0
  532. package/es/channel/index.d.ts +0 -625
  533. package/es/channel/index.mjs +0 -975
  534. package/es/channel/index.mjs.map +0 -1
  535. package/es/contract/Compiler.d.ts +0 -18
  536. package/es/contract/Compiler.mjs +0 -68
  537. package/es/contract/Compiler.mjs.map +0 -1
  538. package/es/contract/aci.d.ts +0 -127
  539. package/es/contract/aci.mjs +0 -508
  540. package/es/contract/aci.mjs.map +0 -1
  541. package/es/contract/methods.d.ts +0 -71
  542. package/es/contract/methods.mjs +0 -104
  543. package/es/contract/methods.mjs.map +0 -1
  544. package/es/deprecated/index.d.ts +0 -143
  545. package/es/deprecated/index.mjs +0 -162
  546. package/es/deprecated/index.mjs.map +0 -1
  547. package/es/deprecated/methods.d.ts +0 -18
  548. package/es/deprecated/methods.mjs +0 -26
  549. package/es/deprecated/methods.mjs.map +0 -1
  550. package/es/tx/builder/address.d.ts +0 -25
  551. package/es/tx/builder/address.mjs +0 -45
  552. package/es/tx/builder/address.mjs.map +0 -1
  553. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +0 -1
  554. package/es/utils/mptree.d.ts +0 -26
  555. package/es/utils/mptree.mjs +0 -165
  556. package/es/utils/mptree.mjs.map +0 -1
  557. package/src/channel/index.ts +0 -1025
  558. package/src/contract/Compiler.ts +0 -67
  559. package/src/contract/aci.ts +0 -537
  560. package/src/contract/methods.ts +0 -123
  561. package/src/deprecated/index.ts +0 -172
  562. package/src/deprecated/methods.ts +0 -25
  563. package/src/tx/builder/address.ts +0 -50
  564. package/src/typings/@aeternity__argon2-browser/index.d.ts +0 -3
  565. package/src/utils/mptree.ts +0 -145
@@ -0,0 +1,551 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ /*
6
+ * ISC License (ISC)
7
+ * Copyright (c) 2022 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
+ /**
23
+ * Contract module - routines to interact with the æternity contract
24
+ *
25
+ * High level documentation of the contracts are available at
26
+ * https://github.com/aeternity/protocol/tree/master/contracts and
27
+ */
28
+
29
+ import _aeternityAeppCalldata from '@aeternity/aepp-calldata';
30
+ const {
31
+ Encoder: Calldata
32
+ } = _aeternityAeppCalldata;
33
+ import { DRY_RUN_ACCOUNT } from "../tx/builder/schema.mjs";
34
+ import { Tag } from "../tx/builder/constants.mjs";
35
+ import { buildContractIdByContractTx, unpackTx } from "../tx/builder/index.mjs";
36
+ import { _buildTx } from "../tx/index.mjs";
37
+ import { send } from "../spend.mjs";
38
+ import { decode } from "../utils/encoder.mjs";
39
+ import { MissingContractDefError, MissingContractAddressError, InactiveContractError, BytecodeMismatchError, DuplicateContractError, MissingFunctionNameError, InvalidMethodInvocationError, NotPayableFunctionError, TypeError, NodeInvocationError, IllegalArgumentError, NoSuchContractFunctionError, MissingEventDefinitionError, AmbiguousEventDefinitionError, UnexpectedTsError, InternalError, NoWalletConnectedError } from "../utils/errors.mjs";
40
+ import { hash as calcHash } from "../utils/crypto.mjs";
41
+ import { getAccount, getContract, getContractByteCode, resolveName, txDryRun } from "../chain.mjs";
42
+ import { concatBuffers } from "../utils/other.mjs";
43
+ import { isNameValid, produceNameId } from "../tx/builder/helpers.mjs";
44
+ /**
45
+ * Generate contract ACI object with predefined js methods for contract usage - can be used for
46
+ * creating a reference to already deployed contracts
47
+ * @category contract
48
+ * @param options - Options object
49
+ * @returns JS Contract API
50
+ * @example
51
+ * ```js
52
+ * const contractIns = await aeSdk.initializeContract({ sourceCode })
53
+ * await contractIns.$deploy([321]) or await contractIns.init(321)
54
+ * const callResult = await contractIns.$call('setState', [123])
55
+ * const staticCallResult = await contractIns.$call('setState', [123], { callStatic: true })
56
+ * ```
57
+ * Also you can call contract like: `await contractIns.setState(123, options)`
58
+ * Then sdk decide to make on-chain or static call(dry-run API) transaction based on function is
59
+ * stateful or not
60
+ */
61
+ class Contract {
62
+ /**
63
+ * Helper to generate a signature to delegate
64
+ * - pre-claim/claim/transfer/revoke of a name to a contract.
65
+ * - register/extend/respond of an Oracle to a contract.
66
+ * @category contract
67
+ * @param ids - The list of id's to prepend
68
+ * @param _options - Options
69
+ * @param _options.omitAddress - Prepend delegation signature with an account address
70
+ * @param _options.onAccount - Account to use
71
+ * @returns Signature
72
+ * @example
73
+ * ```js
74
+ * const aeSdk = new AeSdk({ ... })
75
+ * const contract = await aeSdk.initializeContract({ address: 'ct_asd2ks...' })
76
+ * const aensName = 'example.chain'
77
+ * const onAccount = new MemoryAccount(...) // Sign with a specific account
78
+ * // Preclaim signature
79
+ * const preclaimSig = await contract.$createDelegationSignature([], { onAccount })
80
+ * // Claim, transfer and revoke signature
81
+ * const aensDelegationSig = await contract
82
+ * .$createDelegationSignature([aensName], { onAccount })
83
+ * ```
84
+ * @example
85
+ * ```js
86
+ * const aeSdk = new AeSdk({ ... })
87
+ * const contract = await aeSdk.initializeContract({ address: 'ct_asd2ks...' })
88
+ * const oracleQueryId = 'oq_...'
89
+ * const onAccount = new MemoryAccount(...) // Sign with a specific account
90
+ * // Oracle register and extend signature
91
+ * const oracleDelegationSig = await contract.$createDelegationSignature([], { onAccount })
92
+ * // Oracle respond signature
93
+ * const respondSig = await contract
94
+ * .$createDelegationSignature([oracleQueryId], { onAccount, omitAddress: true })
95
+ * ```
96
+ */
97
+ async $createDelegationSignature() {
98
+ let ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
99
+ let _options = arguments.length > 1 ? arguments[1] : undefined;
100
+ const options = {
101
+ ...this.$options,
102
+ ..._options
103
+ };
104
+ const contractId = this.$options.address;
105
+ if (options.onAccount == null) throw new IllegalArgumentError('Can\'t create delegation signature without account');
106
+ if (contractId == null) throw new MissingContractAddressError('Can\'t create delegation signature without address');
107
+ return options.onAccount.sign(concatBuffers([_Buffer.from(await options.onNode.getNetworkId()), ...(options.omitAddress === true ? [] : [decode(options.onAccount.address)]), ...ids.map(e => isNameValid(e) ? produceNameId(e) : e).map(e => decode(e)), decode(contractId)]), options);
108
+ }
109
+
110
+ /**
111
+ * Compile contract
112
+ * @returns bytecode
113
+ */
114
+ async $compile() {
115
+ if (this.$options.bytecode != null) return this.$options.bytecode;
116
+ if (this.$options.sourceCode == null) throw new IllegalArgumentError('Can\'t compile without source code');
117
+ if (this.$options.onCompiler == null) throw new IllegalArgumentError('Can\'t compile without compiler');
118
+ this.$options.bytecode = (await this.$options.onCompiler.compileBySourceCode(this.$options.sourceCode, this.$options.fileSystem)).bytecode;
119
+ return this.$options.bytecode;
120
+ }
121
+ _handleCallError(_ref, transaction) {
122
+ let {
123
+ returnType,
124
+ returnValue
125
+ } = _ref;
126
+ let message;
127
+ switch (returnType) {
128
+ case 'ok':
129
+ return;
130
+ case 'revert':
131
+ message = this._calldata.decodeFateString(returnValue);
132
+ break;
133
+ case 'error':
134
+ message = decode(returnValue).toString();
135
+ break;
136
+ default:
137
+ throw new InternalError(`Unknown return type: ${returnType}`);
138
+ }
139
+ throw new NodeInvocationError(message, transaction);
140
+ }
141
+ async _sendAndProcess(tx, options) {
142
+ const txData = await send(tx, {
143
+ ...this.$options,
144
+ ...options
145
+ });
146
+ const result = {
147
+ hash: txData.hash,
148
+ tx: unpackTx(txData.rawTx),
149
+ txData,
150
+ rawTx: txData.rawTx
151
+ };
152
+ if (txData.blockHeight == null) return result;
153
+ const {
154
+ callInfo
155
+ } = await this.$options.onNode.getTransactionInfoByHash(txData.hash);
156
+ Object.assign(result.txData, callInfo); // TODO: don't duplicate data in result
157
+ // @ts-expect-error TODO api should be updated to match types
158
+ this._handleCallError(callInfo, tx);
159
+ return {
160
+ ...result,
161
+ result: callInfo
162
+ };
163
+ }
164
+ async _estimateGas(name, params) {
165
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
166
+ const {
167
+ result
168
+ } = await this.$call(name, params, {
169
+ ...options,
170
+ callStatic: true
171
+ });
172
+ if (result == null) throw new UnexpectedTsError();
173
+ const {
174
+ gasUsed
175
+ } = result;
176
+ // taken from https://github.com/aeternity/aepp-sdk-js/issues/1286#issuecomment-977814771
177
+ return Math.floor(gasUsed * 1.25);
178
+ }
179
+
180
+ /**
181
+ * Deploy contract
182
+ * @param params - Contract init function arguments array
183
+ * @param options - Options
184
+ * @returns deploy info
185
+ */
186
+ async $deploy(params, options) {
187
+ var _opt$gasLimit, _other$result;
188
+ const {
189
+ callStatic,
190
+ ...opt
191
+ } = {
192
+ ...this.$options,
193
+ ...options
194
+ };
195
+ if (this.$options.bytecode == null) await this.$compile();
196
+ if (callStatic === true) return this.$call('init', params, {
197
+ ...opt,
198
+ callStatic
199
+ });
200
+ if (this.$options.address != null) throw new DuplicateContractError();
201
+ if (opt.onAccount == null) throw new IllegalArgumentError('Can\'t deploy without account');
202
+ const ownerId = opt.onAccount.address;
203
+ if (this.$options.bytecode == null) throw new IllegalArgumentError('Can\'t deploy without bytecode');
204
+ const tx = await _buildTx(Tag.ContractCreateTx, {
205
+ ...opt,
206
+ gasLimit: (_opt$gasLimit = opt.gasLimit) !== null && _opt$gasLimit !== void 0 ? _opt$gasLimit : await this._estimateGas('init', params, opt),
207
+ callData: this._calldata.encode(this._name, 'init', params),
208
+ code: this.$options.bytecode,
209
+ ownerId
210
+ });
211
+ this.$options.address = buildContractIdByContractTx(tx);
212
+ const {
213
+ hash,
214
+ ...other
215
+ } = await this._sendAndProcess(tx, {
216
+ ...opt,
217
+ onAccount: opt.onAccount
218
+ });
219
+ return {
220
+ ...other,
221
+ ...(((_other$result = other.result) === null || _other$result === void 0 ? void 0 : _other$result.log) != null && {
222
+ decodedEvents: this.$decodeEvents(other.result.log, opt)
223
+ }),
224
+ owner: ownerId,
225
+ transaction: hash,
226
+ address: this.$options.address
227
+ };
228
+ }
229
+
230
+ /**
231
+ * Get function schema from contract ACI object
232
+ * @param name - Function name
233
+ * @returns function ACI
234
+ */
235
+ _getFunctionACI(name) {
236
+ const fn = this._aci.encodedAci.contract.functions.find(f => f.name === name);
237
+ if (fn != null) {
238
+ return fn;
239
+ }
240
+ if (name === 'init') return {
241
+ payable: false
242
+ };
243
+ throw new NoSuchContractFunctionError(`Function ${name} doesn't exist in contract`);
244
+ }
245
+
246
+ /**
247
+ * Call contract function
248
+ * @param fn - Function name
249
+ * @param params - Array of function arguments
250
+ * @param options - Array of function arguments
251
+ * @returns CallResult
252
+ */
253
+ async $call(fn, params) {
254
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
255
+ const {
256
+ callStatic,
257
+ top,
258
+ ...opt
259
+ } = {
260
+ ...this.$options,
261
+ ...options
262
+ };
263
+ const fnACI = this._getFunctionACI(fn);
264
+ const contractId = this.$options.address;
265
+ const {
266
+ onNode
267
+ } = opt;
268
+ if (fn == null) throw new MissingFunctionNameError();
269
+ if (fn === 'init' && callStatic !== true) throw new InvalidMethodInvocationError('"init" can be called only via dryRun');
270
+ if (fn !== 'init' && opt.amount != null && opt.amount > 0 && fnACI.payable === false) {
271
+ throw new NotPayableFunctionError(opt.amount, fn);
272
+ }
273
+ let callerId;
274
+ try {
275
+ if (opt.onAccount == null) throw new InternalError('Use fallback account');
276
+ callerId = opt.onAccount.address;
277
+ } catch (error) {
278
+ const useFallbackAccount = callStatic === true && (error instanceof TypeError && error.message === 'Account should be an address (ak-prefixed string), or instance of AccountBase, got undefined instead' || error instanceof NoWalletConnectedError);
279
+ if (!useFallbackAccount) throw error;
280
+ callerId = DRY_RUN_ACCOUNT.pub;
281
+ }
282
+ const callData = this._calldata.encode(this._name, fn, params);
283
+ let res;
284
+ if (callStatic === true) {
285
+ if (opt.nonce == null && top != null) {
286
+ const topKey = typeof top === 'number' ? 'height' : 'hash';
287
+ opt.nonce = (await getAccount(callerId, {
288
+ [topKey]: top,
289
+ onNode
290
+ })).nonce + 1;
291
+ }
292
+ const txOpt = {
293
+ ...opt,
294
+ onNode,
295
+ callData
296
+ };
297
+ let tx;
298
+ if (fn === 'init') {
299
+ if (this.$options.bytecode == null) throw new IllegalArgumentError('Can\'t dry-run "init" without bytecode');
300
+ tx = await _buildTx(Tag.ContractCreateTx, {
301
+ ...txOpt,
302
+ code: this.$options.bytecode,
303
+ ownerId: callerId
304
+ });
305
+ } else {
306
+ if (contractId == null) throw new MissingContractAddressError('Can\'t dry-run contract without address');
307
+ tx = await _buildTx(Tag.ContractCallTx, {
308
+ ...txOpt,
309
+ callerId,
310
+ contractId
311
+ });
312
+ }
313
+ const {
314
+ callObj,
315
+ ...dryRunOther
316
+ } = await txDryRun(tx, callerId, {
317
+ ...opt,
318
+ top
319
+ });
320
+ if (callObj == null) throw new UnexpectedTsError();
321
+ this._handleCallError({
322
+ returnType: callObj.returnType,
323
+ returnValue: callObj.returnValue
324
+ }, tx);
325
+ res = {
326
+ ...dryRunOther,
327
+ tx: unpackTx(tx),
328
+ result: callObj
329
+ };
330
+ } else {
331
+ var _opt$gasLimit2;
332
+ if (top != null) throw new IllegalArgumentError('Can\'t handle `top` option in on-chain contract call');
333
+ if (contractId == null) throw new MissingContractAddressError('Can\'t call contract without address');
334
+ const tx = await _buildTx(Tag.ContractCallTx, {
335
+ ...opt,
336
+ gasLimit: (_opt$gasLimit2 = opt.gasLimit) !== null && _opt$gasLimit2 !== void 0 ? _opt$gasLimit2 : await this._estimateGas(fn, params, opt),
337
+ callerId,
338
+ contractId,
339
+ callData
340
+ });
341
+ if (opt.onAccount == null) throw new IllegalArgumentError('Can\'t call contract on chain without account');
342
+ res = await this._sendAndProcess(tx, {
343
+ ...opt,
344
+ onAccount: opt.onAccount
345
+ });
346
+ }
347
+ if (callStatic === true || res.txData.blockHeight != null) {
348
+ res.decodedResult = fnACI.returns != null && fnACI.returns !== 'unit' && fn !== 'init' && this._calldata.decode(this._name, fn, res.result.returnValue);
349
+ res.decodedEvents = this.$decodeEvents(res.result.log, opt);
350
+ }
351
+ return res;
352
+ }
353
+
354
+ /**
355
+ * @param ctAddress - Contract address that emitted event
356
+ * @param nameHash - Hash of emitted event name
357
+ * @param options - Options
358
+ * @returns Contract name
359
+ * @throws {@link MissingEventDefinitionError}
360
+ * @throws {@link AmbiguousEventDefinitionError}
361
+ */
362
+ _getContractNameByEvent(ctAddress, nameHash, _ref2) {
363
+ let {
364
+ contractAddressToName
365
+ } = _ref2;
366
+ const addressToName = {
367
+ ...this.$options.contractAddressToName,
368
+ ...contractAddressToName
369
+ };
370
+ if (addressToName[ctAddress] != null) return addressToName[ctAddress];
371
+
372
+ // TODO: consider using a third-party library
373
+ const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
374
+ const matchedEvents = [this._aci.encodedAci, ...this._aci.externalEncodedAci].filter(_ref3 => {
375
+ let {
376
+ contract
377
+ } = _ref3;
378
+ return contract === null || contract === void 0 ? void 0 : contract.event;
379
+ }).map(_ref4 => {
380
+ let {
381
+ contract
382
+ } = _ref4;
383
+ return [contract.name, contract.event.variant];
384
+ }).map(_ref5 => {
385
+ let [name, events] = _ref5;
386
+ return events.map(event => [name, Object.keys(event)[0], Object.values(event)[0]]);
387
+ }).flat().filter(_ref6 => {
388
+ let [, eventName] = _ref6;
389
+ return BigInt(`0x${calcHash(eventName).toString('hex')}`) === nameHash;
390
+ }).filter((_ref7, idx, arr) => {
391
+ let [,, type] = _ref7;
392
+ return !arr.slice(0, idx).some(el => isEqual(el[2], type));
393
+ });
394
+ switch (matchedEvents.length) {
395
+ case 0:
396
+ throw new MissingEventDefinitionError(nameHash.toString(), ctAddress);
397
+ case 1:
398
+ return matchedEvents[0][0];
399
+ default:
400
+ throw new AmbiguousEventDefinitionError(ctAddress, matchedEvents);
401
+ }
402
+ }
403
+
404
+ /**
405
+ * Decode Events
406
+ * @param events - Array of encoded events (callRes.result.log)
407
+ * @param options - Options
408
+ * @returns DecodedEvents
409
+ */
410
+ $decodeEvents(events) {
411
+ let {
412
+ omitUnknown,
413
+ ...opt
414
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
415
+ return events.map(event => {
416
+ const topics = event.topics.map(t => BigInt(t));
417
+ let contractName;
418
+ try {
419
+ contractName = this._getContractNameByEvent(event.address, topics[0], opt);
420
+ } catch (error) {
421
+ if ((omitUnknown !== null && omitUnknown !== void 0 ? omitUnknown : false) && error instanceof MissingEventDefinitionError) return null;
422
+ throw error;
423
+ }
424
+ const decoded = this._calldata.decodeEvent(contractName, event.data, topics);
425
+ const [name, args] = Object.entries(decoded)[0];
426
+ return {
427
+ name,
428
+ args,
429
+ contract: {
430
+ name: contractName,
431
+ address: event.address
432
+ }
433
+ };
434
+ }).filter(e => e != null);
435
+ }
436
+ static async initialize(_ref8) {
437
+ let {
438
+ onCompiler,
439
+ onNode,
440
+ bytecode,
441
+ aci,
442
+ address,
443
+ sourceCodePath,
444
+ sourceCode,
445
+ fileSystem,
446
+ validateBytecode,
447
+ ...otherOptions
448
+ } = _ref8;
449
+ if (aci == null && onCompiler != null) {
450
+ let res;
451
+ if (sourceCodePath != null) res = await onCompiler.compile(sourceCodePath);
452
+ if (sourceCode != null) res = await onCompiler.compileBySourceCode(sourceCode, fileSystem);
453
+ if (res != null) {
454
+ var _bytecode;
455
+ aci = res.aci;
456
+ (_bytecode = bytecode) !== null && _bytecode !== void 0 ? _bytecode : bytecode = res.bytecode;
457
+ }
458
+ }
459
+ if (aci == null) throw new MissingContractDefError();
460
+ if (address != null) {
461
+ address = await resolveName(address, 'contract_pubkey', {
462
+ resolveByNode: true,
463
+ onNode
464
+ });
465
+ }
466
+ if (address == null && sourceCode == null && bytecode == null) {
467
+ throw new MissingContractAddressError('Can\'t create instance by ACI without address');
468
+ }
469
+ if (address != null) {
470
+ const contract = await getContract(address, {
471
+ onNode
472
+ });
473
+ if (contract.active == null) throw new InactiveContractError(address);
474
+ }
475
+ if (validateBytecode === true) {
476
+ if (address == null) throw new MissingContractAddressError('Can\'t validate bytecode without contract address');
477
+ const onChanBytecode = (await getContractByteCode(address, {
478
+ onNode
479
+ })).bytecode;
480
+ let isValid = false;
481
+ if (bytecode != null) isValid = bytecode === onChanBytecode;else if (sourceCode != null) {
482
+ if (onCompiler == null) throw new IllegalArgumentError('Can\'t validate bytecode without compiler');
483
+ isValid = await onCompiler.validateBySourceCode(onChanBytecode, sourceCode, fileSystem);
484
+ }
485
+ if (!isValid) throw new BytecodeMismatchError(sourceCode != null ? 'source code' : 'bytecode');
486
+ }
487
+ return new ContractWithMethods({
488
+ onCompiler,
489
+ onNode,
490
+ sourceCode,
491
+ bytecode,
492
+ aci,
493
+ address,
494
+ fileSystem,
495
+ ...otherOptions
496
+ });
497
+ }
498
+ constructor(_ref9) {
499
+ var _this = this;
500
+ let {
501
+ aci,
502
+ ...otherOptions
503
+ } = _ref9;
504
+ this._aci = aci;
505
+ this._name = aci.encodedAci.contract.name;
506
+ this._calldata = new Calldata([aci.encodedAci, ...aci.externalEncodedAci]);
507
+ this.$options = otherOptions;
508
+
509
+ /**
510
+ * Generate proto function based on contract function using Contract ACI schema
511
+ * All function can be called like:
512
+ * ```js
513
+ * await contract.testFunction()
514
+ * ```
515
+ * then sdk will decide to use dry-run or send tx
516
+ * on-chain base on if function stateful or not.
517
+ * Also, you can manually do that:
518
+ * ```js
519
+ * await contract.testFunction({ callStatic: true }) // use call-static (dry-run)
520
+ * await contract.testFunction({ callStatic: false }) // send tx on-chain
521
+ * ```
522
+ */
523
+ Object.assign(this, Object.fromEntries(this._aci.encodedAci.contract.functions.map(_ref10 => {
524
+ let {
525
+ name,
526
+ arguments: aciArgs,
527
+ stateful
528
+ } = _ref10;
529
+ const callStatic = name !== 'init' && !stateful;
530
+ return [name, async function () {
531
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
532
+ args[_key] = arguments[_key];
533
+ }
534
+ const options = args.length === aciArgs.length + 1 ? args.pop() : {};
535
+ if (typeof options !== 'object') throw new TypeError(`Options should be an object: ${options}`);
536
+ if (name === 'init') return _this.$deploy(args, {
537
+ callStatic,
538
+ ...options
539
+ });
540
+ return _this.$call(name, args, {
541
+ callStatic,
542
+ ...options
543
+ });
544
+ }];
545
+ })));
546
+ }
547
+ }
548
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
549
+ const ContractWithMethods = Contract;
550
+ export default ContractWithMethods;
551
+ //# sourceMappingURL=Contract.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Contract.mjs","names":["DRY_RUN_ACCOUNT","Tag","buildContractIdByContractTx","unpackTx","_buildTx","send","decode","MissingContractDefError","MissingContractAddressError","InactiveContractError","BytecodeMismatchError","DuplicateContractError","MissingFunctionNameError","InvalidMethodInvocationError","NotPayableFunctionError","TypeError","NodeInvocationError","IllegalArgumentError","NoSuchContractFunctionError","MissingEventDefinitionError","AmbiguousEventDefinitionError","UnexpectedTsError","InternalError","NoWalletConnectedError","hash","calcHash","getAccount","getContract","getContractByteCode","resolveName","txDryRun","concatBuffers","isNameValid","produceNameId","Contract","$createDelegationSignature","ids","_options","options","$options","contractId","address","onAccount","sign","from","onNode","getNetworkId","omitAddress","map","e","$compile","bytecode","sourceCode","onCompiler","compileBySourceCode","fileSystem","_handleCallError","transaction","returnType","returnValue","message","_calldata","decodeFateString","toString","_sendAndProcess","tx","txData","result","rawTx","blockHeight","callInfo","getTransactionInfoByHash","Object","assign","_estimateGas","name","params","$call","callStatic","gasUsed","Math","floor","$deploy","opt","ownerId","ContractCreateTx","gasLimit","callData","encode","_name","code","other","log","decodedEvents","$decodeEvents","owner","_getFunctionACI","fn","_aci","encodedAci","contract","functions","find","f","payable","top","fnACI","amount","callerId","error","useFallbackAccount","pub","res","nonce","topKey","txOpt","ContractCallTx","callObj","dryRunOther","decodedResult","returns","_getContractNameByEvent","ctAddress","nameHash","contractAddressToName","addressToName","isEqual","a","b","JSON","stringify","matchedEvents","externalEncodedAci","filter","event","variant","events","keys","values","flat","eventName","BigInt","idx","arr","type","slice","some","el","length","omitUnknown","topics","t","contractName","decoded","decodeEvent","data","args","entries","initialize","aci","sourceCodePath","validateBytecode","otherOptions","compile","resolveByNode","active","onChanBytecode","isValid","validateBySourceCode","ContractWithMethods","constructor","Calldata","fromEntries","arguments","aciArgs","stateful","pop"],"sources":["../../src/contract/Contract.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*/\n\n/**\n * Contract module - routines to interact with the æternity contract\n *\n * High level documentation of the contracts are available at\n * https://github.com/aeternity/protocol/tree/master/contracts and\n */\n\nimport { Encoder as Calldata } from '@aeternity/aepp-calldata';\nimport { DRY_RUN_ACCOUNT } from '../tx/builder/schema';\nimport { Tag, AensName } from '../tx/builder/constants';\nimport { buildContractIdByContractTx, unpackTx } from '../tx/builder';\nimport { _buildTx, BuildTxOptions } from '../tx';\nimport { send, SendOptions } from '../spend';\nimport { decode, Encoded } from '../utils/encoder';\nimport {\n MissingContractDefError,\n MissingContractAddressError,\n InactiveContractError,\n BytecodeMismatchError,\n DuplicateContractError,\n MissingFunctionNameError,\n InvalidMethodInvocationError,\n NotPayableFunctionError,\n TypeError,\n NodeInvocationError,\n IllegalArgumentError,\n NoSuchContractFunctionError,\n MissingEventDefinitionError,\n AmbiguousEventDefinitionError,\n UnexpectedTsError,\n InternalError,\n NoWalletConnectedError,\n} from '../utils/errors';\nimport { hash as calcHash } from '../utils/crypto';\nimport {\n ContractCallObject as NodeContractCallObject, ContractCallReturnType, Event as NodeEvent,\n} from '../apis/node';\nimport CompilerBase, { Aci } from './compiler/Base';\nimport Node, { TransformNodeType } from '../Node';\nimport {\n getAccount, getContract, getContractByteCode, resolveName, txDryRun,\n} from '../chain';\nimport AccountBase from '../account/Base';\nimport { concatBuffers } from '../utils/other';\nimport { isNameValid, produceNameId } from '../tx/builder/helpers';\n\ntype FunctionAci = Aci['encodedAci']['contract']['functions'][0];\n\ninterface Event extends NodeEvent {\n address: Encoded.ContractAddress;\n data: Encoded.ContractBytearray;\n}\n\nexport interface ContractCallObject extends NodeContractCallObject {\n returnValue: Encoded.ContractBytearray;\n log: Event[];\n}\n\ninterface DecodedEvent {\n name: string;\n args: unknown[];\n contract: {\n name: string;\n address: Encoded.ContractAddress;\n };\n}\n\ntype TxData = Awaited<ReturnType<typeof send>>;\n\ninterface SendAndProcessReturnType {\n result?: TransformNodeType<ContractCallObject>;\n hash: TxData['hash'];\n tx: Awaited<ReturnType<typeof unpackTx<Tag.ContractCallTx | Tag.ContractCreateTx>>>;\n txData: TxData;\n rawTx: Encoded.Transaction;\n}\n\nexport interface ContractMethodsBase { [key: string]: (...args: any[]) => any }\n\ntype MethodsToContractApi<M extends ContractMethodsBase> = {\n [Name in keyof M]:\n M[Name] extends (...args: infer Args) => infer Ret\n ? (...args: [\n ...Args,\n ...[] | [Name extends 'init'\n ? Parameters<Contract<M>['$deploy']>[1] : Parameters<Contract<M>['$call']>[2]],\n ]) => Promise<\n Awaited<ReturnType<Contract<M>['$call']>> &\n { decodedResult?: Ret }\n >\n : never\n};\n\ntype ContractWithMethods<M extends ContractMethodsBase> = Contract<M> & MethodsToContractApi<M>;\n\ntype MethodNames<M extends ContractMethodsBase> = keyof M & string | 'init';\n\ntype MethodParameters<M extends ContractMethodsBase, Fn extends MethodNames<M>> =\n Fn extends 'init'\n ? M extends { init: any } ? Parameters<M['init']> : []\n : Parameters<M[Fn]>;\n\n/**\n * Generate contract ACI object with predefined js methods for contract usage - can be used for\n * creating a reference to already deployed contracts\n * @category contract\n * @param options - Options object\n * @returns JS Contract API\n * @example\n * ```js\n * const contractIns = await aeSdk.initializeContract({ sourceCode })\n * await contractIns.$deploy([321]) or await contractIns.init(321)\n * const callResult = await contractIns.$call('setState', [123])\n * const staticCallResult = await contractIns.$call('setState', [123], { callStatic: true })\n * ```\n * Also you can call contract like: `await contractIns.setState(123, options)`\n * Then sdk decide to make on-chain or static call(dry-run API) transaction based on function is\n * stateful or not\n */\nclass Contract<M extends ContractMethodsBase> {\n /**\n * Helper to generate a signature to delegate\n * - pre-claim/claim/transfer/revoke of a name to a contract.\n * - register/extend/respond of an Oracle to a contract.\n * @category contract\n * @param ids - The list of id's to prepend\n * @param _options - Options\n * @param _options.omitAddress - Prepend delegation signature with an account address\n * @param _options.onAccount - Account to use\n * @returns Signature\n * @example\n * ```js\n * const aeSdk = new AeSdk({ ... })\n * const contract = await aeSdk.initializeContract({ address: 'ct_asd2ks...' })\n * const aensName = 'example.chain'\n * const onAccount = new MemoryAccount(...) // Sign with a specific account\n * // Preclaim signature\n * const preclaimSig = await contract.$createDelegationSignature([], { onAccount })\n * // Claim, transfer and revoke signature\n * const aensDelegationSig = await contract\n * .$createDelegationSignature([aensName], { onAccount })\n * ```\n * @example\n * ```js\n * const aeSdk = new AeSdk({ ... })\n * const contract = await aeSdk.initializeContract({ address: 'ct_asd2ks...' })\n * const oracleQueryId = 'oq_...'\n * const onAccount = new MemoryAccount(...) // Sign with a specific account\n * // Oracle register and extend signature\n * const oracleDelegationSig = await contract.$createDelegationSignature([], { onAccount })\n * // Oracle respond signature\n * const respondSig = await contract\n * .$createDelegationSignature([oracleQueryId], { onAccount, omitAddress: true })\n * ```\n */\n async $createDelegationSignature(\n ids: Array<Encoded.Any | AensName> = [],\n _options?: { omitAddress?: boolean; onAccount?: AccountBase },\n ): Promise<Uint8Array> {\n const options = { ...this.$options, ..._options };\n const contractId = this.$options.address;\n if (options.onAccount == null) throw new IllegalArgumentError('Can\\'t create delegation signature without account');\n if (contractId == null) throw new MissingContractAddressError('Can\\'t create delegation signature without address');\n return options.onAccount.sign(\n concatBuffers([\n Buffer.from(await options.onNode.getNetworkId()),\n ...options.omitAddress === true ? [] : [decode(options.onAccount.address)],\n ...ids.map((e) => (isNameValid(e) ? produceNameId(e) : e)).map((e) => decode(e)),\n decode(contractId),\n ]),\n options,\n );\n }\n\n /**\n * Compile contract\n * @returns bytecode\n */\n async $compile(): Promise<Encoded.ContractBytearray> {\n if (this.$options.bytecode != null) return this.$options.bytecode;\n if (this.$options.sourceCode == null) throw new IllegalArgumentError('Can\\'t compile without source code');\n if (this.$options.onCompiler == null) throw new IllegalArgumentError('Can\\'t compile without compiler');\n this.$options.bytecode = (await this.$options.onCompiler\n .compileBySourceCode(this.$options.sourceCode, this.$options.fileSystem)\n ).bytecode;\n return this.$options.bytecode;\n }\n\n protected _handleCallError(\n { returnType, returnValue }: {\n returnType: ContractCallReturnType;\n returnValue: Encoded.ContractBytearray;\n },\n transaction: string,\n ): void {\n let message: string;\n switch (returnType) {\n case 'ok': return;\n case 'revert':\n message = this._calldata.decodeFateString(returnValue);\n break;\n case 'error':\n message = decode(returnValue).toString();\n break;\n default:\n throw new InternalError(`Unknown return type: ${returnType}`);\n }\n throw new NodeInvocationError(message, transaction);\n }\n\n protected async _sendAndProcess(\n tx: Encoded.Transaction,\n options: SendOptions,\n ): Promise<SendAndProcessReturnType> {\n const txData = await send(tx, { ...this.$options, ...options });\n const result = {\n hash: txData.hash,\n tx: unpackTx<Tag.ContractCallTx | Tag.ContractCreateTx>(txData.rawTx),\n txData,\n rawTx: txData.rawTx,\n };\n if (txData.blockHeight == null) return result;\n const { callInfo } = await this.$options.onNode.getTransactionInfoByHash(txData.hash);\n Object.assign(result.txData, callInfo); // TODO: don't duplicate data in result\n // @ts-expect-error TODO api should be updated to match types\n this._handleCallError(callInfo, tx);\n return { ...result, result: callInfo as TransformNodeType<ContractCallObject> };\n }\n\n async _estimateGas<Fn extends MethodNames<M>>(\n name: Fn,\n params: MethodParameters<M, Fn>,\n options: object = {},\n ): Promise<number> {\n const { result } = await this.$call(name, params, { ...options, callStatic: true });\n if (result == null) throw new UnexpectedTsError();\n const { gasUsed } = result;\n // taken from https://github.com/aeternity/aepp-sdk-js/issues/1286#issuecomment-977814771\n return Math.floor(gasUsed * 1.25);\n }\n\n /**\n * Deploy contract\n * @param params - Contract init function arguments array\n * @param options - Options\n * @returns deploy info\n */\n async $deploy(\n params: MethodParameters<M, 'init'>,\n options?: Parameters<Contract<M>['$call']>[2]\n & Partial<BuildTxOptions<Tag.ContractCreateTx, 'ownerId' | 'code' | 'callData'>>,\n ): Promise<Omit<SendAndProcessReturnType, 'hash'> & {\n transaction?: Encoded.TxHash;\n owner?: Encoded.AccountAddress;\n address?: Encoded.ContractAddress;\n decodedEvents?: ReturnType<Contract<M>['$decodeEvents']>;\n }> {\n const { callStatic, ...opt } = { ...this.$options, ...options };\n if (this.$options.bytecode == null) await this.$compile();\n if (callStatic === true) return this.$call('init', params, { ...opt, callStatic });\n if (this.$options.address != null) throw new DuplicateContractError();\n\n if (opt.onAccount == null) throw new IllegalArgumentError('Can\\'t deploy without account');\n const ownerId = opt.onAccount.address;\n if (this.$options.bytecode == null) throw new IllegalArgumentError('Can\\'t deploy without bytecode');\n const tx = await _buildTx(Tag.ContractCreateTx, {\n ...opt,\n gasLimit: opt.gasLimit ?? await this._estimateGas('init', params, opt),\n callData: this._calldata.encode(this._name, 'init', params),\n code: this.$options.bytecode,\n ownerId,\n });\n this.$options.address = buildContractIdByContractTx(tx);\n const { hash, ...other } = await this._sendAndProcess(tx, { ...opt, onAccount: opt.onAccount });\n return {\n ...other,\n ...other.result?.log != null && {\n decodedEvents: this.$decodeEvents(other.result.log, opt),\n },\n owner: ownerId,\n transaction: hash,\n address: this.$options.address,\n };\n }\n\n /**\n * Get function schema from contract ACI object\n * @param name - Function name\n * @returns function ACI\n */\n protected _getFunctionACI(name: string): Partial<FunctionAci> {\n const fn = this._aci.encodedAci.contract.functions.find(\n (f: { name: string }) => f.name === name,\n );\n if (fn != null) {\n return fn;\n }\n if (name === 'init') return { payable: false };\n throw new NoSuchContractFunctionError(`Function ${name} doesn't exist in contract`);\n }\n\n /**\n * Call contract function\n * @param fn - Function name\n * @param params - Array of function arguments\n * @param options - Array of function arguments\n * @returns CallResult\n */\n async $call<Fn extends MethodNames<M>>(\n fn: Fn,\n params: MethodParameters<M, Fn>,\n options: Partial<BuildTxOptions<Tag.ContractCallTx, 'callerId' | 'contractId' | 'callData'>>\n & Parameters<Contract<M>['$decodeEvents']>[1]\n & Omit<Parameters<Contract<M>['_sendAndProcess']>[1], 'onAccount' | 'onNode'>\n & Omit<Parameters<typeof txDryRun>[2], 'onNode'>\n & { onAccount?: AccountBase; onNode?: Node; callStatic?: boolean } = {},\n ): Promise<{\n decodedResult?: any;\n decodedEvents?: ReturnType<Contract<M>['$decodeEvents']>;\n } & SendAndProcessReturnType> {\n const { callStatic, top, ...opt } = { ...this.$options, ...options };\n const fnACI = this._getFunctionACI(fn);\n const contractId = this.$options.address;\n const { onNode } = opt;\n\n if (fn == null) throw new MissingFunctionNameError();\n if (fn === 'init' && callStatic !== true) throw new InvalidMethodInvocationError('\"init\" can be called only via dryRun');\n if (fn !== 'init' && opt.amount != null && opt.amount > 0 && fnACI.payable === false) {\n throw new NotPayableFunctionError(opt.amount, fn);\n }\n\n let callerId;\n try {\n if (opt.onAccount == null) throw new InternalError('Use fallback account');\n callerId = opt.onAccount.address;\n } catch (error) {\n const useFallbackAccount = callStatic === true && (\n (error instanceof TypeError && error.message === 'Account should be an address (ak-prefixed string), or instance of AccountBase, got undefined instead')\n || (error instanceof NoWalletConnectedError)\n );\n if (!useFallbackAccount) throw error;\n callerId = DRY_RUN_ACCOUNT.pub;\n }\n const callData = this._calldata.encode(this._name, fn, params);\n\n let res: any;\n if (callStatic === true) {\n if (opt.nonce == null && top != null) {\n const topKey = typeof top === 'number' ? 'height' : 'hash';\n opt.nonce = (await getAccount(callerId, { [topKey]: top, onNode })).nonce + 1;\n }\n const txOpt = { ...opt, onNode, callData };\n let tx;\n if (fn === 'init') {\n if (this.$options.bytecode == null) throw new IllegalArgumentError('Can\\'t dry-run \"init\" without bytecode');\n tx = await _buildTx(\n Tag.ContractCreateTx,\n { ...txOpt, code: this.$options.bytecode, ownerId: callerId },\n );\n } else {\n if (contractId == null) throw new MissingContractAddressError('Can\\'t dry-run contract without address');\n tx = await _buildTx(Tag.ContractCallTx, { ...txOpt, callerId, contractId });\n }\n\n const { callObj, ...dryRunOther } = await txDryRun(tx, callerId, { ...opt, top });\n if (callObj == null) throw new UnexpectedTsError();\n this._handleCallError({\n returnType: callObj.returnType as ContractCallReturnType,\n returnValue: callObj.returnValue as Encoded.ContractBytearray,\n }, tx);\n res = { ...dryRunOther, tx: unpackTx(tx), result: callObj };\n } else {\n if (top != null) throw new IllegalArgumentError('Can\\'t handle `top` option in on-chain contract call');\n if (contractId == null) throw new MissingContractAddressError('Can\\'t call contract without address');\n const tx = await _buildTx(Tag.ContractCallTx, {\n ...opt,\n gasLimit: opt.gasLimit ?? await this._estimateGas(fn, params, opt),\n callerId,\n contractId,\n callData,\n });\n if (opt.onAccount == null) throw new IllegalArgumentError('Can\\'t call contract on chain without account');\n res = await this._sendAndProcess(tx, { ...opt, onAccount: opt.onAccount });\n }\n if (callStatic === true || res.txData.blockHeight != null) {\n res.decodedResult = fnACI.returns != null && fnACI.returns !== 'unit' && fn !== 'init'\n && this._calldata.decode(this._name, fn, res.result.returnValue);\n res.decodedEvents = this.$decodeEvents(res.result.log, opt);\n }\n return res;\n }\n\n /**\n * @param ctAddress - Contract address that emitted event\n * @param nameHash - Hash of emitted event name\n * @param options - Options\n * @returns Contract name\n * @throws {@link MissingEventDefinitionError}\n * @throws {@link AmbiguousEventDefinitionError}\n */\n protected _getContractNameByEvent(\n ctAddress: Encoded.ContractAddress,\n nameHash: BigInt,\n { contractAddressToName }: {\n contractAddressToName?: { [key: Encoded.ContractAddress]: string };\n },\n ): string {\n const addressToName = { ...this.$options.contractAddressToName, ...contractAddressToName };\n if (addressToName[ctAddress] != null) return addressToName[ctAddress];\n\n // TODO: consider using a third-party library\n const isEqual = (a: any, b: any): boolean => JSON.stringify(a) === JSON.stringify(b);\n\n const matchedEvents = [this._aci.encodedAci, ...this._aci.externalEncodedAci]\n .filter(({ contract }) => contract?.event)\n .map(({ contract }) => [contract.name, contract.event.variant])\n .map(([name, events]) => events.map((event: {}) => (\n [name, Object.keys(event)[0], Object.values(event)[0]]\n )))\n .flat()\n .filter(([, eventName]) => BigInt(`0x${calcHash(eventName).toString('hex')}`) === nameHash)\n .filter(([, , type], idx, arr) => !arr.slice(0, idx).some((el) => isEqual(el[2], type)));\n switch (matchedEvents.length) {\n case 0: throw new MissingEventDefinitionError(nameHash.toString(), ctAddress);\n case 1: return matchedEvents[0][0];\n default: throw new AmbiguousEventDefinitionError(ctAddress, matchedEvents);\n }\n }\n\n /**\n * Decode Events\n * @param events - Array of encoded events (callRes.result.log)\n * @param options - Options\n * @returns DecodedEvents\n */\n $decodeEvents(\n events: Event[],\n { omitUnknown, ...opt }: { omitUnknown?: boolean } &\n Parameters<Contract<M>['_getContractNameByEvent']>[2] = {},\n ): DecodedEvent[] {\n return events\n .map((event) => {\n const topics = event.topics.map((t: string | number) => BigInt(t));\n let contractName;\n try {\n contractName = this._getContractNameByEvent(event.address, topics[0], opt);\n } catch (error) {\n if ((omitUnknown ?? false) && error instanceof MissingEventDefinitionError) return null;\n throw error;\n }\n const decoded = this._calldata.decodeEvent(contractName, event.data, topics);\n const [name, args] = Object.entries(decoded)[0];\n return {\n name,\n args,\n contract: {\n name: contractName,\n address: event.address,\n },\n };\n }).filter((e: DecodedEvent | null): e is DecodedEvent => e != null);\n }\n\n static async initialize<M extends ContractMethodsBase>(\n {\n onCompiler,\n onNode,\n bytecode,\n aci,\n address,\n sourceCodePath,\n sourceCode,\n fileSystem,\n validateBytecode,\n ...otherOptions\n }: Omit<ConstructorParameters<typeof Contract>[0], 'aci' | 'address'> & {\n validateBytecode?: boolean;\n aci?: Aci;\n address?: Encoded.ContractAddress | AensName;\n },\n ): Promise<ContractWithMethods<M>> {\n if (aci == null && onCompiler != null) {\n let res;\n if (sourceCodePath != null) res = await onCompiler.compile(sourceCodePath);\n if (sourceCode != null) res = await onCompiler.compileBySourceCode(sourceCode, fileSystem);\n if (res != null) {\n aci = res.aci;\n bytecode ??= res.bytecode;\n }\n }\n if (aci == null) throw new MissingContractDefError();\n\n if (address != null) {\n address = await resolveName(\n address,\n 'contract_pubkey',\n { resolveByNode: true, onNode },\n ) as Encoded.ContractAddress;\n }\n\n if (address == null && sourceCode == null && bytecode == null) {\n throw new MissingContractAddressError('Can\\'t create instance by ACI without address');\n }\n\n if (address != null) {\n const contract = await getContract(address, { onNode });\n if (contract.active == null) throw new InactiveContractError(address);\n }\n\n if (validateBytecode === true) {\n if (address == null) throw new MissingContractAddressError('Can\\'t validate bytecode without contract address');\n const onChanBytecode = (await getContractByteCode(address, { onNode })).bytecode;\n let isValid = false;\n if (bytecode != null) isValid = bytecode === onChanBytecode;\n else if (sourceCode != null) {\n if (onCompiler == null) throw new IllegalArgumentError('Can\\'t validate bytecode without compiler');\n isValid = await onCompiler.validateBySourceCode(onChanBytecode, sourceCode, fileSystem);\n }\n if (!isValid) throw new BytecodeMismatchError(sourceCode != null ? 'source code' : 'bytecode');\n }\n\n return new ContractWithMethods<M>({\n onCompiler, onNode, sourceCode, bytecode, aci, address, fileSystem, ...otherOptions,\n });\n }\n\n _aci: Aci;\n\n _name: string;\n\n _calldata: Calldata;\n\n $options: Omit<ConstructorParameters<typeof Contract>[0], 'aci'>;\n\n constructor({ aci, ...otherOptions }: {\n onCompiler?: CompilerBase;\n onNode: Node;\n bytecode?: Encoded.ContractBytearray;\n aci: Aci;\n address?: Encoded.ContractAddress;\n sourceCodePath?: Parameters<CompilerBase['compile']>[0];\n sourceCode?: Parameters<CompilerBase['compileBySourceCode']>[0];\n fileSystem?: Parameters<CompilerBase['compileBySourceCode']>[1];\n } & Parameters<Contract<M>['$deploy']>[1]) {\n this._aci = aci;\n this._name = aci.encodedAci.contract.name;\n this._calldata = new Calldata([aci.encodedAci, ...aci.externalEncodedAci]);\n this.$options = otherOptions;\n\n /**\n * Generate proto function based on contract function using Contract ACI schema\n * All function can be called like:\n * ```js\n * await contract.testFunction()\n * ```\n * then sdk will decide to use dry-run or send tx\n * on-chain base on if function stateful or not.\n * Also, you can manually do that:\n * ```js\n * await contract.testFunction({ callStatic: true }) // use call-static (dry-run)\n * await contract.testFunction({ callStatic: false }) // send tx on-chain\n * ```\n */\n Object.assign(\n this,\n Object.fromEntries(this._aci.encodedAci.contract.functions\n .map(({ name, arguments: aciArgs, stateful }: FunctionAci) => {\n const callStatic = name !== 'init' && !stateful;\n return [\n name,\n async (...args: any) => {\n const options = args.length === aciArgs.length + 1 ? args.pop() : {};\n if (typeof options !== 'object') throw new TypeError(`Options should be an object: ${options}`);\n if (name === 'init') return this.$deploy(args, { callStatic, ...options });\n return this.$call(name, args, { callStatic, ...options });\n },\n ];\n })),\n );\n }\n}\n\ninterface ContractWithMethodsClass {\n new <M extends ContractMethodsBase>(\n options: ConstructorParameters<typeof Contract>[0],\n ): ContractWithMethods<M>;\n initialize: typeof Contract['initialize'];\n}\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nconst ContractWithMethods: ContractWithMethodsClass = Contract as any;\n\nexport default ContractWithMethods;\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,mCAAoC,0BAA0B;AAAC;EAAA;AAAA;AAAA,SACtDA,eAAe;AAAA,SACfC,GAAG;AAAA,SACHC,2BAA2B,EAAEC,QAAQ;AAAA,SACrCC,QAAQ;AAAA,SACRC,IAAI;AAAA,SACJC,MAAM;AAAA,SAEbC,uBAAuB,EACvBC,2BAA2B,EAC3BC,qBAAqB,EACrBC,qBAAqB,EACrBC,sBAAsB,EACtBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,uBAAuB,EACvBC,SAAS,EACTC,mBAAmB,EACnBC,oBAAoB,EACpBC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,iBAAiB,EACjBC,aAAa,EACbC,sBAAsB;AAAA,SAEfC,IAAI,IAAIC,QAAQ;AAAA,SAOvBC,UAAU,EAAEC,WAAW,EAAEC,mBAAmB,EAAEC,WAAW,EAAEC,QAAQ;AAAA,SAG5DC,aAAa;AAAA,SACbC,WAAW,EAAEC,aAAa;AA0DnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,CAAgC;EAC5C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,0BAA0B,GAGT;IAAA,IAFrBC,GAAkC,uEAAG,EAAE;IAAA,IACvCC,QAA6D;IAE7D,MAAMC,OAAO,GAAG;MAA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