@aeternity/aepp-sdk 11.0.1 → 12.1.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 (444) hide show
  1. package/LICENSE +1 -1
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -22
  4. package/dist/aepp-sdk.browser-script.js.map +1 -1
  5. package/dist/aepp-sdk.browser.js +2 -1
  6. package/dist/aepp-sdk.browser.js.LICENSE.txt +1 -0
  7. package/dist/aepp-sdk.browser.js.map +1 -1
  8. package/dist/aepp-sdk.js +20765 -1
  9. package/dist/aepp-sdk.js.map +1 -1
  10. package/es/AeSdk.d.ts +37 -0
  11. package/es/AeSdk.mjs +81 -0
  12. package/es/AeSdk.mjs.map +1 -0
  13. package/es/AeSdkAepp.d.ts +70 -0
  14. package/es/AeSdkAepp.mjs +176 -0
  15. package/es/AeSdkAepp.mjs.map +1 -0
  16. package/es/AeSdkBase.d.ts +213 -0
  17. package/es/AeSdkBase.mjs +314 -0
  18. package/es/AeSdkBase.mjs.map +1 -0
  19. package/es/AeSdkWallet.d.ts +104 -0
  20. package/es/AeSdkWallet.mjs +326 -0
  21. package/es/AeSdkWallet.mjs.map +1 -0
  22. package/es/Node.d.ts +41 -0
  23. package/es/Node.mjs +147 -0
  24. package/es/Node.mjs.map +1 -0
  25. package/es/account/Base.d.ts +68 -0
  26. package/es/account/Base.mjs +123 -0
  27. package/es/account/Base.mjs.map +1 -0
  28. package/es/account/Memory.d.ts +26 -0
  29. package/es/account/Memory.mjs +103 -0
  30. package/es/account/Memory.mjs.map +1 -0
  31. package/es/account/Rpc.d.ts +27 -0
  32. package/es/account/Rpc.mjs +80 -0
  33. package/es/account/Rpc.mjs.map +1 -0
  34. package/es/aens.d.ts +222 -0
  35. package/es/aens.mjs +338 -0
  36. package/es/aens.mjs.map +1 -0
  37. package/es/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  38. package/es/aepp-wallet-communication/connection/Browser.mjs +73 -0
  39. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
  41. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +58 -0
  42. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  44. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +146 -0
  45. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
  46. package/es/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  47. package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +16 -11
  48. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
  49. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  50. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
  51. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
  52. package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
  53. package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
  54. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
  55. package/es/aepp-wallet-communication/schema.d.ts +105 -46
  56. package/es/aepp-wallet-communication/schema.mjs +251 -0
  57. package/es/aepp-wallet-communication/schema.mjs.map +1 -0
  58. package/es/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  59. package/es/aepp-wallet-communication/wallet-detector.mjs +62 -0
  60. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  61. package/es/apis/compiler/compiler.d.ts +92 -0
  62. package/es/apis/compiler/compiler.mjs +576 -0
  63. package/es/apis/compiler/compiler.mjs.map +1 -0
  64. package/es/apis/compiler/index.d.ts +2 -0
  65. package/es/apis/compiler/index.mjs +3 -0
  66. package/es/apis/compiler/index.mjs.map +1 -0
  67. package/es/apis/compiler/models/index.d.ts +248 -0
  68. package/es/apis/compiler/models/index.mjs +48 -0
  69. package/es/apis/compiler/models/index.mjs.map +1 -0
  70. package/es/apis/compiler/models/mappers.d.ts +23 -0
  71. package/es/apis/compiler/models/mappers.mjs +585 -0
  72. package/es/apis/compiler/models/mappers.mjs.map +1 -0
  73. package/es/apis/compiler/models/parameters.d.ts +13 -0
  74. package/es/apis/compiler/models/parameters.mjs +71 -0
  75. package/es/apis/compiler/models/parameters.mjs.map +1 -0
  76. package/es/apis/node/index.d.ts +2 -0
  77. package/es/apis/node/index.mjs +3 -0
  78. package/es/apis/node/index.mjs.map +1 -0
  79. package/es/apis/node/models/index.d.ts +1065 -0
  80. package/es/apis/node/models/index.mjs +2 -0
  81. package/es/apis/node/models/index.mjs.map +1 -0
  82. package/es/apis/node/models/mappers.d.ts +95 -0
  83. package/es/apis/node/models/mappers.mjs +4166 -0
  84. package/es/apis/node/models/mappers.mjs.map +1 -0
  85. package/es/apis/node/models/parameters.d.ts +17 -0
  86. package/es/apis/node/models/parameters.mjs +165 -0
  87. package/es/apis/node/models/parameters.mjs.map +1 -0
  88. package/es/apis/node/node.d.ts +215 -0
  89. package/es/apis/node/node.mjs +1165 -0
  90. package/es/apis/node/node.mjs.map +1 -0
  91. package/es/chain.d.ts +248 -0
  92. package/es/chain.mjs +560 -0
  93. package/es/chain.mjs.map +1 -0
  94. package/es/channel/handlers.d.ts +34 -0
  95. package/es/channel/handlers.mjs +164 -131
  96. package/es/channel/handlers.mjs.map +1 -1
  97. package/es/channel/index.d.ts +625 -0
  98. package/es/channel/index.mjs +897 -902
  99. package/es/channel/index.mjs.map +1 -1
  100. package/es/channel/internal.d.ts +101 -0
  101. package/es/channel/internal.mjs +136 -85
  102. package/es/channel/internal.mjs.map +1 -1
  103. package/es/contract/Compiler.d.ts +18 -0
  104. package/es/contract/Compiler.mjs +68 -0
  105. package/es/contract/Compiler.mjs.map +1 -0
  106. package/es/contract/aci.d.ts +127 -0
  107. package/es/contract/aci.mjs +225 -193
  108. package/es/contract/aci.mjs.map +1 -1
  109. package/es/contract/ga.d.ts +69 -0
  110. package/es/contract/ga.mjs +195 -0
  111. package/es/contract/ga.mjs.map +1 -0
  112. package/es/contract/methods.d.ts +71 -0
  113. package/es/contract/methods.mjs +104 -0
  114. package/es/contract/methods.mjs.map +1 -0
  115. package/es/deprecated/index.d.ts +143 -0
  116. package/es/deprecated/index.mjs +162 -0
  117. package/es/deprecated/index.mjs.map +1 -0
  118. package/es/deprecated/methods.d.ts +18 -0
  119. package/es/deprecated/methods.mjs +26 -0
  120. package/es/deprecated/methods.mjs.map +1 -0
  121. package/es/index.d.ts +35 -0
  122. package/es/index.mjs +35 -40
  123. package/es/index.mjs.map +1 -1
  124. package/es/oracle.d.ts +161 -0
  125. package/es/oracle.mjs +306 -0
  126. package/es/oracle.mjs.map +1 -0
  127. package/es/spend.d.ts +62 -0
  128. package/es/spend.mjs +111 -0
  129. package/es/spend.mjs.map +1 -0
  130. package/es/tx/builder/address.d.ts +25 -0
  131. package/es/tx/builder/address.mjs +45 -0
  132. package/es/tx/builder/address.mjs.map +1 -0
  133. package/es/tx/builder/constants.d.ts +70 -0
  134. package/es/tx/builder/constants.mjs +61 -47
  135. package/es/tx/builder/constants.mjs.map +1 -1
  136. package/es/tx/builder/field-types/coin-amount.d.ts +13 -0
  137. package/es/tx/builder/field-types/coin-amount.mjs +26 -0
  138. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -0
  139. package/es/tx/builder/field-types/deposit.d.ts +15 -0
  140. package/es/tx/builder/field-types/deposit.mjs +19 -0
  141. package/es/tx/builder/field-types/deposit.mjs.map +1 -0
  142. package/es/tx/builder/field-types/fee.d.ts +25 -0
  143. package/es/tx/builder/field-types/fee.mjs +150 -0
  144. package/es/tx/builder/field-types/fee.mjs.map +1 -0
  145. package/es/tx/builder/field-types/field.d.ts +6 -0
  146. package/es/tx/builder/field-types/field.mjs +15 -0
  147. package/es/tx/builder/field-types/field.mjs.map +1 -0
  148. package/es/tx/builder/field-types/gas-limit.d.ts +12 -0
  149. package/es/tx/builder/field-types/gas-limit.mjs +33 -0
  150. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -0
  151. package/es/tx/builder/field-types/gas-price.d.ts +8 -0
  152. package/es/tx/builder/field-types/gas-price.mjs +18 -0
  153. package/es/tx/builder/field-types/gas-price.mjs.map +1 -0
  154. package/es/tx/builder/field-types/index.d.ts +70 -0
  155. package/es/tx/builder/field-types/index.mjs +25 -0
  156. package/es/tx/builder/field-types/index.mjs.map +1 -0
  157. package/es/tx/builder/field-types/name-fee.d.ts +20 -0
  158. package/es/tx/builder/field-types/name-fee.mjs +24 -0
  159. package/es/tx/builder/field-types/name-fee.mjs.map +1 -0
  160. package/es/tx/builder/field-types/name-id.d.ts +14 -0
  161. package/es/tx/builder/field-types/name-id.mjs +19 -0
  162. package/es/tx/builder/field-types/name-id.mjs.map +1 -0
  163. package/es/tx/builder/field-types/name.d.ts +13 -0
  164. package/es/tx/builder/field-types/name.mjs +18 -0
  165. package/es/tx/builder/field-types/name.mjs.map +1 -0
  166. package/es/tx/builder/field-types/short-u-int.d.ts +6 -0
  167. package/es/tx/builder/field-types/short-u-int.mjs +12 -0
  168. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -0
  169. package/es/tx/builder/field-types/u-int.d.ts +8 -0
  170. package/es/tx/builder/field-types/u-int.mjs +14 -0
  171. package/es/tx/builder/field-types/u-int.mjs.map +1 -0
  172. package/es/tx/builder/helpers.d.ts +125 -0
  173. package/es/tx/builder/helpers.mjs +94 -198
  174. package/es/tx/builder/helpers.mjs.map +1 -1
  175. package/es/tx/builder/index.d.ts +88 -0
  176. package/es/tx/builder/index.mjs +167 -358
  177. package/es/tx/builder/index.mjs.map +1 -1
  178. package/es/tx/builder/schema.d.ts +1201 -0
  179. package/es/tx/builder/schema.mjs +175 -561
  180. package/es/tx/builder/schema.mjs.map +1 -1
  181. package/es/tx/index.d.ts +64 -0
  182. package/es/tx/index.mjs +151 -265
  183. package/es/tx/index.mjs.map +1 -1
  184. package/es/tx/validator.d.ts +20 -0
  185. package/es/tx/validator.mjs +104 -124
  186. package/es/tx/validator.mjs.map +1 -1
  187. package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
  188. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
  189. package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
  190. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
  191. package/es/typings/bip32-path/index.d.mjs +2 -0
  192. package/es/typings/bip32-path/index.d.mjs.map +1 -0
  193. package/es/typings/blakejs/index.d.mjs.map +1 -1
  194. package/es/typings/sha-js/index.d.mjs +2 -0
  195. package/es/typings/sha-js/index.d.mjs.map +1 -0
  196. package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
  197. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
  198. package/es/utils/amount-formatter.d.ts +42 -0
  199. package/es/utils/amount-formatter.mjs +36 -49
  200. package/es/utils/amount-formatter.mjs.map +1 -1
  201. package/es/utils/autorest.d.ts +6 -0
  202. package/es/utils/autorest.mjs +97 -0
  203. package/es/utils/autorest.mjs.map +1 -0
  204. package/es/utils/bignumber.d.ts +13 -0
  205. package/es/utils/bignumber.mjs +11 -8
  206. package/es/utils/bignumber.mjs.map +1 -1
  207. package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
  208. package/es/utils/bytes.mjs +11 -15
  209. package/es/utils/bytes.mjs.map +1 -1
  210. package/es/utils/crypto.d.ts +88 -0
  211. package/es/utils/crypto.mjs +64 -98
  212. package/es/utils/crypto.mjs.map +1 -1
  213. package/es/utils/encoder-types.d.ts +61 -0
  214. package/es/utils/encoder-types.mjs +36 -0
  215. package/es/utils/encoder-types.mjs.map +1 -0
  216. package/es/utils/encoder.d.ts +25 -0
  217. package/es/utils/encoder.mjs +71 -59
  218. package/es/utils/encoder.mjs.map +1 -1
  219. package/es/{errors.d.ts → utils/errors.d.ts} +246 -59
  220. package/es/utils/errors.mjs +313 -136
  221. package/es/utils/errors.mjs.map +1 -1
  222. package/es/utils/hd-wallet.d.ts +50 -0
  223. package/es/utils/hd-wallet.mjs +86 -45
  224. package/es/utils/hd-wallet.mjs.map +1 -1
  225. package/es/utils/json-big.d.ts +5 -0
  226. package/es/utils/json-big.mjs +12 -16
  227. package/es/utils/json-big.mjs.map +1 -1
  228. package/es/utils/keystore.d.ts +51 -0
  229. package/es/utils/keystore.mjs +101 -194
  230. package/es/utils/keystore.mjs.map +1 -1
  231. package/es/{mptree.d.ts → utils/mptree.d.ts} +6 -9
  232. package/es/utils/mptree.mjs +22 -18
  233. package/es/utils/mptree.mjs.map +1 -1
  234. package/es/utils/other.d.ts +20 -0
  235. package/es/utils/other.mjs +32 -35
  236. package/es/utils/other.mjs.map +1 -1
  237. package/es/utils/semver-satisfies.d.ts +1 -0
  238. package/es/utils/semver-satisfies.mjs +2 -2
  239. package/es/utils/semver-satisfies.mjs.map +1 -1
  240. package/es/utils/string.d.ts +24 -0
  241. package/es/utils/string.mjs +8 -10
  242. package/es/utils/string.mjs.map +1 -1
  243. package/package.json +55 -43
  244. package/src/AeSdk.ts +68 -0
  245. package/src/AeSdkAepp.ts +176 -0
  246. package/src/AeSdkBase.ts +338 -0
  247. package/src/AeSdkWallet.ts +348 -0
  248. package/src/Node.ts +173 -0
  249. package/src/account/Base.ts +124 -0
  250. package/src/account/Memory.ts +98 -0
  251. package/src/account/Rpc.ts +69 -0
  252. package/src/aens.ts +407 -0
  253. package/src/aepp-wallet-communication/connection/Browser.ts +71 -0
  254. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +59 -0
  255. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +122 -0
  256. package/{es/utils/crypto-ts.mjs → src/aepp-wallet-communication/connection-proxy.ts} +18 -18
  257. package/src/aepp-wallet-communication/rpc/RpcClient.ts +143 -0
  258. package/src/aepp-wallet-communication/rpc/types.ts +66 -0
  259. package/src/aepp-wallet-communication/schema.ts +224 -0
  260. package/src/aepp-wallet-communication/wallet-detector.ts +72 -0
  261. package/src/apis/compiler/code-model-v4.yaml +2649 -0
  262. package/src/apis/compiler/compiler.ts +585 -0
  263. package/src/apis/compiler/index.ts +2 -0
  264. package/src/apis/compiler/models/index.ts +301 -0
  265. package/src/apis/compiler/models/mappers.ts +583 -0
  266. package/src/apis/compiler/models/parameters.ts +93 -0
  267. package/src/apis/node/code-model-v4.yaml +10080 -0
  268. package/src/apis/node/index.ts +2 -0
  269. package/src/apis/node/models/index.ts +1257 -0
  270. package/src/apis/node/models/mappers.ts +4280 -0
  271. package/src/apis/node/models/parameters.ts +188 -0
  272. package/src/apis/node/node.ts +1299 -0
  273. package/src/chain.ts +502 -0
  274. package/src/channel/handlers.ts +817 -0
  275. package/src/channel/index.ts +1025 -0
  276. package/src/channel/internal.ts +361 -0
  277. package/src/contract/Compiler.ts +67 -0
  278. package/src/contract/aci.ts +538 -0
  279. package/src/contract/ga.ts +199 -0
  280. package/src/contract/methods.ts +123 -0
  281. package/src/deprecated/index.ts +172 -0
  282. package/src/deprecated/methods.ts +25 -0
  283. package/src/index.ts +56 -0
  284. package/src/oracle.ts +364 -0
  285. package/src/spend.ts +164 -0
  286. package/src/tx/builder/address.ts +50 -0
  287. package/src/tx/builder/constants.ts +126 -0
  288. package/src/tx/builder/field-types/coin-amount.ts +27 -0
  289. package/src/tx/builder/field-types/deposit.ts +21 -0
  290. package/src/tx/builder/field-types/fee.ts +143 -0
  291. package/src/tx/builder/field-types/field.ts +9 -0
  292. package/src/tx/builder/field-types/gas-limit.ts +41 -0
  293. package/src/tx/builder/field-types/gas-price.ts +16 -0
  294. package/src/tx/builder/field-types/index.ts +45 -0
  295. package/src/tx/builder/field-types/name-fee.ts +32 -0
  296. package/src/tx/builder/field-types/name-id.ts +20 -0
  297. package/src/tx/builder/field-types/name.ts +18 -0
  298. package/src/tx/builder/field-types/short-u-int.ts +11 -0
  299. package/src/tx/builder/field-types/u-int.ts +16 -0
  300. package/src/tx/builder/helpers.ts +248 -0
  301. package/src/tx/builder/index.ts +400 -0
  302. package/src/tx/builder/schema.ts +727 -0
  303. package/src/tx/index.ts +192 -0
  304. package/src/tx/validator.ts +230 -0
  305. package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
  306. package/src/typings/@aeternity__uuid/index.d.ts +5 -0
  307. package/src/typings/bip32-path/index.d.ts +33 -0
  308. package/src/typings/blakejs/index.d.ts +4 -32
  309. package/src/typings/sha-js/index.d.ts +5 -0
  310. package/src/typings/tweetnacl-auth/index.d.ts +14 -0
  311. package/src/utils/amount-formatter.ts +56 -69
  312. package/src/utils/autorest.ts +93 -0
  313. package/src/utils/bignumber.ts +11 -12
  314. package/src/utils/bytes.ts +29 -31
  315. package/src/utils/crypto.ts +205 -0
  316. package/src/utils/encoder-types.ts +63 -0
  317. package/src/utils/encoder.ts +116 -71
  318. package/src/utils/errors.ts +482 -366
  319. package/src/utils/hd-wallet.ts +166 -0
  320. package/src/utils/json-big.ts +27 -0
  321. package/src/utils/keystore.ts +182 -0
  322. package/src/utils/mptree.ts +64 -61
  323. package/src/utils/other.ts +34 -41
  324. package/src/utils/semver-satisfies.ts +15 -11
  325. package/src/utils/string.ts +18 -20
  326. package/es/account/base.mjs +0 -179
  327. package/es/account/base.mjs.map +0 -1
  328. package/es/account/memory.mjs +0 -99
  329. package/es/account/memory.mjs.map +0 -1
  330. package/es/account/multiple.mjs +0 -179
  331. package/es/account/multiple.mjs.map +0 -1
  332. package/es/ae/aens.mjs +0 -404
  333. package/es/ae/aens.mjs.map +0 -1
  334. package/es/ae/aepp.mjs +0 -45
  335. package/es/ae/aepp.mjs.map +0 -1
  336. package/es/ae/contract.mjs +0 -159
  337. package/es/ae/contract.mjs.map +0 -1
  338. package/es/ae/index.mjs +0 -207
  339. package/es/ae/index.mjs.map +0 -1
  340. package/es/ae/oracle.mjs +0 -339
  341. package/es/ae/oracle.mjs.map +0 -1
  342. package/es/ae/universal.mjs +0 -45
  343. package/es/ae/universal.mjs.map +0 -1
  344. package/es/ae/wallet.mjs +0 -50
  345. package/es/ae/wallet.mjs.map +0 -1
  346. package/es/amount-formatter.d.ts +0 -58
  347. package/es/bignumber.d.ts +0 -18
  348. package/es/chain/index.mjs +0 -272
  349. package/es/chain/index.mjs.map +0 -1
  350. package/es/chain/node.mjs +0 -442
  351. package/es/chain/node.mjs.map +0 -1
  352. package/es/contract/compiler.mjs +0 -115
  353. package/es/contract/compiler.mjs.map +0 -1
  354. package/es/contract/ga/helpers.mjs +0 -30
  355. package/es/contract/ga/helpers.mjs.map +0 -1
  356. package/es/contract/ga/index.mjs +0 -178
  357. package/es/contract/ga/index.mjs.map +0 -1
  358. package/es/crypto-ts.d.ts +0 -9
  359. package/es/encoder.d.ts +0 -26
  360. package/es/node-pool/index.mjs +0 -188
  361. package/es/node-pool/index.mjs.map +0 -1
  362. package/es/node.mjs +0 -133
  363. package/es/node.mjs.map +0 -1
  364. package/es/other.d.ts +0 -31
  365. package/es/semver-satisfies.d.ts +0 -1
  366. package/es/string.d.ts +0 -26
  367. package/es/tx/builder/field-types.mjs +0 -74
  368. package/es/tx/builder/field-types.mjs.map +0 -1
  369. package/es/tx/tx-object.mjs +0 -283
  370. package/es/tx/tx-object.mjs.map +0 -1
  371. package/es/tx/tx.mjs +0 -938
  372. package/es/tx/tx.mjs.map +0 -1
  373. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs +0 -132
  374. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +0 -1
  375. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +0 -183
  376. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +0 -1
  377. package/es/utils/aepp-wallet-communication/connection/index.mjs +0 -87
  378. package/es/utils/aepp-wallet-communication/connection/index.mjs.map +0 -1
  379. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs +0 -98
  380. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +0 -1
  381. package/es/utils/aepp-wallet-communication/helpers.mjs +0 -92
  382. package/es/utils/aepp-wallet-communication/helpers.mjs.map +0 -1
  383. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +0 -375
  384. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +0 -1
  385. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +0 -275
  386. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +0 -1
  387. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +0 -541
  388. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +0 -1
  389. package/es/utils/aepp-wallet-communication/schema.mjs +0 -102
  390. package/es/utils/aepp-wallet-communication/schema.mjs.map +0 -1
  391. package/es/utils/aepp-wallet-communication/wallet-detector.mjs +0 -110
  392. package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +0 -1
  393. package/es/utils/async-init.mjs +0 -64
  394. package/es/utils/async-init.mjs.map +0 -1
  395. package/es/utils/crypto-ts.mjs.map +0 -1
  396. package/es/utils/swagger.mjs +0 -164
  397. package/es/utils/swagger.mjs.map +0 -1
  398. package/src/account/base.js +0 -153
  399. package/src/account/memory.js +0 -83
  400. package/src/account/multiple.js +0 -162
  401. package/src/ae/aens.js +0 -361
  402. package/src/ae/aepp.js +0 -45
  403. package/src/ae/contract.js +0 -148
  404. package/src/ae/index.js +0 -168
  405. package/src/ae/oracle.js +0 -311
  406. package/src/ae/universal.js +0 -47
  407. package/src/ae/wallet.js +0 -50
  408. package/src/chain/index.js +0 -269
  409. package/src/chain/node.js +0 -320
  410. package/src/channel/handlers.js +0 -673
  411. package/src/channel/index.js +0 -903
  412. package/src/channel/internal.js +0 -236
  413. package/src/contract/aci.js +0 -376
  414. package/src/contract/compiler.js +0 -100
  415. package/src/contract/ga/helpers.js +0 -19
  416. package/src/contract/ga/index.js +0 -150
  417. package/src/index.js +0 -89
  418. package/src/node-pool/index.js +0 -172
  419. package/src/node.js +0 -116
  420. package/src/tx/builder/constants.js +0 -100
  421. package/src/tx/builder/field-types.js +0 -61
  422. package/src/tx/builder/helpers.js +0 -334
  423. package/src/tx/builder/index.js +0 -465
  424. package/src/tx/builder/schema.js +0 -1100
  425. package/src/tx/index.js +0 -301
  426. package/src/tx/tx-object.js +0 -187
  427. package/src/tx/tx.js +0 -631
  428. package/src/tx/validator.js +0 -181
  429. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -119
  430. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -165
  431. package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
  432. package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -86
  433. package/src/utils/aepp-wallet-communication/helpers.js +0 -60
  434. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -294
  435. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -232
  436. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -401
  437. package/src/utils/aepp-wallet-communication/schema.ts +0 -80
  438. package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -92
  439. package/src/utils/async-init.js +0 -45
  440. package/src/utils/crypto.js +0 -219
  441. package/src/utils/hd-wallet.js +0 -100
  442. package/src/utils/json-big.js +0 -26
  443. package/src/utils/keystore.js +0 -219
  444. package/src/utils/swagger.js +0 -156
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/contract/aci.js"],"names":["DRY_RUN_ACCOUNT","GAS_MAX","TxObject","decode","MissingContractDefError","MissingContractAddressError","InactiveContractError","BytecodeMismatchError","InternalError","DuplicateContractError","MissingFunctionNameError","InvalidMethodInvocationError","NotPayableFunctionError","TypeError","NodeInvocationError","IllegalArgumentError","NoSuchContractFunctionError","MissingEventDefinitionError","AmbiguousEventDefinitionError","hash","getContractInstance","source","bytecode","aci","_aci","contractAddress","filesystem","validateBytecode","otherOptions","compilerApi","generateACI","code","options","resolveName","resolveByNode","contract","getContract","active","instance","_name","encoded_aci","name","calldata","Calldata","external_encoded_aci","deployInfo","address","Ae","defaults","callStatic","compilerVersion","onChanBytecode","getContractByteCode","isValid","validateByteCode","then","res","Object","entries","length","compile","compileContract","sendAndProcess","tx","txData","send","result","rawTx","waitMined","callInfo","api","getTransactionInfoByHash","assign","handleCallError","returnType","returnValue","message","decodeFateString","toString","_estimateGas","params","gasUsed","call","Math","floor","deploy","opt","ownerId","contractId","contractCreateTx","gas","callData","encode","freeze","owner","transaction","getFunctionACI","fn","functions","find","f","payable","fnACI","amount","callerId","catch","error","pub","top","getKeyBlock","txOpt","nonce","getAccount","contractCallTx","callObj","dryRunOther","txDryRun","decodedResult","returns","decodedEvents","decodeEvents","log","getContractNameByEvent","nameHash","contractAddressToName","addressToName","matchedEvents","filter","event","map","variant","events","keys","flat","eventName","BigInt","omitUnknown","topics","t","contractName","decoded","decodeEvent","data","args","e","methods","fromEntries","arguments","aciArgs","stateful","genHandler","pop","get"],"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,0BAApC;;;;SACSA,e,EAAiBC,O;OACnBC,Q;SACEC,M;SAEPC,uB,EACAC,2B,EACAC,qB,EACAC,qB,EACAC,a,EACAC,sB,EACAC,wB,EACAC,4B,EACAC,uB,EACAC,S,EACAC,mB,EACAC,oB,EACAC,2B,EACAC,2B,EACAC,6B;SAEOC,I;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,eAAeC,mBAAf,GAQP;AAAA;;AAAA,MAR2C;AACjDC,IAAAA,MADiD;AAEjDC,IAAAA,QAFiD;AAGjDC,IAAAA,GAAG,EAAEC,IAH4C;AAIjDC,IAAAA,eAJiD;AAKjDC,IAAAA,UAAU,GAAG,EALoC;AAMjDC,IAAAA,gBANiD;AAOjD,OAAGC;AAP8C,GAQ3C,uEAAJ,E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,QAAP;AACD","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 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 * ContractACI module\n *\n * @module @aeternity/aepp-sdk/es/contract/aci\n * @export getContractInstance\n */\n\nimport { Encoder as Calldata } from '@aeternity/aepp-calldata'\nimport { DRY_RUN_ACCOUNT, GAS_MAX } from '../tx/builder/schema'\nimport TxObject from '../tx/tx-object'\nimport { decode } from '../tx/builder/helpers'\nimport {\n MissingContractDefError,\n MissingContractAddressError,\n InactiveContractError,\n BytecodeMismatchError,\n InternalError,\n DuplicateContractError,\n MissingFunctionNameError,\n InvalidMethodInvocationError,\n NotPayableFunctionError,\n TypeError,\n NodeInvocationError,\n IllegalArgumentError,\n NoSuchContractFunctionError,\n MissingEventDefinitionError,\n AmbiguousEventDefinitionError\n} from '../utils/errors'\nimport { hash } from '../utils/crypto-ts'\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 * @alias module:@aeternity/aepp-sdk/es/contract/aci\n * @param {Object} [options={}] Options object\n * @param {String} [options.source] Contract source code\n * @param {String} [options.bytecode] Contract bytecode\n * @param {Object} [options.aci] Contract ACI\n * @param {String} [options.contractAddress] Contract address\n * @param {Object} [options.filesystem] Contact source external namespaces map\n * @param {Boolean} [options.validateBytecode] Compare source code with on-chain version\n * @return {ContractInstance} JS Contract API\n * @example\n * const contractIns = await aeSdk.getContractInstance({ source })\n * await contractIns.deploy([321]) or await contractIns.methods.init(321)\n * const callResult = await contractIns.call('setState', [123]) or\n * await contractIns.methods.setState.send(123, options)\n * const staticCallResult = await contractIns.call('setState', [123], { callStatic: true }) or\n * await contractIns.methods.setState.get(123, options)\n * Also you can call contract like: await contractIns.methods.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 */\nexport default async function getContractInstance ({\n source,\n bytecode,\n aci: _aci,\n contractAddress,\n filesystem = {},\n validateBytecode,\n ...otherOptions\n} = {}) {\n if (!_aci && source) {\n _aci = await this.compilerApi.generateACI({ code: source, options: { filesystem } })\n }\n if (!_aci) throw new MissingContractDefError()\n contractAddress = contractAddress && await this.resolveName(\n contractAddress, 'contract_pubkey', { resolveByNode: true }\n )\n if (!contractAddress && !source && !bytecode) {\n throw new MissingContractAddressError('Can\\'t create instance by ACI without address')\n }\n\n if (contractAddress) {\n const contract = await this.getContract(contractAddress)\n if (!contract.active) throw new InactiveContractError(contractAddress)\n }\n\n const instance = {\n _aci,\n _name: _aci.encoded_aci.contract.name,\n calldata: new Calldata([_aci.encoded_aci, ..._aci.external_encoded_aci]),\n source,\n bytecode,\n deployInfo: { address: contractAddress },\n options: {\n ...this.Ae.defaults,\n callStatic: false,\n filesystem,\n ...otherOptions\n },\n compilerVersion: this.compilerVersion\n }\n\n if (validateBytecode) {\n if (!contractAddress) throw new MissingContractAddressError('Can\\'t validate bytecode without contract address')\n const onChanBytecode = (await this.getContractByteCode(contractAddress)).bytecode\n const isValid = source\n ? await this.compilerApi.validateByteCode(\n { bytecode: onChanBytecode, source, options: instance.options }\n ).then((res) => Object.entries(res).length === 0, () => false)\n : bytecode === onChanBytecode\n if (!isValid) throw new BytecodeMismatchError(source ? 'source' : 'bytecode')\n }\n\n /**\n * Compile contract\n * @alias module:@aeternity/aepp-sdk/es/contract/aci\n * @rtype () => ContractInstance: Object\n * @return {String} bytecode bytecode\n */\n instance.compile = async (options = {}) => {\n if (instance.bytecode) throw new IllegalArgumentError('Contract already compiled')\n if (!instance.source) throw new IllegalArgumentError('Can\\'t compile without source code')\n const { bytecode } = await this.compilerApi.compileContract({\n code: instance.source, options: { ...instance.options, ...options }\n })\n instance.bytecode = bytecode\n return instance.bytecode\n }\n\n const sendAndProcess = async (tx, options) => {\n const txData = await this.send(tx, options)\n const result = {\n hash: txData.hash, tx: TxObject({ tx: txData.rawTx }), txData, rawTx: txData.rawTx\n }\n if (options.waitMined === false) return result\n const { callInfo } = await this.api.getTransactionInfoByHash(txData.hash)\n Object.assign(result.txData, callInfo) // TODO: don't duplicate data in result\n await handleCallError(callInfo)\n return { ...result, result: callInfo }\n }\n\n const handleCallError = ({ returnType, returnValue }) => {\n let message\n // TODO: ensure that it works correctly https://github.com/aeternity/aepp-calldata-js/issues/88\n switch (returnType) {\n case 'ok': return\n case 'revert':\n message = instance.calldata.decodeFateString(returnValue)\n break\n case 'error':\n message = decode(returnValue).toString()\n break\n default: throw new InternalError(`Unknown returnType: ${returnType}`)\n }\n throw new NodeInvocationError(message)\n }\n\n instance._estimateGas = async (name, params, options) => {\n const { result: { gasUsed } } =\n await instance.call(name, params, { ...options, callStatic: true })\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 * @alias module:@aeternity/aepp-sdk/es/contract/aci\n * @rtype (init: Array, options: Object) => ContractInstance: Object\n * @param {Array} params Contract init function arguments array\n * @param {Object} [options] options\n * @return {Object} deploy info\n */\n instance.deploy = async (params = [], options) => {\n const opt = { ...instance.options, ...options }\n if (!instance.bytecode) await instance.compile(opt)\n if (opt.callStatic) return instance.call('init', params, opt)\n if (instance.deployInfo.address) throw new DuplicateContractError()\n\n const ownerId = await this.address(opt)\n const { tx, contractId } = await this.contractCreateTx({\n ...opt,\n gas: opt.gas ?? await instance._estimateGas('init', params, opt),\n callData: instance.calldata.encode(instance._name, 'init', params),\n code: instance.bytecode,\n ownerId\n })\n const { hash, rawTx, result, txData } = await sendAndProcess(tx, opt)\n instance.deployInfo = Object.freeze({\n result,\n owner: ownerId,\n transaction: hash,\n rawTx,\n txData,\n address: contractId\n })\n return instance.deployInfo\n }\n\n /**\n * Get function schema from contract ACI object\n * @param {String} name Function name\n * @return {Object} function ACI\n */\n function getFunctionACI (name) {\n const fn = instance._aci.encoded_aci.contract.functions.find(f => f.name === name)\n if (fn) return fn\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 * @alias module:@aeternity/aepp-sdk/es/contract/aci\n * @rtype (init: Array, options: Object = { callStatic: false }) => CallResult: Object\n * @param {String} fn Function name\n * @param {Array} params Array of function arguments\n * @param {Object} [options={}] Array of function arguments\n * @param {Boolean} [options.callStatic=false] Static function call\n * @return {Object} CallResult\n */\n instance.call = async (fn, params = [], options = {}) => {\n const opt = { ...instance.options, ...options }\n const fnACI = getFunctionACI(fn)\n const contractId = instance.deployInfo.address\n\n if (!fn) throw new MissingFunctionNameError()\n if (fn === 'init' && !opt.callStatic) throw new InvalidMethodInvocationError('\"init\" can be called only via dryRun')\n if (!contractId && fn !== 'init') throw new InvalidMethodInvocationError('You need to deploy contract before calling!')\n if (fn !== 'init' && opt.amount > 0 && fnACI.payable === false) throw new NotPayableFunctionError(`You try to pay \"${opt.amount}\" to function \"${fn}\" which is not payable. Only payable function can accept coins`)\n\n const callerId = await this.address(opt).catch(error => {\n if (opt.callStatic) return DRY_RUN_ACCOUNT.pub\n else throw error\n })\n const callData = instance.calldata.encode(instance._name, fn, params)\n\n let res\n if (opt.callStatic) {\n if (typeof opt.top === 'number') {\n opt.top = (await this.getKeyBlock(opt.top)).hash\n }\n const txOpt = {\n ...opt,\n gas: opt.gas ?? GAS_MAX,\n callData,\n nonce: opt.nonce ??\n (opt.top && (await this.getAccount(callerId, { hash: opt.top })).nonce + 1)\n }\n const tx = fn === 'init'\n ? (await this.contractCreateTx({ ...txOpt, code: instance.bytecode, ownerId: callerId })).tx\n : await this.contractCallTx({ ...txOpt, callerId, contractId })\n\n const { callObj, ...dryRunOther } = await this.txDryRun(tx, callerId, opt)\n await handleCallError(callObj)\n res = { ...dryRunOther, tx: TxObject({ tx }), result: callObj }\n } else {\n const tx = await this.contractCallTx({\n ...opt,\n gas: opt.gas ?? await instance._estimateGas(fn, params, opt),\n callerId,\n contractId,\n callData\n })\n res = await sendAndProcess(tx, opt)\n }\n if (opt.waitMined || opt.callStatic) {\n res.decodedResult = fnACI.returns && fnACI.returns !== 'unit' && fn !== 'init' &&\n instance.calldata.decode(instance._name, fn, res.result.returnValue)\n res.decodedEvents = instance.decodeEvents(res.result.log, opt)\n }\n return res\n }\n\n /**\n * @param {String} address Contract address that emitted event\n * @param {BigInt} nameHash Hash of emitted event name\n * @param {Object} [options]\n * @param {Object} [options.contractAddressToName] Map of contract addresses to their names\n * @return {String} Contract name\n * @throws {MissingEventDefinitionError}\n * @throws {AmbiguousEventDefinitionError}\n */\n function getContractNameByEvent (address, nameHash, { contractAddressToName }) {\n const addressToName = { ...instance.options.contractAddressToName, ...contractAddressToName }\n if (addressToName[address]) return addressToName[address]\n\n const matchedEvents = [\n instance._aci.encoded_aci,\n ...instance._aci.external_encoded_aci\n ]\n .filter(({ contract }) => contract?.event)\n .map(({ contract }) => [contract.name, contract.event.variant])\n .map(([name, events]) => events.map(event => [name, Object.keys(event)[0]]))\n .flat()\n .filter(([, eventName]) => BigInt('0x' + hash(eventName).toString('hex')) === nameHash)\n switch (matchedEvents.length) {\n case 0: throw new MissingEventDefinitionError(nameHash, address)\n case 1: return matchedEvents[0][0]\n default: throw new AmbiguousEventDefinitionError(address, matchedEvents)\n }\n }\n\n /**\n * Decode Events\n * @alias module:@aeternity/aepp-sdk/es/contract/aci\n * @rtype (events: Array) => DecodedEvents: Array\n * @param {Array} events Array of encoded events (callRes.result.log)\n * @param {Object} [options]\n * @param {Boolean} [options.omitUnknown] Omit events that can't be decoded in case ACI is not\n * complete\n * @return {Object} DecodedEvents\n */\n instance.decodeEvents = (events, { omitUnknown, ...opt } = {}) => events\n .map(event => {\n const topics = event.topics.map(t => BigInt(t))\n let contractName\n try {\n contractName = getContractNameByEvent(event.address, topics[0], opt)\n } catch (error) {\n if (omitUnknown && error instanceof MissingEventDefinitionError) return null\n throw error\n }\n const decoded = instance.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 })\n .filter(e => e)\n\n /**\n * Generate proto function based on contract function using Contract ACI schema\n * All function can be called like:\n * 'await contract.methods.testFunction()' -> 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 * `await contract.methods.testFunction.get()` -> use call-static(dry-run)\n * `await contract.methods.testFunction.send()` -> send tx on-chain\n */\n instance.methods = Object.fromEntries(instance._aci.encoded_aci.contract.functions\n .map(({ name, arguments: aciArgs, stateful }) => {\n const genHandler = callStatic => (...args) => {\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 instance.deploy(args, { callStatic, ...options })\n return instance.call(name, args, { callStatic, ...options })\n }\n return [\n name,\n Object.assign(\n genHandler(name === 'init' ? false : !stateful),\n {\n get: genHandler(true),\n send: genHandler(false)\n }\n )\n ]\n })\n )\n\n return instance\n}\n"],"file":"aci.mjs"}
1
+ {"version":3,"file":"aci.mjs","names":["DRY_RUN_ACCOUNT","AMOUNT","Tag","buildContractIdByContractTx","unpackTx","_buildTx","send","decode","MissingContractDefError","MissingContractAddressError","InactiveContractError","BytecodeMismatchError","DuplicateContractError","MissingFunctionNameError","InvalidMethodInvocationError","NotPayableFunctionError","TypeError","NodeInvocationError","IllegalArgumentError","NoSuchContractFunctionError","MissingEventDefinitionError","AmbiguousEventDefinitionError","UnexpectedTsError","InternalError","hash","calcHash","getAccount","getContract","getContractByteCode","getKeyBlock","resolveName","txDryRun","getContractInstance","onAccount","onCompiler","onNode","source","bytecode","aci","_aci","contractAddress","fileSystem","validateBytecode","otherOptions","generateACI","code","options","resolveByNode","contract","active","instance","_name","encodedAci","name","calldata","Calldata","externalEncodedAci","deployInfo","address","amount","callStatic","compile","_options","_estimateGas","_params","deploy","call","_fn","decodeEvents","_events","methods","undefined","onChanBytecode","isValid","validateByteCode","then","compileContract","handleCallError","transaction","returnType","returnValue","message","decodeFateString","toString","sendAndProcess","tx","txData","result","rawTx","blockHeight","callInfo","getTransactionInfoByHash","Object","assign","params","gasUsed","Math","floor","opt","ownerId","ContractCreateTx","gasLimit","callData","encode","contractId","freeze","owner","getFunctionACI","fn","functions","find","f","payable","fnACI","callerId","Promise","resolve","catch","error","pub","res","top","txOpt","nonce","ContractCallTx","callObj","dryRunOther","decodedResult","returns","decodedEvents","log","getContractNameByEvent","nameHash","contractAddressToName","addressToName","matchedEvents","filter","event","map","variant","events","keys","flat","eventName","BigInt","length","omitUnknown","topics","t","contractName","decoded","decodeEvent","data","args","entries","e","fromEntries","arguments","aciArgs","stateful","genHandler","pop","get"],"sources":["../../src/contract/aci.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// @ts-expect-error TODO remove\nimport { Encoder as Calldata } from '@aeternity/aepp-calldata';\nimport { DRY_RUN_ACCOUNT, AMOUNT } from '../tx/builder/schema';\nimport { Tag, AensName } from '../tx/builder/constants';\nimport { buildContractIdByContractTx, unpackTx } from '../tx/builder';\nimport { _buildTx } from '../tx';\nimport { send } 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} from '../utils/errors';\nimport { hash as calcHash } from '../utils/crypto';\nimport { Aci as BaseAci } from '../apis/compiler';\nimport { ContractCallReturnType } from '../apis/node';\nimport Compiler from './Compiler';\nimport Node from '../Node';\nimport {\n getAccount, getContract, getContractByteCode, getKeyBlock, resolveName, txDryRun,\n} from '../chain';\nimport AccountBase from '../account/Base';\n\ninterface FunctionACI {\n arguments: any[];\n name: string;\n payable: boolean;\n returns: string;\n stateful: boolean;\n}\n\ninterface Aci extends BaseAci {\n encodedAci: {\n contract: {\n name: string;\n event: any;\n kind: string;\n state: any;\n type_defs: any[];\n functions: FunctionACI[];\n };\n };\n externalEncodedAci: any[];\n}\n\ninterface Event {\n address: Encoded.ContractAddress;\n data: string;\n topics: Array<string | number>;\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\nexport interface ContractInstance {\n _aci: Aci;\n _name: string;\n calldata: any;\n source?: string;\n bytecode?: Encoded.ContractBytearray;\n deployInfo: {\n address?: Encoded.ContractAddress;\n result?: {\n callerId: string;\n callerNonce: string;\n contractId: string;\n gasPrice: bigint;\n gasUsed: number;\n height: number;\n log: any[];\n returnType: ContractCallReturnType;\n returnValue: string;\n };\n owner?: Encoded.AccountAddress;\n transaction?: string;\n rawTx?: string;\n txData?: TxData;\n };\n options: any;\n compile: (options?: {}) => Promise<Encoded.ContractBytearray>;\n _estimateGas: (name: string, params: any[], options: object) => Promise<number>;\n deploy: (params?: any[], options?: object) => Promise<any>;\n call: (fn: string, params?: any[], options?: {}) => Promise<{\n hash: string;\n tx: any;\n txData: TxData;\n rawTx: string;\n result: {\n callerId: Encoded.AccountAddress;\n callerNonce: number;\n contractId: Encoded.ContractAddress;\n gasPrice: number;\n gasUsed: number;\n height: number;\n log: any[];\n returnType: ContractCallReturnType;\n returnValue: string;\n };\n decodedResult: any;\n decodedEvents: DecodedEvent[];\n }>;\n decodeEvents: (\n events: Event[], options?: { omitUnknown?: boolean; contractAddressToName?: any }\n ) => DecodedEvent[];\n methods: any;\n}\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.getContractInstance({ source })\n * await contractIns.deploy([321]) or await contractIns.methods.init(321)\n * const callResult = await contractIns.call('setState', [123]) or\n * await contractIns.methods.setState.send(123, options)\n * const staticCallResult = await contractIns.call('setState', [123], { callStatic: true }) or\n * await contractIns.methods.setState.get(123, options)\n * ```\n * Also you can call contract like: `await contractIns.methods.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 */\nexport default async function getContractInstance({\n onAccount,\n onCompiler,\n onNode,\n source,\n bytecode,\n aci: _aci,\n contractAddress,\n fileSystem = {},\n validateBytecode,\n ...otherOptions\n}: {\n onAccount?: AccountBase;\n onCompiler: Compiler;\n onNode: Node;\n source?: string;\n bytecode?: Encoded.ContractBytearray;\n aci?: Aci;\n contractAddress?: Encoded.ContractAddress | AensName;\n fileSystem?: Record<string, string>;\n validateBytecode?: boolean;\n [key: string]: any;\n}): Promise<ContractInstance> {\n if (_aci == null && source != null) {\n // TODO: should be fixed when the compiledAci interface gets updated\n _aci = await onCompiler.generateACI({ code: source, options: { fileSystem } }) as Aci;\n }\n if (_aci == null) throw new MissingContractDefError();\n\n if (contractAddress != null) {\n contractAddress = await resolveName(\n contractAddress,\n 'contract_pubkey',\n { resolveByNode: true, onNode },\n ) as Encoded.ContractAddress;\n }\n\n if (contractAddress == null && source == null && bytecode == null) {\n throw new MissingContractAddressError('Can\\'t create instance by ACI without address');\n }\n\n if (contractAddress != null) {\n const contract = await getContract(contractAddress, { onNode });\n if (contract.active == null) throw new InactiveContractError(contractAddress);\n }\n\n const instance: ContractInstance = {\n _aci,\n _name: _aci.encodedAci.contract.name,\n calldata: new Calldata([_aci.encodedAci, ..._aci.externalEncodedAci]),\n source,\n bytecode,\n deployInfo: { address: contractAddress },\n options: {\n onAccount,\n onCompiler,\n onNode,\n amount: AMOUNT,\n callStatic: false,\n fileSystem,\n ...otherOptions,\n },\n /* eslint-disable @typescript-eslint/no-unused-vars */\n /* eslint-disable @typescript-eslint/no-empty-function */\n async compile(_options?: {}): Promise<any> {},\n async _estimateGas(_name: string, _params: any[], _options: object): Promise<any> {},\n async deploy(_params?: any[], _options?: any): Promise<any> {},\n async call(_fn: string, _params?: any[], _options?: {}): Promise<any> {},\n decodeEvents(_events: Event[], options?: { omitUnknown?: boolean }): any {},\n /* eslint-enable @typescript-eslint/no-unused-vars */\n /* eslint-enable @typescript-eslint/no-empty-function */\n methods: undefined,\n };\n\n if (validateBytecode != null) {\n if (contractAddress == null) throw new MissingContractAddressError('Can\\'t validate bytecode without contract address');\n const onChanBytecode = (await getContractByteCode(contractAddress, { onNode })).bytecode;\n const isValid: boolean = source != null\n ? await onCompiler.validateByteCode(\n { bytecode: onChanBytecode, source, options: instance.options },\n ).then(() => true, () => false)\n : bytecode === onChanBytecode;\n if (!isValid) throw new BytecodeMismatchError(source != null ? 'source' : 'bytecode');\n }\n\n /**\n * Compile contract\n * @returns bytecode\n */\n instance.compile = async (options = {}): Promise<Encoded.ContractBytearray> => {\n if (instance.bytecode != null) throw new IllegalArgumentError('Contract already compiled');\n if (instance.source == null) throw new IllegalArgumentError('Can\\'t compile without source code');\n instance.bytecode = (await onCompiler.compileContract({\n code: instance.source, options: { ...instance.options, ...options },\n })).bytecode as Encoded.ContractBytearray;\n return instance.bytecode;\n };\n\n const 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 = instance.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 const sendAndProcess = async (tx: Encoded.Transaction, options: any): Promise<{\n result?: ContractInstance['deployInfo']['result'];\n hash: TxData['hash'];\n tx: Awaited<ReturnType<typeof unpackTx<Tag.ContractCallTx | Tag.ContractCreateTx>>>;\n txData: TxData;\n rawTx: Encoded.Transaction;\n }> => {\n options = { ...instance.options, ...options };\n const txData = await send(tx, 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 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 handleCallError(callInfo, tx);\n return { ...result, result: callInfo };\n };\n\n instance._estimateGas = async (name: string, params: any[], options: object): Promise<number> => {\n const { result: { gasUsed } } = await instance\n .call(name, params, { ...options, callStatic: true });\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 instance.deploy = async (\n params = [],\n options?:\n Parameters<typeof instance.compile>[0] &\n Parameters<typeof instance.call>[2] &\n Parameters<AccountBase['address']>[0] &\n Parameters<typeof sendAndProcess>[1],\n ): Promise<ContractInstance['deployInfo']> => {\n const opt = { ...instance.options, ...options };\n if (instance.bytecode == null) await instance.compile(opt);\n // @ts-expect-error TODO: need to fix compatibility between return types of `deploy` and `call`\n if (opt.callStatic === true) return instance.call('init', params, opt);\n if (instance.deployInfo.address != null) throw new DuplicateContractError();\n\n const ownerId = await opt.onAccount.address(options);\n const tx = await _buildTx(Tag.ContractCreateTx, {\n ...opt,\n gasLimit: opt.gasLimit ?? await instance._estimateGas('init', params, opt),\n callData: instance.calldata.encode(instance._name, 'init', params),\n code: instance.bytecode,\n ownerId,\n onNode,\n });\n const contractId = buildContractIdByContractTx(tx);\n const {\n hash, rawTx, result, txData,\n } = await sendAndProcess(tx, opt);\n instance.deployInfo = Object.freeze({\n result,\n owner: ownerId,\n transaction: hash,\n rawTx,\n txData,\n address: contractId,\n });\n return instance.deployInfo;\n };\n\n /**\n * Get function schema from contract ACI object\n * @param name - Function name\n * @returns function ACI\n */\n function getFunctionACI(name: string): Partial<FunctionACI> {\n const fn = instance._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 instance.call = async (fn: string, params: any[] = [], options: object = {}) => {\n const opt = { ...instance.options, ...options };\n const fnACI = getFunctionACI(fn);\n const contractId = instance.deployInfo.address;\n\n if (fn == null) throw new MissingFunctionNameError();\n if (fn === 'init' && opt.callStatic === false) throw new InvalidMethodInvocationError('\"init\" can be called only via dryRun');\n if (contractId == null && fn !== 'init') throw new InvalidMethodInvocationError('You need to deploy contract before calling!');\n if (fn !== 'init' && opt.amount > 0 && fnACI.payable === false) throw new NotPayableFunctionError(opt.amount, fn);\n\n const callerId = await Promise.resolve()\n .then(() => opt.onAccount.address(opt))\n .catch((error: any) => {\n if (opt.callStatic === true) return DRY_RUN_ACCOUNT.pub;\n throw error;\n }) as Encoded.AccountAddress;\n const callData = instance.calldata.encode(instance._name, fn, params);\n\n let res: any;\n if (opt.callStatic === true) {\n if (typeof opt.top === 'number') {\n opt.top = (await getKeyBlock(opt.top, { onNode })).hash;\n }\n const txOpt = { ...opt, onNode, callData };\n if (opt.nonce == null && opt.top != null) {\n opt.nonce = (await getAccount(callerId, { hash: opt.top, onNode })).nonce + 1;\n }\n const tx = await (fn === 'init'\n ? _buildTx(Tag.ContractCreateTx, { ...txOpt, code: instance.bytecode, ownerId: callerId })\n : _buildTx(Tag.ContractCallTx, { ...txOpt, callerId, contractId }));\n\n const { callObj, ...dryRunOther } = await txDryRun(tx, callerId, { onNode, ...opt });\n if (callObj == null) throw new UnexpectedTsError();\n 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 const tx = await _buildTx(Tag.ContractCallTx, {\n ...opt,\n onNode,\n gasLimit: opt.gasLimit ?? await instance._estimateGas(fn, params, opt),\n callerId,\n contractId,\n callData,\n });\n res = await sendAndProcess(tx, opt);\n }\n if (opt.callStatic === true || res.txData.blockHeight != null) {\n res.decodedResult = fnACI.returns != null && fnACI.returns !== 'unit' && fn !== 'init'\n && instance.calldata.decode(instance._name, fn, res.result.returnValue);\n res.decodedEvents = instance.decodeEvents(res.result.log, opt);\n }\n return res;\n };\n\n /**\n * @param address - 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 function getContractNameByEvent(\n address: Encoded.ContractAddress,\n nameHash: BigInt,\n { contractAddressToName }: {\n contractAddressToName?: { [key: Encoded.ContractAddress]: string };\n },\n ): string {\n const addressToName = { ...instance.options.contractAddressToName, ...contractAddressToName };\n if (addressToName[address] != null) return addressToName[address];\n\n const matchedEvents = [\n instance._aci.encodedAci,\n ...instance._aci.externalEncodedAci,\n ]\n .filter(({ contract }) => contract?.event)\n .map(({ contract }) => [contract.name, contract.event.variant])\n .map(([name, events]) => events.map((event: {}) => [name, Object.keys(event)[0]]))\n .flat()\n .filter(([, eventName]) => BigInt(`0x${calcHash(eventName).toString('hex')}`) === nameHash);\n switch (matchedEvents.length) {\n case 0: throw new MissingEventDefinitionError(nameHash.toString(), address);\n case 1: return matchedEvents[0][0];\n default: throw new AmbiguousEventDefinitionError(address, 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 instance.decodeEvents = (\n events: Event[],\n { omitUnknown, ...opt }: { omitUnknown?: boolean } = {},\n ): DecodedEvent[] => events\n .map((event) => {\n const topics = event.topics.map((t: string | number) => BigInt(t));\n let contractName;\n try {\n contractName = 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 = instance.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 * Generate proto function based on contract function using Contract ACI schema\n * All function can be called like:\n * ```js\n * await contract.methods.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.methods.testFunction.get() // use call-static (dry-run)\n * await contract.methods.testFunction.send() // send tx on-chain\n * ```\n */\n instance.methods = Object.fromEntries(instance._aci.encodedAci.contract.functions\n .map(({ name, arguments: aciArgs, stateful }: FunctionACI) => {\n const genHandler = (callStatic: boolean) => 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 as string}`);\n if (name === 'init') return instance.deploy(args, { callStatic, ...options });\n return instance.call(name, args, { callStatic, ...options });\n };\n return [\n name,\n Object.assign(\n genHandler(name === 'init' ? false : !stateful),\n {\n get: genHandler(true),\n send: genHandler(false),\n },\n ),\n ];\n }));\n\n return instance;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAoC,0BAApC;;;;SACSA,e,EAAiBC,M;SACjBC,G;SACAC,2B,EAA6BC,Q;SAC7BC,Q;SACAC,I;SACAC,M;SAEPC,uB,EACAC,2B,EACAC,qB,EACAC,qB,EACAC,sB,EACAC,wB,EACAC,4B,EACAC,uB,EACAC,S,EACAC,mB,EACAC,oB,EACAC,2B,EACAC,2B,EACAC,6B,EACAC,iB,EACAC,a;SAEOC,IAAI,IAAIC,Q;SAMfC,U,EAAYC,W,EAAaC,mB,EAAqBC,W,EAAaC,W,EAAaC,Q;;AAgG1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAeC,mBAAf,OAsBe;EAAA,IAtBoB;IAChDC,SADgD;IAEhDC,UAFgD;IAGhDC,MAHgD;IAIhDC,MAJgD;IAKhDC,QALgD;IAMhDC,GAAG,EAAEC,IAN2C;IAOhDC,eAPgD;IAQhDC,UAAU,GAAG,E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AA+B8B,OAAkB,EAAhE,CAAN;MACjC,IAAIO,IAAI,KAAK,MAAb,EAAqB,OAAOH,QAAQ,CAACe,MAAT,CAAgBwF,IAAhB,EAAsB;QAAE7F,UAAF;QAAc,GAAGd;MAAjB,CAAtB,CAAP;MACrB,OAAOI,QAAQ,CAACgB,IAAT,CAAcb,IAAd,EAAoBoG,IAApB,EAA0B;QAAE7F,UAAF;QAAc,GAAGd;MAAjB,CAA1B,CAAP;IACD,CALD;;IAMA,OAAO,CACLO,IADK,EAELuC,MAAM,CAACC,MAAP,CACEmE,UAAU,CAAC3G,IAAI,KAAK,MAAT,GAAkB,KAAlB,GAA0B,CAAC0G,QAA5B,CADZ,EAEE;MACEG,GAAG,EAAEF,UAAU,CAAC,IAAD,CADjB;MAEE1J,IAAI,EAAE0J,UAAU,CAAC,KAAD;IAFlB,CAFF,CAFK,CAAP;EAUD,CAlBmC,CAAnB,CAAnB;EAoBA,OAAO9G,QAAP;AACD"}
@@ -0,0 +1,69 @@
1
+ import { Tag } from '../tx/builder/constants';
2
+ import { BuildTxOptions } from '../tx';
3
+ import { Encoded } from '../utils/encoder';
4
+ import AccountBase from '../account/Base';
5
+ import { SendOptions } from '../spend';
6
+ import Node from '../Node';
7
+ import { getAccount } from '../chain';
8
+ import Compiler from './Compiler';
9
+ /**
10
+ * Check if account is GA
11
+ * @category contract
12
+ * @param address - Account address
13
+ * @param options - Options
14
+ * @returns if account is GA
15
+ */
16
+ export declare function isGA(address: Encoded.AccountAddress, options: Parameters<typeof getAccount>[1]): Promise<boolean>;
17
+ /**
18
+ * Convert current account to GA
19
+ * @category contract
20
+ * @param authFnName - Authorization function name
21
+ * @param source - Auth contract source code
22
+ * @param args - init arguments
23
+ * @param options - Options
24
+ * @returns General Account Object
25
+ */
26
+ export declare function createGeneralizedAccount(authFnName: string, source: string, args: any[], { onAccount, onCompiler, onNode, ...options }: CreateGeneralizedAccountOptions): Promise<Readonly<{
27
+ owner: Encoded.AccountAddress;
28
+ transaction: Encoded.TxHash;
29
+ rawTx: Encoded.Transaction;
30
+ gaContractId: Encoded.ContractAddress;
31
+ }>>;
32
+ interface CreateGeneralizedAccountOptions extends BuildTxOptions<Tag.GaAttachTx, 'authFun' | 'callData' | 'code' | 'ownerId' | 'gasLimit'>, SendOptions {
33
+ onAccount: AccountBase;
34
+ onCompiler: Compiler;
35
+ onNode: Node;
36
+ gasLimit?: number;
37
+ }
38
+ /**
39
+ * Create a metaTx transaction
40
+ * @category contract
41
+ * @param rawTransaction - Inner transaction
42
+ * @param authData - Object with gaMeta params
43
+ * @param authFnName - Authorization function name
44
+ * @param options - Options
45
+ * @param options.onAccount - Account to use
46
+ * @returns Transaction string
47
+ */
48
+ export declare function createMetaTx(rawTransaction: Encoded.Transaction, authData: {
49
+ gasLimit?: number;
50
+ callData?: Encoded.ContractBytearray;
51
+ source?: string;
52
+ args?: any[];
53
+ }, authFnName: string, { onAccount, onCompiler, onNode, ...options }: {
54
+ onAccount: AccountBase;
55
+ onCompiler: Compiler;
56
+ onNode: Node;
57
+ } & Parameters<AccountBase['address']>[0]): Promise<Encoded.Transaction>;
58
+ /**
59
+ * Build a transaction hash the same as `Auth.tx_hash`
60
+ * @category contract
61
+ * @param transaction - tx-encoded transaction
62
+ * @param options - Options
63
+ * @param options.onNode - Node to use
64
+ * @returns Transaction hash
65
+ */
66
+ export declare function buildAuthTxHash(transaction: Encoded.Transaction, { onNode }: {
67
+ onNode: Node;
68
+ }): Promise<Uint8Array>;
69
+ export {};
@@ -0,0 +1,195 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+
6
+ /*
7
+ * ISC License (ISC)
8
+ * Copyright (c) 2022 aeternity developers
9
+ *
10
+ * Permission to use, copy, modify, and/or distribute this software for any
11
+ * purpose with or without fee is hereby granted, provided that the above
12
+ * copyright notice and this permission notice appear in all copies.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16
+ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
+ * PERFORMANCE OF THIS SOFTWARE.
21
+ */
22
+
23
+ /**
24
+ * Generalized Account module - routines to use generalized account
25
+ */
26
+ import { MAX_AUTH_FUN_GAS } from "../tx/builder/schema.mjs";
27
+ import { Tag } from "../tx/builder/constants.mjs";
28
+ import { buildContractIdByContractTx, buildTx, unpackTx } from "../tx/builder/index.mjs";
29
+ import { _buildTx, getVmVersion, prepareTxParams } from "../tx/index.mjs";
30
+ import { hash } from "../utils/crypto.mjs";
31
+ import { decode } from "../utils/encoder.mjs";
32
+ import { IllegalArgumentError, MissingParamError, InvalidAuthDataError } from "../utils/errors.mjs";
33
+ import { concatBuffers } from "../utils/other.mjs";
34
+ import { getContractInstance } from "./methods.mjs";
35
+ import { send } from "../spend.mjs";
36
+ import { getAccount } from "../chain.mjs";
37
+
38
+ /**
39
+ * Check if account is GA
40
+ * @category contract
41
+ * @param address - Account address
42
+ * @param options - Options
43
+ * @returns if account is GA
44
+ */
45
+ export async function isGA(address, options) {
46
+ const {
47
+ contractId
48
+ } = await getAccount(address, options);
49
+ return contractId != null;
50
+ }
51
+ /**
52
+ * Convert current account to GA
53
+ * @category contract
54
+ * @param authFnName - Authorization function name
55
+ * @param source - Auth contract source code
56
+ * @param args - init arguments
57
+ * @param options - Options
58
+ * @returns General Account Object
59
+ */
60
+
61
+ export async function createGeneralizedAccount(authFnName, source, args, _ref) {
62
+ var _options$gasLimit;
63
+
64
+ let {
65
+ onAccount,
66
+ onCompiler,
67
+ onNode,
68
+ ...options
69
+ } = _ref;
70
+ const ownerId = await onAccount.address(options);
71
+ if (await isGA(ownerId, {
72
+ onNode
73
+ })) throw new IllegalArgumentError(`Account ${ownerId} is already GA`);
74
+ const contract = await getContractInstance({
75
+ onAccount,
76
+ onCompiler,
77
+ onNode,
78
+ source
79
+ });
80
+ const tx = await _buildTx(Tag.GaAttachTx, { ...options,
81
+ onNode,
82
+ code: await contract.compile(),
83
+ gasLimit: (_options$gasLimit = options.gasLimit) !== null && _options$gasLimit !== void 0 ? _options$gasLimit : await contract._estimateGas('init', args, options),
84
+ ownerId,
85
+ callData: contract.calldata.encode(contract._name, 'init', args),
86
+ authFun: hash(authFnName)
87
+ });
88
+ const contractId = buildContractIdByContractTx(tx);
89
+ const {
90
+ hash: transaction,
91
+ rawTx
92
+ } = await send(tx, {
93
+ onNode,
94
+ onAccount,
95
+ onCompiler,
96
+ ...options
97
+ });
98
+ return Object.freeze({
99
+ owner: ownerId,
100
+ transaction,
101
+ rawTx,
102
+ gaContractId: contractId
103
+ });
104
+ }
105
+
106
+ /**
107
+ * Create a metaTx transaction
108
+ * @category contract
109
+ * @param rawTransaction - Inner transaction
110
+ * @param authData - Object with gaMeta params
111
+ * @param authFnName - Authorization function name
112
+ * @param options - Options
113
+ * @param options.onAccount - Account to use
114
+ * @returns Transaction string
115
+ */
116
+ export async function createMetaTx(rawTransaction, authData, authFnName, _ref2) {
117
+ var _authData$gasLimit, _authData$callData;
118
+
119
+ let {
120
+ onAccount,
121
+ onCompiler,
122
+ onNode,
123
+ ...options
124
+ } = _ref2;
125
+
126
+ const wrapInEmptySignedTx = tx => buildTx({
127
+ encodedTx: tx,
128
+ signatures: []
129
+ }, Tag.SignedTx);
130
+
131
+ if (Object.keys(authData).length <= 0) throw new MissingParamError('authData is required');
132
+ const gasLimit = (_authData$gasLimit = authData.gasLimit) !== null && _authData$gasLimit !== void 0 ? _authData$gasLimit : MAX_AUTH_FUN_GAS;
133
+
134
+ if (gasLimit > MAX_AUTH_FUN_GAS) {
135
+ throw new InvalidAuthDataError(`the maximum gasLimit value for ga authFun is ${MAX_AUTH_FUN_GAS}, got ${gasLimit}`);
136
+ }
137
+
138
+ const authCallData = (_authData$callData = authData.callData) !== null && _authData$callData !== void 0 ? _authData$callData : await (async () => {
139
+ if (authData.source == null || authData.args == null) throw new InvalidAuthDataError('Auth data must contain source code and arguments.');
140
+ const contract = await getContractInstance({
141
+ onCompiler,
142
+ onNode,
143
+ source: authData.source
144
+ });
145
+ return contract.calldata.encode(contract._name, authFnName, authData.args);
146
+ })();
147
+ const {
148
+ abiVersion
149
+ } = await getVmVersion(Tag.ContractCallTx, {
150
+ onNode
151
+ });
152
+ const wrappedTx = wrapInEmptySignedTx(unpackTx(rawTransaction));
153
+ const params = { ...options,
154
+ tx: { ...wrappedTx,
155
+ tx: wrappedTx.txObject
156
+ },
157
+ // TODO: accept an address instead
158
+ gaId: await onAccount.address(options),
159
+ abiVersion,
160
+ authData: authCallData,
161
+ gasLimit,
162
+ vsn: 2
163
+ }; // @ts-expect-error createMetaTx needs to be integrated into tx builder
164
+
165
+ const {
166
+ fee
167
+ } = await prepareTxParams(Tag.GaMetaTx, { ...params,
168
+ onNode
169
+ });
170
+ const {
171
+ rlpEncoded: metaTxRlp
172
+ } = buildTx({ ...params,
173
+ fee
174
+ }, Tag.GaMetaTx);
175
+ return wrapInEmptySignedTx(metaTxRlp).tx;
176
+ }
177
+ /**
178
+ * Build a transaction hash the same as `Auth.tx_hash`
179
+ * @category contract
180
+ * @param transaction - tx-encoded transaction
181
+ * @param options - Options
182
+ * @param options.onNode - Node to use
183
+ * @returns Transaction hash
184
+ */
185
+
186
+ export async function buildAuthTxHash(transaction, _ref3) {
187
+ let {
188
+ onNode
189
+ } = _ref3;
190
+ const {
191
+ networkId
192
+ } = await onNode.getStatus();
193
+ return new Uint8Array(hash(concatBuffers([_Buffer.from(networkId), decode(transaction)])));
194
+ }
195
+ //# sourceMappingURL=ga.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ga.mjs","names":["MAX_AUTH_FUN_GAS","Tag","buildContractIdByContractTx","buildTx","unpackTx","_buildTx","getVmVersion","prepareTxParams","hash","decode","IllegalArgumentError","MissingParamError","InvalidAuthDataError","concatBuffers","getContractInstance","send","getAccount","isGA","address","options","contractId","createGeneralizedAccount","authFnName","source","args","onAccount","onCompiler","onNode","ownerId","contract","tx","GaAttachTx","code","compile","gasLimit","_estimateGas","callData","calldata","encode","_name","authFun","transaction","rawTx","Object","freeze","owner","gaContractId","createMetaTx","rawTransaction","authData","wrapInEmptySignedTx","encodedTx","signatures","SignedTx","keys","length","authCallData","abiVersion","ContractCallTx","wrappedTx","params","txObject","gaId","vsn","fee","GaMetaTx","rlpEncoded","metaTxRlp","buildAuthTxHash","networkId","getStatus","Uint8Array","from"],"sources":["../../src/contract/ga.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 * Generalized Account module - routines to use generalized account\n */\n\nimport { MAX_AUTH_FUN_GAS, TxSchema } from '../tx/builder/schema';\nimport { Tag } from '../tx/builder/constants';\nimport {\n buildContractIdByContractTx, buildTx, BuiltTx, TxUnpacked, unpackTx,\n} from '../tx/builder';\nimport {\n _buildTx, BuildTxOptions, getVmVersion, prepareTxParams,\n} from '../tx';\nimport { hash } from '../utils/crypto';\nimport { decode, Encoded, Encoding } from '../utils/encoder';\nimport { IllegalArgumentError, MissingParamError, InvalidAuthDataError } from '../utils/errors';\nimport { concatBuffers } from '../utils/other';\nimport AccountBase from '../account/Base';\nimport { getContractInstance } from './methods';\nimport { send, SendOptions } from '../spend';\nimport Node from '../Node';\nimport { getAccount } from '../chain';\nimport Compiler from './Compiler';\n\n/**\n * Check if account is GA\n * @category contract\n * @param address - Account address\n * @param options - Options\n * @returns if account is GA\n */\nexport async function isGA(\n address: Encoded.AccountAddress,\n options: Parameters<typeof getAccount>[1],\n): Promise<boolean> {\n const { contractId } = await getAccount(address, options);\n return contractId != null;\n}\n\n/**\n * Convert current account to GA\n * @category contract\n * @param authFnName - Authorization function name\n * @param source - Auth contract source code\n * @param args - init arguments\n * @param options - Options\n * @returns General Account Object\n */\nexport async function createGeneralizedAccount(\n authFnName: string,\n source: string,\n args: any[],\n {\n onAccount, onCompiler, onNode, ...options\n }: CreateGeneralizedAccountOptions,\n): Promise<Readonly<{\n owner: Encoded.AccountAddress;\n transaction: Encoded.TxHash;\n rawTx: Encoded.Transaction;\n gaContractId: Encoded.ContractAddress;\n }>> {\n const ownerId = await onAccount.address(options);\n if (await isGA(ownerId, { onNode })) throw new IllegalArgumentError(`Account ${ownerId} is already GA`);\n\n const contract = await getContractInstance({\n onAccount, onCompiler, onNode, source,\n });\n\n const tx = await _buildTx(Tag.GaAttachTx, {\n ...options,\n onNode,\n code: await contract.compile(),\n gasLimit: options.gasLimit ?? await contract._estimateGas('init', args, options),\n ownerId,\n callData: contract.calldata.encode(contract._name, 'init', args),\n authFun: hash(authFnName),\n });\n const contractId = buildContractIdByContractTx(tx);\n const { hash: transaction, rawTx } = await send(tx, {\n onNode, onAccount, onCompiler, ...options,\n });\n\n return Object.freeze({\n owner: ownerId,\n transaction,\n rawTx,\n gaContractId: contractId,\n });\n}\n\ninterface CreateGeneralizedAccountOptions extends\n BuildTxOptions<Tag.GaAttachTx, 'authFun' | 'callData' | 'code' | 'ownerId' | 'gasLimit'>,\n SendOptions {\n onAccount: AccountBase;\n onCompiler: Compiler;\n onNode: Node;\n gasLimit?: number;\n}\n\n/**\n * Create a metaTx transaction\n * @category contract\n * @param rawTransaction - Inner transaction\n * @param authData - Object with gaMeta params\n * @param authFnName - Authorization function name\n * @param options - Options\n * @param options.onAccount - Account to use\n * @returns Transaction string\n */\nexport async function createMetaTx(\n rawTransaction: Encoded.Transaction,\n authData: {\n gasLimit?: number;\n callData?: Encoded.ContractBytearray;\n source?: string;\n args?: any[];\n },\n authFnName: string,\n {\n onAccount, onCompiler, onNode, ...options\n }:\n { onAccount: AccountBase; onCompiler: Compiler; onNode: Node }\n & Parameters<AccountBase['address']>[0],\n): Promise<Encoded.Transaction> {\n const wrapInEmptySignedTx = (\n tx: Encoded.Transaction | Uint8Array | TxUnpacked<TxSchema>,\n ): BuiltTx<TxSchema, Encoding.Transaction> => (\n buildTx({ encodedTx: tx, signatures: [] }, Tag.SignedTx)\n );\n\n if (Object.keys(authData).length <= 0) throw new MissingParamError('authData is required');\n\n const gasLimit = authData.gasLimit ?? MAX_AUTH_FUN_GAS;\n if (gasLimit > MAX_AUTH_FUN_GAS) {\n throw new InvalidAuthDataError(`the maximum gasLimit value for ga authFun is ${MAX_AUTH_FUN_GAS}, got ${gasLimit}`);\n }\n\n const authCallData = authData.callData ?? await (async () => {\n if (authData.source == null || authData.args == null) throw new InvalidAuthDataError('Auth data must contain source code and arguments.');\n const contract = await getContractInstance({\n onCompiler, onNode, source: authData.source,\n });\n return contract.calldata.encode(contract._name, authFnName, authData.args);\n })();\n\n const { abiVersion } = await getVmVersion(Tag.ContractCallTx, { onNode });\n const wrappedTx = wrapInEmptySignedTx(unpackTx<Tag.SignedTx>(rawTransaction));\n const params = {\n ...options,\n tx: {\n ...wrappedTx,\n tx: wrappedTx.txObject,\n },\n // TODO: accept an address instead\n gaId: await onAccount.address(options),\n abiVersion,\n authData: authCallData,\n gasLimit,\n vsn: 2,\n };\n // @ts-expect-error createMetaTx needs to be integrated into tx builder\n const { fee } = await prepareTxParams(Tag.GaMetaTx, { ...params, onNode });\n const { rlpEncoded: metaTxRlp } = buildTx({ ...params, fee }, Tag.GaMetaTx);\n return wrapInEmptySignedTx(metaTxRlp).tx;\n}\n\n/**\n * Build a transaction hash the same as `Auth.tx_hash`\n * @category contract\n * @param transaction - tx-encoded transaction\n * @param options - Options\n * @param options.onNode - Node to use\n * @returns Transaction hash\n */\nexport async function buildAuthTxHash(\n transaction: Encoded.Transaction,\n { onNode }: { onNode: Node },\n): Promise<Uint8Array> {\n const { networkId } = await onNode.getStatus();\n return new Uint8Array(hash(\n concatBuffers([Buffer.from(networkId), decode(transaction)]),\n ));\n}\n"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;SAESA,gB;SACAC,G;SAEPC,2B,EAA6BC,O,EAA8BC,Q;SAG3DC,Q,EAA0BC,Y,EAAcC,e;SAEjCC,I;SACAC,M;SACAC,oB,EAAsBC,iB,EAAmBC,oB;SACzCC,a;SAEAC,mB;SACAC,I;SAEAC,U;;AAGT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,IAAf,CACLC,OADK,EAELC,OAFK,EAGa;EAClB,MAAM;IAAEC;EAAF,IAAiB,MAAMJ,UAAU,CAACE,OAAD,EAAUC,OAAV,CAAvC;EACA,OAAOC,UAAU,IAAI,IAArB;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,eAAeC,wBAAf,CACLC,UADK,EAELC,MAFK,EAGLC,IAHK,QAYD;EAAA;;EAAA,IARJ;IACEC,SADF;IACaC,UADb;IACyBC,MADz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Y,CAACL,GAAG,CAACyD,cAAL,EAAqB;IAAE/B;EAAF,CAArB,CAAzC;EACA,MAAMgC,SAAS,GAAGT,mBAAmB,CAAC9C,QAAQ,CAAe4C,cAAf,CAAT,CAArC;EACA,MAAMY,MAAM,GAAG,EACb,GAAGzC,OADU;IAEbW,EAAE,EAAE,EACF,GAAG6B,SADD;MAEF7B,EAAE,EAAE6B,SAAS,CAACE;IAFZ,CAFS;IAMb;IACAC,IAAI,EAAE,MAAMrC,SAAS,CAACP,OAAV,CAAkBC,OAAlB,CAPC;IAQbsC,UARa;IASbR,QAAQ,EAAEO,YATG;IAUbtB,QAVa;IAWb6B,GAAG,EAAE;EAXQ,CAAf,CAxB8B,CAqC9B;;EACA,MAAM;IAAEC;EAAF,IAAU,MAAMzD,eAAe,CAACN,GAAG,CAACgE,QAAL,EAAe,EAAE,GAAGL,MAAL;IAAajC;EAAb,CAAf,CAArC;EACA,MAAM;IAAEuC,UAAU,EAAEC;EAAd,IAA4BhE,OAAO,CAAC,EAAE,GAAGyD,MAAL;IAAaI;EAAb,CAAD,EAAqB/D,GAAG,CAACgE,QAAzB,CAAzC;EACA,OAAOf,mBAAmB,CAACiB,SAAD,CAAnB,CAA+BrC,EAAtC;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,eAAesC,eAAf,CACL3B,WADK,SAGgB;EAAA,IADrB;IAAEd;EAAF,CACqB;EACrB,MAAM;IAAE0C;EAAF,IAAgB,MAAM1C,MAAM,CAAC2C,SAAP,EAA5B;EACA,OAAO,IAAIC,UAAJ,CAAe/D,IAAI,CACxBK,aAAa,CAAC,CAAC,QAAO2D,IAAP,CAAYH,SAAZ,CAAD,EAAyB5D,MAAM,CAACgC,WAAD,CAA/B,CAAD,CADW,CAAnB,CAAP;AAGD"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Contract module - routines to interact with the æternity contract
3
+ *
4
+ * High level documentation of the contracts are available at
5
+ * https://github.com/aeternity/protocol/tree/master/contracts and
6
+ */
7
+ import { AensName } from '../tx/builder/constants';
8
+ import { Encoded } from '../utils/encoder';
9
+ import AccountBase from '../account/Base';
10
+ import Node from '../Node';
11
+ export { default as getContractInstance } from './aci';
12
+ /**
13
+ * Utility method to create a delegate signature for a contract
14
+ * @category contract
15
+ * @param ids - The list of id's to prepend
16
+ * @param opt - Options
17
+ * @param opt.onNode - Node to use
18
+ * @param opt.onAccount - Account to use
19
+ * @returns Signature in hex representation
20
+ */
21
+ declare function delegateSignatureCommon(ids: Encoded.Any[], { onAccount, onNode, ...opt }: {
22
+ onAccount: AccountBase;
23
+ onNode: Node;
24
+ } & Parameters<AccountBase['sign']>[1]): Promise<string>;
25
+ /**
26
+ * Helper to generate a signature to delegate pre-claim/claim/transfer/revoke of a name to
27
+ * a contract.
28
+ * @category contract
29
+ * @param contractId - Contract Id
30
+ * @param opt - Options
31
+ * @param opt.name - The name
32
+ * @returns Signature for delegation
33
+ * @example
34
+ * ```js
35
+ * const aeSdk = new AeSdk({ ... })
36
+ * const contractId = 'ct_asd2ks...' // contract address
37
+ * const name = 'example.chain' // AENS name
38
+ * const onAccount = await aeSdk.address() // Sign with a specific account
39
+ * // Preclaim signature
40
+ * const preclaimSig = await aeSdk.createAensDelegationSignature(contractId, { onAccount: current })
41
+ * // Claim, transfer and revoke signature
42
+ * const aensDelegationSig = await contract.createAensDelegationSignature(
43
+ * contractId, { name, onAccount: current }
44
+ * )
45
+ * ```
46
+ */
47
+ export declare function createAensDelegationSignature(contractId: Encoded.ContractAddress, opt: Parameters<AccountBase['address']>[0] & Parameters<typeof delegateSignatureCommon>[1] & {
48
+ name?: AensName;
49
+ }): Promise<string>;
50
+ /**
51
+ * Helper to generate a signature to delegate register/extend/respond of a Oracle to a contract.
52
+ * @category contract
53
+ * @param contractId - Contract Id
54
+ * @param opt - Options
55
+ * @param opt.queryId - Oracle Query Id
56
+ * @returns Signature for delegation
57
+ * @example
58
+ * ```js
59
+ * const aeSdk = new AeSdk({ ... })
60
+ * const contractId = 'ct_asd2ks...' // contract address
61
+ * const queryId = 'oq_...' // Oracle Query Id
62
+ * const onAccount = await aeSdk.address() // Sign with a specific account
63
+ * // Oracle register and extend signature
64
+ * const oracleDelegationSig = await aeSdk.createOracleDelegationSignature(contractId)
65
+ * // Oracle respond signature
66
+ * const respondSig = await aeSdk.createOracleDelegationSignature(contractId, { queryId })
67
+ * ```
68
+ */
69
+ export declare function createOracleDelegationSignature(contractId: Encoded.ContractAddress, opt: Parameters<AccountBase['address']>[0] & Parameters<typeof delegateSignatureCommon>[1] & {
70
+ queryId?: Encoded.OracleQueryId;
71
+ }): Promise<string>;
@@ -0,0 +1,104 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+
6
+ /*
7
+ * ISC License (ISC)
8
+ * Copyright (c) 2022 aeternity developers
9
+ *
10
+ * Permission to use, copy, modify, and/or distribute this software for any
11
+ * purpose with or without fee is hereby granted, provided that the above
12
+ * copyright notice and this permission notice appear in all copies.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16
+ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
+ * PERFORMANCE OF THIS SOFTWARE.
21
+ */
22
+
23
+ /**
24
+ * Contract module - routines to interact with the æternity contract
25
+ *
26
+ * High level documentation of the contracts are available at
27
+ * https://github.com/aeternity/protocol/tree/master/contracts and
28
+ */
29
+ import { produceNameId } from "../tx/builder/helpers.mjs";
30
+ import { concatBuffers } from "../utils/other.mjs";
31
+ import { decode } from "../utils/encoder.mjs";
32
+ export { default as getContractInstance } from "./aci.mjs";
33
+ /**
34
+ * Utility method to create a delegate signature for a contract
35
+ * @category contract
36
+ * @param ids - The list of id's to prepend
37
+ * @param opt - Options
38
+ * @param opt.onNode - Node to use
39
+ * @param opt.onAccount - Account to use
40
+ * @returns Signature in hex representation
41
+ */
42
+
43
+ async function delegateSignatureCommon(ids, _ref) {
44
+ let {
45
+ onAccount,
46
+ onNode,
47
+ ...opt
48
+ } = _ref;
49
+ const signature = await onAccount.sign(concatBuffers([_Buffer.from((await onNode.getStatus()).networkId), ...ids.map(e => decode(e))]), opt);
50
+ return _Buffer.from(signature).toString('hex');
51
+ }
52
+ /**
53
+ * Helper to generate a signature to delegate pre-claim/claim/transfer/revoke of a name to
54
+ * a contract.
55
+ * @category contract
56
+ * @param contractId - Contract Id
57
+ * @param opt - Options
58
+ * @param opt.name - The name
59
+ * @returns Signature for delegation
60
+ * @example
61
+ * ```js
62
+ * const aeSdk = new AeSdk({ ... })
63
+ * const contractId = 'ct_asd2ks...' // contract address
64
+ * const name = 'example.chain' // AENS name
65
+ * const onAccount = await aeSdk.address() // Sign with a specific account
66
+ * // Preclaim signature
67
+ * const preclaimSig = await aeSdk.createAensDelegationSignature(contractId, { onAccount: current })
68
+ * // Claim, transfer and revoke signature
69
+ * const aensDelegationSig = await contract.createAensDelegationSignature(
70
+ * contractId, { name, onAccount: current }
71
+ * )
72
+ * ```
73
+ */
74
+
75
+
76
+ export async function createAensDelegationSignature(contractId, opt) {
77
+ return delegateSignatureCommon([await opt.onAccount.address(opt), ...(opt.name != null ? [produceNameId(opt.name)] : []), contractId], opt);
78
+ }
79
+ /**
80
+ * Helper to generate a signature to delegate register/extend/respond of a Oracle to a contract.
81
+ * @category contract
82
+ * @param contractId - Contract Id
83
+ * @param opt - Options
84
+ * @param opt.queryId - Oracle Query Id
85
+ * @returns Signature for delegation
86
+ * @example
87
+ * ```js
88
+ * const aeSdk = new AeSdk({ ... })
89
+ * const contractId = 'ct_asd2ks...' // contract address
90
+ * const queryId = 'oq_...' // Oracle Query Id
91
+ * const onAccount = await aeSdk.address() // Sign with a specific account
92
+ * // Oracle register and extend signature
93
+ * const oracleDelegationSig = await aeSdk.createOracleDelegationSignature(contractId)
94
+ * // Oracle respond signature
95
+ * const respondSig = await aeSdk.createOracleDelegationSignature(contractId, { queryId })
96
+ * ```
97
+ */
98
+
99
+ export async function createOracleDelegationSignature(contractId, opt) {
100
+ var _opt$queryId;
101
+
102
+ return delegateSignatureCommon([(_opt$queryId = opt.queryId) !== null && _opt$queryId !== void 0 ? _opt$queryId : await opt.onAccount.address(opt), contractId], opt);
103
+ }
104
+ //# sourceMappingURL=methods.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods.mjs","names":["produceNameId","concatBuffers","decode","default","getContractInstance","delegateSignatureCommon","ids","onAccount","onNode","opt","signature","sign","from","getStatus","networkId","map","e","toString","createAensDelegationSignature","contractId","address","name","createOracleDelegationSignature","queryId"],"sources":["../../src/contract/methods.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 { AensName } from '../tx/builder/constants';\nimport { produceNameId } from '../tx/builder/helpers';\nimport { concatBuffers } from '../utils/other';\nimport { decode, Encoded } from '../utils/encoder';\nimport AccountBase from '../account/Base';\nimport Node from '../Node';\n\nexport { default as getContractInstance } from './aci';\n\n/**\n * Utility method to create a delegate signature for a contract\n * @category contract\n * @param ids - The list of id's to prepend\n * @param opt - Options\n * @param opt.onNode - Node to use\n * @param opt.onAccount - Account to use\n * @returns Signature in hex representation\n */\nasync function delegateSignatureCommon(\n ids: Encoded.Any[],\n { onAccount, onNode, ...opt }:\n { onAccount: AccountBase; onNode: Node } & Parameters<AccountBase['sign']>[1],\n): Promise<string> {\n const signature = await onAccount.sign(\n concatBuffers([\n Buffer.from((await onNode.getStatus()).networkId),\n ...ids.map((e) => decode(e)),\n ]),\n opt,\n );\n return Buffer.from(signature).toString('hex');\n}\n\n/**\n * Helper to generate a signature to delegate pre-claim/claim/transfer/revoke of a name to\n * a contract.\n * @category contract\n * @param contractId - Contract Id\n * @param opt - Options\n * @param opt.name - The name\n * @returns Signature for delegation\n * @example\n * ```js\n * const aeSdk = new AeSdk({ ... })\n * const contractId = 'ct_asd2ks...' // contract address\n * const name = 'example.chain' // AENS name\n * const onAccount = await aeSdk.address() // Sign with a specific account\n * // Preclaim signature\n * const preclaimSig = await aeSdk.createAensDelegationSignature(contractId, { onAccount: current })\n * // Claim, transfer and revoke signature\n * const aensDelegationSig = await contract.createAensDelegationSignature(\n * contractId, { name, onAccount: current }\n * )\n * ```\n */\nexport async function createAensDelegationSignature(\n contractId: Encoded.ContractAddress,\n opt: Parameters<AccountBase['address']>[0] & Parameters<typeof delegateSignatureCommon>[1] &\n { name?: AensName },\n): Promise<string> {\n return delegateSignatureCommon(\n [\n await opt.onAccount.address(opt),\n ...opt.name != null ? [produceNameId(opt.name)] : [],\n contractId,\n ],\n opt,\n );\n}\n\n/**\n * Helper to generate a signature to delegate register/extend/respond of a Oracle to a contract.\n * @category contract\n * @param contractId - Contract Id\n * @param opt - Options\n * @param opt.queryId - Oracle Query Id\n * @returns Signature for delegation\n * @example\n * ```js\n * const aeSdk = new AeSdk({ ... })\n * const contractId = 'ct_asd2ks...' // contract address\n * const queryId = 'oq_...' // Oracle Query Id\n * const onAccount = await aeSdk.address() // Sign with a specific account\n * // Oracle register and extend signature\n * const oracleDelegationSig = await aeSdk.createOracleDelegationSignature(contractId)\n * // Oracle respond signature\n * const respondSig = await aeSdk.createOracleDelegationSignature(contractId, { queryId })\n * ```\n */\nexport async function createOracleDelegationSignature(\n contractId: Encoded.ContractAddress,\n opt: Parameters<AccountBase['address']>[0] & Parameters<typeof delegateSignatureCommon>[1] &\n { queryId?: Encoded.OracleQueryId },\n): Promise<string> {\n return delegateSignatureCommon(\n [opt.queryId ?? await opt.onAccount.address(opt), contractId],\n opt,\n );\n}\n"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;SAGSA,a;SACAC,a;SACAC,M;SAIAC,OAAO,IAAIC,mB;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeC,uBAAf,CACEC,GADF,QAImB;EAAA,IAFjB;IAAEC,SAAF;IAAaC,MAAb;IAAqB,GAAGC;EAAxB,CAEiB;EACjB,MAAMC,SAAS,GAAG,MAAMH,SAAS,CAACI,IAAV,CACtBV,aAAa,CAAC,CACZ,QAAOW,IAAP,CAAY,CAAC,MAAMJ,MAAM,CAACK,SAAP,EAAP,EAA2BC,SAAvC,CADY,EAEZ,GAAGR,GAAG,CAACS,GAAJ,CAASC,CAAD,IAAOd,MAAM,CAACc,CAAD,CAArB,CAFS,CAAD,CADS,EAKtBP,GALsB,CAAxB;EAOA,O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