@aeternity/aepp-sdk 9.0.1 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/README.md +15 -14
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +7 -36
  4. package/dist/aepp-sdk.browser-script.js.map +1 -1
  5. package/dist/aepp-sdk.browser.js +1 -1
  6. package/dist/aepp-sdk.browser.js.map +1 -1
  7. package/dist/aepp-sdk.js +1 -1
  8. package/dist/aepp-sdk.js.map +1 -1
  9. package/es/account/base.mjs +179 -0
  10. package/es/account/base.mjs.map +1 -0
  11. package/es/account/memory.mjs +99 -0
  12. package/es/account/memory.mjs.map +1 -0
  13. package/es/account/multiple.mjs +179 -0
  14. package/es/account/multiple.mjs.map +1 -0
  15. package/es/ae/aens.mjs +404 -0
  16. package/es/ae/aens.mjs.map +1 -0
  17. package/es/ae/{aepp.js → aepp.mjs} +9 -9
  18. package/es/ae/aepp.mjs.map +1 -0
  19. package/es/ae/contract.mjs +159 -0
  20. package/es/ae/contract.mjs.map +1 -0
  21. package/es/ae/index.mjs +207 -0
  22. package/es/ae/index.mjs.map +1 -0
  23. package/es/ae/oracle.mjs +339 -0
  24. package/es/ae/oracle.mjs.map +1 -0
  25. package/es/ae/{universal.js → universal.mjs} +10 -10
  26. package/es/ae/universal.mjs.map +1 -0
  27. package/es/ae/{wallet.js → wallet.mjs} +10 -10
  28. package/es/ae/wallet.mjs.map +1 -0
  29. package/es/aepp-wallet-communication/schema.d.ts +74 -0
  30. package/es/bignumber.d.ts +1 -7
  31. package/es/chain/{index.js → index.mjs} +29 -9
  32. package/es/chain/index.mjs.map +1 -0
  33. package/es/chain/node.mjs +442 -0
  34. package/es/chain/node.mjs.map +1 -0
  35. package/es/channel/handlers.mjs +1110 -0
  36. package/es/channel/handlers.mjs.map +1 -0
  37. package/es/channel/{index.js → index.mjs} +245 -472
  38. package/es/channel/index.mjs.map +1 -0
  39. package/es/channel/internal.mjs +283 -0
  40. package/es/channel/internal.mjs.map +1 -0
  41. package/es/contract/aci.mjs +477 -0
  42. package/es/contract/aci.mjs.map +1 -0
  43. package/es/contract/compiler.mjs +115 -0
  44. package/es/contract/compiler.mjs.map +1 -0
  45. package/es/contract/ga/helpers.mjs +30 -0
  46. package/es/contract/ga/helpers.mjs.map +1 -0
  47. package/es/contract/ga/index.mjs +178 -0
  48. package/es/contract/ga/index.mjs.map +1 -0
  49. package/es/errors.d.ts +284 -0
  50. package/es/index.mjs +57 -0
  51. package/es/index.mjs.map +1 -0
  52. package/es/node-pool/index.mjs +188 -0
  53. package/es/node-pool/index.mjs.map +1 -0
  54. package/es/node.mjs +133 -0
  55. package/es/node.mjs.map +1 -0
  56. package/es/other.d.ts +1 -1
  57. package/es/tx/builder/field-types.mjs +74 -0
  58. package/es/tx/builder/field-types.mjs.map +1 -0
  59. package/es/tx/builder/helpers.mjs +363 -0
  60. package/es/tx/builder/helpers.mjs.map +1 -0
  61. package/es/tx/builder/index.mjs +606 -0
  62. package/es/tx/builder/index.mjs.map +1 -0
  63. package/es/tx/builder/schema.mjs +760 -0
  64. package/es/tx/builder/schema.mjs.map +1 -0
  65. package/es/tx/{index.js → index.mjs} +107 -15
  66. package/es/tx/index.mjs.map +1 -0
  67. package/es/tx/tx-object.mjs +283 -0
  68. package/es/tx/tx-object.mjs.map +1 -0
  69. package/es/tx/tx.mjs +938 -0
  70. package/es/tx/tx.mjs.map +1 -0
  71. package/es/tx/validator.mjs +247 -0
  72. package/es/tx/validator.mjs.map +1 -0
  73. package/es/typings/blakejs/index.d.mjs +2 -0
  74. package/es/typings/blakejs/{index.d.js.map → index.d.mjs.map} +1 -1
  75. package/es/utils/aepp-wallet-communication/connection/{browser-runtime.js → browser-runtime.mjs} +27 -29
  76. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +1 -0
  77. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +183 -0
  78. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +1 -0
  79. package/es/utils/aepp-wallet-communication/connection/{index.js → index.mjs} +7 -3
  80. package/es/utils/aepp-wallet-communication/connection/index.mjs.map +1 -0
  81. package/es/utils/aepp-wallet-communication/{content-script-bridge.js → content-script-bridge.mjs} +29 -23
  82. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +1 -0
  83. package/es/utils/aepp-wallet-communication/helpers.mjs +92 -0
  84. package/es/utils/aepp-wallet-communication/helpers.mjs.map +1 -0
  85. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +375 -0
  86. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +1 -0
  87. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +275 -0
  88. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +1 -0
  89. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +541 -0
  90. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +1 -0
  91. package/es/utils/aepp-wallet-communication/schema.mjs +102 -0
  92. package/es/utils/aepp-wallet-communication/schema.mjs.map +1 -0
  93. package/es/utils/aepp-wallet-communication/wallet-detector.mjs +110 -0
  94. package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  95. package/es/utils/amount-formatter.mjs +139 -0
  96. package/es/utils/amount-formatter.mjs.map +1 -0
  97. package/es/utils/async-init.mjs +64 -0
  98. package/es/utils/async-init.mjs.map +1 -0
  99. package/es/utils/bignumber.mjs +21 -0
  100. package/es/utils/bignumber.mjs.map +1 -0
  101. package/es/utils/{bytes.js → bytes.mjs} +16 -12
  102. package/es/utils/bytes.mjs.map +1 -0
  103. package/es/utils/{crypto-ts.js → crypto-ts.mjs} +11 -3
  104. package/es/utils/crypto-ts.mjs.map +1 -0
  105. package/es/utils/crypto.mjs +239 -0
  106. package/es/utils/crypto.mjs.map +1 -0
  107. package/es/utils/errors.mjs +689 -0
  108. package/es/utils/errors.mjs.map +1 -0
  109. package/es/utils/hd-wallet.mjs +111 -0
  110. package/es/utils/hd-wallet.mjs.map +1 -0
  111. package/es/utils/json-big.mjs +45 -0
  112. package/es/utils/json-big.mjs.map +1 -0
  113. package/es/utils/keystore.mjs +240 -0
  114. package/es/utils/keystore.mjs.map +1 -0
  115. package/es/utils/mptree.mjs +161 -0
  116. package/es/utils/mptree.mjs.map +1 -0
  117. package/es/utils/other.mjs +43 -0
  118. package/es/utils/other.mjs.map +1 -0
  119. package/es/utils/semver-satisfies.mjs +16 -0
  120. package/es/utils/semver-satisfies.mjs.map +1 -0
  121. package/es/utils/{string.js → string.mjs} +5 -14
  122. package/es/utils/string.mjs.map +1 -0
  123. package/es/utils/swagger.mjs +164 -0
  124. package/es/utils/swagger.mjs.map +1 -0
  125. package/package.json +55 -62
  126. package/src/account/base.js +3 -1
  127. package/src/account/memory.js +13 -8
  128. package/src/account/multiple.js +31 -22
  129. package/src/ae/aens.js +75 -77
  130. package/src/ae/aepp.js +2 -2
  131. package/src/ae/contract.js +27 -291
  132. package/src/ae/index.js +9 -7
  133. package/src/ae/oracle.js +51 -28
  134. package/src/ae/universal.js +4 -2
  135. package/src/ae/wallet.js +2 -2
  136. package/src/chain/index.js +29 -6
  137. package/src/chain/node.js +95 -67
  138. package/src/channel/handlers.js +30 -21
  139. package/src/channel/index.js +44 -20
  140. package/src/channel/internal.js +30 -24
  141. package/src/contract/aci.js +376 -0
  142. package/src/contract/compiler.js +41 -91
  143. package/src/contract/ga/helpers.js +10 -13
  144. package/src/contract/ga/index.js +42 -33
  145. package/src/index.js +9 -10
  146. package/src/node-pool/index.js +29 -17
  147. package/src/node.js +33 -36
  148. package/src/tx/builder/field-types.js +61 -0
  149. package/src/tx/builder/helpers.js +126 -84
  150. package/src/tx/builder/index.js +83 -41
  151. package/src/tx/builder/schema.js +50 -40
  152. package/src/tx/index.js +101 -12
  153. package/src/tx/tx-object.js +35 -15
  154. package/src/tx/tx.js +232 -153
  155. package/src/tx/validator.js +34 -12
  156. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +11 -5
  157. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +35 -13
  158. package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
  159. package/src/utils/aepp-wallet-communication/content-script-bridge.js +14 -7
  160. package/src/utils/aepp-wallet-communication/helpers.js +6 -14
  161. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +107 -60
  162. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +24 -11
  163. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +98 -56
  164. package/src/utils/aepp-wallet-communication/schema.ts +80 -0
  165. package/src/utils/aepp-wallet-communication/wallet-detector.js +6 -2
  166. package/src/utils/amount-formatter.ts +4 -3
  167. package/src/utils/async-init.js +10 -6
  168. package/src/utils/bignumber.ts +3 -10
  169. package/src/utils/bytes.ts +3 -2
  170. package/src/utils/crypto-ts.ts +2 -2
  171. package/src/utils/crypto.js +10 -144
  172. package/src/utils/errors.ts +683 -0
  173. package/src/utils/hd-wallet.js +11 -26
  174. package/src/utils/keystore.js +57 -53
  175. package/src/utils/mptree.ts +12 -6
  176. package/src/utils/other.ts +1 -1
  177. package/src/utils/semver-satisfies.ts +1 -1
  178. package/src/utils/swagger.js +75 -45
  179. package/es/account/base.js +0 -259
  180. package/es/account/base.js.map +0 -1
  181. package/es/account/memory.js +0 -86
  182. package/es/account/memory.js.map +0 -1
  183. package/es/account/multiple.js +0 -267
  184. package/es/account/multiple.js.map +0 -1
  185. package/es/ae/aens.js +0 -829
  186. package/es/ae/aens.js.map +0 -1
  187. package/es/ae/aepp.js.map +0 -1
  188. package/es/ae/contract.js +0 -985
  189. package/es/ae/contract.js.map +0 -1
  190. package/es/ae/index.js +0 -442
  191. package/es/ae/index.js.map +0 -1
  192. package/es/ae/oracle.js +0 -690
  193. package/es/ae/oracle.js.map +0 -1
  194. package/es/ae/universal.js.map +0 -1
  195. package/es/ae/wallet.js.map +0 -1
  196. package/es/chain/index.js.map +0 -1
  197. package/es/chain/node.js +0 -1119
  198. package/es/chain/node.js.map +0 -1
  199. package/es/channel/handlers.js +0 -1601
  200. package/es/channel/handlers.js.map +0 -1
  201. package/es/channel/index.js.map +0 -1
  202. package/es/channel/internal.js +0 -438
  203. package/es/channel/internal.js.map +0 -1
  204. package/es/contract/aci/helpers.js +0 -298
  205. package/es/contract/aci/helpers.js.map +0 -1
  206. package/es/contract/aci/index.js +0 -517
  207. package/es/contract/aci/index.js.map +0 -1
  208. package/es/contract/aci/transformation.js +0 -742
  209. package/es/contract/aci/transformation.js.map +0 -1
  210. package/es/contract/compiler.js +0 -316
  211. package/es/contract/compiler.js.map +0 -1
  212. package/es/contract/ga/helpers.js +0 -120
  213. package/es/contract/ga/helpers.js.map +0 -1
  214. package/es/contract/ga/index.js +0 -307
  215. package/es/contract/ga/index.js.map +0 -1
  216. package/es/contract/index.js +0 -158
  217. package/es/contract/index.js.map +0 -1
  218. package/es/index.js +0 -57
  219. package/es/index.js.map +0 -1
  220. package/es/node-pool/index.js +0 -204
  221. package/es/node-pool/index.js.map +0 -1
  222. package/es/node.js +0 -228
  223. package/es/node.js.map +0 -1
  224. package/es/tx/builder/helpers.js +0 -355
  225. package/es/tx/builder/helpers.js.map +0 -1
  226. package/es/tx/builder/index.js +0 -686
  227. package/es/tx/builder/index.js.map +0 -1
  228. package/es/tx/builder/schema.js +0 -695
  229. package/es/tx/builder/schema.js.map +0 -1
  230. package/es/tx/index.js.map +0 -1
  231. package/es/tx/tx-object.js +0 -297
  232. package/es/tx/tx-object.js.map +0 -1
  233. package/es/tx/tx.js +0 -1757
  234. package/es/tx/tx.js.map +0 -1
  235. package/es/tx/validator.js +0 -344
  236. package/es/tx/validator.js.map +0 -1
  237. package/es/typings/blakejs/index.d.js +0 -2
  238. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
  239. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -211
  240. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
  241. package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
  242. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
  243. package/es/utils/aepp-wallet-communication/helpers.js +0 -148
  244. package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
  245. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -652
  246. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
  247. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -285
  248. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
  249. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -763
  250. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
  251. package/es/utils/aepp-wallet-communication/schema.js +0 -103
  252. package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
  253. package/es/utils/aepp-wallet-communication/wallet-detector.js +0 -135
  254. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
  255. package/es/utils/amount-formatter.js +0 -152
  256. package/es/utils/amount-formatter.js.map +0 -1
  257. package/es/utils/async-init.js +0 -103
  258. package/es/utils/async-init.js.map +0 -1
  259. package/es/utils/bignumber.js +0 -36
  260. package/es/utils/bignumber.js.map +0 -1
  261. package/es/utils/bytes.js.map +0 -1
  262. package/es/utils/crypto-ts.js.map +0 -1
  263. package/es/utils/crypto.js +0 -358
  264. package/es/utils/crypto.js.map +0 -1
  265. package/es/utils/hd-wallet.js +0 -148
  266. package/es/utils/hd-wallet.js.map +0 -1
  267. package/es/utils/json-big.js +0 -78
  268. package/es/utils/json-big.js.map +0 -1
  269. package/es/utils/keystore.js +0 -393
  270. package/es/utils/keystore.js.map +0 -1
  271. package/es/utils/mptree.js +0 -198
  272. package/es/utils/mptree.js.map +0 -1
  273. package/es/utils/other.js +0 -93
  274. package/es/utils/other.js.map +0 -1
  275. package/es/utils/semver-satisfies.js +0 -35
  276. package/es/utils/semver-satisfies.js.map +0 -1
  277. package/es/utils/string.js.map +0 -1
  278. package/es/utils/swagger.js +0 -269
  279. package/es/utils/swagger.js.map +0 -1
  280. package/src/contract/aci/helpers.js +0 -140
  281. package/src/contract/aci/index.js +0 -191
  282. package/src/contract/aci/transformation.js +0 -464
  283. package/src/contract/index.js +0 -159
  284. package/src/utils/aepp-wallet-communication/schema.js +0 -110
@@ -0,0 +1,477 @@
1
+ /*
2
+ * ISC License (ISC)
3
+ * Copyright (c) 2018 aeternity developers
4
+ *
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose with or without fee is hereby granted, provided that the above
7
+ * copyright notice and this permission notice appear in all copies.
8
+ *
9
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ * PERFORMANCE OF THIS SOFTWARE.
16
+ */
17
+
18
+ /**
19
+ * ContractACI module
20
+ *
21
+ * @module @aeternity/aepp-sdk/es/contract/aci
22
+ * @export getContractInstance
23
+ */
24
+ import _aeternityAeppCalldata from '@aeternity/aepp-calldata';
25
+ const {
26
+ Encoder: Calldata
27
+ } = _aeternityAeppCalldata;
28
+ import { DRY_RUN_ACCOUNT, GAS_MAX } from "../tx/builder/schema.mjs";
29
+ import TxObject from "../tx/tx-object.mjs";
30
+ import { decode } from "../tx/builder/helpers.mjs";
31
+ import { MissingContractDefError, MissingContractAddressError, InactiveContractError, BytecodeMismatchError, InternalError, DuplicateContractError, MissingFunctionNameError, InvalidMethodInvocationError, NotPayableFunctionError, TypeError, NodeInvocationError, IllegalArgumentError, NoSuchContractFunctionError, MissingEventDefinitionError, AmbiguousEventDefinitionError } from "../utils/errors.mjs";
32
+ import { hash } from "../utils/crypto-ts.mjs";
33
+ /**
34
+ * Generate contract ACI object with predefined js methods for contract usage - can be used for
35
+ * creating a reference to already deployed contracts
36
+ * @alias module:@aeternity/aepp-sdk/es/contract/aci
37
+ * @param {Object} [options={}] Options object
38
+ * @param {String} [options.source] Contract source code
39
+ * @param {String} [options.bytecode] Contract bytecode
40
+ * @param {Object} [options.aci] Contract ACI
41
+ * @param {String} [options.contractAddress] Contract address
42
+ * @param {Object} [options.filesystem] Contact source external namespaces map
43
+ * @param {Boolean} [options.validateBytecode] Compare source code with on-chain version
44
+ * @return {ContractInstance} JS Contract API
45
+ * @example
46
+ * const contractIns = await aeSdk.getContractInstance({ source })
47
+ * await contractIns.deploy([321]) or await contractIns.methods.init(321)
48
+ * const callResult = await contractIns.call('setState', [123]) or
49
+ * await contractIns.methods.setState.send(123, options)
50
+ * const staticCallResult = await contractIns.call('setState', [123], { callStatic: true }) or
51
+ * await contractIns.methods.setState.get(123, options)
52
+ * Also you can call contract like: await contractIns.methods.setState(123, options)
53
+ * Then sdk decide to make on-chain or static call(dry-run API) transaction based on function is
54
+ * stateful or not
55
+ */
56
+
57
+ export default async function getContractInstance() {
58
+ var _this = this;
59
+
60
+ let {
61
+ source,
62
+ bytecode,
63
+ aci: _aci,
64
+ contractAddress,
65
+ filesystem = {},
66
+ validateBytecode,
67
+ ...otherOptions
68
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
69
+
70
+ if (!_aci && source) {
71
+ _aci = await this.compilerApi.generateACI({
72
+ code: source,
73
+ options: {
74
+ filesystem
75
+ }
76
+ });
77
+ }
78
+
79
+ if (!_aci) throw new MissingContractDefError();
80
+ contractAddress = contractAddress && (await this.resolveName(contractAddress, 'contract_pubkey', {
81
+ resolveByNode: true
82
+ }));
83
+
84
+ if (!contractAddress && !source && !bytecode) {
85
+ throw new MissingContractAddressError('Can\'t create instance by ACI without address');
86
+ }
87
+
88
+ if (contractAddress) {
89
+ const contract = await this.getContract(contractAddress);
90
+ if (!contract.active) throw new InactiveContractError(contractAddress);
91
+ }
92
+
93
+ const instance = {
94
+ _aci,
95
+ _name: _aci.encoded_aci.contract.name,
96
+ calldata: new Calldata([_aci.encoded_aci, ..._aci.external_encoded_aci]),
97
+ source,
98
+ bytecode,
99
+ deployInfo: {
100
+ address: contractAddress
101
+ },
102
+ options: { ...this.Ae.defaults,
103
+ callStatic: false,
104
+ filesystem,
105
+ ...otherOptions
106
+ },
107
+ compilerVersion: this.compilerVersion
108
+ };
109
+
110
+ if (validateBytecode) {
111
+ if (!contractAddress) throw new MissingContractAddressError('Can\'t validate bytecode without contract address');
112
+ const onChanBytecode = (await this.getContractByteCode(contractAddress)).bytecode;
113
+ const isValid = source ? await this.compilerApi.validateByteCode({
114
+ bytecode: onChanBytecode,
115
+ source,
116
+ options: instance.options
117
+ }).then(res => Object.entries(res).length === 0, () => false) : bytecode === onChanBytecode;
118
+ if (!isValid) throw new BytecodeMismatchError(source ? 'source' : 'bytecode');
119
+ }
120
+ /**
121
+ * Compile contract
122
+ * @alias module:@aeternity/aepp-sdk/es/contract/aci
123
+ * @rtype () => ContractInstance: Object
124
+ * @return {String} bytecode bytecode
125
+ */
126
+
127
+
128
+ instance.compile = async function () {
129
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
130
+ if (instance.bytecode) throw new IllegalArgumentError('Contract already compiled');
131
+ if (!instance.source) throw new IllegalArgumentError('Can\'t compile without source code');
132
+ const {
133
+ bytecode
134
+ } = await _this.compilerApi.compileContract({
135
+ code: instance.source,
136
+ options: { ...instance.options,
137
+ ...options
138
+ }
139
+ });
140
+ instance.bytecode = bytecode;
141
+ return instance.bytecode;
142
+ };
143
+
144
+ const sendAndProcess = async (tx, options) => {
145
+ const txData = await this.send(tx, options);
146
+ const result = {
147
+ hash: txData.hash,
148
+ tx: TxObject({
149
+ tx: txData.rawTx
150
+ }),
151
+ txData,
152
+ rawTx: txData.rawTx
153
+ };
154
+ if (options.waitMined === false) return result;
155
+ const {
156
+ callInfo
157
+ } = await this.api.getTransactionInfoByHash(txData.hash);
158
+ Object.assign(result.txData, callInfo); // TODO: don't duplicate data in result
159
+
160
+ await handleCallError(callInfo);
161
+ return { ...result,
162
+ result: callInfo
163
+ };
164
+ };
165
+
166
+ const handleCallError = _ref => {
167
+ let {
168
+ returnType,
169
+ returnValue
170
+ } = _ref;
171
+ let message; // TODO: ensure that it works correctly https://github.com/aeternity/aepp-calldata-js/issues/88
172
+
173
+ switch (returnType) {
174
+ case 'ok':
175
+ return;
176
+
177
+ case 'revert':
178
+ message = instance.calldata.decodeFateString(returnValue);
179
+ break;
180
+
181
+ case 'error':
182
+ message = decode(returnValue).toString();
183
+ break;
184
+
185
+ default:
186
+ throw new InternalError(`Unknown returnType: ${returnType}`);
187
+ }
188
+
189
+ throw new NodeInvocationError(message);
190
+ };
191
+
192
+ instance._estimateGas = async (name, params, options) => {
193
+ const {
194
+ result: {
195
+ gasUsed
196
+ }
197
+ } = await instance.call(name, params, { ...options,
198
+ callStatic: true
199
+ }); // taken from https://github.com/aeternity/aepp-sdk-js/issues/1286#issuecomment-977814771
200
+
201
+ return Math.floor(gasUsed * 1.25);
202
+ };
203
+ /**
204
+ * Deploy contract
205
+ * @alias module:@aeternity/aepp-sdk/es/contract/aci
206
+ * @rtype (init: Array, options: Object) => ContractInstance: Object
207
+ * @param {Array} params Contract init function arguments array
208
+ * @param {Object} [options] options
209
+ * @return {Object} deploy info
210
+ */
211
+
212
+
213
+ instance.deploy = async function () {
214
+ var _opt$gas;
215
+
216
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
217
+ let options = arguments.length > 1 ? arguments[1] : undefined;
218
+ const opt = { ...instance.options,
219
+ ...options
220
+ };
221
+ if (!instance.bytecode) await instance.compile(opt);
222
+ if (opt.callStatic) return instance.call('init', params, opt);
223
+ if (instance.deployInfo.address) throw new DuplicateContractError();
224
+ const ownerId = await _this.address(opt);
225
+ const {
226
+ tx,
227
+ contractId
228
+ } = await _this.contractCreateTx({ ...opt,
229
+ gas: (_opt$gas = opt.gas) !== null && _opt$gas !== void 0 ? _opt$gas : await instance._estimateGas('init', params, opt),
230
+ callData: instance.calldata.encode(instance._name, 'init', params),
231
+ code: instance.bytecode,
232
+ ownerId
233
+ });
234
+ const {
235
+ hash,
236
+ rawTx,
237
+ result,
238
+ txData
239
+ } = await sendAndProcess(tx, opt);
240
+ instance.deployInfo = Object.freeze({
241
+ result,
242
+ owner: ownerId,
243
+ transaction: hash,
244
+ rawTx,
245
+ txData,
246
+ address: contractId
247
+ });
248
+ return instance.deployInfo;
249
+ };
250
+ /**
251
+ * Get function schema from contract ACI object
252
+ * @param {String} name Function name
253
+ * @return {Object} function ACI
254
+ */
255
+
256
+
257
+ function getFunctionACI(name) {
258
+ const fn = instance._aci.encoded_aci.contract.functions.find(f => f.name === name);
259
+
260
+ if (fn) return fn;
261
+ if (name === 'init') return {
262
+ payable: false
263
+ };
264
+ throw new NoSuchContractFunctionError(`Function ${name} doesn't exist in contract`);
265
+ }
266
+ /**
267
+ * Call contract function
268
+ * @alias module:@aeternity/aepp-sdk/es/contract/aci
269
+ * @rtype (init: Array, options: Object = { callStatic: false }) => CallResult: Object
270
+ * @param {String} fn Function name
271
+ * @param {Array} params Array of function arguments
272
+ * @param {Object} [options={}] Array of function arguments
273
+ * @param {Boolean} [options.callStatic=false] Static function call
274
+ * @return {Object} CallResult
275
+ */
276
+
277
+
278
+ instance.call = async function (fn) {
279
+ let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
280
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
281
+ const opt = { ...instance.options,
282
+ ...options
283
+ };
284
+ const fnACI = getFunctionACI(fn);
285
+ const contractId = instance.deployInfo.address;
286
+ if (!fn) throw new MissingFunctionNameError();
287
+ if (fn === 'init' && !opt.callStatic) throw new InvalidMethodInvocationError('"init" can be called only via dryRun');
288
+ if (!contractId && fn !== 'init') throw new InvalidMethodInvocationError('You need to deploy contract before calling!');
289
+ if (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`);
290
+ const callerId = await _this.address(opt).catch(error => {
291
+ if (opt.callStatic) return DRY_RUN_ACCOUNT.pub;else throw error;
292
+ });
293
+ const callData = instance.calldata.encode(instance._name, fn, params);
294
+ let res;
295
+
296
+ if (opt.callStatic) {
297
+ var _opt$gas2, _opt$nonce;
298
+
299
+ if (typeof opt.top === 'number') {
300
+ opt.top = (await _this.getKeyBlock(opt.top)).hash;
301
+ }
302
+
303
+ const txOpt = { ...opt,
304
+ gas: (_opt$gas2 = opt.gas) !== null && _opt$gas2 !== void 0 ? _opt$gas2 : GAS_MAX,
305
+ callData,
306
+ nonce: (_opt$nonce = opt.nonce) !== null && _opt$nonce !== void 0 ? _opt$nonce : opt.top && (await _this.getAccount(callerId, {
307
+ hash: opt.top
308
+ })).nonce + 1
309
+ };
310
+ const tx = fn === 'init' ? (await _this.contractCreateTx({ ...txOpt,
311
+ code: instance.bytecode,
312
+ ownerId: callerId
313
+ })).tx : await _this.contractCallTx({ ...txOpt,
314
+ callerId,
315
+ contractId
316
+ });
317
+ const {
318
+ callObj,
319
+ ...dryRunOther
320
+ } = await _this.txDryRun(tx, callerId, opt);
321
+ await handleCallError(callObj);
322
+ res = { ...dryRunOther,
323
+ tx: TxObject({
324
+ tx
325
+ }),
326
+ result: callObj
327
+ };
328
+ } else {
329
+ var _opt$gas3;
330
+
331
+ const tx = await _this.contractCallTx({ ...opt,
332
+ gas: (_opt$gas3 = opt.gas) !== null && _opt$gas3 !== void 0 ? _opt$gas3 : await instance._estimateGas(fn, params, opt),
333
+ callerId,
334
+ contractId,
335
+ callData
336
+ });
337
+ res = await sendAndProcess(tx, opt);
338
+ }
339
+
340
+ if (opt.waitMined || opt.callStatic) {
341
+ res.decodedResult = fnACI.returns && fnACI.returns !== 'unit' && fn !== 'init' && instance.calldata.decode(instance._name, fn, res.result.returnValue);
342
+ res.decodedEvents = instance.decodeEvents(res.result.log, opt);
343
+ }
344
+
345
+ return res;
346
+ };
347
+ /**
348
+ * @param {String} address Contract address that emitted event
349
+ * @param {BigInt} nameHash Hash of emitted event name
350
+ * @param {Object} [options]
351
+ * @param {Object} [options.contractAddressToName] Map of contract addresses to their names
352
+ * @return {String} Contract name
353
+ * @throws {MissingEventDefinitionError}
354
+ * @throws {AmbiguousEventDefinitionError}
355
+ */
356
+
357
+
358
+ function getContractNameByEvent(address, nameHash, _ref2) {
359
+ let {
360
+ contractAddressToName
361
+ } = _ref2;
362
+ const addressToName = { ...instance.options.contractAddressToName,
363
+ ...contractAddressToName
364
+ };
365
+ if (addressToName[address]) return addressToName[address];
366
+ const matchedEvents = [instance._aci.encoded_aci, ...instance._aci.external_encoded_aci].filter(_ref3 => {
367
+ let {
368
+ contract
369
+ } = _ref3;
370
+ return contract === null || contract === void 0 ? void 0 : contract.event;
371
+ }).map(_ref4 => {
372
+ let {
373
+ contract
374
+ } = _ref4;
375
+ return [contract.name, contract.event.variant];
376
+ }).map(_ref5 => {
377
+ let [name, events] = _ref5;
378
+ return events.map(event => [name, Object.keys(event)[0]]);
379
+ }).flat().filter(_ref6 => {
380
+ let [, eventName] = _ref6;
381
+ return BigInt('0x' + hash(eventName).toString('hex')) === nameHash;
382
+ });
383
+
384
+ switch (matchedEvents.length) {
385
+ case 0:
386
+ throw new MissingEventDefinitionError(nameHash, address);
387
+
388
+ case 1:
389
+ return matchedEvents[0][0];
390
+
391
+ default:
392
+ throw new AmbiguousEventDefinitionError(address, matchedEvents);
393
+ }
394
+ }
395
+ /**
396
+ * Decode Events
397
+ * @alias module:@aeternity/aepp-sdk/es/contract/aci
398
+ * @rtype (events: Array) => DecodedEvents: Array
399
+ * @param {Array} events Array of encoded events (callRes.result.log)
400
+ * @param {Object} [options]
401
+ * @param {Boolean} [options.omitUnknown] Omit events that can't be decoded in case ACI is not
402
+ * complete
403
+ * @return {Object} DecodedEvents
404
+ */
405
+
406
+
407
+ instance.decodeEvents = function (events) {
408
+ let {
409
+ omitUnknown,
410
+ ...opt
411
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
412
+ return events.map(event => {
413
+ const topics = event.topics.map(t => BigInt(t));
414
+ let contractName;
415
+
416
+ try {
417
+ contractName = getContractNameByEvent(event.address, topics[0], opt);
418
+ } catch (error) {
419
+ if (omitUnknown && error instanceof MissingEventDefinitionError) return null;
420
+ throw error;
421
+ }
422
+
423
+ const decoded = instance.calldata.decodeEvent(contractName, event.data, topics);
424
+ const [name, args] = Object.entries(decoded)[0];
425
+ return {
426
+ name,
427
+ args,
428
+ contract: {
429
+ name: contractName,
430
+ address: event.address
431
+ }
432
+ };
433
+ }).filter(e => e);
434
+ };
435
+ /**
436
+ * Generate proto function based on contract function using Contract ACI schema
437
+ * All function can be called like:
438
+ * 'await contract.methods.testFunction()' -> then sdk will decide to use dry-run or send tx
439
+ * on-chain base on if function stateful or not.
440
+ * Also you can manually do that:
441
+ * `await contract.methods.testFunction.get()` -> use call-static(dry-run)
442
+ * `await contract.methods.testFunction.send()` -> send tx on-chain
443
+ */
444
+
445
+
446
+ instance.methods = Object.fromEntries(instance._aci.encoded_aci.contract.functions.map(_ref7 => {
447
+ let {
448
+ name,
449
+ arguments: aciArgs,
450
+ stateful
451
+ } = _ref7;
452
+
453
+ const genHandler = callStatic => function () {
454
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
455
+ args[_key] = arguments[_key];
456
+ }
457
+
458
+ const options = args.length === aciArgs.length + 1 ? args.pop() : {};
459
+ if (typeof options !== 'object') throw new TypeError(`Options should be an object: ${options}`);
460
+ if (name === 'init') return instance.deploy(args, {
461
+ callStatic,
462
+ ...options
463
+ });
464
+ return instance.call(name, args, {
465
+ callStatic,
466
+ ...options
467
+ });
468
+ };
469
+
470
+ return [name, Object.assign(genHandler(name === 'init' ? false : !stateful), {
471
+ get: genHandler(true),
472
+ send: genHandler(false)
473
+ })];
474
+ }));
475
+ return instance;
476
+ }
477
+ //# sourceMappingURL=aci.mjs.map
@@ -0,0 +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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AAM,IAAInB,SAAJ,CAAe,gCAA+BmB,OAAQ,EAAtD,CAAN;AACjC,UAAIS,IAAI,KAAK,MAAb,EAAqB,OAAOH,QAAQ,CAAC+C,MAAT,CAAgB0D,IAAhB,EAAsB;AAAE9F,QAAAA,UAAF;AAAc,WAAGjB;AAAjB,OAAtB,CAAP;AACrB,aAAOM,QAAQ,CAAC4C,IAAT,CAAczC,IAAd,EAAoBsG,IAApB,EAA0B;AAAE9F,QAAAA,UAAF;AAAc,WAAGjB;AAAjB,OAA1B,CAAP;AACD,KALD;;AAMA,WAAO,CACLS,IADK,EAELgB,MAAM,CAACe,MAAP,CACE8E,UAAU,CAAC7G,IAAI,KAAK,MAAT,GAAkB,KAAlB,GAA0B,CAAC4G,QAA5B,CADZ,EAEE;AACEG,MAAAA,GAAG,EAAEF,UAAU,CAAC,IAAD,CADjB;AAEErF,MAAAA,IAAI,EAAEqF,UAAU,CAAC,KAAD;AAFlB,KAFF,CAFK,CAAP;AAUD,GAlBmC,CAAnB,CAAnB;AAqBA,SAAOhH,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 (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"}
@@ -0,0 +1,115 @@
1
+ /*
2
+ * ISC License (ISC)
3
+ * Copyright (c) 2021 aeternity developers
4
+ *
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose with or without fee is hereby granted, provided that the above
7
+ * copyright notice and this permission notice appear in all copies.
8
+ *
9
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ * PERFORMANCE OF THIS SOFTWARE.
16
+ */
17
+
18
+ /**
19
+ * ContractCompilerHttp module
20
+ *
21
+ * @module @aeternity/aepp-sdk/es/contract/compiler
22
+ * @export ContractCompilerHttp
23
+ * @example import { ContractCompilerHttp } from '@aeternity/aepp-sdk'
24
+ */
25
+ import semverSatisfies from "../utils/semver-satisfies.mjs";
26
+ import AsyncInit from "../utils/async-init.mjs";
27
+ import genSwaggerClient from "../utils/swagger.mjs";
28
+ import { MissingParamError, UnsupportedVersionError } from "../utils/errors.mjs";
29
+ import { mapObject } from "../utils/other.mjs";
30
+ /**
31
+ * Contract Compiler Stamp
32
+ *
33
+ * This stamp include api call's related to contract compiler functionality.
34
+ * @function
35
+ * @alias module:@aeternity/aepp-sdk/es/contract/compiler
36
+ * @rtype Stamp
37
+ * @param {Object} [options={}] - Initializer object
38
+ * @param {String} [options.compilerUrl] compilerUrl - Url for compiler API
39
+ * @return {Object} Contract compiler instance
40
+ * @example ContractCompilerHttp({ compilerUrl: 'COMPILER_URL' })
41
+ */
42
+
43
+ export default AsyncInit.compose({
44
+ async init(_ref) {
45
+ let {
46
+ compilerUrl,
47
+ ignoreVersion
48
+ } = _ref;
49
+ if (!compilerUrl) return;
50
+ await this.setCompilerUrl(compilerUrl, {
51
+ ignoreVersion
52
+ });
53
+ },
54
+
55
+ methods: {
56
+ async setCompilerUrl(compilerUrl) {
57
+ let {
58
+ ignoreVersion = false
59
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
60
+ if (!compilerUrl) throw new MissingParamError('compilerUrl required');
61
+ compilerUrl = compilerUrl.replace(/\/$/, '');
62
+ const client = await genSwaggerClient(`${compilerUrl}/api`, {
63
+ disableBigNumbers: true,
64
+ disableCaseConversion: true,
65
+ responseInterceptor: response => {
66
+ if (response.ok) return;
67
+ let message = `${new URL(response.url).pathname.slice(1)} error`;
68
+
69
+ if (response.body.reason) {
70
+ message += ': ' + response.body.reason + (response.body.parameter ? ` in ${response.body.parameter}` : '') + ( // TODO: revising after improving documentation https://github.com/aeternity/aesophia_http/issues/78
71
+ response.body.info ? ` (${JSON.stringify(response.body.info)})` : '');
72
+ }
73
+
74
+ if (Array.isArray(response.body)) {
75
+ message += ':\n' + response.body.map(e => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context ? `(${e.context})` : ''}`).map(e => e.trim()) // TODO: remove after fixing https://github.com/aeternity/aesophia_http/issues/80
76
+ .join('\n');
77
+ }
78
+
79
+ response.statusText = message;
80
+ return response;
81
+ }
82
+ });
83
+ this.compilerVersion = client.spec.info.version;
84
+ this.compilerApi = mapObject(client.api, _ref2 => {
85
+ let [key, fn] = _ref2;
86
+ return [key, function () {
87
+ let {
88
+ options: {
89
+ filesystem,
90
+ ...options
91
+ } = {},
92
+ ...args
93
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
94
+ return fn({ ...args,
95
+ options: { ...options,
96
+ file_system: filesystem
97
+ }
98
+ });
99
+ }];
100
+ });
101
+ if (ignoreVersion) return;
102
+
103
+ if (!semverSatisfies(this.compilerVersion, COMPILER_GE_VERSION, COMPILER_LT_VERSION)) {
104
+ throw new UnsupportedVersionError('compiler', this.compilerVersion, COMPILER_GE_VERSION, COMPILER_LT_VERSION);
105
+ }
106
+ }
107
+
108
+ },
109
+ props: {
110
+ compilerVersion: null
111
+ }
112
+ });
113
+ const COMPILER_GE_VERSION = '6.1.0';
114
+ const COMPILER_LT_VERSION = '7.0.0';
115
+ //# sourceMappingURL=compiler.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/contract/compiler.js"],"names":["semverSatisfies","AsyncInit","genSwaggerClient","MissingParamError","UnsupportedVersionError","mapObject","compose","init","compilerUrl","ignoreVersion","setCompilerUrl","methods","replace","client","disableBigNumbers","disableCaseConversion","responseInterceptor","response","ok","message","URL","url","pathname","slice","body","reason","parameter","info","JSON","stringify","Array","isArray","map","e","type","pos","line","col","context","trim","join","statusText","compilerVersion","spec","version","compilerApi","api","key","fn","options","filesystem","args","file_system","COMPILER_GE_VERSION","COMPILER_LT_VERSION","props"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;A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,GAAGA,OAAL;AAAcG,cAAAA,WAAW,EAAEF;AAA3B;AAD+C,WAAD,CAAlE;AAAA,SAFa,CAAf;AAAA,OAF0B,CAA5B;AAUA,UAAIzC,aAAJ,EAAmB;;AACnB,UAAI,CAACT,eAAe,CAAC,KAAK0C,eAAN,EAAuBW,mBAAvB,EAA4CC,mBAA5C,CAApB,EAAsF;AACpF,cAAM,IAAIlD,uBAAJ,CACJ,UADI,EACQ,KAAKsC,eADb,EAC8BW,mBAD9B,EACmDC,mBADnD,CAAN;AAGD;AACF;;AA3CM,GALsB;AAkD/BC,EAAAA,KAAK,EAAE;AACLb,IAAAA,eAAe,EAAE;AADZ;AAlDwB,CAAlB,CAAf;AAuDA,MAAMW,mBAAmB,GAAG,OAA5B;AACA,MAAMC,mBAAmB,GAAG,OAA5B","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2021 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * ContractCompilerHttp module\n *\n * @module @aeternity/aepp-sdk/es/contract/compiler\n * @export ContractCompilerHttp\n * @example import { ContractCompilerHttp } from '@aeternity/aepp-sdk'\n */\n\nimport semverSatisfies from '../utils/semver-satisfies'\nimport AsyncInit from '../utils/async-init'\nimport genSwaggerClient from '../utils/swagger'\nimport { MissingParamError, UnsupportedVersionError } from '../utils/errors'\nimport { mapObject } from '../utils/other'\n\n/**\n * Contract Compiler Stamp\n *\n * This stamp include api call's related to contract compiler functionality.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/contract/compiler\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @param {String} [options.compilerUrl] compilerUrl - Url for compiler API\n * @return {Object} Contract compiler instance\n * @example ContractCompilerHttp({ compilerUrl: 'COMPILER_URL' })\n */\nexport default AsyncInit.compose({\n async init ({ compilerUrl, ignoreVersion }) {\n if (!compilerUrl) return\n await this.setCompilerUrl(compilerUrl, { ignoreVersion })\n },\n methods: {\n async setCompilerUrl (compilerUrl, { ignoreVersion = false } = {}) {\n if (!compilerUrl) throw new MissingParamError('compilerUrl required')\n compilerUrl = compilerUrl.replace(/\\/$/, '')\n const client = await genSwaggerClient(`${compilerUrl}/api`, {\n disableBigNumbers: true,\n disableCaseConversion: true,\n responseInterceptor: response => {\n if (response.ok) return\n let message = `${new URL(response.url).pathname.slice(1)} error`\n if (response.body.reason) {\n message += ': ' + response.body.reason +\n (response.body.parameter ? ` in ${response.body.parameter}` : '') +\n // TODO: revising after improving documentation https://github.com/aeternity/aesophia_http/issues/78\n (response.body.info ? ` (${JSON.stringify(response.body.info)})` : '')\n }\n if (Array.isArray(response.body)) {\n message += ':\\n' + response.body\n .map(e => `${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context ? `(${e.context})` : ''}`)\n .map(e => e.trim()) // TODO: remove after fixing https://github.com/aeternity/aesophia_http/issues/80\n .join('\\n')\n }\n response.statusText = message\n return response\n }\n })\n this.compilerVersion = client.spec.info.version\n this.compilerApi = mapObject(\n client.api,\n ([key, fn]) => [\n key,\n ({ options: { filesystem, ...options } = {}, ...args } = {}) => fn({\n ...args, options: { ...options, file_system: filesystem }\n })\n ]\n )\n\n if (ignoreVersion) return\n if (!semverSatisfies(this.compilerVersion, COMPILER_GE_VERSION, COMPILER_LT_VERSION)) {\n throw new UnsupportedVersionError(\n 'compiler', this.compilerVersion, COMPILER_GE_VERSION, COMPILER_LT_VERSION\n )\n }\n }\n },\n props: {\n compilerVersion: null\n }\n})\n\nconst COMPILER_GE_VERSION = '6.1.0'\nconst COMPILER_LT_VERSION = '7.0.0'\n"],"file":"compiler.mjs"}