@aeternity/aepp-sdk 9.0.1 → 10.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/aepp-sdk.browser-script.js +1 -1
  2. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -9
  3. package/dist/aepp-sdk.browser-script.js.map +1 -1
  4. package/dist/aepp-sdk.browser.js +1 -1
  5. package/dist/aepp-sdk.browser.js.map +1 -1
  6. package/dist/aepp-sdk.js +1 -1
  7. package/dist/aepp-sdk.js.map +1 -1
  8. package/es/account/base.js +30 -122
  9. package/es/account/base.js.map +1 -1
  10. package/es/account/memory.js +17 -19
  11. package/es/account/memory.js.map +1 -1
  12. package/es/account/multiple.js +73 -164
  13. package/es/account/multiple.js.map +1 -1
  14. package/es/ae/aens.js +164 -599
  15. package/es/ae/aens.js.map +1 -1
  16. package/es/ae/contract.js +82 -759
  17. package/es/ae/contract.js.map +1 -1
  18. package/es/ae/index.js +78 -315
  19. package/es/ae/index.js.map +1 -1
  20. package/es/ae/oracle.js +130 -498
  21. package/es/ae/oracle.js.map +1 -1
  22. package/es/chain/index.js +1 -1
  23. package/es/chain/index.js.map +1 -1
  24. package/es/chain/node.js +288 -1008
  25. package/es/chain/node.js.map +1 -1
  26. package/es/channel/handlers.js +597 -1086
  27. package/es/channel/handlers.js.map +1 -1
  28. package/es/channel/index.js +203 -451
  29. package/es/channel/index.js.map +1 -1
  30. package/es/channel/internal.js +129 -301
  31. package/es/channel/internal.js.map +1 -1
  32. package/es/contract/aci/index.js +319 -480
  33. package/es/contract/aci/index.js.map +1 -1
  34. package/es/contract/aci/transformation.js +35 -711
  35. package/es/contract/aci/transformation.js.map +1 -1
  36. package/es/contract/compiler.js +129 -203
  37. package/es/contract/compiler.js.map +1 -1
  38. package/es/contract/ga/helpers.js +16 -114
  39. package/es/contract/ga/helpers.js.map +1 -1
  40. package/es/contract/ga/index.js +101 -242
  41. package/es/contract/ga/index.js.map +1 -1
  42. package/es/contract/index.js +1 -1
  43. package/es/contract/index.js.map +1 -1
  44. package/es/index.js +1 -2
  45. package/es/index.js.map +1 -1
  46. package/es/node-pool/index.js +54 -73
  47. package/es/node-pool/index.js.map +1 -1
  48. package/es/node.js +56 -157
  49. package/es/node.js.map +1 -1
  50. package/es/other.d.ts +1 -1
  51. package/es/tx/builder/helpers.js +38 -75
  52. package/es/tx/builder/helpers.js.map +1 -1
  53. package/es/tx/builder/index.js +196 -294
  54. package/es/tx/builder/index.js.map +1 -1
  55. package/es/tx/builder/schema.js +577 -459
  56. package/es/tx/builder/schema.js.map +1 -1
  57. package/es/tx/index.js +1 -1
  58. package/es/tx/index.js.map +1 -1
  59. package/es/tx/tx-object.js +105 -132
  60. package/es/tx/tx-object.js.map +1 -1
  61. package/es/tx/tx.js +808 -1628
  62. package/es/tx/tx.js.map +1 -1
  63. package/es/tx/validator.js +132 -268
  64. package/es/tx/validator.js.map +1 -1
  65. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +17 -21
  66. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
  67. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +38 -74
  68. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
  69. package/es/utils/aepp-wallet-communication/content-script-bridge.js +14 -15
  70. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
  71. package/es/utils/aepp-wallet-communication/helpers.js +60 -105
  72. package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
  73. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +179 -510
  74. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
  75. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +70 -89
  76. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
  77. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +353 -600
  78. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
  79. package/es/utils/aepp-wallet-communication/schema.js +43 -39
  80. package/es/utils/aepp-wallet-communication/schema.js.map +1 -1
  81. package/es/utils/aepp-wallet-communication/wallet-detector.js +32 -58
  82. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
  83. package/es/utils/amount-formatter.js +41 -61
  84. package/es/utils/amount-formatter.js.map +1 -1
  85. package/es/utils/async-init.js +28 -64
  86. package/es/utils/async-init.js.map +1 -1
  87. package/es/utils/bignumber.js +3 -11
  88. package/es/utils/bignumber.js.map +1 -1
  89. package/es/utils/bytes.js +5 -9
  90. package/es/utils/bytes.js.map +1 -1
  91. package/es/utils/crypto.js +47 -62
  92. package/es/utils/crypto.js.map +1 -1
  93. package/es/utils/hd-wallet.js +45 -81
  94. package/es/utils/hd-wallet.js.map +1 -1
  95. package/es/utils/json-big.js +16 -49
  96. package/es/utils/json-big.js.map +1 -1
  97. package/es/utils/keystore.js +81 -246
  98. package/es/utils/keystore.js.map +1 -1
  99. package/es/utils/mptree.js +88 -134
  100. package/es/utils/mptree.js.map +1 -1
  101. package/es/utils/other.js +10 -60
  102. package/es/utils/other.js.map +1 -1
  103. package/es/utils/semver-satisfies.js +9 -28
  104. package/es/utils/semver-satisfies.js.map +1 -1
  105. package/es/utils/string.js +4 -13
  106. package/es/utils/string.js.map +1 -1
  107. package/es/utils/swagger.js +85 -224
  108. package/es/utils/swagger.js.map +1 -1
  109. package/package.json +44 -40
  110. package/src/account/multiple.js +18 -19
  111. package/src/ae/aens.js +25 -21
  112. package/src/ae/contract.js +32 -163
  113. package/src/ae/index.js +3 -3
  114. package/src/ae/oracle.js +18 -14
  115. package/src/chain/node.js +2 -4
  116. package/src/channel/handlers.js +0 -1
  117. package/src/channel/index.js +4 -5
  118. package/src/contract/aci/index.js +221 -102
  119. package/src/contract/aci/transformation.js +30 -422
  120. package/src/contract/compiler.js +45 -4
  121. package/src/contract/ga/helpers.js +1 -8
  122. package/src/contract/ga/index.js +13 -11
  123. package/src/index.js +0 -2
  124. package/src/node-pool/index.js +21 -12
  125. package/src/node.js +22 -26
  126. package/src/tx/builder/index.js +2 -1
  127. package/src/tx/builder/schema.js +2 -1
  128. package/src/tx/tx.js +147 -143
  129. package/src/tx/validator.js +9 -7
  130. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +1 -3
  131. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +3 -3
  132. package/src/utils/aepp-wallet-communication/schema.js +1 -3
  133. package/src/utils/bignumber.ts +2 -1
  134. package/src/utils/other.ts +1 -1
  135. package/src/utils/semver-satisfies.ts +1 -1
  136. package/src/utils/swagger.js +14 -7
  137. 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 _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
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,180 +89,23 @@ 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)
107
+ * @param {Array} params Arguments of contract constructor(init) function. Can be array of arguments or callData string
108
+ * @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)
462
109
  * @param {Object} [options.filesystem={}] Contract external namespaces map* @return {Promise<Object>} Result object
463
110
  * @return {Promise<Object>} Result object
464
111
  * @example
@@ -475,104 +122,12 @@ function contractCall(_x20, _x21, _x22) {
475
122
  */
476
123
 
477
124
 
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);
125
+ async function contractDeploy(code, source, params, options) {
126
+ const contract = await this.getContractInstance({ ...options,
127
+ source
128
+ });
129
+ contract.bytecode = code;
130
+ return contract.deploy(params, options);
576
131
  }
577
132
  /**
578
133
  * Compile contract source code
@@ -593,106 +148,23 @@ function contractDeploy(_x23, _x24) {
593
148
  */
594
149
 
595
150
 
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);
151
+ async function contractCompile(source) {
152
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
153
+ const opt = { ...this.Ae.defaults,
154
+ ...options
155
+ };
156
+ const bytecode = await this.compileContractAPI(source, options);
157
+ return Object.freeze({
158
+ encodeCall: (name, args) => this.contractEncodeCallDataAPI(source, name, args, opt),
159
+ deploy: (init, options) => this.contractDeploy(bytecode, source, init, { ...opt,
160
+ ...options
161
+ }),
162
+ deployStatic: (init, options) => this.contractCallStatic(source, null, 'init', init, { ...opt,
163
+ ...options,
164
+ bytecode
165
+ }),
166
+ bytecode
167
+ });
696
168
  }
697
169
  /**
698
170
  * Utility method to create a delegate signature for a contract
@@ -706,52 +178,11 @@ function contractCompile(_x25) {
706
178
  */
707
179
 
708
180
 
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);
181
+ async function delegateSignatureCommon() {
182
+ let ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
183
+ let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
184
+ 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);
185
+ return Buffer.from(signature).toString('hex');
755
186
  }
756
187
  /**
757
188
  * Helper to generate a signature to delegate pre-claim/claim/transfer/revoke of a name to a contract.
@@ -776,70 +207,13 @@ function delegateSignatureCommon() {
776
207
  */
777
208
 
778
209
 
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);
210
+ async function createAensDelegationSignature(_ref) {
211
+ let {
212
+ contractId,
213
+ name
214
+ } = _ref;
215
+ let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
216
+ return this.delegateSignatureCommon([...(name ? [produceNameId(name)] : []), contractId], opt);
843
217
  }
844
218
  /**
845
219
  * Helper to generate a signature to delegate register/extend/respond of a Oracle to a contract.
@@ -864,34 +238,13 @@ function createAensDelegationSignature(_x26) {
864
238
  */
865
239
 
866
240
 
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);
241
+ async function createOracleDelegationSignature(_ref2) {
242
+ let {
243
+ contractId,
244
+ queryId
245
+ } = _ref2;
246
+ let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
247
+ return this.delegateSignatureCommon([...(queryId ? [queryId] : []), contractId], opt);
895
248
  }
896
249
  /**
897
250
  * Contract Stamp
@@ -924,49 +277,19 @@ function createOracleDelegationSignature(_x27) {
924
277
  */
925
278
 
926
279
 
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, {
280
+ export const ContractAPI = Ae.compose(ContractBase, {
954
281
  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,
282
+ getContractInstance,
283
+ contractCompile,
284
+ contractCallStatic,
285
+ contractDeploy,
286
+ contractCall,
964
287
  // Delegation for contract
965
- delegateSignatureCommon: delegateSignatureCommon,
288
+ delegateSignatureCommon,
966
289
  // AENS
967
- createAensDelegationSignature: createAensDelegationSignature,
290
+ createAensDelegationSignature,
968
291
  // Oracle
969
- createOracleDelegationSignature: createOracleDelegationSignature
292
+ createOracleDelegationSignature
970
293
  },
971
294
  deepProps: {
972
295
  Ae: {
@@ -979,7 +302,7 @@ export var ContractAPI = Ae.compose(ContractBase, {
979
302
  }
980
303
  }
981
304
  });
982
- export var Contract = ContractAPI.compose(NodePool);
983
- export var ContractWithCompiler = Contract.compose(ContractCompilerAPI);
305
+ export const Contract = ContractAPI.compose(NodePool);
306
+ export const ContractWithCompiler = Contract.compose(ContractCompilerAPI);
984
307
  export default ContractWithCompiler;
985
308
  //# sourceMappingURL=contract.js.map