nexa-wallet-sdk 0.5.2 → 0.5.4
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.
- package/dist/index.cjs +21 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +21 -49
- package/dist/index.mjs.map +1 -1
- package/dist/index.web.mjs +21 -49
- package/dist/index.web.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -149,7 +149,7 @@ $parcel$export(module.exports, "SighashType", () => $l50U0$libnexats.SighashType
|
|
|
149
149
|
$parcel$export(module.exports, "AccountKeysUtils", () => $4d68f29c39c1a3e4$export$94f569bf4eb0f6f6);
|
|
150
150
|
// @ts-ignore
|
|
151
151
|
var $2dd241e44b9dc3c2$exports = {};
|
|
152
|
-
$2dd241e44b9dc3c2$exports = JSON.parse("{\"name\":\"nexa-wallet-sdk\",\"version\":\"0.5.
|
|
152
|
+
$2dd241e44b9dc3c2$exports = JSON.parse("{\"name\":\"nexa-wallet-sdk\",\"version\":\"0.5.4\",\"type\":\"module\",\"source\":\"src/index.ts\",\"types\":\"dist/index.d.ts\",\"main\":\"dist/index.cjs\",\"module\":\"dist/index.mjs\",\"browser\":\"dist/index.web.mjs\",\"exports\":{\"types\":\"./dist/index.d.ts\",\"node\":{\"import\":\"./dist/index.mjs\",\"require\":\"./dist/index.cjs\"},\"browser\":\"./dist/index.web.mjs\",\"default\":\"./dist/index.mjs\"},\"scripts\":{\"build\":\"parcel build\",\"lint\":\"eslint .\",\"fix-lint\":\"eslint --fix .\",\"dev\":\"parcel watch\",\"test\":\"vitest run\",\"clean\":\"rm -rf dist .parcel-cache\",\"docs\":\"typedoc\",\"docs:serve\":\"typedoc && npx serve docs -l 8080\",\"docs:mkdocs\":\"typedoc && mkdocs serve\",\"docs:build\":\"typedoc && mkdocs build\",\"docs:setup\":\"./scripts/setup-docs.sh\",\"wallet-cli\":\"node examples/wallet-cli.cjs\"},\"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\",\"eslint\":\"^9.20.1\",\"parcel\":\"^2.15.4\",\"typedoc\":\"^0.28.7\",\"typedoc-plugin-markdown\":\"^4.7.0\",\"typedoc-plugin-rename-defaults\":\"^0.7.3\",\"typescript\":\"^5.8.3\",\"typescript-eslint\":\"^8.24.1\",\"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\",\"prompt-sync\":\"^4.2.0\",\"wallet-comms-sdk\":\"^0.6.1\"},\"files\":[\"dist\"],\"directories\":{\"test\":\"tests\"},\"@parcel/resolver-default\":{\"packageExports\":true}}");
|
|
153
153
|
|
|
154
154
|
|
|
155
155
|
|
|
@@ -1431,7 +1431,7 @@ class $4d68f29c39c1a3e4$export$94f569bf4eb0f6f6 {
|
|
|
1431
1431
|
|
|
1432
1432
|
|
|
1433
1433
|
/** Maximum number of inputs/outputs allowed in a single transaction */ const $b4a043612f1c4089$var$MAX_INPUTS_OUTPUTS = 250;
|
|
1434
|
-
async function $b4a043612f1c4089$export$afd979971a55acfc(txBuilder, keys, totalTxValue, options
|
|
1434
|
+
async function $b4a043612f1c4089$export$afd979971a55acfc(txBuilder, keys, totalTxValue, options) {
|
|
1435
1435
|
let rKeys = keys.receiveKeys.filter((k)=>BigInt(k.balance) > 0n);
|
|
1436
1436
|
let cKeys = keys.changeKeys.filter((k)=>BigInt(k.balance) > 0n);
|
|
1437
1437
|
let allKeys = rKeys.concat(cKeys);
|
|
@@ -1441,7 +1441,6 @@ async function $b4a043612f1c4089$export$afd979971a55acfc(txBuilder, keys, totalT
|
|
|
1441
1441
|
for (let key of allKeys){
|
|
1442
1442
|
let utxos = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getNexaUtxos(key.address);
|
|
1443
1443
|
for (let utxo of utxos){
|
|
1444
|
-
if (spentOutpoints && spentOutpoints.has(utxo.outpoint_hash)) continue;
|
|
1445
1444
|
let input = {
|
|
1446
1445
|
outpoint: utxo.outpoint_hash,
|
|
1447
1446
|
address: key.address,
|
|
@@ -1449,7 +1448,6 @@ async function $b4a043612f1c4089$export$afd979971a55acfc(txBuilder, keys, totalT
|
|
|
1449
1448
|
templateData: options.templateData
|
|
1450
1449
|
};
|
|
1451
1450
|
txBuilder.from(input);
|
|
1452
|
-
if (spentOutpoints) spentOutpoints.add(utxo.outpoint_hash);
|
|
1453
1451
|
if (!usedKeys.has(key.address)) usedKeys.set(key.address, key.key.privateKey);
|
|
1454
1452
|
if (options.isConsolidate) {
|
|
1455
1453
|
txBuilder.change(options.toChange ?? keys.receiveKeys[keys.receiveKeys.length - 1].address);
|
|
@@ -1493,7 +1491,7 @@ async function $b4a043612f1c4089$export$afd979971a55acfc(txBuilder, keys, totalT
|
|
|
1493
1491
|
};
|
|
1494
1492
|
throw new Error(JSON.stringify(err));
|
|
1495
1493
|
}
|
|
1496
|
-
async function $b4a043612f1c4089$export$931e37acdaa22dcf(txBuilder, keys, token, outTokenAmount
|
|
1494
|
+
async function $b4a043612f1c4089$export$931e37acdaa22dcf(txBuilder, keys, token, outTokenAmount) {
|
|
1497
1495
|
let allKeys = keys.receiveKeys.concat(keys.changeKeys);
|
|
1498
1496
|
if ((0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(allKeys)) throw new Error("Not enough token balance.");
|
|
1499
1497
|
let usedKeys = new Map();
|
|
@@ -1502,7 +1500,6 @@ async function $b4a043612f1c4089$export$931e37acdaa22dcf(txBuilder, keys, token,
|
|
|
1502
1500
|
let utxos = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getTokenUtxos(key.address, token);
|
|
1503
1501
|
for (let utxo of utxos){
|
|
1504
1502
|
if (utxo.token_amount < 0) continue;
|
|
1505
|
-
if (spentOutpoints && spentOutpoints.has(utxo.outpoint_hash)) continue;
|
|
1506
1503
|
txBuilder.from({
|
|
1507
1504
|
outpoint: utxo.outpoint_hash,
|
|
1508
1505
|
address: key.address,
|
|
@@ -1510,7 +1507,6 @@ async function $b4a043612f1c4089$export$931e37acdaa22dcf(txBuilder, keys, token,
|
|
|
1510
1507
|
groupId: utxo.group,
|
|
1511
1508
|
groupAmount: BigInt(utxo.token_amount)
|
|
1512
1509
|
});
|
|
1513
|
-
if (spentOutpoints) spentOutpoints.add(utxo.outpoint_hash);
|
|
1514
1510
|
inTokenAmount = inTokenAmount + BigInt(utxo.token_amount);
|
|
1515
1511
|
if (!usedKeys.has(key.address)) usedKeys.set(key.address, key.key.privateKey);
|
|
1516
1512
|
if (inTokenAmount > (0, $bc5ca2c06b1affa3$export$8ba128bc85947a2a)) throw new Error("Token inputs exceeded max amount. Consider sending in small chunks");
|
|
@@ -1636,7 +1632,7 @@ async function $b4a043612f1c4089$export$fc6e64edb1452fc7(txBuilder, keys, token,
|
|
|
1636
1632
|
if (!mintAuthorityFound) throw new Error(`Mint authority not found for token ${authTokenId}`);
|
|
1637
1633
|
return privateKeys;
|
|
1638
1634
|
}
|
|
1639
|
-
async function $b4a043612f1c4089$export$661377a8795b235c(txBuilder, keys, token, amount, parentToken
|
|
1635
|
+
async function $b4a043612f1c4089$export$661377a8795b235c(txBuilder, keys, token, amount, parentToken) {
|
|
1640
1636
|
const privateKeys = [];
|
|
1641
1637
|
const allKeys = (0, $4d68f29c39c1a3e4$export$94f569bf4eb0f6f6).getAllKeys(keys);
|
|
1642
1638
|
const authTokenId = parentToken || token;
|
|
@@ -1647,19 +1643,16 @@ async function $b4a043612f1c4089$export$661377a8795b235c(txBuilder, keys, token,
|
|
|
1647
1643
|
let authUtxos = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getTokenUtxos(key.address, authTokenId);
|
|
1648
1644
|
for (let utxo of authUtxos){
|
|
1649
1645
|
if (!(0, $22e282633cad8f97$export$7f7cffd29bf2d96d)(utxo.token_amount, 'melt')) continue;
|
|
1650
|
-
// Skip if already spent
|
|
1651
|
-
if (spentOutpoints && spentOutpoints.has(utxo.outpoint_hash)) continue;
|
|
1652
1646
|
// Add melt authority as input
|
|
1653
1647
|
txBuilder.from({
|
|
1654
1648
|
outpoint: utxo.outpoint_hash,
|
|
1655
1649
|
address: key.address,
|
|
1656
1650
|
satoshis: utxo.value
|
|
1657
1651
|
});
|
|
1658
|
-
if (spentOutpoints) spentOutpoints.add(utxo.outpoint_hash);
|
|
1659
1652
|
// Preserve the melt authority for future use
|
|
1660
1653
|
if ((0, $l50U0$libnexats.GroupToken).allowsRenew(BigInt.asUintN(64, BigInt(utxo.token_amount)))) {
|
|
1661
1654
|
const authChangeAddress = keys.changeKeys.length > 0 ? keys.changeKeys[keys.changeKeys.length - 1].address : keys.receiveKeys[keys.receiveKeys.length - 1].address;
|
|
1662
|
-
txBuilder.to(authChangeAddress, (0, $l50U0$libnexats.Transaction).DUST_AMOUNT,
|
|
1655
|
+
txBuilder.to(authChangeAddress, (0, $l50U0$libnexats.Transaction).DUST_AMOUNT, authTokenId, (0, $22e282633cad8f97$export$636fb0b03b94ac81)(utxo.token_amount));
|
|
1663
1656
|
}
|
|
1664
1657
|
privateKeys.push(key.key.privateKey);
|
|
1665
1658
|
meltAuthorityFound = true;
|
|
@@ -1674,8 +1667,6 @@ async function $b4a043612f1c4089$export$661377a8795b235c(txBuilder, keys, token,
|
|
|
1674
1667
|
for (let utxo of utxos){
|
|
1675
1668
|
// Skip authorities (negative amounts)
|
|
1676
1669
|
if (utxo.token_amount < 0) continue;
|
|
1677
|
-
// Skip if already spent
|
|
1678
|
-
if (spentOutpoints && spentOutpoints.has(utxo.outpoint_hash)) continue;
|
|
1679
1670
|
// Add token UTXO as input
|
|
1680
1671
|
txBuilder.from({
|
|
1681
1672
|
outpoint: utxo.outpoint_hash,
|
|
@@ -1684,7 +1675,6 @@ async function $b4a043612f1c4089$export$661377a8795b235c(txBuilder, keys, token,
|
|
|
1684
1675
|
groupId: utxo.group,
|
|
1685
1676
|
groupAmount: BigInt(utxo.token_amount)
|
|
1686
1677
|
});
|
|
1687
|
-
if (spentOutpoints) spentOutpoints.add(utxo.outpoint_hash);
|
|
1688
1678
|
inTokenAmount += BigInt(utxo.token_amount);
|
|
1689
1679
|
if (!privateKeys.includes(key.key.privateKey)) privateKeys.push(key.key.privateKey);
|
|
1690
1680
|
// Check if we have enough tokens to melt
|
|
@@ -1700,7 +1690,7 @@ async function $b4a043612f1c4089$export$661377a8795b235c(txBuilder, keys, token,
|
|
|
1700
1690
|
}
|
|
1701
1691
|
throw new Error(`Not enough token balance to melt. Required: ${amount}, Available: ${inTokenAmount}`);
|
|
1702
1692
|
}
|
|
1703
|
-
async function $b4a043612f1c4089$export$28a843ca046a6b3f(txBuilder, keys, token, perms, toAddr
|
|
1693
|
+
async function $b4a043612f1c4089$export$28a843ca046a6b3f(txBuilder, keys, token, perms, toAddr) {
|
|
1704
1694
|
let allKeys = (0, $4d68f29c39c1a3e4$export$94f569bf4eb0f6f6).getAllKeys(keys);
|
|
1705
1695
|
let usedKeys = [];
|
|
1706
1696
|
let reqiredPerms = new Set(perms);
|
|
@@ -1709,7 +1699,6 @@ async function $b4a043612f1c4089$export$28a843ca046a6b3f(txBuilder, keys, token,
|
|
|
1709
1699
|
let utxos = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getTokenUtxos(key.address, token);
|
|
1710
1700
|
for (let utxo of utxos){
|
|
1711
1701
|
if (utxo.token_amount > 0) continue;
|
|
1712
|
-
if (spentOutpoints && spentOutpoints.has(utxo.outpoint_hash)) continue;
|
|
1713
1702
|
let found = false;
|
|
1714
1703
|
for (let perm of reqiredPerms)if ((0, $22e282633cad8f97$export$7f7cffd29bf2d96d)(utxo.token_amount, perm)) {
|
|
1715
1704
|
reqiredPerms.delete(perm);
|
|
@@ -1722,7 +1711,6 @@ async function $b4a043612f1c4089$export$28a843ca046a6b3f(txBuilder, keys, token,
|
|
|
1722
1711
|
satoshis: utxo.value
|
|
1723
1712
|
});
|
|
1724
1713
|
usedKeys.push(key.key.privateKey);
|
|
1725
|
-
if (spentOutpoints) spentOutpoints.add(utxo.outpoint_hash);
|
|
1726
1714
|
// duplicate
|
|
1727
1715
|
const duplicateAddress = toAddr != null ? toAddr : keys.changeKeys.length > 0 ? keys.changeKeys[keys.changeKeys.length - 1].address : keys.receiveKeys[keys.receiveKeys.length - 1].address;
|
|
1728
1716
|
txBuilder.to(duplicateAddress, (0, $l50U0$libnexats.Transaction).DUST_AMOUNT, token, (0, $22e282633cad8f97$export$636fb0b03b94ac81)(utxo.token_amount));
|
|
@@ -2397,15 +2385,15 @@ class $e1896e59040fa3c5$export$2e2bcd8739ae039 extends (0, $57b0117fe8233fef$exp
|
|
|
2397
2385
|
let nK = [];
|
|
2398
2386
|
if (this.tokens.size > 0) for (const tokenAction of this.tokens){
|
|
2399
2387
|
if (tokenAction.action == 'mint') tK = tK.concat(await (0, $b4a043612f1c4089$export$fc6e64edb1452fc7)(this.transactionBuilder, this._account.accountKeys, tokenAction.token, tokenAction.amount, tokenAction.parentToken, this.spentOutpoints));
|
|
2400
|
-
else if (tokenAction.action == 'melt') tK = tK.concat(await (0, $b4a043612f1c4089$export$661377a8795b235c)(this.transactionBuilder, this._account.accountKeys, tokenAction.token, tokenAction.amount, tokenAction.parentToken
|
|
2388
|
+
else if (tokenAction.action == 'melt') tK = tK.concat(await (0, $b4a043612f1c4089$export$661377a8795b235c)(this.transactionBuilder, this._account.accountKeys, tokenAction.token, tokenAction.amount, tokenAction.parentToken));
|
|
2401
2389
|
else if (tokenAction.action == 'group') tK = tK.concat(await (0, $b4a043612f1c4089$export$d7f2b844e1d59768)(this.transactionBuilder, this._account.accountKeys, tokenAction.extraData?.opReturnData, this.network, this.spentOutpoints));
|
|
2402
2390
|
else if (tokenAction.action == 'subgroup') tK = tK.concat(await (0, $b4a043612f1c4089$export$1dfa5d829fc95097)(this.transactionBuilder, this._account.accountKeys, tokenAction.parentToken, 'subgroup', tokenAction.token, this._account.accountKeys.receiveKeys.at(-1).address, tokenAction.extraData?.quantity, this.spentOutpoints));
|
|
2403
|
-
else if (tokenAction.action == 'renew') tK = tK.concat(await (0, $b4a043612f1c4089$export$28a843ca046a6b3f)(this.transactionBuilder, this._account.accountKeys, tokenAction.token, tokenAction.extraData.perms, tokenAction.extraData.address
|
|
2391
|
+
else if (tokenAction.action == 'renew') tK = tK.concat(await (0, $b4a043612f1c4089$export$28a843ca046a6b3f)(this.transactionBuilder, this._account.accountKeys, tokenAction.token, tokenAction.extraData.perms, tokenAction.extraData.address));
|
|
2404
2392
|
else if (tokenAction.action == 'delete') tK = tK.concat(await (0, $b4a043612f1c4089$export$48a48877d6df17e9)(this.transactionBuilder, this._account.accountKeys, tokenAction.extraData.outpoint));
|
|
2405
|
-
else tK = tK.concat(await (0, $b4a043612f1c4089$export$931e37acdaa22dcf)(this.transactionBuilder, this._account.accountKeys, tokenAction.token, tokenAction.amount
|
|
2393
|
+
else tK = tK.concat(await (0, $b4a043612f1c4089$export$931e37acdaa22dcf)(this.transactionBuilder, this._account.accountKeys, tokenAction.token, tokenAction.amount));
|
|
2406
2394
|
this._keysToSign.concat(tK);
|
|
2407
2395
|
}
|
|
2408
|
-
nK = nK.concat(await (0, $b4a043612f1c4089$export$afd979971a55acfc)(this.transactionBuilder, this._account.accountKeys, this.totalValue, this.txOptions
|
|
2396
|
+
nK = nK.concat(await (0, $b4a043612f1c4089$export$afd979971a55acfc)(this.transactionBuilder, this._account.accountKeys, this.totalValue, this.txOptions));
|
|
2409
2397
|
this._keysToSign = tK.concat(nK);
|
|
2410
2398
|
});
|
|
2411
2399
|
return this;
|
|
@@ -3344,15 +3332,13 @@ class $b76d3bd5024ccfc0$export$2e2bcd8739ae039 {
|
|
|
3344
3332
|
|
|
3345
3333
|
|
|
3346
3334
|
const $52632971edbdb934$var$MAX_INPUTS_OUTPUTS = 250;
|
|
3347
|
-
async function $52632971edbdb934$export$20e004915450ed44(txBuilder, addresses, totalTxValue, options
|
|
3335
|
+
async function $52632971edbdb934$export$20e004915450ed44(txBuilder, addresses, totalTxValue, options) {
|
|
3348
3336
|
if ((0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(addresses)) throw new Error("Not enough Nexa balance.");
|
|
3349
3337
|
let usedAddresses = new Set();
|
|
3350
3338
|
let origAmount = options.isConsolidate ? 0 : Number(totalTxValue);
|
|
3351
3339
|
for (let item of addresses){
|
|
3352
3340
|
let utxos = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getNexaUtxos(item.address);
|
|
3353
3341
|
for (let utxo of utxos){
|
|
3354
|
-
// Skip if this outpoint is already spent
|
|
3355
|
-
if (spentOutpoints && spentOutpoints.has(utxo.outpoint_hash)) continue;
|
|
3356
3342
|
let input = {
|
|
3357
3343
|
outpoint: utxo.outpoint_hash,
|
|
3358
3344
|
address: item.address,
|
|
@@ -3360,8 +3346,6 @@ async function $52632971edbdb934$export$20e004915450ed44(txBuilder, addresses, t
|
|
|
3360
3346
|
templateData: options.templateData
|
|
3361
3347
|
};
|
|
3362
3348
|
txBuilder.from(input);
|
|
3363
|
-
// Add to spent outpoints set
|
|
3364
|
-
if (spentOutpoints) spentOutpoints.add(utxo.outpoint_hash);
|
|
3365
3349
|
if (!usedAddresses.has(item.address)) usedAddresses.add(item.address);
|
|
3366
3350
|
if (options.isConsolidate) {
|
|
3367
3351
|
// need to handle change
|
|
@@ -3405,7 +3389,7 @@ async function $52632971edbdb934$export$20e004915450ed44(txBuilder, addresses, t
|
|
|
3405
3389
|
};
|
|
3406
3390
|
throw new Error(JSON.stringify(err));
|
|
3407
3391
|
}
|
|
3408
|
-
async function $52632971edbdb934$export$49bc96b87058cba4(txBuilder, addresses, token, outTokenAmount
|
|
3392
|
+
async function $52632971edbdb934$export$49bc96b87058cba4(txBuilder, addresses, token, outTokenAmount) {
|
|
3409
3393
|
if ((0, $bc5ca2c06b1affa3$export$c8733ae29fb53302)(addresses)) throw new Error("Not enough token balance.");
|
|
3410
3394
|
let usedKeys = new Set();
|
|
3411
3395
|
let inTokenAmount = 0n;
|
|
@@ -3413,8 +3397,6 @@ async function $52632971edbdb934$export$49bc96b87058cba4(txBuilder, addresses, t
|
|
|
3413
3397
|
let utxos = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getTokenUtxos(item.address, token);
|
|
3414
3398
|
for (let utxo of utxos){
|
|
3415
3399
|
if (utxo.token_amount < 0) continue;
|
|
3416
|
-
// Skip if this outpoint is already spent
|
|
3417
|
-
if (spentOutpoints && spentOutpoints.has(utxo.outpoint_hash)) continue;
|
|
3418
3400
|
txBuilder.from({
|
|
3419
3401
|
outpoint: utxo.outpoint_hash,
|
|
3420
3402
|
address: item.address,
|
|
@@ -3422,8 +3404,6 @@ async function $52632971edbdb934$export$49bc96b87058cba4(txBuilder, addresses, t
|
|
|
3422
3404
|
groupId: utxo.group,
|
|
3423
3405
|
groupAmount: BigInt(utxo.token_amount)
|
|
3424
3406
|
});
|
|
3425
|
-
// Add to spent outpoints set
|
|
3426
|
-
if (spentOutpoints) spentOutpoints.add(utxo.outpoint_hash);
|
|
3427
3407
|
inTokenAmount = inTokenAmount + BigInt(utxo.token_amount);
|
|
3428
3408
|
if (!usedKeys.has(item.address)) usedKeys.add(item.address);
|
|
3429
3409
|
if (inTokenAmount > (0, $bc5ca2c06b1affa3$export$8ba128bc85947a2a)) throw new Error("Token inputs exceeded max amount. Consider sending in small chunks");
|
|
@@ -3538,7 +3518,7 @@ async function $52632971edbdb934$export$91f9f23df90683cc(txBuilder, addresses, t
|
|
|
3538
3518
|
if (!mintAuthorityFound) throw new Error(`Mint authority not found for token ${authTokenId}`);
|
|
3539
3519
|
return usedAddresses;
|
|
3540
3520
|
}
|
|
3541
|
-
async function $52632971edbdb934$export$cfda880a425a2203(txBuilder, addresses, token, amount, parentToken
|
|
3521
|
+
async function $52632971edbdb934$export$cfda880a425a2203(txBuilder, addresses, token, amount, parentToken) {
|
|
3542
3522
|
const usedAddresses = [];
|
|
3543
3523
|
// Determine which token to look for melt authority
|
|
3544
3524
|
const authTokenId = parentToken || token;
|
|
@@ -3549,15 +3529,14 @@ async function $52632971edbdb934$export$cfda880a425a2203(txBuilder, addresses, t
|
|
|
3549
3529
|
let authUtxos = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getTokenUtxos(item.address, authTokenId);
|
|
3550
3530
|
for (let utxo of authUtxos){
|
|
3551
3531
|
if (!(0, $22e282633cad8f97$export$7f7cffd29bf2d96d)(utxo.token_amount, 'melt')) continue;
|
|
3552
|
-
// Skip if already spent
|
|
3553
|
-
if (spentOutpoints && spentOutpoints.has(utxo.outpoint_hash)) continue;
|
|
3554
3532
|
// Add melt authority as input
|
|
3555
3533
|
txBuilder.from({
|
|
3556
3534
|
outpoint: utxo.outpoint_hash,
|
|
3557
3535
|
address: item.address,
|
|
3558
3536
|
satoshis: utxo.value
|
|
3559
3537
|
});
|
|
3560
|
-
if
|
|
3538
|
+
// Preserve the melt authority for future use if renewable
|
|
3539
|
+
if ((0, $l50U0$libnexats.GroupToken).allowsRenew(BigInt.asUintN(64, BigInt(utxo.token_amount)))) txBuilder.to(item.address, (0, $l50U0$libnexats.Transaction).DUST_AMOUNT, authTokenId, (0, $22e282633cad8f97$export$636fb0b03b94ac81)(utxo.token_amount));
|
|
3561
3540
|
usedAddresses.push(item.address);
|
|
3562
3541
|
meltAuthorityFound = true;
|
|
3563
3542
|
break;
|
|
@@ -3571,8 +3550,6 @@ async function $52632971edbdb934$export$cfda880a425a2203(txBuilder, addresses, t
|
|
|
3571
3550
|
for (let utxo of utxos){
|
|
3572
3551
|
// Skip authorities (negative amounts)
|
|
3573
3552
|
if (utxo.token_amount < 0) continue;
|
|
3574
|
-
// Skip if already spent
|
|
3575
|
-
if (spentOutpoints && spentOutpoints.has(utxo.outpoint_hash)) continue;
|
|
3576
3553
|
// Add token UTXO as input
|
|
3577
3554
|
txBuilder.from({
|
|
3578
3555
|
outpoint: utxo.outpoint_hash,
|
|
@@ -3581,7 +3558,6 @@ async function $52632971edbdb934$export$cfda880a425a2203(txBuilder, addresses, t
|
|
|
3581
3558
|
groupId: utxo.group,
|
|
3582
3559
|
groupAmount: BigInt(utxo.token_amount)
|
|
3583
3560
|
});
|
|
3584
|
-
if (spentOutpoints) spentOutpoints.add(utxo.outpoint_hash);
|
|
3585
3561
|
inTokenAmount += BigInt(utxo.token_amount);
|
|
3586
3562
|
if (!usedAddresses.includes(item.address)) usedAddresses.push(item.address);
|
|
3587
3563
|
// Check if we have enough tokens to melt
|
|
@@ -3594,7 +3570,7 @@ async function $52632971edbdb934$export$cfda880a425a2203(txBuilder, addresses, t
|
|
|
3594
3570
|
}
|
|
3595
3571
|
throw new Error(`Not enough token balance to melt. Required: ${amount}, Available: ${inTokenAmount}`);
|
|
3596
3572
|
}
|
|
3597
|
-
async function $52632971edbdb934$export$5c44e04d8c04c292(txBuilder, addresses, token, perms, toAddr
|
|
3573
|
+
async function $52632971edbdb934$export$5c44e04d8c04c292(txBuilder, addresses, token, perms, toAddr) {
|
|
3598
3574
|
let usedAddresses = [];
|
|
3599
3575
|
let reqiredPerms = new Set(perms);
|
|
3600
3576
|
reqiredPerms.add('authorise');
|
|
@@ -3602,8 +3578,6 @@ async function $52632971edbdb934$export$5c44e04d8c04c292(txBuilder, addresses, t
|
|
|
3602
3578
|
let utxos = await (0, $b5bfd17fdf06d231$export$eaa49f0478d81b9d).getTokenUtxos(item.address, token);
|
|
3603
3579
|
for (let utxo of utxos){
|
|
3604
3580
|
if (utxo.token_amount > 0) continue;
|
|
3605
|
-
// Skip if this outpoint is already spent
|
|
3606
|
-
if (spentOutpoints && spentOutpoints.has(utxo.outpoint_hash)) continue;
|
|
3607
3581
|
let found = false;
|
|
3608
3582
|
for (let perm of reqiredPerms)if ((0, $22e282633cad8f97$export$7f7cffd29bf2d96d)(utxo.token_amount, perm)) {
|
|
3609
3583
|
reqiredPerms.delete(perm);
|
|
@@ -3616,8 +3590,6 @@ async function $52632971edbdb934$export$5c44e04d8c04c292(txBuilder, addresses, t
|
|
|
3616
3590
|
satoshis: utxo.value
|
|
3617
3591
|
});
|
|
3618
3592
|
usedAddresses.push(item.address);
|
|
3619
|
-
// Add to spent outpoints set
|
|
3620
|
-
if (spentOutpoints) spentOutpoints.add(utxo.outpoint_hash);
|
|
3621
3593
|
// duplicate
|
|
3622
3594
|
txBuilder.to(toAddr != null ? toAddr : item.address, (0, $l50U0$libnexats.Transaction).DUST_AMOUNT, token, (0, $22e282633cad8f97$export$636fb0b03b94ac81)(utxo.token_amount));
|
|
3623
3595
|
if (reqiredPerms.size === 0) return usedAddresses;
|
|
@@ -3679,7 +3651,7 @@ class $2ce5b75d10954bb1$export$2e2bcd8739ae039 extends (0, $57b0117fe8233fef$exp
|
|
|
3679
3651
|
* Adds a token melting operation to the transaction
|
|
3680
3652
|
* @param token Token ID to melt
|
|
3681
3653
|
* @param amount Amount to melt
|
|
3682
|
-
* @param toAddr Destination address for melted tokens
|
|
3654
|
+
* @param toAddr Destination address for change of melted tokens
|
|
3683
3655
|
* @param parent Optional parent token ID (for NFT/SFT melting)
|
|
3684
3656
|
* @returns This instance for chaining
|
|
3685
3657
|
*/ melt(token, amount, toAddr, parent) {
|
|
@@ -3702,22 +3674,22 @@ class $2ce5b75d10954bb1$export$2e2bcd8739ae039 extends (0, $57b0117fe8233fef$exp
|
|
|
3702
3674
|
if (tokenAction.action == 'mint') // Use specialized mint function for groups and subgroups
|
|
3703
3675
|
tokenAddresses = tokenAddresses.concat(await (0, $52632971edbdb934$export$91f9f23df90683cc)(this.transactionBuilder, this._availableAddresses, tokenAction.token, tokenAction.amount, tokenAction.parentToken, this.spentOutpoints));
|
|
3704
3676
|
else if (tokenAction.action == 'melt') // Use specialized melt function for groups and subgroups
|
|
3705
|
-
tokenAddresses = tokenAddresses.concat(await (0, $52632971edbdb934$export$cfda880a425a2203)(this.transactionBuilder, this._availableAddresses, tokenAction.token, tokenAction.amount, tokenAction.parentToken
|
|
3677
|
+
tokenAddresses = tokenAddresses.concat(await (0, $52632971edbdb934$export$cfda880a425a2203)(this.transactionBuilder, this._availableAddresses, tokenAction.token, tokenAction.amount, tokenAction.parentToken));
|
|
3706
3678
|
else if (tokenAction.action == 'group') // Handle group token creation
|
|
3707
3679
|
tokenAddresses = tokenAddresses.concat(await (0, $52632971edbdb934$export$74e83de914f372c5)(this.transactionBuilder, this._availableAddresses, tokenAction.extraData?.opReturnData, this.network, this.spentOutpoints));
|
|
3708
3680
|
else if (tokenAction.action == 'subgroup') // Handle subgroup token creation
|
|
3709
3681
|
tokenAddresses = tokenAddresses.concat(await (0, $52632971edbdb934$export$d7c9c386067a6463)(this.transactionBuilder, this._availableAddresses, tokenAction.parentToken, tokenAction.action, tokenAction.token, this._availableAddresses[0]?.address, tokenAction.extraData?.quantity, this.spentOutpoints));
|
|
3710
3682
|
else if (tokenAction.action == 'renew') // Handle authority renewal
|
|
3711
|
-
tokenAddresses = tokenAddresses.concat(await (0, $52632971edbdb934$export$5c44e04d8c04c292)(this.transactionBuilder, this._availableAddresses, tokenAction.token, tokenAction.extraData.perms, tokenAction.extraData?.address
|
|
3683
|
+
tokenAddresses = tokenAddresses.concat(await (0, $52632971edbdb934$export$5c44e04d8c04c292)(this.transactionBuilder, this._availableAddresses, tokenAction.token, tokenAction.extraData.perms, tokenAction.extraData?.address));
|
|
3712
3684
|
else if (tokenAction.action == 'delete') // Handle authority deletion
|
|
3713
3685
|
tokenAddresses = tokenAddresses.concat(await (0, $52632971edbdb934$export$1eb54f2f084fd3c6)(this.transactionBuilder, this._availableAddresses, tokenAction.extraData.outpoint));
|
|
3714
3686
|
else // Handle regular token transfers
|
|
3715
|
-
tokenAddresses = tokenAddresses.concat(await (0, $52632971edbdb934$export$49bc96b87058cba4)(this.transactionBuilder, this._availableAddresses, tokenAction.token, tokenAction.amount
|
|
3687
|
+
tokenAddresses = tokenAddresses.concat(await (0, $52632971edbdb934$export$49bc96b87058cba4)(this.transactionBuilder, this._availableAddresses, tokenAction.token, tokenAction.amount));
|
|
3716
3688
|
// Accumulate addresses that need signing
|
|
3717
3689
|
this._addressesToSignWith.concat(tokenAddresses);
|
|
3718
3690
|
}
|
|
3719
3691
|
// Populate NEXA inputs for transaction fees and change
|
|
3720
|
-
nexaAddresses = nexaAddresses.concat(await (0, $52632971edbdb934$export$20e004915450ed44)(this.transactionBuilder, this._availableAddresses, this.totalValue, this.txOptions
|
|
3692
|
+
nexaAddresses = nexaAddresses.concat(await (0, $52632971edbdb934$export$20e004915450ed44)(this.transactionBuilder, this._availableAddresses, this.totalValue, this.txOptions));
|
|
3721
3693
|
// Combine all addresses that need signing
|
|
3722
3694
|
this._addressesToSignWith = tokenAddresses.concat(nexaAddresses);
|
|
3723
3695
|
});
|