@aeternity/aepp-sdk
Version:
SDK for the æternity blockchain
842 lines (749 loc) • 31.3 kB
JavaScript
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
import _fromPairs from "ramda/src/fromPairs";
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
import _merge from "ramda/src/merge";
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
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; }
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; }
import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
import _Object$freeze from "@babel/runtime-corejs3/core-js-stable/object/freeze";
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
import { salt } from '../utils/crypto';
import { commitmentHash, ensureNameValid, getMinimumNameFee, classify, isAuctionName, validatePointers, encode, produceNameId } from '../tx/builder/helpers';
import Ae from './';
import { CLIENT_TTL, NAME_FEE, NAME_TTL } from '../tx/builder/schema';
/**
* Revoke a name
* @instance
* @function
* @alias module:@aeternity/aepp-sdk/es/ae/aens
* @category async
* @param {String} name Name hash
* @param {Object} [options={}] options
* @param {(String|Object)} [options.onAccount] onAccount Make operation on specific account from sdk(you pass publickKey) or
* using provided KeyPair(Can be keypair object or MemoryAccount)
* @param {(Number|String|BigNumber)} [options.fee] fee
* @param {(Number|String|BigNumber)} [options.ttl] ttl
* @param {(Number|String|BigNumber)} [options.nonce] nonce
* @return {Promise<Object>} Transaction result
* @example
* const name = 'test.chain'
* const nameObject = await sdkInstance.aensQuery(name)
*
* await sdkInstance.aensRevoke(name, { fee, ttl , nonce })
* // or
* await nameObject.revoke({ fee, ttl, nonce })
*/
function revoke(_x) {
return _revoke.apply(this, arguments);
}
/**
* Update a name
* @instance
* @function
* @category async
* @alias module:@aeternity/aepp-sdk/es/ae/aens
* @param {String} name AENS name
* @param {String[]} pointers Array of name pointers. Can be oracle|account|contract|channel public key
* @param {Object} [options={}]
* @param {Boolean} [options.extendPointers=false] extendPointers Get the pointers from the node and merge with provided one. Pointers with the same type will be overwrited
* @param {(String|Object)} [options.onAccount] onAccount Make operation on specific account from sdk(you pass publickKey) or
* using provided KeyPair(Can be keypair object or MemoryAccount)
* @param {(Number|String|BigNumber)} [options.fee] fee
* @param {(Number|String|BigNumber)} [options.ttl] ttl
* @param {(Number|String|BigNumber)} [options.nonce] nonce
* @param {(Number|String|BigNumber)} [options.nameTtl=50000] nameTtl Name ttl represented in number of blocks (Max value is 50000 blocks)
* @param {(Number|String|BigNumber)} [options.clientTtl=84600] clientTtl a suggestion as to how long any clients should cache this information
* @return {Promise<Object>}
* @throws Invalid pointer array error
* @example
* const name = 'test.chain'
* const pointersArray = ['ak_asd23dasdas...,' 'ct_asdf34fasdasd...']
* const nameObject = await sdkInstance.aensQuery(name)
*
* await sdkInstance.aensUpdate(name, pointersArray, { nameTtl, ttl, fee, nonce, clientTtl })
* // or
* await nameObject.update(pointersArray, { nameTtl, ttl, fee, nonce, clientTtl })
*/
function _revoke() {
_revoke = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(name) {
var options,
opt,
nameRevokeTx,
_args = arguments;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
ensureNameValid(name);
opt = _merge(this.Ae.defaults, options);
_context.t0 = this;
_context.t1 = _merge;
_context.t2 = opt;
_context.t3 = produceNameId(name);
_context.next = 9;
return this.address(opt);
case 9:
_context.t4 = _context.sent;
_context.t5 = {
nameId: _context.t3,
accountId: _context.t4
};
_context.t6 = (0, _context.t1)(_context.t2, _context.t5);
_context.next = 14;
return _context.t0.nameRevokeTx.call(_context.t0, _context.t6);
case 14:
nameRevokeTx = _context.sent;
return _context.abrupt("return", this.send(nameRevokeTx, opt));
case 16:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
return _revoke.apply(this, arguments);
}
function update(_x2) {
return _update.apply(this, arguments);
}
/**
* Transfer a domain to another account
* @instance
* @function
* @category async
* @alias module:@aeternity/aepp-sdk/es/ae/aens
* @param {String} name AENS name
* @param {String} account Recipient account publick key
* @param {Object} [options={}]
* @param {(String|Object)} [options.onAccount] onAccount Make operation on specific account from sdk(you pass publickKey) or
* using provided KeyPair(Can be keypair object or MemoryAccount)
* @param {(Number|String|BigNumber)} [options.fee] fee
* @param {(Number|String|BigNumber)} [options.ttl] ttl
* @param {(Number|String|BigNumber)} [options.nonce] nonce
* @return {Promise<Object>} Transaction result
* @example
* const name = 'test.chain'
* const recipientPub = 'ak_asd23dasdas...'
* const nameObject = await sdkInstance.aensQuery(name)
*
* await sdkInstance.aensTransfer(name, recipientPub, { ttl, fee, nonce })
* // or
* await nameObject.transfer(recipientPub, { ttl, fee, nonce })
*/
function _update() {
_update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(name) {
var _context2, _context3;
var pointers,
options,
opt,
nameUpdateTx,
_args2 = arguments;
return _regeneratorRuntime.wrap(function _callee2$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
pointers = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : [];
options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {
extendPointers: false
};
ensureNameValid(name);
opt = _merge(this.Ae.defaults, options);
if (validatePointers(pointers)) {
_context5.next = 6;
break;
}
throw new Error('Invalid pointers array');
case 6:
_context5.t0 = _reduceInstanceProperty;
_context5.t1 = _concatInstanceProperty(_context3 = []);
_context5.t2 = _context3;
_context5.t3 = _toConsumableArray;
if (!options.extendPointers) {
_context5.next = 16;
break;
}
_context5.next = 13;
return this.getName(name);
case 13:
_context5.t4 = _context5.sent.pointers;
_context5.next = 17;
break;
case 16:
_context5.t4 = [];
case 17:
_context5.t5 = _context5.t4;
_context5.t6 = (0, _context5.t3)(_context5.t5);
_context5.t7 = _toConsumableArray(_mapInstanceProperty(pointers).call(pointers, function (p) {
return _fromPairs([['id', p], ['key', classify(p)]]);
}));
_context5.t8 = _context2 = _context5.t1.call.call(_context5.t1, _context5.t2, _context5.t6, _context5.t7);
pointers = (0, _context5.t0)(_context5.t8).call(_context2, function (acc, el) {
var _context4;
return _concatInstanceProperty(_context4 = []).call(_context4, _toConsumableArray(_filterInstanceProperty(acc).call(acc, function (p) {
return p.key !== el.key;
})), [el]);
}, []);
_context5.t9 = this;
_context5.t10 = _merge;
_context5.t11 = opt;
_context5.t12 = produceNameId(name);
_context5.next = 28;
return this.address(opt);
case 28:
_context5.t13 = _context5.sent;
_context5.t14 = pointers;
_context5.t15 = {
nameId: _context5.t12,
accountId: _context5.t13,
pointers: _context5.t14
};
_context5.t16 = (0, _context5.t10)(_context5.t11, _context5.t15);
_context5.next = 34;
return _context5.t9.nameUpdateTx.call(_context5.t9, _context5.t16);
case 34:
nameUpdateTx = _context5.sent;
return _context5.abrupt("return", this.send(nameUpdateTx, opt));
case 36:
case "end":
return _context5.stop();
}
}
}, _callee2, this);
}));
return _update.apply(this, arguments);
}
function transfer(_x3, _x4) {
return _transfer.apply(this, arguments);
}
/**
* Query the AENS name info from the node
* and return the object with info and predefined functions for manipulating name
* @instance
* @function
* @category async
* @alias module:@aeternity/aepp-sdk/es/ae/aens
* @param {String} name
* @param {Object} opt Options
* @return {Promise<Object>}
* @example
* const nameObject = sdkInstance.aensQuery('test.chain')
* console.log(nameObject)
* {
* id, // name hash
* pointers, // array of pointers
* update, // Update name function
* extendTtl, // Extend Ttl name function
* transfer, // Transfer name function
* revoke // Revoke name function
* }
*/
function _transfer() {
_transfer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(name, account) {
var options,
opt,
nameTransferTx,
_args3 = arguments;
return _regeneratorRuntime.wrap(function _callee3$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
options = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
ensureNameValid(name);
opt = _merge(this.Ae.defaults, options);
_context6.t0 = this;
_context6.t1 = _merge;
_context6.t2 = opt;
_context6.t3 = produceNameId(name);
_context6.next = 9;
return this.address(opt);
case 9:
_context6.t4 = _context6.sent;
_context6.t5 = account;
_context6.t6 = {
nameId: _context6.t3,
accountId: _context6.t4,
recipientId: _context6.t5
};
_context6.t7 = (0, _context6.t1)(_context6.t2, _context6.t6);
_context6.next = 15;
return _context6.t0.nameTransferTx.call(_context6.t0, _context6.t7);
case 15:
nameTransferTx = _context6.sent;
return _context6.abrupt("return", this.send(nameTransferTx, opt));
case 17:
case "end":
return _context6.stop();
}
}
}, _callee3, this);
}));
return _transfer.apply(this, arguments);
}
function query(_x5) {
return _query.apply(this, arguments);
}
/**
* Claim a previously preclaimed registration. This can only be done after the
* preclaim step
* @instance
* @function
* @category async
* @alias module:@aeternity/aepp-sdk/es/ae/aens
* @param {String} name
* @param {Number} salt Salt from pre-claim, or 0 if it's a bid
* @param {Object} [options={}] options
* @param {String|Object} [options.onAccount] onAccount Make operation on specific account from sdk(you pass publickKey) or
* using provided KeyPair(Can be keypair object or MemoryAccount)
* @param {Number|String|BigNumber} [options.fee] fee
* @param {Number|String|BigNumber} [options.ttl] ttl
* @param {Number|String|BigNumber} [options.nonce] nonce
* @param {Number|String} [options.nameFee] Name Fee (By default calculated by sdk)
* @param {Number|String} [options.vsn = 2] Transaction vsn from Lima is 2
* @return {Promise<Object>} the result of the claim
* @example
* const name = 'test.chain'
* const salt = preclaimResult.salt // salt from pre-claim transaction
*
* await sdkInstance.aensClaim(name, salt, { ttl, fee, nonce, nameFee })
*/
function _query() {
_query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(name) {
var _this = this;
var opt,
o,
_args8 = arguments;
return _regeneratorRuntime.wrap(function _callee8$(_context12) {
while (1) {
switch (_context12.prev = _context12.next) {
case 0:
opt = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
ensureNameValid(name);
_context12.next = 4;
return this.getName(name);
case 4:
o = _context12.sent;
return _context12.abrupt("return", _Object$freeze(_Object$assign(o, {
pointers: o.pointers || [],
update: function () {
var _update2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
var pointers,
options,
_args4 = arguments;
return _regeneratorRuntime.wrap(function _callee4$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
pointers = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : [];
options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
_context7.t0 = _objectSpread;
_context7.t1 = _objectSpread;
_context7.t2 = {};
_context7.next = 7;
return _this.aensUpdate(name, pointers, _merge(opt, options));
case 7:
_context7.t3 = _context7.sent;
_context7.t4 = (0, _context7.t1)(_context7.t2, _context7.t3);
_context7.next = 11;
return _this.aensQuery(name);
case 11:
_context7.t5 = _context7.sent;
return _context7.abrupt("return", (0, _context7.t0)(_context7.t4, _context7.t5));
case 13:
case "end":
return _context7.stop();
}
}
}, _callee4);
}));
function update() {
return _update2.apply(this, arguments);
}
return update;
}(),
transfer: function () {
var _transfer2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(account) {
var options,
_args5 = arguments;
return _regeneratorRuntime.wrap(function _callee5$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
_context8.t0 = _objectSpread;
_context8.t1 = _objectSpread;
_context8.t2 = {};
_context8.next = 6;
return _this.aensTransfer(name, account, _merge(opt, options));
case 6:
_context8.t3 = _context8.sent;
_context8.t4 = (0, _context8.t1)(_context8.t2, _context8.t3);
_context8.next = 10;
return _this.aensQuery(name);
case 10:
_context8.t5 = _context8.sent;
return _context8.abrupt("return", (0, _context8.t0)(_context8.t4, _context8.t5));
case 12:
case "end":
return _context8.stop();
}
}
}, _callee5);
}));
function transfer(_x10) {
return _transfer2.apply(this, arguments);
}
return transfer;
}(),
revoke: function () {
var _revoke2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
var options,
_args6 = arguments;
return _regeneratorRuntime.wrap(function _callee6$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
return _context9.abrupt("return", _this.aensRevoke(name, _merge(opt, options)));
case 2:
case "end":
return _context9.stop();
}
}
}, _callee6);
}));
function revoke() {
return _revoke2.apply(this, arguments);
}
return revoke;
}(),
extendTtl: function () {
var _extendTtl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
var _context10;
var nameTtl,
options,
_args7 = arguments;
return _regeneratorRuntime.wrap(function _callee7$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
case 0:
nameTtl = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : NAME_TTL;
options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
if (!(!nameTtl || typeof nameTtl !== 'number' || nameTtl > NAME_TTL)) {
_context11.next = 4;
break;
}
throw new Error('Ttl must be an number and less then 50000 blocks');
case 4:
_context11.t0 = _objectSpread;
_context11.t1 = _objectSpread;
_context11.t2 = {};
_context11.next = 9;
return _this.aensUpdate(name, _mapInstanceProperty(_context10 = o.pointers).call(_context10, function (p) {
return p.id;
}), _objectSpread(_objectSpread({}, _merge(opt, options)), {}, {
nameTtl: nameTtl
}));
case 9:
_context11.t3 = _context11.sent;
_context11.t4 = (0, _context11.t1)(_context11.t2, _context11.t3);
_context11.next = 13;
return _this.aensQuery(name);
case 13:
_context11.t5 = _context11.sent;
return _context11.abrupt("return", (0, _context11.t0)(_context11.t4, _context11.t5));
case 15:
case "end":
return _context11.stop();
}
}
}, _callee7);
}));
function extendTtl() {
return _extendTtl.apply(this, arguments);
}
return extendTtl;
}()
})));
case 6:
case "end":
return _context12.stop();
}
}
}, _callee8, this);
}));
return _query.apply(this, arguments);
}
function claim(_x6, _x7) {
return _claim.apply(this, arguments);
}
/**
* Preclaim a name. Sends a hash of the name and a random salt to the node
* @instance
* @function
* @category async
* @alias module:@aeternity/aepp-sdk/es/ae/aens
* @param {String} name
* @param {Object} [options={}]
* @param {String|Object} [options.onAccount] onAccount Make operation on specific account from sdk(you pass publickKey) or
* using provided KeyPair(Can be keypair object or MemoryAccount)
* @param {Number|String|BigNumber} [options.fee] fee
* @param {Number|String|BigNumber} [options.ttl] ttl
* @param {Number|String|BigNumber} [options.nonce] nonce
* @return {Promise<Object>}
* @example
* const name = 'test.chain'
* const salt = preclaimResult.salt // salt from pre-claim transaction
*
* await sdkInstance.aensPreclaim(name, { ttl, fee, nonce })
* {
* ...transactionResult,
* claim, // Claim function (options={}) => claimTransactionResult
* salt,
* commitmentId
* }
*/
function _claim() {
_claim = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(name, salt) {
var options,
opt,
minNameFee,
_context13,
claimTx,
result,
nameInter,
_args9 = arguments;
return _regeneratorRuntime.wrap(function _callee9$(_context14) {
while (1) {
switch (_context14.prev = _context14.next) {
case 0:
options = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : {
vsn: 2
};
ensureNameValid(name);
opt = _merge(this.Ae.defaults, options);
minNameFee = getMinimumNameFee(name);
if (!(opt.nameFee !== this.Ae.defaults.nameFee && minNameFee.gt(opt.nameFee))) {
_context14.next = 6;
break;
}
throw new Error(_concatInstanceProperty(_context13 = "the provided fee ".concat(opt.nameFee, " is not enough to execute the claim, required: ")).call(_context13, minNameFee));
case 6:
opt.nameFee = opt.nameFee !== this.Ae.defaults.nameFee ? opt.nameFee : minNameFee;
_context14.t0 = this;
_context14.t1 = _merge;
_context14.t2 = opt;
_context14.next = 12;
return this.address(opt);
case 12:
_context14.t3 = _context14.sent;
_context14.t4 = salt;
_context14.t5 = encode(name, 'nm');
_context14.t6 = {
accountId: _context14.t3,
nameSalt: _context14.t4,
name: _context14.t5
};
_context14.t7 = (0, _context14.t1)(_context14.t2, _context14.t6);
_context14.next = 19;
return _context14.t0.nameClaimTx.call(_context14.t0, _context14.t7);
case 19:
claimTx = _context14.sent;
_context14.next = 22;
return this.send(claimTx, opt);
case 22:
result = _context14.sent;
if (isAuctionName(name)) {
_context14.next = 34;
break;
}
delete opt.vsn;
if (!opt.waitMined) {
_context14.next = 31;
break;
}
_context14.next = 28;
return this.aensQuery(name, opt);
case 28:
_context14.t8 = _context14.sent;
_context14.next = 32;
break;
case 31:
_context14.t8 = {};
case 32:
nameInter = _context14.t8;
return _context14.abrupt("return", _Object$assign(result, nameInter));
case 34:
return _context14.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
nameFee: opt.nameFee
}));
case 35:
case "end":
return _context14.stop();
}
}
}, _callee9, this);
}));
return _claim.apply(this, arguments);
}
function preclaim(_x8) {
return _preclaim.apply(this, arguments);
}
/**
* Bid to name auction
* @instance
* @function
* @category async
* @alias module:@aeternity/aepp-sdk/es/ae/aens
* @param {String} name Domain name
* @param {String|Number} nameFee Name fee (bid fee)
* @param {Object} [options={}]
* @param {String|Object} [options.onAccount] onAccount Make operation on specific account from sdk(you pass publickKey) or
* using provided KeyPair(Can be keypair object or MemoryAccount)
* @param {Number|String|BigNumber} [options.fee] fee
* @param {Number|String|BigNumber} [options.ttl] ttl
* @param {Number|String|BigNumber} [options.nonce] nonce
* @return {Promise<Object>} Transaction result
* @example
* const name = 'test.chain'
* const bidFee = computeBidFee(name, startFee, incrementPercentage)
*
* await sdkInstance.aensBid(name, 213109412839123, { ttl, fee, nonce })
*/
function _preclaim() {
_preclaim = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(name) {
var _this2 = this;
var options,
opt,
_salt,
height,
commitmentId,
preclaimTx,
result,
_args10 = arguments;
return _regeneratorRuntime.wrap(function _callee10$(_context15) {
while (1) {
switch (_context15.prev = _context15.next) {
case 0:
options = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {};
ensureNameValid(name);
opt = _merge(this.Ae.defaults, options);
_salt = salt();
_context15.next = 6;
return this.height();
case 6:
height = _context15.sent;
commitmentId = commitmentHash(name, _salt);
_context15.t0 = this;
_context15.t1 = _merge;
_context15.t2 = opt;
_context15.next = 13;
return this.address(opt);
case 13:
_context15.t3 = _context15.sent;
_context15.t4 = commitmentId;
_context15.t5 = {
accountId: _context15.t3,
commitmentId: _context15.t4
};
_context15.t6 = (0, _context15.t1)(_context15.t2, _context15.t5);
_context15.next = 19;
return _context15.t0.namePreclaimTx.call(_context15.t0, _context15.t6);
case 19:
preclaimTx = _context15.sent;
_context15.next = 22;
return this.send(preclaimTx, opt);
case 22:
result = _context15.sent;
return _context15.abrupt("return", _Object$freeze(_objectSpread(_objectSpread({}, result), {}, {
height: height,
claim: function claim(options) {
return _this2.aensClaim(name, _salt, _objectSpread(_objectSpread({}, options), {}, {
onAccount: opt.onAccount
}));
},
salt: _salt,
commitmentId: commitmentId
})));
case 24:
case "end":
return _context15.stop();
}
}
}, _callee10, this);
}));
return _preclaim.apply(this, arguments);
}
function bid(_x9) {
return _bid.apply(this, arguments);
}
/**
* Aens Stamp
*
* Aens provides name-system related methods atop
* {@link module:@aeternity/aepp-sdk/es/ae--Ae} clients.
* @function
* @alias module:@aeternity/aepp-sdk/es/ae/aens
* @rtype Stamp
* @param {Object} [options={}] - Initializer object
* @return {Object} Aens instance
*/
function _bid() {
_bid = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(name) {
var nameFee,
options,
_args11 = arguments;
return _regeneratorRuntime.wrap(function _callee11$(_context16) {
while (1) {
switch (_context16.prev = _context16.next) {
case 0:
nameFee = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : NAME_FEE;
options = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : {};
return _context16.abrupt("return", this.aensClaim(name, 0, _objectSpread(_objectSpread({}, options), {}, {
nameFee: nameFee,
vsn: 2
})));
case 3:
case "end":
return _context16.stop();
}
}
}, _callee11, this);
}));
return _bid.apply(this, arguments);
}
var Aens = Ae.compose({
methods: {
aensQuery: query,
aensPreclaim: preclaim,
aensClaim: claim,
aensUpdate: update,
aensTransfer: transfer,
aensRevoke: revoke,
aensBid: bid
},
deepProps: {
Ae: {
defaults: {
clientTtl: CLIENT_TTL,
nameTtl: NAME_TTL,
// aec_governance:name_claim_max_expiration() => 50000
nameFee: NAME_FEE
}
}
}
});
export default Aens;
//# sourceMappingURL=aens.js.map