@dolaned/wallet-sdk-ts
Version:
Wallet SDK for the Nexa blockchain
1,193 lines (1,109 loc) • 131 kB
JavaScript
var $l50U0$libnexats = require("libnexa-ts");
var $l50U0$bip39 = require("bip39");
var $l50U0$vgrunnerelectrumcash = require("@vgrunner/electrum-cash");
var $l50U0$jsbigdecimal = require("js-big-decimal");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
var $parcel$global = globalThis;
function $parcel$defineInteropFlag(a) {
Object.defineProperty(a, '__esModule', {value: true, configurable: true});
}
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
var $parcel$modules = {};
var $parcel$inits = {};
var parcelRequire = $parcel$global["parcelRequire77ae"];
if (parcelRequire == null) {
parcelRequire = function(id) {
if (id in $parcel$modules) {
return $parcel$modules[id].exports;
}
if (id in $parcel$inits) {
var init = $parcel$inits[id];
delete $parcel$inits[id];
var module = {id: id, exports: {}};
$parcel$modules[id] = module;
init.call(module.exports, module, module.exports);
return module.exports;
}
var err = new Error("Cannot find module '" + id + "'");
err.code = 'MODULE_NOT_FOUND';
throw err;
};
parcelRequire.register = function register(id, init) {
$parcel$inits[id] = init;
};
$parcel$global["parcelRequire77ae"] = parcelRequire;
}
var parcelRegister = parcelRequire.register;
parcelRegister("kNPhA", function(module, exports) {
$parcel$export(module.exports, "default", () => $f25029ea39a3086e$export$2e2bcd8739ae039);
var $cpiMl = parcelRequire("cpiMl");
var $j6iK9 = parcelRequire("j6iK9");
/** Detect free variable `exports`. */ var freeExports = exports && !exports.nodeType && exports;
/** Detect free variable `module`. */ var freeModule = freeExports && true && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports;
/** Built-in value references. */ var Buffer = moduleExports ? (0, $cpiMl.default).Buffer : undefined;
/* Built-in method references for those with the same name as other `lodash` methods. */ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
/**
* Checks if `value` is a buffer.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
* @example
*
* _.isBuffer(new Buffer(2));
* // => true
*
* _.isBuffer(new Uint8Array(2));
* // => false
*/ var isBuffer = nativeIsBuffer || (0, $j6iK9.default);
var $f25029ea39a3086e$export$2e2bcd8739ae039 = isBuffer;
});
parcelRegister("cpiMl", function(module, exports) {
$parcel$export(module.exports, "default", () => $908662eb8e7c9a57$export$2e2bcd8739ae039);
var $hYTRB = parcelRequire("hYTRB");
/** Detect free variable `self`. */ var $908662eb8e7c9a57$var$freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */ var $908662eb8e7c9a57$var$root = (0, $hYTRB.default) || $908662eb8e7c9a57$var$freeSelf || Function('return this')();
var $908662eb8e7c9a57$export$2e2bcd8739ae039 = $908662eb8e7c9a57$var$root;
});
parcelRegister("hYTRB", function(module, exports) {
$parcel$export(module.exports, "default", () => $d1735f9d9792bc22$export$2e2bcd8739ae039);
/** Detect free variable `global` from Node.js. */ var $d1735f9d9792bc22$var$freeGlobal = typeof $parcel$global == 'object' && $parcel$global && $parcel$global.Object === Object && $parcel$global;
var $d1735f9d9792bc22$export$2e2bcd8739ae039 = $d1735f9d9792bc22$var$freeGlobal;
});
parcelRegister("j6iK9", function(module, exports) {
$parcel$export(module.exports, "default", () => $de7d1de29f9a7741$export$2e2bcd8739ae039);
/**
* This method returns `false`.
*
* @static
* @memberOf _
* @since 4.13.0
* @category Util
* @returns {boolean} Returns `false`.
* @example
*
* _.times(2, _.stubFalse);
* // => [false, false]
*/ function $de7d1de29f9a7741$var$stubFalse() {
return false;
}
var $de7d1de29f9a7741$export$2e2bcd8739ae039 = $de7d1de29f9a7741$var$stubFalse;
});
$parcel$defineInteropFlag(module.exports);
$parcel$export(module.exports, "default", () => $56b18ab116ff33bd$export$2e2bcd8739ae039);
$parcel$export(module.exports, "Wallet", () => $b76d3bd5024ccfc0$export$2e2bcd8739ae039);
$parcel$export(module.exports, "WatchOnlyWallet", () => $f4ad400261a08cba$export$2e2bcd8739ae039);
$parcel$export(module.exports, "AccountType", () => $0d59d2bcffd646c5$export$b8ca5fa4899cbfc7);
$parcel$export(module.exports, "TxTokenType", () => $0d59d2bcffd646c5$export$dcc1fb6ad5308e56);
$parcel$export(module.exports, "BaseAccount", () => $f8a48da5c0b6346a$export$c54c8796e94a37a0);
$parcel$export(module.exports, "DefaultAccount", () => $1c49a4fffc97409b$export$2e2bcd8739ae039);
$parcel$export(module.exports, "DappAccount", () => $cf960f437fe63027$export$2e2bcd8739ae039);
$parcel$export(module.exports, "VaultAccount", () => $0b557605c0e99621$export$2e2bcd8739ae039);
$parcel$export(module.exports, "AccountStore", () => $7fcf3b163a95e69a$export$2e2bcd8739ae039);
$parcel$export(module.exports, "WalletTransactionCreator", () => $e1896e59040fa3c5$export$2e2bcd8739ae039);
$parcel$export(module.exports, "WatchOnlyTransactionCreator", () => $2ce5b75d10954bb1$export$2e2bcd8739ae039);
$parcel$export(module.exports, "rostrumProvider", () => $b5bfd17fdf06d231$export$eaa49f0478d81b9d);
// @ts-ignore
var $2dd241e44b9dc3c2$exports = {};
$2dd241e44b9dc3c2$exports = JSON.parse("{\"name\":\"@nexa/wallet-sdk-ts\",\"version\":\"0.1.0\",\"main\":\"dist/index.js\",\"module\":\"dist/index.mjs\",\"types\":\"dist/index.d.ts\",\"source\":\"src/index.ts\",\"scripts\":{\"build\":\"parcel build\",\"dev\":\"parcel watch\",\"test\":\"vitest run\",\"clean\":\"rm -rf dist .parcel-cache\"},\"repository\":{\"type\":\"git\",\"url\":\"git+ssh://git@gitlab.com/nexa/wallet-sdk-ts.git\"},\"keywords\":[\"nexa\",\"wallet\",\"web3\",\"crypto\",\"dapp\",\"walletcomms\",\"walletsdk\"],\"contributors\":[{\"name\":\"Dolaned\"},{\"name\":\"Griffith\"},{\"name\":\"Vgrunner\"},{\"name\":\"myendy\"}],\"author\":\"Dolaned\",\"license\":\"MIT\",\"bugs\":{\"url\":\"https://gitlab.com/nexa/wallet-sdk-ts/issues\"},\"homepage\":\"https://gitlab.com/nexa/wallet-sdk-ts#readme\",\"description\":\"Wallet SDK for the Nexa blockchain\",\"devDependencies\":{\"@parcel/packager-ts\":\"^2.15.4\",\"@parcel/transformer-typescript-types\":\"^2.15.4\",\"@types/lodash-es\":\"^4.17.12\",\"@types/node\":\"^22.13.1\",\"parcel\":\"^2.15.4\",\"typescript\":\"^5.8.3\",\"vitest\":\"^3.0.8\"},\"targets\":{\"main\":{\"context\":\"node\",\"outputFormat\":\"commonjs\",\"distDir\":\"dist\",\"isLibrary\":true,\"includeNodeModules\":[\"lodash-es\"]},\"module\":{\"context\":\"node\",\"outputFormat\":\"esmodule\",\"distDir\":\"dist\",\"isLibrary\":true},\"browser\":{\"context\":\"browser\",\"outputFormat\":\"esmodule\",\"distDir\":\"dist\",\"isLibrary\":true}},\"dependencies\":{\"@vgrunner/electrum-cash\":\"^2.0.12\",\"bip39\":\"^3.1.0\",\"js-big-decimal\":\"^2.2.0\",\"libnexa-ts\":\"^1.0.5\",\"lodash-es\":\"^4.17.21\"},\"directories\":{\"test\":\"tests\"}}");
const $95d1e8196bc3f78b$export$1f6f962b0b96558 = {
WS: 'ws',
WSS: 'wss'
};
class $b5bfd17fdf06d231$export$ba81aefc89aef50c {
constructor(){}
async getVersion() {
return await this.execute('server.version');
}
async getBlockTip() {
return await this.execute('blockchain.headers.tip');
}
async getBalance(address) {
return await this.execute('blockchain.address.get_balance', address, 'exclude_tokens');
}
async getTransactionsHistory(address) {
return await this.execute('blockchain.address.get_history', address);
}
async getFirstUse(address) {
return await this.execute('blockchain.address.get_first_use', address);
}
async getTransaction(id, verbose = true) {
return await this.execute('blockchain.transaction.get', id, verbose);
}
async getUtxo(outpoint) {
return await this.execute('blockchain.utxo.get', outpoint);
}
async getNexaUtxos(address) {
return await this.execute('blockchain.address.listunspent', address, 'exclude_tokens');
}
async getTokenUtxos(address, token) {
let listunspent = await this.execute('token.address.listunspent', address, null, token);
return listunspent.unspent;
}
async getTokensBalance(address, token) {
if (token) return await this.execute('token.address.get_balance', address, null, token);
return await this.execute('token.address.get_balance', address);
}
async getTokenGenesis(token) {
return await this.execute('token.genesis.info', token);
}
async subscribeToAddresses(addresses, callback) {
for (const addr of addresses)await this.client?.subscribe(callback, 'blockchain.address.subscribe', addr);
}
async broadcast(txHex) {
return await this.execute('blockchain.transaction.broadcast', txHex);
}
async getLatency() {
try {
let start = Date.now();
let res = await this.getBlockTip();
if (res) return Date.now() - start;
return 0;
} catch {
return 0;
}
}
async connect(params) {
try {
if (!params) params = {
host: 'aus.electrum.nexa.onethirtyseven.dev',
port: 30004,
scheme: (0, $95d1e8196bc3f78b$export$1f6f962b0b96558).WSS
};
this.client = new (0, $l50U0$vgrunnerelectrumcash.ElectrumClient)("com.otoplo.wallet", "1.4.3", params.host, params.port, params.scheme, 30000, 10000, true);
await this.client.connect();
} catch (e) {
if (e instanceof Error) console.info(e.message);
else console.error(e);
throw e;
}
}
async disconnect(force) {
try {
return await this.client.disconnect(force);
} catch (e) {
console.log(e);
return false;
}
}
async execute(method, ...parameters) {
var res = await this.client.request(method, ...parameters);
if (res instanceof Error) throw res;
return res;
}
}
const $b5bfd17fdf06d231$export$eaa49f0478d81b9d = new $b5bfd17fdf06d231$export$ba81aefc89aef50c();
/**
* Checks if `value` is `null` or `undefined`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is nullish, else `false`.
* @example
*
* _.isNil(null);
* // => true
*
* _.isNil(void 0);
* // => true
*
* _.isNil(NaN);
* // => false
*/ function $54dde1e65fb8e5b8$var$isNil(value) {
return value == null;
}
var $54dde1e65fb8e5b8$export$2e2bcd8739ae039 = $54dde1e65fb8e5b8$var$isNil;
class $f8a48da5c0b6346a$export$c54c8796e94a37a0 {
get transactions() {
return this._transactions;
}
set transactions(value) {
this._transactions = value;
}
constructor(_bip44Account){
this._tokenBalances = {};
this._transactions = new Map();
this._bip44Account = _bip44Account;
this._balance = {
confirmed: 0,
unconfirmed: 0
};
this._tokenBalances = {};
}
get balance() {
return this._balance;
}
set balance(value) {
this._balance = value;
}
get tokenBalances() {
return this._tokenBalances;
}
set tokenBalances(value) {
this._tokenBalances = value;
}
}
class $cf960f437fe63027$export$2e2bcd8739ae039 extends (0, $f8a48da5c0b6346a$export$c54c8796e94a37a0) {
constructor(bip44Account, accountIndex, addressKey){
super(bip44Account);
this._accountIndex = accountIndex;
this._accountKey = addressKey;
}
// this is used in AccountStore.ts to get the key to be used in the map for this account
getAccountStoreKey() {
return String(this._bip44Account + '.' + this._accountIndex);
}
getAccountType() {
return (0, $0d59d2bcffd646c5$export$b8ca5fa4899cbfc7).DAPP_ACCOUNT;
}
getNewAddress() {
return this._accountKey.address;
}
getNewChangeAddress() {
return this._accountKey.address;
}
get accountIndexes() {
return {
rIndex: this._accountIndex,
cIndex: 0
};
}
get accountKeys() {
return {
receiveKeys: [
this._accountKey
],
changeKeys: [
this._accountKey
]
};
}
async loadBalances() {
let balances = await (0, $0d59d2bcffd646c5$export$9e38d26dbd7c33f4)([
this._accountKey
]);
let tokenBalances = [
this._accountKey
].map((k)=>k.tokensBalance);
super.balance = (0, $0d59d2bcffd646c5$export$a26005fb5b8d1e4a)(balances);
super.tokenBalances = (0, $0d59d2bcffd646c5$export$dec515296f176dbe)(tokenBalances);
}
getKeyFromAddress(address) {
return this._accountKey;
}
async getTransactions(fromHeight, address) {
let txPromises = [];
const transactions = await (0, $0d59d2bcffd646c5$export$a2ed4b531376a5a4)([
address ?? this._accountKey.address
], fromHeight ?? 0);
for (let tx of transactions.txs.values()){
let t = await (0, $0d59d2bcffd646c5$export$9c6f4f51acbc89b9)(tx, [
address ?? this._accountKey.address
]);
txPromises.push(t);
}
await Promise.all(txPromises);
for (let txEntity of txPromises)this.transactions.set(txEntity.txId, txEntity);
return this.transactions;
}
}
class $1c49a4fffc97409b$export$2e2bcd8739ae039 extends (0, $f8a48da5c0b6346a$export$c54c8796e94a37a0) {
constructor(bip44Account, accountIndexes, accountKeys){
super(bip44Account);
if (accountIndexes.rIndex < 0) throw new Error(`Can not create nexa account with an rindex of ${accountIndexes.rIndex}. must be >= 0.`);
if (accountIndexes.cIndex < 0) throw new Error(`Can not create nexa account with an cindex of ${accountIndexes.cIndex}. must be >= 0.`);
this._accountIndexes = accountIndexes;
this._accountKeys = accountKeys;
}
// this is used in AccountStore.ts to get the key to be used in the map for this account
getAccountStoreKey() {
return String(this._bip44Account);
}
getAccountType() {
return (0, $0d59d2bcffd646c5$export$b8ca5fa4899cbfc7).NEXA_ACCOUNT;
}
getNewAddress() {
return this._accountKeys.receiveKeys[this._accountKeys.receiveKeys.length - 1]?.address ?? '';
}
getNewChangeAddress() {
return this._accountKeys.changeKeys[this._accountKeys.changeKeys.length - 1]?.address ?? '';
}
get accountIndexes() {
return this._accountIndexes;
}
get accountKeys() {
return this._accountKeys;
}
async loadBalances() {
let balances = await (0, $0d59d2bcffd646c5$export$9e38d26dbd7c33f4)(this._accountKeys.receiveKeys.concat(this._accountKeys.changeKeys));
let tokenBalances = this._accountKeys.receiveKeys.concat(this._accountKeys.changeKeys).map((k)=>k.tokensBalance);
super.balance = (0, $0d59d2bcffd646c5$export$a26005fb5b8d1e4a)(balances);
super.tokenBalances = (0, $0d59d2bcffd646c5$export$dec515296f176dbe)(tokenBalances);
}
getKeyFromAddress(address) {
const allKeys = this._accountKeys.receiveKeys.concat(this._accountKeys.changeKeys);
const keyFound = allKeys.find((key)=>key.address === address);
return keyFound;
}
async getTransactions(fromHeight, address) {
let receiveAddresses = this.accountKeys.receiveKeys.map((ak)=>ak.address);
let changeAddresses = this.accountKeys.changeKeys.map((ak)=>ak.address);
let allAddresses = receiveAddresses.concat(changeAddresses);
let rTxs = (0, $0d59d2bcffd646c5$export$a2ed4b531376a5a4)(address != null ? [
address
] : receiveAddresses, fromHeight ?? 0);
let cTxs = (0, $0d59d2bcffd646c5$export$a2ed4b531376a5a4)(address != null ? [
address
] : receiveAddresses, fromHeight ?? 0);
let [rData, cData] = await Promise.all([
rTxs,
cTxs
]);
let txHistory = rData.txs;
for (let tx of cData.txs.values())txHistory.set(tx.tx_hash, tx);
let txPromises = [];
for (let tx of txHistory.values()){
let t = await (0, $0d59d2bcffd646c5$export$9c6f4f51acbc89b9)(tx, allAddresses);
txPromises.push(t);
}
await Promise.all(txPromises);
for (let txEntity of txPromises)this.transactions.set(txEntity.txId, txEntity);
return this.transactions;
}
}
class $0b557605c0e99621$export$2e2bcd8739ae039 extends (0, $f8a48da5c0b6346a$export$c54c8796e94a37a0) {
constructor(bip44Account, accountIndex, addressKey){
super(bip44Account);
this._accountIndex = accountIndex;
this._accountKey = addressKey;
}
// this is used in AccountStore.ts to get the key to be used in the map for this account
getAccountStoreKey() {
return String(this._bip44Account + '.' + this._accountIndex);
}
getAccountType() {
return (0, $0d59d2bcffd646c5$export$b8ca5fa4899cbfc7).VAULT_ACCOUNT;
}
getNewAddress() {
return this._accountKey.address;
}
getNewChangeAddress() {
return this._accountKey.address;
}
get accountIndexes() {
return {
rIndex: this._accountIndex,
cIndex: 0
};
}
get accountKeys() {
return {
receiveKeys: [
this._accountKey
],
changeKeys: [
this._accountKey
]
};
}
async loadBalances() {
let balances = await (0, $0d59d2bcffd646c5$export$9e38d26dbd7c33f4)([
this._accountKey
]);
let tokenBalances = [
this._accountKey
].map((k)=>k.tokensBalance);
super.balance = (0, $0d59d2bcffd646c5$export$a26005fb5b8d1e4a)(balances);
super.tokenBalances = (0, $0d59d2bcffd646c5$export$dec515296f176dbe)(tokenBalances);
}
getKeyFromAddress(address) {
return this._accountKey;
}
async getTransactions(fromHeight, address) {
let txPromises = [];
const transactions = await (0, $0d59d2bcffd646c5$export$a2ed4b531376a5a4)([
address ?? this._accountKey.address
], fromHeight ?? 0);
for (let tx of transactions.txs.values()){
let t = await (0, $0d59d2bcffd646c5$export$9c6f4f51acbc89b9)(tx, [
address ?? this._accountKey.address
]);
txPromises.push(t);
}
await Promise.all(txPromises);
for (let txEntity of txPromises)this.transactions.set(txEntity.txId, txEntity);
return this.transactions;
}
}
const $bc5ca2c06b1affa3$export$8ba128bc85947a2a = 9223372036854775807n;
function $bc5ca2c06b1affa3$export$78d0476e8d098ba7() {
return Math.floor(Date.now() / 1000);
}
function $bc5ca2c06b1affa3$export$c8733ae29fb53302(arg) {
return !arg || arg.length === 0;
}
function $bc5ca2c06b1affa3$export$78e516cc94be797b(amount, decimals) {
let val = new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(amount).divide(new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(Math.pow(10, decimals)), decimals).getPrettyValue();
if (val.match(/\./)) val = val.replace(/\.?0+$/, '');
return val;
}
function $bc5ca2c06b1affa3$export$9ad78026dec58d6(amount, decimals) {
return new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(amount).multiply(new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(Math.pow(10, decimals))).getValue();
}
function $bc5ca2c06b1affa3$export$23010fd5dda8dec1(address) {
if ((0, $l50U0$libnexats.CommonUtils).isHexa(address)) return Buffer.from(address, 'hex');
return (0, $l50U0$libnexats.Address).fromString(address).data;
}
function $bc5ca2c06b1affa3$export$254a5c7330bbfd41(token) {
if ((0, $l50U0$libnexats.CommonUtils).isHexa(token)) return token;
return $bc5ca2c06b1affa3$export$23010fd5dda8dec1(token).toString('hex');
}
var $0d59d2bcffd646c5$export$dcc1fb6ad5308e56 = /*#__PURE__*/ function(TxTokenType) {
TxTokenType[TxTokenType["NO_GROUP"] = 0] = "NO_GROUP";
TxTokenType[TxTokenType["CREATE"] = 1] = "CREATE";
TxTokenType[TxTokenType["MINT"] = 2] = "MINT";
TxTokenType[TxTokenType["MELT"] = 3] = "MELT";
TxTokenType[TxTokenType["RENEW"] = 4] = "RENEW";
TxTokenType[TxTokenType["TRANSFER"] = 5] = "TRANSFER";
return TxTokenType;
}({});
var $0d59d2bcffd646c5$export$b8ca5fa4899cbfc7 = /*#__PURE__*/ function(AccountType) {
AccountType[AccountType["NEXA_ACCOUNT"] = 0] = "NEXA_ACCOUNT";
AccountType[AccountType["VAULT_ACCOUNT"] = 1] = "VAULT_ACCOUNT";
AccountType[AccountType["DAPP_ACCOUNT"] = 2] = "DAPP_ACCOUNT";
return AccountType;
}({});
function $0d59d2bcffd646c5$export$8d986bd2866fe6ab(address, network, type = (0, $l50U0$libnexats.AddressType).PayToScriptTemplate) {
return (0, $l50U0$libnexats.Address).isValid(address, network, type);
}
function $0d59d2bcffd646c5$export$11f4ae2b4ff9633d(mnemonic, passphrase) {
const seed = $l50U0$bip39.mnemonicToSeedSync(mnemonic, passphrase);
const masterKey = (0, $l50U0$libnexats.HDPrivateKey).fromSeed(seed);
return masterKey.deriveChild(44, true).deriveChild(29223, true);
}
function $0d59d2bcffd646c5$export$b3a12d67e2f5f8c9(masterKey, account) {
return masterKey.deriveChild(account, true);
}
function $0d59d2bcffd646c5$export$d6e8eb22902c6b88(accountKey, fromRIndex, rIndex, fromCIndex, cIndex) {
if (fromRIndex < 0) throw new Error(`Can not generate keys with fromRIndex ${fromRIndex}. must be >= 0.`);
if (fromCIndex < 0) throw new Error(`Can not generate keys with fromCIndex ${fromCIndex}. must be >= 0.`);
let receive = accountKey.deriveChild(0, false);
let change = accountKey.deriveChild(1, false);
let rKeys = [], cKeys = [];
for(let index = fromRIndex; index < rIndex; index++){
let k = receive.deriveChild(index, false);
let addr = k.privateKey.toAddress().toString();
rKeys.push({
key: k,
address: addr,
balance: "0",
tokensBalance: {}
});
}
for(let index = fromCIndex; index < cIndex; index++){
let k = change.deriveChild(index, false);
let addr = k.privateKey.toAddress().toString();
cKeys.push({
key: k,
address: addr,
balance: "0",
tokensBalance: {}
});
}
return {
receiveKeys: rKeys,
changeKeys: cKeys
};
}
function $0d59d2bcffd646c5$export$1e0ce394ebe84ca9(accountKey, rIndex) {
let receive = accountKey.deriveChild(0, false);
let k = receive.deriveChild(rIndex, false);
let addr = k.privateKey.toAddress().toString();
return {
key: k,
address: addr,
balance: "0",
tokensBalance: {}
};
}
async function $0d59d2bcffd646c5$var$discoverUsedAccountIndexes(deriveKey) {
let lastUsed = -1, index = 0, toScan = 20;
while(toScan > 0){
toScan--;
let rAddr = deriveKey.deriveChild(index, false).privateKey.toAddress().toString();
let isUsed = await $0d59d2bcffd646c5$var$isAddressUsed(rAddr);
if (isUsed) {
lastUsed = index;
toScan = 20;
}
index++;
}
// return the last used index, returns -1 if no indexes are used
return lastUsed;
}
async function $0d59d2bcffd646c5$export$4aeb2c92e53ab137(accountKey) {
let receiveKey = accountKey.deriveChild(0, false);
let changeKey = accountKey.deriveChild(1, false);
let rIndexPromise = $0d59d2bcffd646c5$var$discoverUsedAccountIndexes(receiveKey);
let cIndexPromise = $0d59d2bcffd646c5$var$discoverUsedAccountIndexes(changeKey);
let [rIndex, cIndex] = await Promise.all([
rIndexPromise,
cIndexPromise
]);
// get the index that is the last used nexa addr
let indexes = {
rIndex: rIndex,
cIndex: cIndex
};
return indexes;
}
async function $0d59d2bcffd646c5$export$f421913908d4303e(masterKey) {
let accounts = [];
let index = 0;
while(true){
const nexaAccountKey = $0d59d2bcffd646c5$export$b3a12d67e2f5f8c9(masterKey, index);
const indexes = await $0d59d2bcffd646c5$export$4aeb2c92e53ab137(nexaAccountKey);
if (indexes.rIndex < 0 && indexes.cIndex < 0) break;
if (indexes.rIndex < 0) indexes.rIndex = 0;
if (indexes.cIndex < 0) indexes.cIndex = 0;
// make account after break check, otherwise we might push an empty account
const nexaAccount = new (0, $1c49a4fffc97409b$export$2e2bcd8739ae039)(index, indexes, $0d59d2bcffd646c5$export$d6e8eb22902c6b88(nexaAccountKey, indexes.rIndex + 1, indexes.rIndex + 20, indexes.cIndex + 1, indexes.cIndex + 20));
await nexaAccount.loadBalances();
accounts.push(nexaAccount);
if (index == 0) index = 100;
else index++;
}
if (accounts.length == 0) {
// default account was unused but we need to populate at least one account,
// make the default account here
let defaultNexaAccountKey = $0d59d2bcffd646c5$export$b3a12d67e2f5f8c9(masterKey, 0);
// get the last used indexes, -1 means unused
let defaultIndexes = {
rIndex: 0,
cIndex: 0
};
const defaultAccount = new (0, $1c49a4fffc97409b$export$2e2bcd8739ae039)(0, defaultIndexes, $0d59d2bcffd646c5$export$d6e8eb22902c6b88(defaultNexaAccountKey, defaultIndexes.rIndex, defaultIndexes.rIndex + 20, defaultIndexes.cIndex, defaultIndexes.cIndex + 20));
await defaultAccount.loadBalances();
accounts.push(defaultAccount);
}
return accounts;
}
async function $0d59d2bcffd646c5$var$findUsedVaultAccounts(masterKey) {
// all vaults are in bip44 account 1
let vaultAccountKey = $0d59d2bcffd646c5$export$b3a12d67e2f5f8c9(masterKey, 1);
// all vaults are in the external chain
let vaultChain = vaultAccountKey.deriveChild(0, false);
// get the index that is the last used vault
return await $0d59d2bcffd646c5$var$discoverUsedAccountIndexes(vaultChain);
}
async function $0d59d2bcffd646c5$export$eb24265dd203eccb(masterKey) {
let accounts = [];
// all vaults are in bip44 account 1
let vaultAccountKey = $0d59d2bcffd646c5$export$b3a12d67e2f5f8c9(masterKey, 1);
// find the next unused vault
let lastUsedVaultIndex = await $0d59d2bcffd646c5$var$findUsedVaultAccounts(masterKey);
// if all vaults unused, generate at least the first vault account
if (lastUsedVaultIndex < 0) lastUsedVaultIndex = 0;
// for each vault found, make the DefaultAccount for that vault
for(let index = 0; index <= lastUsedVaultIndex; index++){
const vaultAccount = new (0, $0b557605c0e99621$export$2e2bcd8739ae039)(1, index, $0d59d2bcffd646c5$export$1e0ce394ebe84ca9(vaultAccountKey, index));
await vaultAccount.loadBalances();
accounts.push(vaultAccount);
}
return accounts;
}
async function $0d59d2bcffd646c5$var$findUsedDappAccounts(masterKey) {
// all dApp accounts are in bip44 account 2
let dappAccountKey = $0d59d2bcffd646c5$export$b3a12d67e2f5f8c9(masterKey, 2);
// all dApp accounts use the external chain
let dappChain = dappAccountKey.deriveChild(0, false);
// get the index that is the next unused dApp account
return await $0d59d2bcffd646c5$var$discoverUsedAccountIndexes(dappChain);
}
async function $0d59d2bcffd646c5$export$e3d879d0e09f52c3(masterKey) {
let accounts = [];
// all dApp accounts are in bip44 account 2
let dappAccountKey = $0d59d2bcffd646c5$export$b3a12d67e2f5f8c9(masterKey, 2);
// find the next unused dapp account
let lastUsedDappIndex = await $0d59d2bcffd646c5$var$findUsedDappAccounts(masterKey);
// if all dapp accounts unused, generate at least the first dapp account
if (lastUsedDappIndex < 0) lastUsedDappIndex = 0;
// for each dApp account found, make the DefaultAccount for that dApp account
// for each vault found, make the DefaultAccount for that vault
for(let index = 0; index <= lastUsedDappIndex; index++){
const dappAccount = new (0, $cf960f437fe63027$export$2e2bcd8739ae039)(2, index, $0d59d2bcffd646c5$export$1e0ce394ebe84ca9(dappAccountKey, index));
await dappAccount.loadBalances();
accounts.push(dappAccount);
}
return accounts;
}
async function $0d59d2bcffd646c5$export$4e4f91181d6bd31c(masterKey) {
let accounts = [];
// accounts 0, 100+
const nexaAccounts = await $0d59d2bcffd646c5$export$f421913908d4303e(masterKey);
// vaults in bip44 account 1
const vaultAccounts = await $0d59d2bcffd646c5$export$eb24265dd203eccb(masterKey);
// dApp accounts in bip44 account 2
const dappAccounts = await $0d59d2bcffd646c5$export$e3d879d0e09f52c3(masterKey);
// 3 - 99 are reserved and will go here when added
accounts = accounts.concat(nexaAccounts);
accounts = accounts.concat(vaultAccounts);
accounts = accounts.concat(dappAccounts);
return accounts;
}
async function $0d59d2bcffd646c5$var$isAddressUsed(address) {
try {
let firstUse = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getFirstUse(address);
return firstUse.tx_hash && firstUse.tx_hash !== "";
} catch (e) {
if (e instanceof Error && e.message.includes("not found")) return false;
throw e;
}
}
async function $0d59d2bcffd646c5$var$getKeyTokenBalance(key) {
let tokensBalance = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getTokensBalance(key.address);
let balance = {};
for(const cToken in tokensBalance.confirmed)if (tokensBalance.confirmed[cToken] != 0) balance[cToken] = {
confirmed: BigInt(tokensBalance.confirmed[cToken]).toString(),
unconfirmed: "0"
};
for(const uToken in tokensBalance.unconfirmed)if (tokensBalance.unconfirmed[uToken] != 0) {
if (balance[uToken]) balance[uToken].unconfirmed = BigInt(tokensBalance.unconfirmed[uToken]).toString();
else balance[uToken] = {
confirmed: "0",
unconfirmed: BigInt(tokensBalance.unconfirmed[uToken]).toString()
};
}
return balance;
}
async function $0d59d2bcffd646c5$var$getAndUpdateAddressKeyBalance(key) {
let balance = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getBalance(key.address);
key.balance = (BigInt(balance.confirmed) + BigInt(balance.unconfirmed)).toString();
key.tokensBalance = await $0d59d2bcffd646c5$var$getKeyTokenBalance(key);
return balance;
}
async function $0d59d2bcffd646c5$export$9e38d26dbd7c33f4(keys) {
let promises = [];
keys.forEach((key)=>{
let b = $0d59d2bcffd646c5$var$getAndUpdateAddressKeyBalance(key);
promises.push(b);
});
return await Promise.all(promises);
}
function $0d59d2bcffd646c5$export$a26005fb5b8d1e4a(balances) {
let confirmed = new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(0), unconfirmed = new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(0);
balances.forEach((b)=>{
confirmed = confirmed.add(new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(b.confirmed));
unconfirmed = unconfirmed.add(new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(b.unconfirmed));
});
return {
confirmed: confirmed.getValue(),
unconfirmed: unconfirmed.getValue()
};
}
function $0d59d2bcffd646c5$export$dec515296f176dbe(balances) {
let tokensBalance = {};
balances.forEach((b)=>{
for(const key in b)if (tokensBalance[key]) {
tokensBalance[key].confirmed = (BigInt(tokensBalance[key].confirmed) + BigInt(b[key].confirmed)).toString();
tokensBalance[key].unconfirmed = (BigInt(tokensBalance[key].unconfirmed) + BigInt(b[key].unconfirmed)).toString();
} else tokensBalance[key] = {
confirmed: b[key].confirmed,
unconfirmed: b[key].unconfirmed
};
});
return tokensBalance;
}
async function $0d59d2bcffd646c5$export$a2ed4b531376a5a4(addresses, fromHeight) {
let index = 0, i = 0, data = new Map(), maxHeight = fromHeight;
for (let address of addresses){
i++;
let txHistory = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getTransactionsHistory(address);
if (txHistory && txHistory.length > 0) {
index = i;
for (let tx of txHistory)if (tx.height === 0 || tx.height > fromHeight) {
maxHeight = Math.max(maxHeight, tx.height);
data.set(tx.tx_hash, tx);
}
}
}
return {
index: index,
txs: data,
lastHeight: maxHeight
};
}
async function $0d59d2bcffd646c5$var$rescanAddressesHistory(addresses) {
let index = 0, i = 0, minHeight = Number.MAX_SAFE_INTEGER;
for (let address of addresses){
i++;
let txHistory = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getTransactionsHistory(address);
if (!(0, $54dde1e65fb8e5b8$export$2e2bcd8739ae039)(txHistory)) {
index = i;
let heights = txHistory.filter((tx)=>tx.height > 0).map((h)=>h.height);
if (!(0, $54dde1e65fb8e5b8$export$2e2bcd8739ae039)(heights)) minHeight = Math.min(minHeight, ...heights);
}
}
return {
index: index > 0 ? index + 1 : 0,
height: minHeight == Number.MAX_SAFE_INTEGER ? 0 : minHeight
};
}
async function $0d59d2bcffd646c5$export$ef13479e8d3251d7(accountType, masterKey) {
if (accountType == 0) {
let defaultNexaAccountKey = $0d59d2bcffd646c5$export$b3a12d67e2f5f8c9(masterKey, 0);
const defaultIndexes = await $0d59d2bcffd646c5$export$4aeb2c92e53ab137(defaultNexaAccountKey);
if (defaultIndexes.rIndex < 0 && defaultIndexes.cIndex < 0) return 0;
else // account 0 was not empty
for(let index = 100;; index++){
const nexaAccountKey = $0d59d2bcffd646c5$export$b3a12d67e2f5f8c9(masterKey, index);
const indexes = await $0d59d2bcffd646c5$export$4aeb2c92e53ab137(nexaAccountKey);
if (indexes.rIndex < 0 && indexes.cIndex < 0) return index;
}
} else if (accountType == 1) {
// find the next unused vault
const lastUsedVault = await $0d59d2bcffd646c5$var$findUsedVaultAccounts(masterKey);
return lastUsedVault + 1;
} else if (accountType == 2) {
// find the next unused dapp account
const lastUsedDappAccount = await $0d59d2bcffd646c5$var$findUsedDappAccounts(masterKey);
return lastUsedDappAccount + 1;
} else throw new Error("Can not get next account index. Invalid accountType.");
}
async function $0d59d2bcffd646c5$export$9c6f4f51acbc89b9(txHistory, myAddresses) {
let t = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getTransaction(txHistory.tx_hash);
let outputs = t.vout.filter((utxo)=>!(0, $54dde1e65fb8e5b8$export$2e2bcd8739ae039)(utxo.scriptPubKey.addresses));
let isOutgoing = t.vin.length > 0 && myAddresses.includes(t.vin[0].addresses[0]);
let isIncoming = !isOutgoing || outputs.every((utxo)=>myAddresses.includes(utxo.scriptPubKey.addresses[0]));
let isConfirmed = t.height > 0;
let txEntry = {};
txEntry.txId = t.txid;
txEntry.txIdem = t.txidem;
txEntry.height = isConfirmed ? t.height : 0;
txEntry.time = isConfirmed ? t.time : (0, $bc5ca2c06b1affa3$export$78d0476e8d098ba7)();
txEntry.fee = t.fee_satoshi;
if (isOutgoing && isIncoming) {
txEntry.state = 'both';
txEntry.value = "0";
txEntry.payTo = "Payment to yourself";
} else if (isIncoming) {
txEntry.state = 'incoming';
let utxos = outputs.filter((utxo)=>myAddresses.includes(utxo.scriptPubKey.addresses[0]));
let amount = new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(0);
utxos.forEach((utxo)=>{
amount = amount.add(new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(utxo.value_satoshi));
});
txEntry.value = amount.getValue();
txEntry.payTo = utxos[0].scriptPubKey.addresses[0];
} else if (isOutgoing) {
txEntry.state = 'outgoing';
let utxos = outputs.filter((utxo)=>!myAddresses.includes(utxo.scriptPubKey.addresses[0]));
let amount = new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(0);
utxos.forEach((utxo)=>{
amount = amount.add(new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(utxo.value_satoshi));
});
txEntry.value = amount.getValue();
txEntry.payTo = utxos[0].scriptPubKey.addresses[0];
}
let [txType, txGroup, tokenAmount, extraGroup] = $0d59d2bcffd646c5$var$classifyTokenTransaction(t.vin, outputs, txEntry.state, myAddresses);
txEntry.txGroupType = txType;
txEntry.token = txGroup;
txEntry.tokenAmount = tokenAmount;
txEntry.extraGroup = extraGroup;
return txEntry;
}
function $0d59d2bcffd646c5$var$classifyTokenTransaction(vin, vout, txState, myAddresses) {
let groupInputs = vin.filter((input)=>!(0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(input.group));
let groupOutputs = vout.filter((output)=>!(0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(output.scriptPubKey.group));
if ((0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(groupInputs) && (0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(groupOutputs)) return [
0,
"none",
"0",
"none"
];
let myGroupInputs = groupInputs.filter((input)=>myAddresses.includes(input.addresses[0]));
let myGroupOutputs = groupOutputs.filter((output)=>myAddresses.includes(output.scriptPubKey.addresses[0]));
if ((0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(myGroupInputs) && (0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(myGroupOutputs)) return [
0,
"none",
"0",
"none"
];
if ((0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(groupInputs)) {
let group = myGroupOutputs.find((output)=>BigInt(output.scriptPubKey.groupQuantity) < 0n)?.scriptPubKey.group ?? "none";
return [
1,
group,
"0",
"none"
];
}
if ((0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(groupOutputs)) {
if (txState === 'incoming') return [
0,
"none",
"0",
"none"
];
let inputs = myGroupInputs.filter((input)=>BigInt(input.groupQuantity) > 0n);
if (!(0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(inputs)) {
let amount = new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(0);
inputs.forEach((utxo)=>{
amount = amount.add(new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(utxo.groupQuantity));
});
let group = inputs[0].group;
let extraGroup = myGroupInputs.find((input)=>BigInt(input.groupQuantity) < 0n && inputs[0].group != input.group)?.group ?? "none";
return [
3,
group,
amount.getValue(),
extraGroup
];
}
let group = myGroupInputs.find((input)=>BigInt(input.groupQuantity) < 0n)?.group ?? "none";
let extraGroup = myGroupInputs.find((input)=>BigInt(input.groupQuantity) < 0n && group != input.group)?.group ?? "none";
return [
3,
group,
"0",
extraGroup
];
}
let tokenInputs = groupInputs.filter((input)=>BigInt(input.groupQuantity) > 0n);
let tokenOutputs = groupOutputs.filter((output)=>BigInt(output.scriptPubKey.groupQuantity) > 0n);
if ((0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(tokenInputs) && (0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(tokenOutputs)) {
let group = groupInputs.find((input)=>BigInt(input.groupQuantity) < 0n)?.group ?? "none";
let extraGroup = groupOutputs.find((output)=>BigInt(output.scriptPubKey.groupQuantity) < 0n && group != output.scriptPubKey.group)?.scriptPubKey.group ?? "none";
return [
4,
extraGroup !== 'none' ? extraGroup : group,
"0",
extraGroup !== 'none' ? group : extraGroup
];
}
if ((0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(tokenInputs)) {
let group = tokenOutputs[0].scriptPubKey.group;
let amount = new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(0);
tokenOutputs.forEach((utxo)=>{
amount = amount.add(new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(utxo.scriptPubKey.groupQuantity));
});
let extraGroup = groupInputs.find((input)=>BigInt(input.groupQuantity) < 0n && group != input.group)?.group ?? "none";
return [
2,
group,
amount.getValue(),
extraGroup
];
}
if ((0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(tokenOutputs)) {
let group = tokenInputs[0].group;
let amount = new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(0);
tokenInputs.forEach((utxo)=>{
amount = amount.add(new (0, ($parcel$interopDefault($l50U0$jsbigdecimal)))(utxo.groupQuantity));
});
let extraGroup = groupInputs.find((input)=>BigInt(input.groupQuantity) < 0n && group != input.group)?.group ?? "none";
return [
3,
group,
amount.getValue(),
extraGroup
];
}
let outQuantitySum = tokenOutputs.map((output)=>BigInt(output.scriptPubKey.groupQuantity)).reduce((a, b)=>a + b, 0n);
let inQuantitySum = tokenInputs.map((input)=>BigInt(input.groupQuantity)).reduce((a, b)=>a + b, 0n);
if (outQuantitySum > inQuantitySum) {
let group = tokenOutputs[0].scriptPubKey.group;
let extraGroup = groupInputs.find((input)=>BigInt(input.groupQuantity) < 0n && group != input.group)?.group ?? "none";
return [
2,
group,
(outQuantitySum - inQuantitySum).toString(),
extraGroup
];
}
if (inQuantitySum > outQuantitySum) {
let group = tokenInputs[0].group;
let extraGroup = groupInputs.find((input)=>BigInt(input.groupQuantity) < 0n && group != input.group)?.group ?? "none";
return [
3,
group,
(inQuantitySum - outQuantitySum).toString(),
extraGroup
];
}
let group = tokenOutputs[0].scriptPubKey.group;
let amount = "";
if (txState === 'incoming') amount = tokenOutputs.filter((output)=>myAddresses.includes(output.scriptPubKey.addresses[0])).map((output)=>BigInt(output.scriptPubKey.groupQuantity)).reduce((a, b)=>a + b, 0n).toString();
else if (txState === 'outgoing') amount = tokenOutputs.filter((output)=>!myAddresses.includes(output.scriptPubKey.addresses[0])).map((output)=>BigInt(output.scriptPubKey.groupQuantity)).reduce((a, b)=>a + b, 0n).toString();
else amount = "0";
return [
5,
group,
amount,
"none"
];
}
var $kNPhA = parcelRequire("kNPhA");
var $cpiMl = parcelRequire("cpiMl");
/** Built-in value references. */ var $ff9e97e034030f4b$var$Symbol = (0, $cpiMl.default).Symbol;
var $ff9e97e034030f4b$export$2e2bcd8739ae039 = $ff9e97e034030f4b$var$Symbol;
/** Used for built-in method references. */ var $5821915922f18ec9$var$objectProto = Object.prototype;
/** Used to check objects for own properties. */ var $5821915922f18ec9$var$hasOwnProperty = $5821915922f18ec9$var$objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/ var $5821915922f18ec9$var$nativeObjectToString = $5821915922f18ec9$var$objectProto.toString;
/** Built-in value references. */ var $5821915922f18ec9$var$symToStringTag = (0, $ff9e97e034030f4b$export$2e2bcd8739ae039) ? (0, $ff9e97e034030f4b$export$2e2bcd8739ae039).toStringTag : undefined;
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/ function $5821915922f18ec9$var$getRawTag(value) {
var isOwn = $5821915922f18ec9$var$hasOwnProperty.call(value, $5821915922f18ec9$var$symToStringTag), tag = value[$5821915922f18ec9$var$symToStringTag];
try {
value[$5821915922f18ec9$var$symToStringTag] = undefined;
var unmasked = true;
} catch (e) {}
var result = $5821915922f18ec9$var$nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) value[$5821915922f18ec9$var$symToStringTag] = tag;
else delete value[$5821915922f18ec9$var$symToStringTag];
}
return result;
}
var $5821915922f18ec9$export$2e2bcd8739ae039 = $5821915922f18ec9$var$getRawTag;
/** Used for built-in method references. */ var $8b46445dc5373cfc$var$objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/ var $8b46445dc5373cfc$var$nativeObjectToString = $8b46445dc5373cfc$var$objectProto.toString;
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/ function $8b46445dc5373cfc$var$objectToString(value) {
return $8b46445dc5373cfc$var$nativeObjectToString.call(value);
}
var $8b46445dc5373cfc$export$2e2bcd8739ae039 = $8b46445dc5373cfc$var$objectToString;
/** `Object#toString` result references. */ var $6911cdf7f985d482$var$nullTag = '[object Null]', $6911cdf7f985d482$var$undefinedTag = '[object Undefined]';
/** Built-in value references. */ var $6911cdf7f985d482$var$symToStringTag = (0, $ff9e97e034030f4b$export$2e2bcd8739ae039) ? (0, $ff9e97e034030f4b$export$2e2bcd8739ae039).toStringTag : undefined;
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/ function $6911cdf7f985d482$var$baseGetTag(value) {
if (value == null) return value === undefined ? $6911cdf7f985d482$var$undefinedTag : $6911cdf7f985d482$var$nullTag;
return $6911cdf7f985d482$var$symToStringTag && $6911cdf7f985d482$var$symToStringTag in Object(value) ? (0, $5821915922f18ec9$export$2e2bcd8739ae039)(value) : (0, $8b46445dc5373cfc$export$2e2bcd8739ae039)(value);
}
var $6911cdf7f985d482$export$2e2bcd8739ae039 = $6911cdf7f985d482$var$baseGetTag;
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/ var $36cc8c1055cfbf3b$var$isArray = Array.isArray;
var $36cc8c1055cfbf3b$export$2e2bcd8739ae039 = $36cc8c1055cfbf3b$var$isArray;
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/ function $2dbf41b550c5f478$var$isObjectLike(value) {
return value != null && typeof value == 'object';
}
var $2dbf41b550c5f478$export$2e2bcd8739ae039 = $2dbf41b550c5f478$var$isObjectLike;
/** `Object#toString` result references. */ var $90290c84737dbb50$var$stringTag = '[object String]';
/**
* Checks if `value` is classified as a `String` primitive or object.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a string, else `false`.
* @example
*
* _.isString('abc');
* // => true
*
* _.isString(1);
* // => false
*/ function $90290c84737dbb50$var$isString(value) {
return typeof value == 'string' || !(0, $36cc8c1055cfbf3b$export$2e2bcd8739ae039)(value) && (0, $2dbf41b550c5f478$export$2e2bcd8739ae039)(value) && (0, $6911cdf7f985d482$export$2e2bcd8739ae039)(value) == $90290c84737dbb50$var$stringTag;
}
var $90290c84737dbb50$export$2e2bcd8739ae039 = $90290c84737dbb50$var$isString;
function $22e282633cad8f97$export$7f7cffd29bf2d96d(authFlags, permission) {
if (authFlags > 0) return false;
let flags = BigInt.asUintN(64, BigInt(authFlags));
switch(permission){
case 'authorise':
return (0, $l50U0$libnexats.GroupToken).allowsRenew(flags);
case 'mint':
return (0, $l50U0$libnexats.GroupToken).allowsMint(flags);
case 'melt':
return (0, $l50U0$libnexats.GroupToken).allowsMelt(flags);
case 'rescript':
return (0, $l50U0$libnexats.GroupToken).allowsRescript(flags);
case 'subgroup':
return (0, $l50U0$libnexats.GroupToken).allowsSubgroup(flags);
default:
return false;
}
}
function $22e282633cad8f97$export$636fb0b03b94ac81(authFlags, withSubgroup = true) {
if (authFlags > 0) retur