@aeternity/aepp-sdk 8.2.0 → 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 (145) hide show
  1. package/README.md +16 -9
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -9
  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.js +33 -119
  10. package/es/account/base.js.map +1 -1
  11. package/es/account/memory.js +17 -19
  12. package/es/account/memory.js.map +1 -1
  13. package/es/account/multiple.js +75 -154
  14. package/es/account/multiple.js.map +1 -1
  15. package/es/ae/aens.js +164 -599
  16. package/es/ae/aens.js.map +1 -1
  17. package/es/ae/contract.js +108 -916
  18. package/es/ae/contract.js.map +1 -1
  19. package/es/ae/index.js +89 -250
  20. package/es/ae/index.js.map +1 -1
  21. package/es/ae/oracle.js +132 -500
  22. package/es/ae/oracle.js.map +1 -1
  23. package/es/chain/index.js +4 -23
  24. package/es/chain/index.js.map +1 -1
  25. package/es/chain/node.js +292 -1018
  26. package/es/chain/node.js.map +1 -1
  27. package/es/channel/handlers.js +597 -1086
  28. package/es/channel/handlers.js.map +1 -1
  29. package/es/channel/index.js +203 -451
  30. package/es/channel/index.js.map +1 -1
  31. package/es/channel/internal.js +129 -301
  32. package/es/channel/internal.js.map +1 -1
  33. package/es/contract/aci/index.js +319 -491
  34. package/es/contract/aci/index.js.map +1 -1
  35. package/es/contract/aci/transformation.js +35 -711
  36. package/es/contract/aci/transformation.js.map +1 -1
  37. package/es/contract/compiler.js +129 -203
  38. package/es/contract/compiler.js.map +1 -1
  39. package/es/contract/ga/helpers.js +17 -122
  40. package/es/contract/ga/helpers.js.map +1 -1
  41. package/es/contract/ga/index.js +102 -247
  42. package/es/contract/ga/index.js.map +1 -1
  43. package/es/contract/index.js +1 -1
  44. package/es/contract/index.js.map +1 -1
  45. package/es/index.js +2 -3
  46. package/es/index.js.map +1 -1
  47. package/es/node-pool/index.js +54 -73
  48. package/es/node-pool/index.js.map +1 -1
  49. package/es/node.js +56 -157
  50. package/es/node.js.map +1 -1
  51. package/es/other.d.ts +1 -1
  52. package/es/tx/builder/helpers.js +49 -89
  53. package/es/tx/builder/helpers.js.map +1 -1
  54. package/es/tx/builder/index.js +205 -303
  55. package/es/tx/builder/index.js.map +1 -1
  56. package/es/tx/builder/schema.js +585 -573
  57. package/es/tx/builder/schema.js.map +1 -1
  58. package/es/tx/index.js +1 -1
  59. package/es/tx/index.js.map +1 -1
  60. package/es/tx/tx-object.js +105 -135
  61. package/es/tx/tx-object.js.map +1 -1
  62. package/es/tx/tx.js +810 -1586
  63. package/es/tx/tx.js.map +1 -1
  64. package/es/tx/validator.js +191 -426
  65. package/es/tx/validator.js.map +1 -1
  66. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +17 -21
  67. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
  68. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +38 -74
  69. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
  70. package/es/utils/aepp-wallet-communication/content-script-bridge.js +14 -15
  71. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
  72. package/es/utils/aepp-wallet-communication/helpers.js +60 -105
  73. package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
  74. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +179 -510
  75. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
  76. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +70 -89
  77. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
  78. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +354 -603
  79. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
  80. package/es/utils/aepp-wallet-communication/schema.js +43 -39
  81. package/es/utils/aepp-wallet-communication/schema.js.map +1 -1
  82. package/es/utils/aepp-wallet-communication/wallet-detector.js +32 -58
  83. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
  84. package/es/utils/amount-formatter.js +41 -61
  85. package/es/utils/amount-formatter.js.map +1 -1
  86. package/es/utils/async-init.js +28 -64
  87. package/es/utils/async-init.js.map +1 -1
  88. package/es/utils/bignumber.js +3 -11
  89. package/es/utils/bignumber.js.map +1 -1
  90. package/es/utils/bytes.js +5 -9
  91. package/es/utils/bytes.js.map +1 -1
  92. package/es/utils/crypto.js +49 -75
  93. package/es/utils/crypto.js.map +1 -1
  94. package/es/utils/hd-wallet.js +45 -81
  95. package/es/utils/hd-wallet.js.map +1 -1
  96. package/es/utils/json-big.js +16 -49
  97. package/es/utils/json-big.js.map +1 -1
  98. package/es/utils/keystore.js +81 -246
  99. package/es/utils/keystore.js.map +1 -1
  100. package/es/utils/mptree.js +88 -134
  101. package/es/utils/mptree.js.map +1 -1
  102. package/es/utils/other.js +10 -60
  103. package/es/utils/other.js.map +1 -1
  104. package/es/utils/semver-satisfies.js +9 -28
  105. package/es/utils/semver-satisfies.js.map +1 -1
  106. package/es/utils/string.js +4 -13
  107. package/es/utils/string.js.map +1 -1
  108. package/es/utils/swagger.js +85 -218
  109. package/es/utils/swagger.js.map +1 -1
  110. package/package.json +52 -43
  111. package/src/account/base.js +8 -9
  112. package/src/account/multiple.js +20 -16
  113. package/src/ae/aens.js +25 -21
  114. package/src/ae/contract.js +65 -246
  115. package/src/ae/index.js +31 -7
  116. package/src/ae/oracle.js +21 -17
  117. package/src/chain/index.js +2 -12
  118. package/src/chain/node.js +26 -29
  119. package/src/channel/handlers.js +0 -1
  120. package/src/channel/index.js +4 -5
  121. package/src/contract/aci/index.js +221 -106
  122. package/src/contract/aci/transformation.js +30 -422
  123. package/src/contract/compiler.js +45 -4
  124. package/src/contract/ga/helpers.js +2 -12
  125. package/src/contract/ga/index.js +22 -26
  126. package/src/index.js +2 -4
  127. package/src/node-pool/index.js +21 -12
  128. package/src/node.js +22 -26
  129. package/src/tx/builder/helpers.js +12 -24
  130. package/src/tx/builder/index.js +18 -15
  131. package/src/tx/builder/schema.js +43 -108
  132. package/src/tx/tx-object.js +0 -2
  133. package/src/tx/tx.js +157 -144
  134. package/src/tx/validator.js +134 -202
  135. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +1 -3
  136. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +9 -10
  137. package/src/utils/aepp-wallet-communication/schema.js +1 -3
  138. package/src/utils/amount-formatter.ts +1 -1
  139. package/src/utils/bignumber.ts +2 -1
  140. package/src/utils/crypto.js +4 -17
  141. package/src/utils/other.ts +1 -1
  142. package/src/utils/semver-satisfies.ts +1 -1
  143. package/src/utils/swagger.js +24 -7
  144. package/CHANGELOG.md +0 -1716
  145. package/src/contract/aci/helpers.js +0 -140
package/es/ae/aens.js CHANGED
@@ -1,27 +1,30 @@
1
- import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
2
- import _fromPairs from "ramda/src/fromPairs";
3
- import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
4
- import _merge from "ramda/src/merge";
5
- import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
6
-
7
- 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; }
8
-
9
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context17; _forEachInstanceProperty(_context17 = ownKeys(Object(source), true)).call(_context17, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context18; _forEachInstanceProperty(_context18 = ownKeys(Object(source))).call(_context18, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
1
+ /*
2
+ * ISC License (ISC)
3
+ * Copyright (c) 2018 aeternity developers
4
+ *
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose with or without fee is hereby granted, provided that the above
7
+ * copyright notice and this permission notice appear in all copies.
8
+ *
9
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ * PERFORMANCE OF THIS SOFTWARE.
16
+ */
10
17
 
11
- import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
12
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
13
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
14
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
15
- import _Object$freeze from "@babel/runtime-corejs3/core-js-stable/object/freeze";
16
- import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
17
- import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
18
- import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
19
- import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
20
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
21
- import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
22
- import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
23
- import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
24
- import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
18
+ /**
19
+ * Aens module - routines to interact with the æternity naming system
20
+ *
21
+ * The high-level description of the naming system is
22
+ * https://github.com/aeternity/protocol/blob/master/AENS.md in the protocol
23
+ * repository.
24
+ * @module @aeternity/aepp-sdk/es/ae/aens
25
+ * @export Aens
26
+ * @example import { Aens } from '@aeternity/aepp-sdk'
27
+ */
25
28
  import { salt } from '../utils/crypto';
26
29
  import { commitmentHash, ensureNameValid, getMinimumNameFee, classify, isAuctionName, validatePointers, encode, produceNameId } from '../tx/builder/helpers';
27
30
  import Ae from './';
@@ -49,8 +52,17 @@ import { CLIENT_TTL, NAME_FEE, NAME_TTL } from '../tx/builder/schema';
49
52
  * await nameObject.revoke({ fee, ttl, nonce })
50
53
  */
51
54
 
52
- function revoke(_x) {
53
- return _revoke.apply(this, arguments);
55
+ async function revoke(name) {
56
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
57
+ ensureNameValid(name);
58
+ const opt = { ...this.Ae.defaults,
59
+ ...options
60
+ };
61
+ const nameRevokeTx = await this.nameRevokeTx({ ...opt,
62
+ nameId: produceNameId(name),
63
+ accountId: await this.address(opt)
64
+ });
65
+ return this.send(nameRevokeTx, opt);
54
66
  }
55
67
  /**
56
68
  * Update a name
@@ -82,52 +94,23 @@ function revoke(_x) {
82
94
  */
83
95
 
84
96
 
85
- function _revoke() {
86
- _revoke = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(name) {
87
- var options,
88
- opt,
89
- nameRevokeTx,
90
- _args = arguments;
91
- return _regeneratorRuntime.wrap(function _callee$(_context) {
92
- while (1) {
93
- switch (_context.prev = _context.next) {
94
- case 0:
95
- options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
96
- ensureNameValid(name);
97
- opt = _merge(this.Ae.defaults, options);
98
- _context.t0 = this;
99
- _context.t1 = _merge;
100
- _context.t2 = opt;
101
- _context.t3 = produceNameId(name);
102
- _context.next = 9;
103
- return this.address(opt);
104
-
105
- case 9:
106
- _context.t4 = _context.sent;
107
- _context.t5 = {
108
- nameId: _context.t3,
109
- accountId: _context.t4
110
- };
111
- _context.t6 = (0, _context.t1)(_context.t2, _context.t5);
112
- _context.next = 14;
113
- return _context.t0.nameRevokeTx.call(_context.t0, _context.t6);
114
-
115
- case 14:
116
- nameRevokeTx = _context.sent;
117
- return _context.abrupt("return", this.send(nameRevokeTx, opt));
118
-
119
- case 16:
120
- case "end":
121
- return _context.stop();
122
- }
123
- }
124
- }, _callee, this);
125
- }));
126
- return _revoke.apply(this, arguments);
127
- }
128
-
129
- function update(_x2) {
130
- return _update.apply(this, arguments);
97
+ async function update(name) {
98
+ let pointers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
99
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
100
+ extendPointers: false
101
+ };
102
+ ensureNameValid(name);
103
+ const opt = { ...this.Ae.defaults,
104
+ ...options
105
+ };
106
+ if (!validatePointers(pointers)) throw new Error('Invalid pointers array');
107
+ pointers = [...(options.extendPointers ? (await this.getName(name)).pointers : []), ...pointers.map(p => Object.fromEntries([['id', p], ['key', classify(p)]]))].reduce((acc, el) => [...acc.filter(p => p.key !== el.key), el], []);
108
+ const nameUpdateTx = await this.nameUpdateTx({ ...opt,
109
+ nameId: produceNameId(name),
110
+ accountId: await this.address(opt),
111
+ pointers
112
+ });
113
+ return this.send(nameUpdateTx, opt);
131
114
  }
132
115
  /**
133
116
  * Transfer a domain to another account
@@ -155,104 +138,18 @@ function update(_x2) {
155
138
  */
156
139
 
157
140
 
158
- function _update() {
159
- _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(name) {
160
- var _context2, _context3;
161
-
162
- var pointers,
163
- options,
164
- opt,
165
- nameUpdateTx,
166
- _args2 = arguments;
167
- return _regeneratorRuntime.wrap(function _callee2$(_context5) {
168
- while (1) {
169
- switch (_context5.prev = _context5.next) {
170
- case 0:
171
- pointers = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : [];
172
- options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {
173
- extendPointers: false
174
- };
175
- ensureNameValid(name);
176
- opt = _merge(this.Ae.defaults, options);
177
-
178
- if (validatePointers(pointers)) {
179
- _context5.next = 6;
180
- break;
181
- }
182
-
183
- throw new Error('Invalid pointers array');
184
-
185
- case 6:
186
- _context5.t0 = _reduceInstanceProperty;
187
- _context5.t1 = _concatInstanceProperty(_context3 = []);
188
- _context5.t2 = _context3;
189
- _context5.t3 = _toConsumableArray;
190
-
191
- if (!options.extendPointers) {
192
- _context5.next = 16;
193
- break;
194
- }
195
-
196
- _context5.next = 13;
197
- return this.getName(name);
198
-
199
- case 13:
200
- _context5.t4 = _context5.sent.pointers;
201
- _context5.next = 17;
202
- break;
203
-
204
- case 16:
205
- _context5.t4 = [];
206
-
207
- case 17:
208
- _context5.t5 = _context5.t4;
209
- _context5.t6 = (0, _context5.t3)(_context5.t5);
210
- _context5.t7 = _toConsumableArray(_mapInstanceProperty(pointers).call(pointers, function (p) {
211
- return _fromPairs([['id', p], ['key', classify(p)]]);
212
- }));
213
- _context5.t8 = _context2 = _context5.t1.call.call(_context5.t1, _context5.t2, _context5.t6, _context5.t7);
214
- pointers = (0, _context5.t0)(_context5.t8).call(_context2, function (acc, el) {
215
- var _context4;
216
-
217
- return _concatInstanceProperty(_context4 = []).call(_context4, _toConsumableArray(_filterInstanceProperty(acc).call(acc, function (p) {
218
- return p.key !== el.key;
219
- })), [el]);
220
- }, []);
221
- _context5.t9 = this;
222
- _context5.t10 = _merge;
223
- _context5.t11 = opt;
224
- _context5.t12 = produceNameId(name);
225
- _context5.next = 28;
226
- return this.address(opt);
227
-
228
- case 28:
229
- _context5.t13 = _context5.sent;
230
- _context5.t14 = pointers;
231
- _context5.t15 = {
232
- nameId: _context5.t12,
233
- accountId: _context5.t13,
234
- pointers: _context5.t14
235
- };
236
- _context5.t16 = (0, _context5.t10)(_context5.t11, _context5.t15);
237
- _context5.next = 34;
238
- return _context5.t9.nameUpdateTx.call(_context5.t9, _context5.t16);
239
-
240
- case 34:
241
- nameUpdateTx = _context5.sent;
242
- return _context5.abrupt("return", this.send(nameUpdateTx, opt));
243
-
244
- case 36:
245
- case "end":
246
- return _context5.stop();
247
- }
248
- }
249
- }, _callee2, this);
250
- }));
251
- return _update.apply(this, arguments);
252
- }
253
-
254
- function transfer(_x3, _x4) {
255
- return _transfer.apply(this, arguments);
141
+ async function transfer(name, account) {
142
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
143
+ ensureNameValid(name);
144
+ const opt = { ...this.Ae.defaults,
145
+ ...options
146
+ };
147
+ const nameTransferTx = await this.nameTransferTx({ ...opt,
148
+ nameId: produceNameId(name),
149
+ accountId: await this.address(opt),
150
+ recipientId: account
151
+ });
152
+ return this.send(nameTransferTx, opt);
256
153
  }
257
154
  /**
258
155
  * Query the AENS name info from the node
@@ -278,54 +175,49 @@ function transfer(_x3, _x4) {
278
175
  */
279
176
 
280
177
 
281
- function _transfer() {
282
- _transfer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(name, account) {
283
- var options,
284
- opt,
285
- nameTransferTx,
286
- _args3 = arguments;
287
- return _regeneratorRuntime.wrap(function _callee3$(_context6) {
288
- while (1) {
289
- switch (_context6.prev = _context6.next) {
290
- case 0:
291
- options = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
292
- ensureNameValid(name);
293
- opt = _merge(this.Ae.defaults, options);
294
- _context6.t0 = this;
295
- _context6.t1 = _merge;
296
- _context6.t2 = opt;
297
- _context6.t3 = produceNameId(name);
298
- _context6.next = 9;
299
- return this.address(opt);
300
-
301
- case 9:
302
- _context6.t4 = _context6.sent;
303
- _context6.t5 = account;
304
- _context6.t6 = {
305
- nameId: _context6.t3,
306
- accountId: _context6.t4,
307
- recipientId: _context6.t5
308
- };
309
- _context6.t7 = (0, _context6.t1)(_context6.t2, _context6.t6);
310
- _context6.next = 15;
311
- return _context6.t0.nameTransferTx.call(_context6.t0, _context6.t7);
312
-
313
- case 15:
314
- nameTransferTx = _context6.sent;
315
- return _context6.abrupt("return", this.send(nameTransferTx, opt));
316
-
317
- case 17:
318
- case "end":
319
- return _context6.stop();
320
- }
321
- }
322
- }, _callee3, this);
178
+ async function query(name) {
179
+ var _this = this;
180
+
181
+ let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
182
+ ensureNameValid(name);
183
+ const o = await this.getName(name);
184
+ return Object.freeze(Object.assign(o, {
185
+ pointers: o.pointers || [],
186
+ update: async function () {
187
+ let pointers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
188
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
189
+ return { ...(await _this.aensUpdate(name, pointers, { ...opt,
190
+ ...options
191
+ })),
192
+ ...(await _this.aensQuery(name))
193
+ };
194
+ },
195
+ transfer: async function (account) {
196
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
197
+ return { ...(await _this.aensTransfer(name, account, { ...opt,
198
+ ...options
199
+ })),
200
+ ...(await _this.aensQuery(name))
201
+ };
202
+ },
203
+ revoke: async function () {
204
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
205
+ return _this.aensRevoke(name, { ...opt,
206
+ ...options
207
+ });
208
+ },
209
+ extendTtl: async function () {
210
+ let nameTtl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : NAME_TTL;
211
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
212
+ if (!nameTtl || typeof nameTtl !== 'number' || nameTtl > NAME_TTL) throw new Error('Ttl must be an number and less then 180000 blocks');
213
+ return { ...(await _this.aensUpdate(name, o.pointers.map(p => p.id), { ...opt,
214
+ ...options,
215
+ nameTtl
216
+ })),
217
+ ...(await _this.aensQuery(name))
218
+ };
219
+ }
323
220
  }));
324
- return _transfer.apply(this, arguments);
325
- }
326
-
327
- function query(_x5) {
328
- return _query.apply(this, arguments);
329
221
  }
330
222
  /**
331
223
  * Claim a previously preclaimed registration. This can only be done after the
@@ -352,201 +244,33 @@ function query(_x5) {
352
244
  */
353
245
 
354
246
 
355
- function _query() {
356
- _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(name) {
357
- var _this = this;
358
-
359
- var opt,
360
- o,
361
- _args8 = arguments;
362
- return _regeneratorRuntime.wrap(function _callee8$(_context12) {
363
- while (1) {
364
- switch (_context12.prev = _context12.next) {
365
- case 0:
366
- opt = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
367
- ensureNameValid(name);
368
- _context12.next = 4;
369
- return this.getName(name);
370
-
371
- case 4:
372
- o = _context12.sent;
373
- return _context12.abrupt("return", _Object$freeze(_Object$assign(o, {
374
- pointers: o.pointers || [],
375
- update: function () {
376
- var _update2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
377
- var pointers,
378
- options,
379
- _args4 = arguments;
380
- return _regeneratorRuntime.wrap(function _callee4$(_context7) {
381
- while (1) {
382
- switch (_context7.prev = _context7.next) {
383
- case 0:
384
- pointers = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : [];
385
- options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
386
- _context7.t0 = _objectSpread;
387
- _context7.t1 = _objectSpread;
388
- _context7.t2 = {};
389
- _context7.next = 7;
390
- return _this.aensUpdate(name, pointers, _merge(opt, options));
391
-
392
- case 7:
393
- _context7.t3 = _context7.sent;
394
- _context7.t4 = (0, _context7.t1)(_context7.t2, _context7.t3);
395
- _context7.next = 11;
396
- return _this.aensQuery(name);
397
-
398
- case 11:
399
- _context7.t5 = _context7.sent;
400
- return _context7.abrupt("return", (0, _context7.t0)(_context7.t4, _context7.t5));
401
-
402
- case 13:
403
- case "end":
404
- return _context7.stop();
405
- }
406
- }
407
- }, _callee4);
408
- }));
409
-
410
- function update() {
411
- return _update2.apply(this, arguments);
412
- }
413
-
414
- return update;
415
- }(),
416
- transfer: function () {
417
- var _transfer2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(account) {
418
- var options,
419
- _args5 = arguments;
420
- return _regeneratorRuntime.wrap(function _callee5$(_context8) {
421
- while (1) {
422
- switch (_context8.prev = _context8.next) {
423
- case 0:
424
- options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
425
- _context8.t0 = _objectSpread;
426
- _context8.t1 = _objectSpread;
427
- _context8.t2 = {};
428
- _context8.next = 6;
429
- return _this.aensTransfer(name, account, _merge(opt, options));
430
-
431
- case 6:
432
- _context8.t3 = _context8.sent;
433
- _context8.t4 = (0, _context8.t1)(_context8.t2, _context8.t3);
434
- _context8.next = 10;
435
- return _this.aensQuery(name);
436
-
437
- case 10:
438
- _context8.t5 = _context8.sent;
439
- return _context8.abrupt("return", (0, _context8.t0)(_context8.t4, _context8.t5));
440
-
441
- case 12:
442
- case "end":
443
- return _context8.stop();
444
- }
445
- }
446
- }, _callee5);
447
- }));
448
-
449
- function transfer(_x11) {
450
- return _transfer2.apply(this, arguments);
451
- }
452
-
453
- return transfer;
454
- }(),
455
- revoke: function () {
456
- var _revoke2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
457
- var options,
458
- _args6 = arguments;
459
- return _regeneratorRuntime.wrap(function _callee6$(_context9) {
460
- while (1) {
461
- switch (_context9.prev = _context9.next) {
462
- case 0:
463
- options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
464
- return _context9.abrupt("return", _this.aensRevoke(name, _merge(opt, options)));
247
+ async function claim(name, salt, options) {
248
+ ensureNameValid(name);
249
+ const opt = { ...this.Ae.defaults,
250
+ ...options
251
+ };
252
+ const minNameFee = getMinimumNameFee(name);
465
253
 
466
- case 2:
467
- case "end":
468
- return _context9.stop();
469
- }
470
- }
471
- }, _callee6);
472
- }));
473
-
474
- function revoke() {
475
- return _revoke2.apply(this, arguments);
476
- }
477
-
478
- return revoke;
479
- }(),
480
- extendTtl: function () {
481
- var _extendTtl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
482
- var _context10;
483
-
484
- var nameTtl,
485
- options,
486
- _args7 = arguments;
487
- return _regeneratorRuntime.wrap(function _callee7$(_context11) {
488
- while (1) {
489
- switch (_context11.prev = _context11.next) {
490
- case 0:
491
- nameTtl = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : NAME_TTL;
492
- options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
493
-
494
- if (!(!nameTtl || typeof nameTtl !== 'number' || nameTtl > NAME_TTL)) {
495
- _context11.next = 4;
496
- break;
497
- }
498
-
499
- throw new Error('Ttl must be an number and less then 180000 blocks');
500
-
501
- case 4:
502
- _context11.t0 = _objectSpread;
503
- _context11.t1 = _objectSpread;
504
- _context11.t2 = {};
505
- _context11.next = 9;
506
- return _this.aensUpdate(name, _mapInstanceProperty(_context10 = o.pointers).call(_context10, function (p) {
507
- return p.id;
508
- }), _objectSpread(_objectSpread({}, _merge(opt, options)), {}, {
509
- nameTtl: nameTtl
510
- }));
511
-
512
- case 9:
513
- _context11.t3 = _context11.sent;
514
- _context11.t4 = (0, _context11.t1)(_context11.t2, _context11.t3);
515
- _context11.next = 13;
516
- return _this.aensQuery(name);
517
-
518
- case 13:
519
- _context11.t5 = _context11.sent;
520
- return _context11.abrupt("return", (0, _context11.t0)(_context11.t4, _context11.t5));
521
-
522
- case 15:
523
- case "end":
524
- return _context11.stop();
525
- }
526
- }
527
- }, _callee7);
528
- }));
529
-
530
- function extendTtl() {
531
- return _extendTtl.apply(this, arguments);
532
- }
533
-
534
- return extendTtl;
535
- }()
536
- })));
254
+ if (opt.nameFee !== this.Ae.defaults.nameFee && minNameFee.gt(opt.nameFee)) {
255
+ throw new Error(`the provided fee ${opt.nameFee} is not enough to execute the claim, required: ${minNameFee}`);
256
+ }
537
257
 
538
- case 6:
539
- case "end":
540
- return _context12.stop();
541
- }
542
- }
543
- }, _callee8, this);
544
- }));
545
- return _query.apply(this, arguments);
546
- }
258
+ opt.nameFee = opt.nameFee !== this.Ae.defaults.nameFee ? opt.nameFee : minNameFee;
259
+ const claimTx = await this.nameClaimTx({ ...opt,
260
+ accountId: await this.address(opt),
261
+ nameSalt: salt,
262
+ name: encode(name, 'nm')
263
+ });
264
+ const result = await this.send(claimTx, opt);
265
+
266
+ if (!isAuctionName(name)) {
267
+ const nameInter = opt.waitMined ? await this.aensQuery(name, opt) : {};
268
+ return Object.assign(result, nameInter);
269
+ }
547
270
 
548
- function claim(_x6, _x7, _x8) {
549
- return _claim.apply(this, arguments);
271
+ return { ...result,
272
+ nameFee: opt.nameFee
273
+ };
550
274
  }
551
275
  /**
552
276
  * Preclaim a name. Sends a hash of the name and a random salt to the node
@@ -576,96 +300,30 @@ function claim(_x6, _x7, _x8) {
576
300
  */
577
301
 
578
302
 
579
- function _claim() {
580
- _claim = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(name, salt, options) {
581
- var opt, minNameFee, _context13, claimTx, result, nameInter;
582
-
583
- return _regeneratorRuntime.wrap(function _callee9$(_context14) {
584
- while (1) {
585
- switch (_context14.prev = _context14.next) {
586
- case 0:
587
- ensureNameValid(name);
588
- opt = _merge(this.Ae.defaults, options);
589
- minNameFee = getMinimumNameFee(name);
590
-
591
- if (!(opt.nameFee !== this.Ae.defaults.nameFee && minNameFee.gt(opt.nameFee))) {
592
- _context14.next = 5;
593
- break;
594
- }
595
-
596
- throw new Error(_concatInstanceProperty(_context13 = "the provided fee ".concat(opt.nameFee, " is not enough to execute the claim, required: ")).call(_context13, minNameFee));
597
-
598
- case 5:
599
- opt.nameFee = opt.nameFee !== this.Ae.defaults.nameFee ? opt.nameFee : minNameFee;
600
- _context14.t0 = this;
601
- _context14.t1 = _merge;
602
- _context14.t2 = opt;
603
- _context14.next = 11;
604
- return this.address(opt);
605
-
606
- case 11:
607
- _context14.t3 = _context14.sent;
608
- _context14.t4 = salt;
609
- _context14.t5 = encode(name, 'nm');
610
- _context14.t6 = {
611
- accountId: _context14.t3,
612
- nameSalt: _context14.t4,
613
- name: _context14.t5
614
- };
615
- _context14.t7 = (0, _context14.t1)(_context14.t2, _context14.t6);
616
- _context14.next = 18;
617
- return _context14.t0.nameClaimTx.call(_context14.t0, _context14.t7);
618
-
619
- case 18:
620
- claimTx = _context14.sent;
621
- _context14.next = 21;
622
- return this.send(claimTx, opt);
623
-
624
- case 21:
625
- result = _context14.sent;
626
-
627
- if (isAuctionName(name)) {
628
- _context14.next = 32;
629
- break;
630
- }
631
-
632
- if (!opt.waitMined) {
633
- _context14.next = 29;
634
- break;
635
- }
636
-
637
- _context14.next = 26;
638
- return this.aensQuery(name, opt);
639
-
640
- case 26:
641
- _context14.t8 = _context14.sent;
642
- _context14.next = 30;
643
- break;
644
-
645
- case 29:
646
- _context14.t8 = {};
647
-
648
- case 30:
649
- nameInter = _context14.t8;
650
- return _context14.abrupt("return", _Object$assign(result, nameInter));
651
-
652
- case 32:
653
- return _context14.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
654
- nameFee: opt.nameFee
655
- }));
656
-
657
- case 33:
658
- case "end":
659
- return _context14.stop();
660
- }
661
- }
662
- }, _callee9, this);
663
- }));
664
- return _claim.apply(this, arguments);
665
- }
666
-
667
- function preclaim(_x9) {
668
- return _preclaim.apply(this, arguments);
303
+ async function preclaim(name) {
304
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
305
+ ensureNameValid(name);
306
+ const opt = { ...this.Ae.defaults,
307
+ ...options
308
+ };
309
+
310
+ const _salt = salt();
311
+
312
+ const height = await this.height();
313
+ const commitmentId = commitmentHash(name, _salt);
314
+ const preclaimTx = await this.namePreclaimTx({ ...opt,
315
+ accountId: await this.address(opt),
316
+ commitmentId
317
+ });
318
+ const result = await this.send(preclaimTx, opt);
319
+ return Object.freeze({ ...result,
320
+ height,
321
+ claim: options => this.aensClaim(name, _salt, { ...options,
322
+ onAccount: opt.onAccount
323
+ }),
324
+ salt: _salt,
325
+ commitmentId
326
+ });
669
327
  }
670
328
  /**
671
329
  * Bid to name auction
@@ -690,80 +348,13 @@ function preclaim(_x9) {
690
348
  */
691
349
 
692
350
 
693
- function _preclaim() {
694
- _preclaim = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(name) {
695
- var _this2 = this;
696
-
697
- var options,
698
- opt,
699
- _salt,
700
- height,
701
- commitmentId,
702
- preclaimTx,
703
- result,
704
- _args10 = arguments;
705
-
706
- return _regeneratorRuntime.wrap(function _callee10$(_context15) {
707
- while (1) {
708
- switch (_context15.prev = _context15.next) {
709
- case 0:
710
- options = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {};
711
- ensureNameValid(name);
712
- opt = _merge(this.Ae.defaults, options);
713
- _salt = salt();
714
- _context15.next = 6;
715
- return this.height();
716
-
717
- case 6:
718
- height = _context15.sent;
719
- commitmentId = commitmentHash(name, _salt);
720
- _context15.t0 = this;
721
- _context15.t1 = _merge;
722
- _context15.t2 = opt;
723
- _context15.next = 13;
724
- return this.address(opt);
725
-
726
- case 13:
727
- _context15.t3 = _context15.sent;
728
- _context15.t4 = commitmentId;
729
- _context15.t5 = {
730
- accountId: _context15.t3,
731
- commitmentId: _context15.t4
732
- };
733
- _context15.t6 = (0, _context15.t1)(_context15.t2, _context15.t5);
734
- _context15.next = 19;
735
- return _context15.t0.namePreclaimTx.call(_context15.t0, _context15.t6);
736
-
737
- case 19:
738
- preclaimTx = _context15.sent;
739
- _context15.next = 22;
740
- return this.send(preclaimTx, opt);
741
-
742
- case 22:
743
- result = _context15.sent;
744
- return _context15.abrupt("return", _Object$freeze(_objectSpread(_objectSpread({}, result), {}, {
745
- height: height,
746
- claim: function claim(options) {
747
- return _this2.aensClaim(name, _salt, _objectSpread(_objectSpread({}, options), {}, {
748
- onAccount: opt.onAccount
749
- }));
750
- },
751
- salt: _salt,
752
- commitmentId: commitmentId
753
- })));
754
-
755
- case 24:
756
- case "end":
757
- return _context15.stop();
758
- }
759
- }
760
- }, _callee10, this);
761
- }));
762
- return _preclaim.apply(this, arguments);
763
- }
764
-
765
- function bid(_x10) {
766
- return _bid.apply(this, arguments);
351
+ async function bid(name) {
352
+ let nameFee = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NAME_FEE;
353
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
354
+ return this.aensClaim(name, 0, { ...options,
355
+ nameFee,
356
+ vsn: 2
357
+ });
767
358
  }
768
359
  /**
769
360
  * Aens Stamp
@@ -778,33 +369,7 @@ function bid(_x10) {
778
369
  */
779
370
 
780
371
 
781
- function _bid() {
782
- _bid = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(name) {
783
- var nameFee,
784
- options,
785
- _args11 = arguments;
786
- return _regeneratorRuntime.wrap(function _callee11$(_context16) {
787
- while (1) {
788
- switch (_context16.prev = _context16.next) {
789
- case 0:
790
- nameFee = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : NAME_FEE;
791
- options = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : {};
792
- return _context16.abrupt("return", this.aensClaim(name, 0, _objectSpread(_objectSpread({}, options), {}, {
793
- nameFee: nameFee,
794
- vsn: 2
795
- })));
796
-
797
- case 3:
798
- case "end":
799
- return _context16.stop();
800
- }
801
- }
802
- }, _callee11, this);
803
- }));
804
- return _bid.apply(this, arguments);
805
- }
806
-
807
- var Aens = Ae.compose({
372
+ const Aens = Ae.compose({
808
373
  methods: {
809
374
  aensQuery: query,
810
375
  aensPreclaim: preclaim,