@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
package/es/ae/contract.js DELETED
@@ -1,985 +0,0 @@
1
- import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
- import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
- import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
- import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
- import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
- import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
- import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
10
- import _merge from "ramda/src/merge";
11
- import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/objectWithoutProperties";
12
- import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
13
- import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
14
- var _excluded = ["callObj"];
15
- import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
16
- import _Object$freeze from "@babel/runtime-corejs3/core-js-stable/object/freeze";
17
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
18
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
19
- import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
20
-
21
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
22
-
23
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context15; _forEachInstanceProperty(_context15 = ownKeys(Object(source), true)).call(_context15, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context16; _forEachInstanceProperty(_context16 = ownKeys(Object(source))).call(_context16, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
24
-
25
- /*
26
- * ISC License (ISC)
27
- * Copyright (c) 2018 aeternity developers
28
- *
29
- * Permission to use, copy, modify, and/or distribute this software for any
30
- * purpose with or without fee is hereby granted, provided that the above
31
- * copyright notice and this permission notice appear in all copies.
32
- *
33
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
34
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
35
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
36
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
37
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
38
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39
- * PERFORMANCE OF THIS SOFTWARE.
40
- */
41
-
42
- /**
43
- * Contract module - routines to interact with the æternity contract
44
- *
45
- * High level documentation of the contracts are available at
46
- * https://github.com/aeternity/protocol/tree/master/contracts and
47
- *
48
- * @module @aeternity/aepp-sdk/es/ae/contract
49
- * @export Contract
50
- * @example import { Contract } from '@aeternity/aepp-sdk'
51
- */
52
- import Ae from './';
53
- import ContractCompilerAPI from '../contract/compiler';
54
- import ContractBase from '../contract';
55
- import getContractInstance from '../contract/aci';
56
- import NodePool from '../node-pool';
57
- import { AMOUNT, DEPOSIT, DRY_RUN_ACCOUNT, GAS, MIN_GAS_PRICE } from '../tx/builder/schema';
58
- import { decode, produceNameId } from '../tx/builder/helpers';
59
- import TxObject from '../tx/tx-object';
60
-
61
- function _sendAndProcess(_x, _x2, _x3, _x4) {
62
- return _sendAndProcess2.apply(this, arguments);
63
- }
64
- /**
65
- * Handle contract call error
66
- * @function
67
- * @private
68
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
69
- * @category async
70
- * @param {String} source contract source code
71
- * @param {String} name name of called method
72
- * @param {Object} result call result object
73
- * @throws Error Decoded error
74
- * @return {Promise<void>}
75
- */
76
-
77
-
78
- function _sendAndProcess2() {
79
- _sendAndProcess2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(tx, source, name, options) {
80
- var txData, result, txInfo;
81
- return _regeneratorRuntime.wrap(function _callee$(_context) {
82
- while (1) {
83
- switch (_context.prev = _context.next) {
84
- case 0:
85
- _context.next = 2;
86
- return this.send(tx, options);
87
-
88
- case 2:
89
- txData = _context.sent;
90
- result = {
91
- hash: txData.hash,
92
- tx: TxObject({
93
- tx: txData.rawTx
94
- }),
95
- txData: txData,
96
- rawTx: txData.rawTx
97
- };
98
-
99
- if (!(options.waitMined === false)) {
100
- _context.next = 6;
101
- break;
102
- }
103
-
104
- return _context.abrupt("return", result);
105
-
106
- case 6:
107
- _context.next = 8;
108
- return this.getTxInfo(txData.hash);
109
-
110
- case 8:
111
- txInfo = _context.sent;
112
- _context.next = 11;
113
- return this._handleCallError(source, name, txInfo);
114
-
115
- case 11:
116
- return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
117
- result: txInfo
118
- }));
119
-
120
- case 12:
121
- case "end":
122
- return _context.stop();
123
- }
124
- }
125
- }, _callee, this);
126
- }));
127
- return _sendAndProcess2.apply(this, arguments);
128
- }
129
-
130
- function _handleCallError(_x5, _x6, _x7) {
131
- return _handleCallError2.apply(this, arguments);
132
- }
133
- /**
134
- * Encode call data for contract call
135
- * @function
136
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
137
- * @category async
138
- * @param {String} source Contract source code
139
- * @param {String} name Name of function to call
140
- * @param {Array} args Argument's for call
141
- * @param {Object} [options={}] Options
142
- * @param {Object} [options.filesystem={}] Contract external namespaces map
143
- * @return {Promise<String>}
144
- */
145
-
146
-
147
- function _handleCallError2() {
148
- _handleCallError2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(source, name, result) {
149
- var error, message;
150
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
151
- while (1) {
152
- switch (_context2.prev = _context2.next) {
153
- case 0:
154
- if (!(result.returnType === 'ok')) {
155
- _context2.next = 2;
156
- break;
157
- }
158
-
159
- return _context2.abrupt("return");
160
-
161
- case 2:
162
- _context2.next = 4;
163
- return this.contractDecodeCallResultAPI(source, name, result.returnValue, result.returnType);
164
-
165
- case 4:
166
- error = _context2.sent;
167
- message = error[{
168
- revert: 'abort'
169
- }[result.returnType] || result.returnType][0];
170
- throw new Error("Invocation failed".concat(message ? ": \"".concat(message, "\"") : ''));
171
-
172
- case 7:
173
- case "end":
174
- return _context2.stop();
175
- }
176
- }
177
- }, _callee2, this);
178
- }));
179
- return _handleCallError2.apply(this, arguments);
180
- }
181
-
182
- function contractEncodeCall(_x8, _x9, _x10, _x11) {
183
- return _contractEncodeCall.apply(this, arguments);
184
- }
185
- /**
186
- * Decode contract call result data
187
- * @function
188
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
189
- * @category async
190
- * @param {String} source - source code
191
- * @param {String } fn - function name
192
- * @param {String} callValue - result call data
193
- * @param {String} callResult - result status
194
- * @param {Object} [options={}] Options
195
- * @param {Object} [options.filesystem={}] Contract external namespaces map
196
- * @return {Promise<String>} Result object
197
- * @example
198
- * const decodedData = await client.contractDecodeData(SourceCode ,'functionName', 'cb_asdasdasd...', 'ok|revert')lt
199
- */
200
-
201
-
202
- function _contractEncodeCall() {
203
- _contractEncodeCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(source, name, args, options) {
204
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
205
- while (1) {
206
- switch (_context3.prev = _context3.next) {
207
- case 0:
208
- return _context3.abrupt("return", this.contractEncodeCallDataAPI(source, name, args, options));
209
-
210
- case 1:
211
- case "end":
212
- return _context3.stop();
213
- }
214
- }
215
- }, _callee3, this);
216
- }));
217
- return _contractEncodeCall.apply(this, arguments);
218
- }
219
-
220
- function contractDecodeData(_x12, _x13, _x14, _x15, _x16) {
221
- return _contractDecodeData.apply(this, arguments);
222
- }
223
- /**
224
- * Static contract call(using dry-run)
225
- * @function
226
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
227
- * @category async
228
- * @param {String} source Contract source code
229
- * @param {String} address Contract address
230
- * @param {String} name Name of function to call
231
- * @param {Array|String} args Argument's or callData for call/deploy transaction
232
- * @param {Object} [options]
233
- * @param {Number|String} [options.top] Block height or hash on which you want to call contract
234
- * @param {String} [options.bytecode] Block hash on which you want to call contract
235
- * @param {Object} [options.filesystem] Contract external namespaces map
236
- * @return {Promise<Object>} Result object
237
- * @example
238
- * const callResult = await client.contractCallStatic(source, address, fnName, args)
239
- * {
240
- * result: TX_DATA,
241
- * decode: (type) => Decode call result
242
- * }
243
- */
244
-
245
-
246
- function _contractDecodeData() {
247
- _contractDecodeData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(source, fn, callValue, callResult, options) {
248
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
249
- while (1) {
250
- switch (_context4.prev = _context4.next) {
251
- case 0:
252
- return _context4.abrupt("return", this.contractDecodeCallResultAPI(source, fn, callValue, callResult, options));
253
-
254
- case 1:
255
- case "end":
256
- return _context4.stop();
257
- }
258
- }
259
- }, _callee4, this);
260
- }));
261
- return _contractDecodeData.apply(this, arguments);
262
- }
263
-
264
- function contractCallStatic(_x17, _x18, _x19) {
265
- return _contractCallStatic.apply(this, arguments);
266
- }
267
- /**
268
- * Call contract function
269
- * @function
270
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
271
- * @category async
272
- * @param {String} source Contract source code
273
- * @param {String} address Contract address or AENS name
274
- * @param {String} name Name of function to call
275
- * @param {Array|String} argsOrCallData Argument's array or callData for call function
276
- * @param {Object} [options={}] Transaction options (fee, ttl, gas, amount, deposit)
277
- * @param {Object} [options.filesystem={}] Contract external namespaces map* @return {Promise<Object>} Result object
278
- * @example
279
- * const callResult = await client.contractCall(source, address, fnName, args = [], options)
280
- * {
281
- * hash: TX_HASH,
282
- * result: TX_DATA,
283
- * decode: (type) => Decode call result
284
- * }
285
- */
286
-
287
-
288
- function _contractCallStatic() {
289
- _contractCallStatic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(source, address, name) {
290
- var _this = this;
291
-
292
- var args,
293
- options,
294
- callerId,
295
- txOpt,
296
- tx,
297
- _yield$this$txDryRun,
298
- callObj,
299
- dryRunOther,
300
- returnType,
301
- returnValue,
302
- _args5 = arguments;
303
-
304
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
305
- while (1) {
306
- switch (_context5.prev = _context5.next) {
307
- case 0:
308
- args = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : [];
309
- options = _args5.length > 4 && _args5[4] !== undefined ? _args5[4] : {};
310
- _context5.next = 4;
311
- return this.address(options)["catch"](function () {
312
- return DRY_RUN_ACCOUNT.pub;
313
- });
314
-
315
- case 4:
316
- callerId = _context5.sent;
317
-
318
- if (!(typeof options.top === 'number')) {
319
- _context5.next = 9;
320
- break;
321
- }
322
-
323
- _context5.next = 8;
324
- return this.getKeyBlock(options.top);
325
-
326
- case 8:
327
- options.top = _context5.sent.hash;
328
-
329
- case 9:
330
- _context5.t0 = _objectSpread;
331
- _context5.t1 = _objectSpread(_objectSpread({}, this.Ae.defaults), options);
332
- _context5.t2 = {};
333
-
334
- if (!_Array$isArray(args)) {
335
- _context5.next = 18;
336
- break;
337
- }
338
-
339
- _context5.next = 15;
340
- return this.contractEncodeCall(source, name, args, options);
341
-
342
- case 15:
343
- _context5.t3 = _context5.sent;
344
- _context5.next = 19;
345
- break;
346
-
347
- case 18:
348
- _context5.t3 = args;
349
-
350
- case 19:
351
- _context5.t4 = _context5.t3;
352
- _context5.t5 = options.top;
353
-
354
- if (!_context5.t5) {
355
- _context5.next = 26;
356
- break;
357
- }
358
-
359
- _context5.next = 24;
360
- return this.getAccount(callerId, {
361
- hash: options.top
362
- });
363
-
364
- case 24:
365
- _context5.t6 = _context5.sent.nonce;
366
- _context5.t5 = _context5.t6 + 1;
367
-
368
- case 26:
369
- _context5.t7 = _context5.t5;
370
- _context5.t8 = {
371
- callData: _context5.t4,
372
- nonce: _context5.t7
373
- };
374
- txOpt = (0, _context5.t0)(_context5.t1, _context5.t2, _context5.t8);
375
-
376
- if (!(name === 'init')) {
377
- _context5.next = 35;
378
- break;
379
- }
380
-
381
- _context5.next = 32;
382
- return this.contractCreateTx(_objectSpread(_objectSpread({}, txOpt), {}, {
383
- code: options.bytecode,
384
- ownerId: callerId
385
- }));
386
-
387
- case 32:
388
- _context5.t9 = _context5.sent.tx;
389
- _context5.next = 48;
390
- break;
391
-
392
- case 35:
393
- _context5.t10 = this;
394
- _context5.t11 = _objectSpread;
395
- _context5.t12 = _objectSpread({}, txOpt);
396
- _context5.t13 = {};
397
- _context5.t14 = callerId;
398
- _context5.next = 42;
399
- return this.resolveName(address, 'ct', {
400
- resolveByNode: true
401
- });
402
-
403
- case 42:
404
- _context5.t15 = _context5.sent;
405
- _context5.t16 = {
406
- callerId: _context5.t14,
407
- contractId: _context5.t15
408
- };
409
- _context5.t17 = (0, _context5.t11)(_context5.t12, _context5.t13, _context5.t16);
410
- _context5.next = 47;
411
- return _context5.t10.contractCallTx.call(_context5.t10, _context5.t17);
412
-
413
- case 47:
414
- _context5.t9 = _context5.sent;
415
-
416
- case 48:
417
- tx = _context5.t9;
418
- _context5.next = 51;
419
- return this.txDryRun(tx, callerId, options);
420
-
421
- case 51:
422
- _yield$this$txDryRun = _context5.sent;
423
- callObj = _yield$this$txDryRun.callObj;
424
- dryRunOther = _objectWithoutProperties(_yield$this$txDryRun, _excluded);
425
- _context5.next = 56;
426
- return this._handleCallError(source, name, callObj);
427
-
428
- case 56:
429
- returnType = callObj.returnType, returnValue = callObj.returnValue;
430
- return _context5.abrupt("return", _objectSpread(_objectSpread({}, dryRunOther), {}, {
431
- tx: TxObject({
432
- tx: tx
433
- }),
434
- result: callObj,
435
- decode: function decode() {
436
- return _this.contractDecodeData(source, name, returnValue, returnType, options);
437
- }
438
- }));
439
-
440
- case 58:
441
- case "end":
442
- return _context5.stop();
443
- }
444
- }
445
- }, _callee5, this);
446
- }));
447
- return _contractCallStatic.apply(this, arguments);
448
- }
449
-
450
- function contractCall(_x20, _x21, _x22) {
451
- return _contractCall.apply(this, arguments);
452
- }
453
- /**
454
- * Deploy contract to the node
455
- * @function
456
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
457
- * @category async
458
- * @param {String} code Compiled contract
459
- * @param {String} source Contract source code
460
- * @param {Array|String} initState Arguments of contract constructor(init) function. Can be array of arguments or callData string
461
- * @param {Object} [options={}] Transaction options (fee, ttl, gas, amount, deposit)
462
- * @param {Object} [options.filesystem={}] Contract external namespaces map* @return {Promise<Object>} Result object
463
- * @return {Promise<Object>} Result object
464
- * @example
465
- * const deployed = await client.contractDeploy(bytecode, source, init = [], options)
466
- * {
467
- * owner: OWNER_PUB_KEY,
468
- * transaction: TX_HASH,
469
- * address: CONTRACT_ADDRESS,
470
- * createdAt: Date,
471
- * result: DEPLOY_TX_DATA,
472
- * call: (fnName, args = [], options) => Call contract function,
473
- * callStatic: (fnName, args = [], options) => Static all contract function
474
- * }
475
- */
476
-
477
-
478
- function _contractCall() {
479
- _contractCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(source, address, name) {
480
- var _this2 = this;
481
-
482
- var argsOrCallData,
483
- options,
484
- opt,
485
- tx,
486
- _yield$this$_sendAndP,
487
- hash,
488
- rawTx,
489
- result,
490
- txData,
491
- _args6 = arguments;
492
-
493
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
494
- while (1) {
495
- switch (_context6.prev = _context6.next) {
496
- case 0:
497
- argsOrCallData = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : [];
498
- options = _args6.length > 4 && _args6[4] !== undefined ? _args6[4] : {};
499
- opt = _merge(this.Ae.defaults, options);
500
- _context6.t0 = this;
501
- _context6.t1 = _merge;
502
- _context6.t2 = opt;
503
- _context6.next = 8;
504
- return this.address(opt);
505
-
506
- case 8:
507
- _context6.t3 = _context6.sent;
508
- _context6.next = 11;
509
- return this.resolveName(address, 'ct', {
510
- resolveByNode: true
511
- });
512
-
513
- case 11:
514
- _context6.t4 = _context6.sent;
515
-
516
- if (!_Array$isArray(argsOrCallData)) {
517
- _context6.next = 18;
518
- break;
519
- }
520
-
521
- _context6.next = 15;
522
- return this.contractEncodeCall(source, name, argsOrCallData, opt);
523
-
524
- case 15:
525
- _context6.t5 = _context6.sent;
526
- _context6.next = 19;
527
- break;
528
-
529
- case 18:
530
- _context6.t5 = argsOrCallData;
531
-
532
- case 19:
533
- _context6.t6 = _context6.t5;
534
- _context6.t7 = {
535
- callerId: _context6.t3,
536
- contractId: _context6.t4,
537
- callData: _context6.t6
538
- };
539
- _context6.t8 = (0, _context6.t1)(_context6.t2, _context6.t7);
540
- _context6.next = 24;
541
- return _context6.t0.contractCallTx.call(_context6.t0, _context6.t8);
542
-
543
- case 24:
544
- tx = _context6.sent;
545
- _context6.next = 27;
546
- return this._sendAndProcess(tx, source, name, opt);
547
-
548
- case 27:
549
- _yield$this$_sendAndP = _context6.sent;
550
- hash = _yield$this$_sendAndP.hash;
551
- rawTx = _yield$this$_sendAndP.rawTx;
552
- result = _yield$this$_sendAndP.result;
553
- txData = _yield$this$_sendAndP.txData;
554
- return _context6.abrupt("return", {
555
- hash: hash,
556
- rawTx: rawTx,
557
- result: result,
558
- txData: txData,
559
- decode: function decode() {
560
- return result ? _this2.contractDecodeData(source, name, result.returnValue, result.returnType, opt) : {};
561
- }
562
- });
563
-
564
- case 33:
565
- case "end":
566
- return _context6.stop();
567
- }
568
- }
569
- }, _callee6, this);
570
- }));
571
- return _contractCall.apply(this, arguments);
572
- }
573
-
574
- function contractDeploy(_x23, _x24) {
575
- return _contractDeploy.apply(this, arguments);
576
- }
577
- /**
578
- * Compile contract source code
579
- * @function
580
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
581
- * @category async
582
- * @param {String} source Contract sourece code
583
- * @param {Object} [options={}] Transaction options (fee, ttl, gas, amount, deposit)
584
- * @param {Object} [options.filesystem={}] Contract external namespaces map* @return {Promise<Object>} Result object
585
- * @return {Promise<Object>} Result object
586
- * @example
587
- * const compiled = await client.contractCompile(SOURCE_CODE)
588
- * {
589
- * bytecode: CONTRACT_BYTE_CODE,
590
- * deploy: (init = [], options = {}) => Deploy Contract,
591
- * encodeCall: (fnName, args = []) => Prepare callData
592
- * }
593
- */
594
-
595
-
596
- function _contractDeploy() {
597
- _contractDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(code, source) {
598
- var _this3 = this;
599
-
600
- var initState,
601
- options,
602
- opt,
603
- callData,
604
- ownerId,
605
- _yield$this$contractC,
606
- tx,
607
- contractId,
608
- _yield$this$_sendAndP2,
609
- hash,
610
- rawTx,
611
- result,
612
- txData,
613
- _args7 = arguments;
614
-
615
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
616
- while (1) {
617
- switch (_context7.prev = _context7.next) {
618
- case 0:
619
- initState = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : [];
620
- options = _args7.length > 3 && _args7[3] !== undefined ? _args7[3] : {};
621
- opt = _objectSpread(_objectSpread(_objectSpread({}, this.Ae.defaults), options), {}, {
622
- deposit: DEPOSIT
623
- });
624
-
625
- if (!_Array$isArray(initState)) {
626
- _context7.next = 9;
627
- break;
628
- }
629
-
630
- _context7.next = 6;
631
- return this.contractEncodeCall(source, 'init', initState, opt);
632
-
633
- case 6:
634
- _context7.t0 = _context7.sent;
635
- _context7.next = 10;
636
- break;
637
-
638
- case 9:
639
- _context7.t0 = initState;
640
-
641
- case 10:
642
- callData = _context7.t0;
643
- _context7.next = 13;
644
- return this.address(opt);
645
-
646
- case 13:
647
- ownerId = _context7.sent;
648
- _context7.next = 16;
649
- return this.contractCreateTx(_merge(opt, {
650
- callData: callData,
651
- code: code,
652
- ownerId: ownerId
653
- }));
654
-
655
- case 16:
656
- _yield$this$contractC = _context7.sent;
657
- tx = _yield$this$contractC.tx;
658
- contractId = _yield$this$contractC.contractId;
659
- _context7.next = 21;
660
- return this._sendAndProcess(tx, source, 'init', opt);
661
-
662
- case 21:
663
- _yield$this$_sendAndP2 = _context7.sent;
664
- hash = _yield$this$_sendAndP2.hash;
665
- rawTx = _yield$this$_sendAndP2.rawTx;
666
- result = _yield$this$_sendAndP2.result;
667
- txData = _yield$this$_sendAndP2.txData;
668
- return _context7.abrupt("return", _Object$freeze({
669
- result: result,
670
- owner: ownerId,
671
- transaction: hash,
672
- rawTx: rawTx,
673
- txData: txData,
674
- address: contractId,
675
- call: function call(name, args, options) {
676
- return _this3.contractCall(source, contractId, name, args, _objectSpread(_objectSpread({}, opt), options));
677
- },
678
- callStatic: function callStatic(name, args, options) {
679
- return _this3.contractCallStatic(source, contractId, name, args, _objectSpread(_objectSpread({}, opt), options));
680
- },
681
- createdAt: new Date()
682
- }));
683
-
684
- case 27:
685
- case "end":
686
- return _context7.stop();
687
- }
688
- }
689
- }, _callee7, this);
690
- }));
691
- return _contractDeploy.apply(this, arguments);
692
- }
693
-
694
- function contractCompile(_x25) {
695
- return _contractCompile.apply(this, arguments);
696
- }
697
- /**
698
- * Utility method to create a delegate signature for a contract
699
- * @function
700
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
701
- * @category async
702
- * @param {String[]} ids The list of id's to prepend
703
- * @param {Object} [opt={}] options
704
- * @param {{ onAccount: String | Object }} [opt={}] opt Options
705
- * @return {Promise<String>} Signature in hex representation
706
- */
707
-
708
-
709
- function _contractCompile() {
710
- _contractCompile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(source) {
711
- var _this4 = this;
712
-
713
- var options,
714
- opt,
715
- bytecode,
716
- _args8 = arguments;
717
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
718
- while (1) {
719
- switch (_context8.prev = _context8.next) {
720
- case 0:
721
- options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
722
- opt = _objectSpread(_objectSpread({}, this.Ae.defaults), options);
723
- _context8.next = 4;
724
- return this.compileContractAPI(source, options);
725
-
726
- case 4:
727
- bytecode = _context8.sent;
728
- return _context8.abrupt("return", _Object$freeze({
729
- encodeCall: function encodeCall(name, args) {
730
- return _this4.contractEncodeCall(source, name, args, opt);
731
- },
732
- deploy: function deploy(init, options) {
733
- return _this4.contractDeploy(bytecode, source, init, _objectSpread(_objectSpread({}, opt), options));
734
- },
735
- deployStatic: function deployStatic(init, options) {
736
- return _this4.contractCallStatic(source, null, 'init', init, _objectSpread(_objectSpread(_objectSpread({}, opt), options), {}, {
737
- bytecode: bytecode
738
- }));
739
- },
740
- bytecode: bytecode
741
- }));
742
-
743
- case 6:
744
- case "end":
745
- return _context8.stop();
746
- }
747
- }
748
- }, _callee8, this);
749
- }));
750
- return _contractCompile.apply(this, arguments);
751
- }
752
-
753
- function delegateSignatureCommon() {
754
- return _delegateSignatureCommon.apply(this, arguments);
755
- }
756
- /**
757
- * Helper to generate a signature to delegate pre-claim/claim/transfer/revoke of a name to a contract.
758
- * @function
759
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
760
- * @category async
761
- * @param {String} contractId Contract Id
762
- * @param {String} [name] The name
763
- * @param {{ onAccount: String | Object }} [opt={}] opt Options
764
- * @return {Promise<String>} Signature for delegation
765
- * @example
766
- * const client = await Universal({ ... })
767
- * const contractId = 'ct_asd2ks...' // contract address
768
- * const name = 'example.chain' // AENS name
769
- * const onAccount = await client.address() // Sign with a specific account
770
- * // Preclaim signature
771
- * const params = { contractId }
772
- * const preclaimSig = await client.createAensDelegationSignature(params, { onAccount: current })
773
- * // Claim, transfer and revoke signature
774
- * const params = { contractId, name }
775
- * const aensDelegationSig = await contract.createAensDelegationSignature(params, name, { onAccount: current })
776
- */
777
-
778
-
779
- function _delegateSignatureCommon() {
780
- _delegateSignatureCommon = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
781
- var _context9;
782
-
783
- var ids,
784
- opt,
785
- _args9 = arguments;
786
- return _regeneratorRuntime.wrap(function _callee9$(_context10) {
787
- while (1) {
788
- switch (_context10.prev = _context10.next) {
789
- case 0:
790
- ids = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : [];
791
- opt = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : {};
792
- _context10.t0 = this;
793
- _context10.t1 = _concatInstanceProperty(Buffer);
794
- _context10.t2 = Buffer;
795
- _context10.t3 = _concatInstanceProperty(_context9 = [Buffer.from(this.getNetworkId(opt))]);
796
- _context10.t4 = _context9;
797
- _context10.t5 = _toConsumableArray;
798
-
799
- if (!Object.prototype.hasOwnProperty.call(opt, 'onAccount')) {
800
- _context10.next = 17;
801
- break;
802
- }
803
-
804
- _context10.t7 = decode;
805
- _context10.next = 12;
806
- return this.address(opt);
807
-
808
- case 12:
809
- _context10.t8 = _context10.sent;
810
- _context10.t9 = (0, _context10.t7)(_context10.t8);
811
- _context10.t6 = [_context10.t9];
812
- _context10.next = 18;
813
- break;
814
-
815
- case 17:
816
- _context10.t6 = [];
817
-
818
- case 18:
819
- _context10.t10 = _context10.t6;
820
- _context10.t11 = (0, _context10.t5)(_context10.t10);
821
- _context10.t12 = _toConsumableArray(_mapInstanceProperty(ids).call(ids, function (e) {
822
- return decode(e);
823
- }));
824
- _context10.t13 = _context10.t3.call.call(_context10.t3, _context10.t4, _context10.t11, _context10.t12);
825
- _context10.t14 = _context10.t1.call.call(_context10.t1, _context10.t2, _context10.t13);
826
- _context10.t15 = opt;
827
- return _context10.abrupt("return", _context10.t0.sign.call(_context10.t0, _context10.t14, _context10.t15).then(function (s) {
828
- return Buffer.from(s).toString('hex');
829
- }));
830
-
831
- case 25:
832
- case "end":
833
- return _context10.stop();
834
- }
835
- }
836
- }, _callee9, this);
837
- }));
838
- return _delegateSignatureCommon.apply(this, arguments);
839
- }
840
-
841
- function createAensDelegationSignature(_x26) {
842
- return _createAensDelegationSignature.apply(this, arguments);
843
- }
844
- /**
845
- * Helper to generate a signature to delegate register/extend/respond of a Oracle to a contract.
846
- * @function
847
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
848
- * @category async
849
- * @param {String} contractId Contract Id
850
- * @param {String} [queryId] Oracle Query Id
851
- * @param {{ onAccount: String | Object }} [opt={}] opt Options
852
- * @return {Promise<String>} Signature for delegation
853
- * @example
854
- * const client = await Universal({ ... })
855
- * const contractId = 'ct_asd2ks...' // contract address
856
- * const queryId = 'oq_...' // Oracle Query Id
857
- * const onAccount = await client.address() // Sign with a specific account
858
- * // Oracle register and extend signature
859
- * const params = { contractId }
860
- * const oracleDelegationSig = await contract.createOracleDelegationSignature(params, { onAccount })
861
- * // Oracle respond signature
862
- * const params = { contractId, queryId }
863
- * const respondSig = await contract.createOracleDelegationSignature(params, queryId)
864
- */
865
-
866
-
867
- function _createAensDelegationSignature() {
868
- _createAensDelegationSignature = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref) {
869
- var _context11;
870
-
871
- var contractId,
872
- name,
873
- opt,
874
- _args10 = arguments;
875
- return _regeneratorRuntime.wrap(function _callee10$(_context12) {
876
- while (1) {
877
- switch (_context12.prev = _context12.next) {
878
- case 0:
879
- contractId = _ref.contractId, name = _ref.name;
880
- opt = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {};
881
- return _context12.abrupt("return", this.delegateSignatureCommon(_concatInstanceProperty(_context11 = []).call(_context11, _toConsumableArray(name ? [produceNameId(name)] : []), [contractId]), opt));
882
-
883
- case 3:
884
- case "end":
885
- return _context12.stop();
886
- }
887
- }
888
- }, _callee10, this);
889
- }));
890
- return _createAensDelegationSignature.apply(this, arguments);
891
- }
892
-
893
- function createOracleDelegationSignature(_x27) {
894
- return _createOracleDelegationSignature.apply(this, arguments);
895
- }
896
- /**
897
- * Contract Stamp
898
- *
899
- * Provide contract implementation
900
- * {@link module:@aeternity/aepp-sdk/es/ae--Ae} clients.
901
- * @function
902
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
903
- * @rtype Stamp
904
- * @param {Object} [options={}] - Initializer object
905
- * @return {Object} Contract instance
906
- * @example
907
- * import Transaction from '@aeternity/aepp-sdk/es/tx/tx
908
- * import MemoryAccount from '@aeternity/aepp-sdk/es/account/memory
909
- * import ChainNode from '@aeternity/aepp-sdk/es/chain/node
910
- * import ContractCompilerAPI from '@aeternity/aepp-sdk/es/contract/compiler
911
- * // or using bundle
912
- * import {
913
- * Transaction,
914
- * MemoryAccount,
915
- * ChainNode,
916
- * ContractCompilerAPI
917
- * } from '@aeternity/aepp-sdk
918
- *
919
- * const ContractWithAE = await Contract
920
- * .compose(Transaction, MemoryAccount, ChainNode) // AE implementation
921
- * .compose(ContractCompilerAPI) // ContractBase implementation
922
- * const client = await ContractWithAe({ url, internalUrl, compilerUrl, keypair, ... })
923
- *
924
- */
925
-
926
-
927
- function _createOracleDelegationSignature() {
928
- _createOracleDelegationSignature = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref2) {
929
- var _context13;
930
-
931
- var contractId,
932
- queryId,
933
- opt,
934
- _args11 = arguments;
935
- return _regeneratorRuntime.wrap(function _callee11$(_context14) {
936
- while (1) {
937
- switch (_context14.prev = _context14.next) {
938
- case 0:
939
- contractId = _ref2.contractId, queryId = _ref2.queryId;
940
- opt = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
941
- return _context14.abrupt("return", this.delegateSignatureCommon(_concatInstanceProperty(_context13 = []).call(_context13, _toConsumableArray(queryId ? [queryId] : []), [contractId]), opt));
942
-
943
- case 3:
944
- case "end":
945
- return _context14.stop();
946
- }
947
- }
948
- }, _callee11, this);
949
- }));
950
- return _createOracleDelegationSignature.apply(this, arguments);
951
- }
952
-
953
- export var ContractAPI = Ae.compose(ContractBase, {
954
- methods: {
955
- getContractInstance: getContractInstance,
956
- contractCompile: contractCompile,
957
- contractCallStatic: contractCallStatic,
958
- contractDeploy: contractDeploy,
959
- contractCall: contractCall,
960
- contractEncodeCall: contractEncodeCall,
961
- contractDecodeData: contractDecodeData,
962
- _handleCallError: _handleCallError,
963
- _sendAndProcess: _sendAndProcess,
964
- // Delegation for contract
965
- delegateSignatureCommon: delegateSignatureCommon,
966
- // AENS
967
- createAensDelegationSignature: createAensDelegationSignature,
968
- // Oracle
969
- createOracleDelegationSignature: createOracleDelegationSignature
970
- },
971
- deepProps: {
972
- Ae: {
973
- defaults: {
974
- deposit: DEPOSIT,
975
- gasPrice: MIN_GAS_PRICE,
976
- amount: AMOUNT,
977
- gas: GAS
978
- }
979
- }
980
- }
981
- });
982
- export var Contract = ContractAPI.compose(NodePool);
983
- export var ContractWithCompiler = Contract.compose(ContractCompilerAPI);
984
- export default ContractWithCompiler;
985
- //# sourceMappingURL=contract.js.map