@aeternity/aepp-sdk 8.2.1 → 10.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 (159) hide show
  1. package/CHANGELOG.md +216 -337
  2. package/README.md +16 -9
  3. package/dist/aepp-sdk.browser-script.js +1 -1
  4. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -9
  5. package/dist/aepp-sdk.browser-script.js.map +1 -1
  6. package/dist/aepp-sdk.browser.js +1 -1
  7. package/dist/aepp-sdk.browser.js.map +1 -1
  8. package/dist/aepp-sdk.js +1 -1
  9. package/dist/aepp-sdk.js.map +1 -1
  10. package/es/account/base.js +36 -120
  11. package/es/account/base.js.map +1 -1
  12. package/es/account/memory.js +17 -19
  13. package/es/account/memory.js.map +1 -1
  14. package/es/account/multiple.js +79 -156
  15. package/es/account/multiple.js.map +1 -1
  16. package/es/ae/aens.js +205 -626
  17. package/es/ae/aens.js.map +1 -1
  18. package/es/ae/contract.js +114 -918
  19. package/es/ae/contract.js.map +1 -1
  20. package/es/ae/index.js +90 -250
  21. package/es/ae/index.js.map +1 -1
  22. package/es/ae/oracle.js +136 -504
  23. package/es/ae/oracle.js.map +1 -1
  24. package/es/ae/universal.js.map +1 -1
  25. package/es/chain/index.js +12 -27
  26. package/es/chain/index.js.map +1 -1
  27. package/es/chain/node.js +289 -1020
  28. package/es/chain/node.js.map +1 -1
  29. package/es/channel/handlers.js +597 -1086
  30. package/es/channel/handlers.js.map +1 -1
  31. package/es/channel/index.js +238 -465
  32. package/es/channel/index.js.map +1 -1
  33. package/es/channel/internal.js +129 -301
  34. package/es/channel/internal.js.map +1 -1
  35. package/es/contract/aci/index.js +328 -495
  36. package/es/contract/aci/index.js.map +1 -1
  37. package/es/contract/aci/transformation.js +35 -711
  38. package/es/contract/aci/transformation.js.map +1 -1
  39. package/es/contract/compiler.js +131 -203
  40. package/es/contract/compiler.js.map +1 -1
  41. package/es/contract/ga/helpers.js +17 -122
  42. package/es/contract/ga/helpers.js.map +1 -1
  43. package/es/contract/ga/index.js +108 -249
  44. package/es/contract/ga/index.js.map +1 -1
  45. package/es/contract/index.js +7 -3
  46. package/es/contract/index.js.map +1 -1
  47. package/es/index.js +3 -3
  48. package/es/index.js.map +1 -1
  49. package/es/node-pool/index.js +57 -74
  50. package/es/node-pool/index.js.map +1 -1
  51. package/es/node.js +65 -161
  52. package/es/node.js.map +1 -1
  53. package/es/other.d.ts +1 -1
  54. package/es/tx/builder/helpers.js +62 -115
  55. package/es/tx/builder/helpers.js.map +1 -1
  56. package/es/tx/builder/index.js +218 -309
  57. package/es/tx/builder/index.js.map +1 -1
  58. package/es/tx/builder/schema.js +586 -573
  59. package/es/tx/builder/schema.js.map +1 -1
  60. package/es/tx/index.js +102 -13
  61. package/es/tx/index.js.map +1 -1
  62. package/es/tx/tx-object.js +114 -138
  63. package/es/tx/tx-object.js.map +1 -1
  64. package/es/tx/tx.js +810 -1586
  65. package/es/tx/tx.js.map +1 -1
  66. package/es/tx/validator.js +191 -426
  67. package/es/tx/validator.js.map +1 -1
  68. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +20 -23
  69. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
  70. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +53 -80
  71. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
  72. package/es/utils/aepp-wallet-communication/connection/index.js +2 -1
  73. package/es/utils/aepp-wallet-communication/connection/index.js.map +1 -1
  74. package/es/utils/aepp-wallet-communication/content-script-bridge.js +24 -19
  75. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
  76. package/es/utils/aepp-wallet-communication/helpers.js +60 -105
  77. package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
  78. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +191 -514
  79. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
  80. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +78 -93
  81. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
  82. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +381 -613
  83. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
  84. package/es/utils/aepp-wallet-communication/schema.js +43 -39
  85. package/es/utils/aepp-wallet-communication/schema.js.map +1 -1
  86. package/es/utils/aepp-wallet-communication/wallet-detector.js +32 -58
  87. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
  88. package/es/utils/amount-formatter.js +41 -61
  89. package/es/utils/amount-formatter.js.map +1 -1
  90. package/es/utils/async-init.js +28 -64
  91. package/es/utils/async-init.js.map +1 -1
  92. package/es/utils/bignumber.js +3 -11
  93. package/es/utils/bignumber.js.map +1 -1
  94. package/es/utils/bytes.js +5 -9
  95. package/es/utils/bytes.js.map +1 -1
  96. package/es/utils/crypto.js +41 -106
  97. package/es/utils/crypto.js.map +1 -1
  98. package/es/utils/hd-wallet.js +45 -81
  99. package/es/utils/hd-wallet.js.map +1 -1
  100. package/es/utils/json-big.js +16 -49
  101. package/es/utils/json-big.js.map +1 -1
  102. package/es/utils/keystore.js +81 -246
  103. package/es/utils/keystore.js.map +1 -1
  104. package/es/utils/mptree.js +88 -134
  105. package/es/utils/mptree.js.map +1 -1
  106. package/es/utils/other.js +10 -60
  107. package/es/utils/other.js.map +1 -1
  108. package/es/utils/semver-satisfies.js +9 -28
  109. package/es/utils/semver-satisfies.js.map +1 -1
  110. package/es/utils/string.js +4 -13
  111. package/es/utils/string.js.map +1 -1
  112. package/es/utils/swagger.js +87 -224
  113. package/es/utils/swagger.js.map +1 -1
  114. package/package.json +51 -44
  115. package/src/account/base.js +11 -10
  116. package/src/account/multiple.js +24 -18
  117. package/src/ae/aens.js +64 -61
  118. package/src/ae/contract.js +71 -248
  119. package/src/ae/index.js +34 -9
  120. package/src/ae/oracle.js +30 -22
  121. package/src/ae/universal.js +3 -1
  122. package/src/chain/index.js +10 -16
  123. package/src/chain/node.js +38 -38
  124. package/src/channel/handlers.js +10 -4
  125. package/src/channel/index.js +44 -20
  126. package/src/contract/aci/index.js +234 -112
  127. package/src/contract/aci/transformation.js +30 -422
  128. package/src/contract/compiler.js +50 -5
  129. package/src/contract/ga/helpers.js +6 -14
  130. package/src/contract/ga/index.js +28 -28
  131. package/src/contract/index.js +6 -2
  132. package/src/index.js +4 -4
  133. package/src/node-pool/index.js +24 -13
  134. package/src/node.js +29 -30
  135. package/src/tx/builder/helpers.js +31 -56
  136. package/src/tx/builder/index.js +67 -28
  137. package/src/tx/builder/schema.js +79 -121
  138. package/src/tx/index.js +101 -12
  139. package/src/tx/tx-object.js +25 -8
  140. package/src/tx/tx.js +229 -150
  141. package/src/tx/validator.js +134 -202
  142. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +3 -2
  143. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +25 -7
  144. package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
  145. package/src/utils/aepp-wallet-communication/content-script-bridge.js +10 -4
  146. package/src/utils/aepp-wallet-communication/helpers.js +4 -2
  147. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +33 -12
  148. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +9 -5
  149. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +59 -29
  150. package/src/utils/aepp-wallet-communication/schema.js +1 -3
  151. package/src/utils/aepp-wallet-communication/wallet-detector.js +4 -1
  152. package/src/utils/amount-formatter.ts +1 -1
  153. package/src/utils/bignumber.ts +2 -1
  154. package/src/utils/crypto.js +4 -68
  155. package/src/utils/keystore.js +10 -2
  156. package/src/utils/other.ts +1 -1
  157. package/src/utils/semver-satisfies.ts +1 -1
  158. package/src/utils/swagger.js +22 -10
  159. package/src/contract/aci/helpers.js +0 -140
package/es/ae/contract.js CHANGED
@@ -1,27 +1,3 @@
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 _context18; _forEachInstanceProperty(_context18 = ownKeys(Object(source), true)).call(_context18, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context19; _forEachInstanceProperty(_context19 = ownKeys(Object(source))).call(_context19, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
24
-
25
1
  /*
26
2
  * ISC License (ISC)
27
3
  * Copyright (c) 2018 aeternity developers
@@ -54,181 +30,18 @@ import ContractCompilerAPI from '../contract/compiler';
54
30
  import ContractBase from '../contract';
55
31
  import getContractInstance from '../contract/aci';
56
32
  import NodePool from '../node-pool';
57
- import { AMOUNT, DEPOSIT, DRY_RUN_ACCOUNT, GAS, MIN_GAS_PRICE } from '../tx/builder/schema';
33
+ import { AMOUNT, DEPOSIT, GAS, MIN_GAS_PRICE } from '../tx/builder/schema';
58
34
  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
35
  /**
224
36
  * Static contract call(using dry-run)
225
37
  * @function
226
38
  * @alias module:@aeternity/aepp-sdk/es/ae/contract
227
39
  * @category async
40
+ * @deprecated
228
41
  * @param {String} source Contract source code
229
- * @param {String} address Contract address
42
+ * @param {String} contractAddress Contract address
230
43
  * @param {String} name Name of function to call
231
- * @param {Array|String} args Argument's or callData for call/deploy transaction
44
+ * @param {Array} args Arguments array for call/deploy transaction
232
45
  * @param {Object} [options]
233
46
  * @param {Number|String} [options.top] Block height or hash on which you want to call contract
234
47
  * @param {String} [options.bytecode] Block hash on which you want to call contract
@@ -242,39 +55,30 @@ function contractDecodeData(_x12, _x13, _x14, _x15, _x16) {
242
55
  * }
243
56
  */
244
57
 
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);
58
+ async function contractCallStatic(source, contractAddress, name) {
59
+ let args = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
60
+ let options = arguments.length > 4 ? arguments[4] : undefined;
61
+ const contract = await this.getContractInstance({ ...options,
62
+ source,
63
+ contractAddress
64
+ });
65
+ return contract.call(name, args, { ...options,
66
+ callStatic: true
67
+ });
266
68
  }
267
69
  /**
268
70
  * Call contract function
269
71
  * @function
270
72
  * @alias module:@aeternity/aepp-sdk/es/ae/contract
271
73
  * @category async
74
+ * @deprecated
272
75
  * @param {String} source Contract source code
273
- * @param {String} address Contract address or AENS name
76
+ * @param {String} contractAddress Contract address or AENS name
274
77
  * @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
78
+ * @param {Array} args Arguments array for call/deploy transaction
79
+ * @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)
80
+ * @param {Object} [options.filesystem] Contract external namespaces map
81
+ * @return {Promise<Object>} Result object
278
82
  * @example
279
83
  * const callResult = await client.contractCall(source, address, fnName, args = [], options)
280
84
  * {
@@ -285,181 +89,25 @@ function contractCallStatic(_x17, _x18, _x19) {
285
89
  */
286
90
 
287
91
 
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);
92
+ async function contractCall(source, contractAddress, name, args, options) {
93
+ const contract = await this.getContractInstance({ ...options,
94
+ source,
95
+ contractAddress
96
+ });
97
+ return contract.call(name, args, options);
452
98
  }
453
99
  /**
454
100
  * Deploy contract to the node
455
101
  * @function
456
102
  * @alias module:@aeternity/aepp-sdk/es/ae/contract
457
103
  * @category async
104
+ * @deprecated
458
105
  * @param {String} code Compiled contract
459
106
  * @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
107
+ * @param {Array} params Arguments of contract constructor(init) function. Can be array of
108
+ * arguments or callData string
109
+ * @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)
110
+ * @param {Object} [options.filesystem={}] Contract external namespaces map*
463
111
  * @return {Promise<Object>} Result object
464
112
  * @example
465
113
  * const deployed = await client.contractDeploy(bytecode, source, init = [], options)
@@ -475,104 +123,12 @@ function contractCall(_x20, _x21, _x22) {
475
123
  */
476
124
 
477
125
 
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);
126
+ async function contractDeploy(code, source, params, options) {
127
+ const contract = await this.getContractInstance({ ...options,
128
+ source
129
+ });
130
+ contract.bytecode = code;
131
+ return contract.deploy(params, options);
576
132
  }
577
133
  /**
578
134
  * Compile contract source code
@@ -581,7 +137,7 @@ function contractDeploy(_x23, _x24) {
581
137
  * @category async
582
138
  * @param {String} source Contract sourece code
583
139
  * @param {Object} [options={}] Transaction options (fee, ttl, gas, amount, deposit)
584
- * @param {Object} [options.filesystem={}] Contract external namespaces map* @return {Promise<Object>} Result object
140
+ * @param {Object} [options.filesystem={}] Contract external namespaces map*
585
141
  * @return {Promise<Object>} Result object
586
142
  * @example
587
143
  * const compiled = await client.contractCompile(SOURCE_CODE)
@@ -593,104 +149,23 @@ function contractDeploy(_x23, _x24) {
593
149
  */
594
150
 
595
151
 
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({}, this.Ae.defaults), options);
622
-
623
- if (!_Array$isArray(initState)) {
624
- _context7.next = 9;
625
- break;
626
- }
627
-
628
- _context7.next = 6;
629
- return this.contractEncodeCall(source, 'init', initState, opt);
630
-
631
- case 6:
632
- _context7.t0 = _context7.sent;
633
- _context7.next = 10;
634
- break;
635
-
636
- case 9:
637
- _context7.t0 = initState;
638
-
639
- case 10:
640
- callData = _context7.t0;
641
- _context7.next = 13;
642
- return this.address(opt);
643
-
644
- case 13:
645
- ownerId = _context7.sent;
646
- _context7.next = 16;
647
- return this.contractCreateTx(_merge(opt, {
648
- callData: callData,
649
- code: code,
650
- ownerId: ownerId
651
- }));
652
-
653
- case 16:
654
- _yield$this$contractC = _context7.sent;
655
- tx = _yield$this$contractC.tx;
656
- contractId = _yield$this$contractC.contractId;
657
- _context7.next = 21;
658
- return this._sendAndProcess(tx, source, 'init', opt);
659
-
660
- case 21:
661
- _yield$this$_sendAndP2 = _context7.sent;
662
- hash = _yield$this$_sendAndP2.hash;
663
- rawTx = _yield$this$_sendAndP2.rawTx;
664
- result = _yield$this$_sendAndP2.result;
665
- txData = _yield$this$_sendAndP2.txData;
666
- return _context7.abrupt("return", _Object$freeze({
667
- result: result,
668
- owner: ownerId,
669
- transaction: hash,
670
- rawTx: rawTx,
671
- txData: txData,
672
- address: contractId,
673
- call: function call(name, args, options) {
674
- return _this3.contractCall(source, contractId, name, args, _objectSpread(_objectSpread({}, opt), options));
675
- },
676
- callStatic: function callStatic(name, args, options) {
677
- return _this3.contractCallStatic(source, contractId, name, args, _objectSpread(_objectSpread({}, opt), options));
678
- },
679
- createdAt: new Date()
680
- }));
681
-
682
- case 27:
683
- case "end":
684
- return _context7.stop();
685
- }
686
- }
687
- }, _callee7, this);
688
- }));
689
- return _contractDeploy.apply(this, arguments);
690
- }
691
-
692
- function contractCompile(_x25) {
693
- return _contractCompile.apply(this, arguments);
152
+ async function contractCompile(source) {
153
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
154
+ const opt = { ...this.Ae.defaults,
155
+ ...options
156
+ };
157
+ const bytecode = await this.compileContractAPI(source, options);
158
+ return Object.freeze({
159
+ encodeCall: (name, args) => this.contractEncodeCallDataAPI(source, name, args, opt),
160
+ deploy: (init, options) => this.contractDeploy(bytecode, source, init, { ...opt,
161
+ ...options
162
+ }),
163
+ deployStatic: (init, options) => this.contractCallStatic(source, null, 'init', init, { ...opt,
164
+ ...options,
165
+ bytecode
166
+ }),
167
+ bytecode
168
+ });
694
169
  }
695
170
  /**
696
171
  * Utility method to create a delegate signature for a contract
@@ -704,325 +179,76 @@ function contractCompile(_x25) {
704
179
  */
705
180
 
706
181
 
707
- function _contractCompile() {
708
- _contractCompile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(source) {
709
- var _this4 = this;
710
-
711
- var options,
712
- opt,
713
- bytecode,
714
- _args8 = arguments;
715
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
716
- while (1) {
717
- switch (_context8.prev = _context8.next) {
718
- case 0:
719
- options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
720
- opt = _objectSpread(_objectSpread({}, this.Ae.defaults), options);
721
- _context8.next = 4;
722
- return this.compileContractAPI(source, options);
723
-
724
- case 4:
725
- bytecode = _context8.sent;
726
- return _context8.abrupt("return", _Object$freeze({
727
- encodeCall: function encodeCall(name, args) {
728
- return _this4.contractEncodeCall(source, name, args, opt);
729
- },
730
- deploy: function deploy(init, options) {
731
- return _this4.contractDeploy(bytecode, source, init, _objectSpread(_objectSpread({}, opt), options));
732
- },
733
- deployStatic: function deployStatic(init, options) {
734
- return _this4.contractCallStatic(source, null, 'init', init, _objectSpread(_objectSpread(_objectSpread({}, opt), options), {}, {
735
- bytecode: bytecode
736
- }));
737
- },
738
- bytecode: bytecode
739
- }));
740
-
741
- case 6:
742
- case "end":
743
- return _context8.stop();
744
- }
745
- }
746
- }, _callee8, this);
747
- }));
748
- return _contractCompile.apply(this, arguments);
749
- }
750
-
751
- function delegateSignatureCommon() {
752
- return _delegateSignatureCommon.apply(this, arguments);
753
- }
754
- /**
755
- * Helper to generate a signature to delegate a name pre-claim to a contract.
756
- * @function
757
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
758
- * @category async
759
- * @param {String} contractId Contract Id
760
- * @param {{ onAccount: String | Object }} [opt={}] opt Options
761
- * @return {Promise<String>} Signature for delegation
762
- */
763
-
764
-
765
- function _delegateSignatureCommon() {
766
- _delegateSignatureCommon = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
767
- var _context9;
768
-
769
- var ids,
770
- opt,
771
- _args9 = arguments;
772
- return _regeneratorRuntime.wrap(function _callee9$(_context10) {
773
- while (1) {
774
- switch (_context10.prev = _context10.next) {
775
- case 0:
776
- ids = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : [];
777
- opt = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : {};
778
- _context10.t0 = this;
779
- _context10.t1 = _concatInstanceProperty(Buffer);
780
- _context10.t2 = Buffer;
781
- _context10.t3 = _concatInstanceProperty;
782
- _context10.t4 = Buffer.from(this.getNetworkId(opt));
783
- _context10.t5 = decode;
784
- _context10.next = 10;
785
- return this.address(opt);
786
-
787
- case 10:
788
- _context10.t6 = _context10.sent;
789
- _context10.t7 = (0, _context10.t5)(_context10.t6);
790
- _context10.t8 = _context9 = [_context10.t4, _context10.t7];
791
- _context10.t9 = (0, _context10.t3)(_context10.t8).call(_context9, _toConsumableArray(_mapInstanceProperty(ids).call(ids, function (e) {
792
- return decode(e);
793
- })));
794
- _context10.t10 = _context10.t1.call.call(_context10.t1, _context10.t2, _context10.t9);
795
- _context10.t11 = opt;
796
- return _context10.abrupt("return", _context10.t0.sign.call(_context10.t0, _context10.t10, _context10.t11).then(function (s) {
797
- return Buffer.from(s).toString('hex');
798
- }));
799
-
800
- case 17:
801
- case "end":
802
- return _context10.stop();
803
- }
804
- }
805
- }, _callee9, this);
806
- }));
807
- return _delegateSignatureCommon.apply(this, arguments);
808
- }
809
-
810
- function delegateNamePreclaimSignature(_x26) {
811
- return _delegateNamePreclaimSignature.apply(this, arguments);
812
- }
813
- /**
814
- * Helper to generate a signature to delegate a name claim to a contract.
815
- * @function
816
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
817
- * @category async
818
- * @param {String} name The name being claimed
819
- * @param {String} contractId Contract Id
820
- * @param {{ onAccount: String | Object }} [opt={}] opt Options
821
- * @return {Promise<String>} Signature for delegation
822
- */
823
-
824
-
825
- function _delegateNamePreclaimSignature() {
826
- _delegateNamePreclaimSignature = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(contractId) {
827
- var opt,
828
- _args10 = arguments;
829
- return _regeneratorRuntime.wrap(function _callee10$(_context11) {
830
- while (1) {
831
- switch (_context11.prev = _context11.next) {
832
- case 0:
833
- opt = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {};
834
- return _context11.abrupt("return", this.delegateSignatureCommon([contractId], opt));
835
-
836
- case 2:
837
- case "end":
838
- return _context11.stop();
839
- }
840
- }
841
- }, _callee10, this);
842
- }));
843
- return _delegateNamePreclaimSignature.apply(this, arguments);
844
- }
845
-
846
- function delegateNameClaimSignature(_x27, _x28) {
847
- return _delegateNameClaimSignature.apply(this, arguments);
848
- }
849
- /**
850
- * Helper to generate a signature to delegate a name transfer to a contract.
851
- * @function
852
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
853
- * @category async
854
- * @param {String} contractId Contract Id
855
- * @param {String} name The name being transferred
856
- * @param {{ onAccount: String | Object }} [opt={}] opt Options
857
- * @return {Promise<String>} Signature for delegation
858
- */
859
-
860
-
861
- function _delegateNameClaimSignature() {
862
- _delegateNameClaimSignature = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(contractId, name) {
863
- var opt,
864
- _args11 = arguments;
865
- return _regeneratorRuntime.wrap(function _callee11$(_context12) {
866
- while (1) {
867
- switch (_context12.prev = _context12.next) {
868
- case 0:
869
- opt = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : {};
870
- return _context12.abrupt("return", this.delegateSignatureCommon([produceNameId(name), contractId], opt));
871
-
872
- case 2:
873
- case "end":
874
- return _context12.stop();
875
- }
876
- }
877
- }, _callee11, this);
878
- }));
879
- return _delegateNameClaimSignature.apply(this, arguments);
880
- }
881
-
882
- function delegateNameTransferSignature(_x29, _x30) {
883
- return _delegateNameTransferSignature.apply(this, arguments);
884
- }
885
- /**
886
- * Helper to generate a signature to delegate a name revoke to a contract.
887
- * @function
888
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
889
- * @category async
890
- * @param {String} contractId Contract Id
891
- * @param {String} name The name being revoked
892
- * @param {{ onAccount: String | Object }} [opt={}] opt Options
893
- * @return {Promise<String>} Signature for delegation
894
- */
895
-
896
-
897
- function _delegateNameTransferSignature() {
898
- _delegateNameTransferSignature = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(contractId, name) {
899
- var opt,
900
- _args12 = arguments;
901
- return _regeneratorRuntime.wrap(function _callee12$(_context13) {
902
- while (1) {
903
- switch (_context13.prev = _context13.next) {
904
- case 0:
905
- opt = _args12.length > 2 && _args12[2] !== undefined ? _args12[2] : {};
906
- return _context13.abrupt("return", this.delegateSignatureCommon([produceNameId(name), contractId], opt));
907
-
908
- case 2:
909
- case "end":
910
- return _context13.stop();
911
- }
912
- }
913
- }, _callee12, this);
914
- }));
915
- return _delegateNameTransferSignature.apply(this, arguments);
916
- }
917
-
918
- function delegateNameRevokeSignature(_x31, _x32) {
919
- return _delegateNameRevokeSignature.apply(this, arguments);
920
- }
921
- /**
922
- * Helper to generate a signature to delegate a Oracle register to a contract.
923
- * @function
924
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
925
- * @category async
926
- * @param {String} contractId Contract Id
927
- * @param {{ onAccount: String | Object }} [opt={}] opt Options
928
- * @return {Promise<String>} Signature for delegation
929
- */
930
-
931
-
932
- function _delegateNameRevokeSignature() {
933
- _delegateNameRevokeSignature = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(contractId, name) {
934
- var opt,
935
- _args13 = arguments;
936
- return _regeneratorRuntime.wrap(function _callee13$(_context14) {
937
- while (1) {
938
- switch (_context14.prev = _context14.next) {
939
- case 0:
940
- opt = _args13.length > 2 && _args13[2] !== undefined ? _args13[2] : {};
941
- return _context14.abrupt("return", this.delegateSignatureCommon([produceNameId(name), contractId], opt));
942
-
943
- case 2:
944
- case "end":
945
- return _context14.stop();
946
- }
947
- }
948
- }, _callee13, this);
949
- }));
950
- return _delegateNameRevokeSignature.apply(this, arguments);
951
- }
952
-
953
- function delegateOracleRegisterSignature(_x33) {
954
- return _delegateOracleRegisterSignature.apply(this, arguments);
182
+ async function delegateSignatureCommon() {
183
+ let ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
184
+ let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
185
+ const signature = await this.sign(Buffer.concat([Buffer.from(this.getNetworkId(opt)), ...(Object.prototype.hasOwnProperty.call(opt, 'onAccount') ? [decode(await this.address(opt))] : []), ...ids.map(e => decode(e))]), opt);
186
+ return Buffer.from(signature).toString('hex');
955
187
  }
956
188
  /**
957
- * Helper to generate a signature to delegate a Oracle extend to a contract.
189
+ * Helper to generate a signature to delegate pre-claim/claim/transfer/revoke of a name to
190
+ * a contract.
958
191
  * @function
959
192
  * @alias module:@aeternity/aepp-sdk/es/ae/contract
960
193
  * @category async
961
194
  * @param {String} contractId Contract Id
195
+ * @param {String} [name] The name
962
196
  * @param {{ onAccount: String | Object }} [opt={}] opt Options
963
197
  * @return {Promise<String>} Signature for delegation
198
+ * @example
199
+ * const client = await Universal({ ... })
200
+ * const contractId = 'ct_asd2ks...' // contract address
201
+ * const name = 'example.chain' // AENS name
202
+ * const onAccount = await client.address() // Sign with a specific account
203
+ * // Preclaim signature
204
+ * const params = { contractId }
205
+ * const preclaimSig = await client.createAensDelegationSignature(params, { onAccount: current })
206
+ * // Claim, transfer and revoke signature
207
+ * const params = { contractId, name }
208
+ * const aensDelegationSig = await contract.createAensDelegationSignature(
209
+ * params, name, { onAccount: current }
210
+ * )
964
211
  */
965
212
 
966
213
 
967
- function _delegateOracleRegisterSignature() {
968
- _delegateOracleRegisterSignature = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(contractId) {
969
- var opt,
970
- _args14 = arguments;
971
- return _regeneratorRuntime.wrap(function _callee14$(_context15) {
972
- while (1) {
973
- switch (_context15.prev = _context15.next) {
974
- case 0:
975
- opt = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
976
- return _context15.abrupt("return", this.delegateSignatureCommon([contractId], opt));
977
-
978
- case 2:
979
- case "end":
980
- return _context15.stop();
981
- }
982
- }
983
- }, _callee14, this);
984
- }));
985
- return _delegateOracleRegisterSignature.apply(this, arguments);
986
- }
987
-
988
- function delegateOracleExtendSignature(_x34) {
989
- return _delegateOracleExtendSignature.apply(this, arguments);
214
+ async function createAensDelegationSignature(_ref) {
215
+ let {
216
+ contractId,
217
+ name
218
+ } = _ref;
219
+ let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
220
+ return this.delegateSignatureCommon([...(name ? [produceNameId(name)] : []), contractId], opt);
990
221
  }
991
222
  /**
992
- * Helper to generate a signature to delegate a Oracle respond to a contract.
223
+ * Helper to generate a signature to delegate register/extend/respond of a Oracle to a contract.
993
224
  * @function
994
225
  * @alias module:@aeternity/aepp-sdk/es/ae/contract
995
226
  * @category async
996
- * @param {String} queryId Oracle Query Id
997
227
  * @param {String} contractId Contract Id
228
+ * @param {String} [queryId] Oracle Query Id
998
229
  * @param {{ onAccount: String | Object }} [opt={}] opt Options
999
230
  * @return {Promise<String>} Signature for delegation
231
+ * @example
232
+ * const client = await Universal({ ... })
233
+ * const contractId = 'ct_asd2ks...' // contract address
234
+ * const queryId = 'oq_...' // Oracle Query Id
235
+ * const onAccount = await client.address() // Sign with a specific account
236
+ * // Oracle register and extend signature
237
+ * const params = { contractId }
238
+ * const oracleDelegationSig = await contract.createOracleDelegationSignature(params, { onAccount })
239
+ * // Oracle respond signature
240
+ * const params = { contractId, queryId }
241
+ * const respondSig = await contract.createOracleDelegationSignature(params, queryId)
1000
242
  */
1001
243
 
1002
244
 
1003
- function _delegateOracleExtendSignature() {
1004
- _delegateOracleExtendSignature = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(contractId) {
1005
- var opt,
1006
- _args15 = arguments;
1007
- return _regeneratorRuntime.wrap(function _callee15$(_context16) {
1008
- while (1) {
1009
- switch (_context16.prev = _context16.next) {
1010
- case 0:
1011
- opt = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : {};
1012
- return _context16.abrupt("return", this.delegateSignatureCommon([contractId], opt));
1013
-
1014
- case 2:
1015
- case "end":
1016
- return _context16.stop();
1017
- }
1018
- }
1019
- }, _callee15, this);
1020
- }));
1021
- return _delegateOracleExtendSignature.apply(this, arguments);
1022
- }
1023
-
1024
- function delegateOracleRespondSignature(_x35, _x36) {
1025
- return _delegateOracleRespondSignature.apply(this, arguments);
245
+ async function createOracleDelegationSignature(_ref2) {
246
+ let {
247
+ contractId,
248
+ queryId
249
+ } = _ref2;
250
+ let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
251
+ return this.delegateSignatureCommon([...(queryId ? [queryId] : []), contractId], opt);
1026
252
  }
1027
253
  /**
1028
254
  * Contract Stamp
@@ -1055,49 +281,19 @@ function delegateOracleRespondSignature(_x35, _x36) {
1055
281
  */
1056
282
 
1057
283
 
1058
- function _delegateOracleRespondSignature() {
1059
- _delegateOracleRespondSignature = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(queryId, contractId) {
1060
- var opt,
1061
- _args16 = arguments;
1062
- return _regeneratorRuntime.wrap(function _callee16$(_context17) {
1063
- while (1) {
1064
- switch (_context17.prev = _context17.next) {
1065
- case 0:
1066
- opt = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
1067
- return _context17.abrupt("return", this.delegateSignatureCommon([queryId, contractId], opt));
1068
-
1069
- case 2:
1070
- case "end":
1071
- return _context17.stop();
1072
- }
1073
- }
1074
- }, _callee16, this);
1075
- }));
1076
- return _delegateOracleRespondSignature.apply(this, arguments);
1077
- }
1078
-
1079
- export var ContractAPI = Ae.compose(ContractBase, {
284
+ export const ContractAPI = Ae.compose(ContractBase, {
1080
285
  methods: {
1081
- getContractInstance: getContractInstance,
1082
- contractCompile: contractCompile,
1083
- contractCallStatic: contractCallStatic,
1084
- contractDeploy: contractDeploy,
1085
- contractCall: contractCall,
1086
- contractEncodeCall: contractEncodeCall,
1087
- contractDecodeData: contractDecodeData,
1088
- _handleCallError: _handleCallError,
1089
- _sendAndProcess: _sendAndProcess,
286
+ getContractInstance,
287
+ contractCompile,
288
+ contractCallStatic,
289
+ contractDeploy,
290
+ contractCall,
1090
291
  // Delegation for contract
292
+ delegateSignatureCommon,
1091
293
  // AENS
1092
- delegateSignatureCommon: delegateSignatureCommon,
1093
- delegateNamePreclaimSignature: delegateNamePreclaimSignature,
1094
- delegateNameClaimSignature: delegateNameClaimSignature,
1095
- delegateNameTransferSignature: delegateNameTransferSignature,
1096
- delegateNameRevokeSignature: delegateNameRevokeSignature,
294
+ createAensDelegationSignature,
1097
295
  // Oracle
1098
- delegateOracleRegisterSignature: delegateOracleRegisterSignature,
1099
- delegateOracleExtendSignature: delegateOracleExtendSignature,
1100
- delegateOracleRespondSignature: delegateOracleRespondSignature
296
+ createOracleDelegationSignature
1101
297
  },
1102
298
  deepProps: {
1103
299
  Ae: {
@@ -1110,7 +306,7 @@ export var ContractAPI = Ae.compose(ContractBase, {
1110
306
  }
1111
307
  }
1112
308
  });
1113
- export var Contract = ContractAPI.compose(NodePool);
1114
- export var ContractWithCompiler = Contract.compose(ContractCompilerAPI);
309
+ export const Contract = ContractAPI.compose(NodePool);
310
+ export const ContractWithCompiler = Contract.compose(ContractCompilerAPI);
1115
311
  export default ContractWithCompiler;
1116
312
  //# sourceMappingURL=contract.js.map