@pioneer-platform/pioneer-sdk 4.20.0 → 4.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +593 -445
- package/dist/index.es.js +594 -445
- package/dist/index.js +594 -445
- package/package.json +2 -2
- package/src/TransactionManager.ts +21 -4
- package/src/fees/index.ts +60 -57
- package/src/fees/index.ts.backup +510 -0
- package/src/getPubkey.ts +57 -26
- package/src/index.ts +391 -61
- package/src/txbuilder/createUnsignedEvmTx.ts +118 -63
- package/src/txbuilder/createUnsignedRippleTx.ts +12 -11
- package/src/txbuilder/createUnsignedStakingTx.ts +13 -11
- package/src/txbuilder/createUnsignedTendermintTx.ts +41 -17
- package/src/txbuilder/createUnsignedUxtoTx.ts +122 -57
- package/src/txbuilder/createUnsignedUxtoTx.ts.backup +384 -0
- package/src/txbuilder/templates/mayachain.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -488,49 +488,6 @@ var require_utils = __commonJS((exports, module) => {
|
|
|
488
488
|
};
|
|
489
489
|
});
|
|
490
490
|
|
|
491
|
-
// ../../../node_modules/coinselect/split.js
|
|
492
|
-
var require_split = __commonJS((exports, module) => {
|
|
493
|
-
var utils = require_utils();
|
|
494
|
-
module.exports = function split(utxos, outputs, feeRate) {
|
|
495
|
-
if (!isFinite(utils.uintOrNaN(feeRate)))
|
|
496
|
-
return {};
|
|
497
|
-
var bytesAccum = utils.transactionBytes(utxos, outputs);
|
|
498
|
-
var fee = feeRate * bytesAccum;
|
|
499
|
-
if (outputs.length === 0)
|
|
500
|
-
return { fee };
|
|
501
|
-
var inAccum = utils.sumOrNaN(utxos);
|
|
502
|
-
var outAccum = utils.sumForgiving(outputs);
|
|
503
|
-
var remaining = inAccum - outAccum - fee;
|
|
504
|
-
if (!isFinite(remaining) || remaining < 0)
|
|
505
|
-
return { fee };
|
|
506
|
-
var unspecified = outputs.reduce(function(a2, x2) {
|
|
507
|
-
return a2 + !isFinite(x2.value);
|
|
508
|
-
}, 0);
|
|
509
|
-
if (remaining === 0 && unspecified === 0)
|
|
510
|
-
return utils.finalize(utxos, outputs, feeRate);
|
|
511
|
-
var splitOutputsCount = outputs.reduce(function(a2, x2) {
|
|
512
|
-
if (x2.value !== undefined)
|
|
513
|
-
return a2;
|
|
514
|
-
return a2 + 1;
|
|
515
|
-
}, 0);
|
|
516
|
-
var splitValue = Math.floor(remaining / splitOutputsCount);
|
|
517
|
-
if (!outputs.every(function(x2) {
|
|
518
|
-
return x2.value !== undefined || splitValue > utils.dustThreshold(x2, feeRate);
|
|
519
|
-
}))
|
|
520
|
-
return { fee };
|
|
521
|
-
outputs = outputs.map(function(x2) {
|
|
522
|
-
if (x2.value !== undefined)
|
|
523
|
-
return x2;
|
|
524
|
-
var y2 = {};
|
|
525
|
-
for (var k in x2)
|
|
526
|
-
y2[k] = x2[k];
|
|
527
|
-
y2.value = splitValue;
|
|
528
|
-
return y2;
|
|
529
|
-
});
|
|
530
|
-
return utils.finalize(utxos, outputs, feeRate);
|
|
531
|
-
};
|
|
532
|
-
});
|
|
533
|
-
|
|
534
491
|
// ../../../node_modules/coinselect/accumulative.js
|
|
535
492
|
var require_accumulative = __commonJS((exports, module) => {
|
|
536
493
|
var utils = require_utils();
|
|
@@ -611,10 +568,53 @@ var require_coinselect = __commonJS((exports, module) => {
|
|
|
611
568
|
};
|
|
612
569
|
});
|
|
613
570
|
|
|
571
|
+
// ../../../node_modules/coinselect/split.js
|
|
572
|
+
var require_split = __commonJS((exports, module) => {
|
|
573
|
+
var utils = require_utils();
|
|
574
|
+
module.exports = function split(utxos, outputs, feeRate) {
|
|
575
|
+
if (!isFinite(utils.uintOrNaN(feeRate)))
|
|
576
|
+
return {};
|
|
577
|
+
var bytesAccum = utils.transactionBytes(utxos, outputs);
|
|
578
|
+
var fee = feeRate * bytesAccum;
|
|
579
|
+
if (outputs.length === 0)
|
|
580
|
+
return { fee };
|
|
581
|
+
var inAccum = utils.sumOrNaN(utxos);
|
|
582
|
+
var outAccum = utils.sumForgiving(outputs);
|
|
583
|
+
var remaining = inAccum - outAccum - fee;
|
|
584
|
+
if (!isFinite(remaining) || remaining < 0)
|
|
585
|
+
return { fee };
|
|
586
|
+
var unspecified = outputs.reduce(function(a2, x2) {
|
|
587
|
+
return a2 + !isFinite(x2.value);
|
|
588
|
+
}, 0);
|
|
589
|
+
if (remaining === 0 && unspecified === 0)
|
|
590
|
+
return utils.finalize(utxos, outputs, feeRate);
|
|
591
|
+
var splitOutputsCount = outputs.reduce(function(a2, x2) {
|
|
592
|
+
if (x2.value !== undefined)
|
|
593
|
+
return a2;
|
|
594
|
+
return a2 + 1;
|
|
595
|
+
}, 0);
|
|
596
|
+
var splitValue = Math.floor(remaining / splitOutputsCount);
|
|
597
|
+
if (!outputs.every(function(x2) {
|
|
598
|
+
return x2.value !== undefined || splitValue > utils.dustThreshold(x2, feeRate);
|
|
599
|
+
}))
|
|
600
|
+
return { fee };
|
|
601
|
+
outputs = outputs.map(function(x2) {
|
|
602
|
+
if (x2.value !== undefined)
|
|
603
|
+
return x2;
|
|
604
|
+
var y2 = {};
|
|
605
|
+
for (var k in x2)
|
|
606
|
+
y2[k] = x2[k];
|
|
607
|
+
y2.value = splitValue;
|
|
608
|
+
return y2;
|
|
609
|
+
});
|
|
610
|
+
return utils.finalize(utxos, outputs, feeRate);
|
|
611
|
+
};
|
|
612
|
+
});
|
|
613
|
+
|
|
614
614
|
// src/index.ts
|
|
615
615
|
var import_pioneer_client = __toESM(require_lib(), 1);
|
|
616
616
|
import { KeepKeySdk } from "@keepkey/keepkey-sdk";
|
|
617
|
-
import { caipToNetworkId as
|
|
617
|
+
import { caipToNetworkId as caipToNetworkId6, networkIdToCaip } from "@pioneer-platform/pioneer-caip";
|
|
618
618
|
import { addressNListToBIP32 as addressNListToBIP322, getPaths } from "@pioneer-platform/pioneer-coins";
|
|
619
619
|
import { assetData as assetData2 } from "@pioneer-platform/pioneer-discovery";
|
|
620
620
|
import { Events } from "@pioneer-platform/pioneer-events";
|
|
@@ -812,6 +812,7 @@ function R(t) {
|
|
|
812
812
|
e[n] = t[n].listener || t[n];
|
|
813
813
|
return e;
|
|
814
814
|
}
|
|
815
|
+
var A = o;
|
|
815
816
|
var P = o.prototype;
|
|
816
817
|
|
|
817
818
|
// src/charts/utils.ts
|
|
@@ -1405,42 +1406,31 @@ var getPubkey = async (networkId, path, sdk, context) => {
|
|
|
1405
1406
|
console.error("⏰ [PUBKEY] Address retrieval timeout for", networkId);
|
|
1406
1407
|
}, 30000);
|
|
1407
1408
|
try {
|
|
1408
|
-
let result;
|
|
1409
1409
|
switch (networkType) {
|
|
1410
1410
|
case "UTXO":
|
|
1411
|
-
|
|
1411
|
+
({ address } = await sdk.address.utxoGetAddress(addressInfo));
|
|
1412
1412
|
break;
|
|
1413
1413
|
case "EVM":
|
|
1414
|
-
|
|
1414
|
+
({ address } = await sdk.address.ethereumGetAddress(addressInfo));
|
|
1415
1415
|
break;
|
|
1416
1416
|
case "OSMOSIS":
|
|
1417
|
-
|
|
1417
|
+
({ address } = await sdk.address.osmosisGetAddress(addressInfo));
|
|
1418
1418
|
break;
|
|
1419
1419
|
case "COSMOS":
|
|
1420
|
-
|
|
1420
|
+
({ address } = await sdk.address.cosmosGetAddress(addressInfo));
|
|
1421
1421
|
break;
|
|
1422
1422
|
case "MAYACHAIN":
|
|
1423
|
-
|
|
1423
|
+
({ address } = await sdk.address.mayachainGetAddress(addressInfo));
|
|
1424
1424
|
break;
|
|
1425
1425
|
case "THORCHAIN":
|
|
1426
|
-
|
|
1426
|
+
({ address } = await sdk.address.thorchainGetAddress(addressInfo));
|
|
1427
1427
|
break;
|
|
1428
1428
|
case "XRP":
|
|
1429
|
-
|
|
1429
|
+
({ address } = await sdk.address.xrpGetAddress(addressInfo));
|
|
1430
1430
|
break;
|
|
1431
1431
|
default:
|
|
1432
1432
|
throw new Error(`Unsupported network type for networkId: ${networkId}`);
|
|
1433
1433
|
}
|
|
1434
|
-
if (!result) {
|
|
1435
|
-
throw new Error(`Address call returned null/undefined for ${networkType} (${networkId})`);
|
|
1436
|
-
}
|
|
1437
|
-
if (typeof result === "object" && result.address) {
|
|
1438
|
-
address = result.address;
|
|
1439
|
-
} else if (typeof result === "string") {
|
|
1440
|
-
address = result;
|
|
1441
|
-
} else {
|
|
1442
|
-
throw new Error(`Invalid address response format for ${networkType} (${networkId}): ${JSON.stringify(result)}`);
|
|
1443
|
-
}
|
|
1444
1434
|
clearTimeout(addressTimeout);
|
|
1445
1435
|
} catch (addressError) {
|
|
1446
1436
|
clearTimeout(addressTimeout);
|
|
@@ -1455,6 +1445,10 @@ var getPubkey = async (networkId, path, sdk, context) => {
|
|
|
1455
1445
|
pubkey.master = address;
|
|
1456
1446
|
pubkey.address = address;
|
|
1457
1447
|
if (["xpub", "ypub", "zpub"].includes(path.type)) {
|
|
1448
|
+
console.log("\uD83D\uDD11 [XPUB] Starting xpub retrieval for path type:", path.type);
|
|
1449
|
+
console.log("\uD83D\uDD11 [XPUB] Network:", networkId);
|
|
1450
|
+
console.log("\uD83D\uDD11 [XPUB] Path:", addressNListToBIP32(path.addressNList));
|
|
1451
|
+
console.log("\uD83D\uDD11 [XPUB] Script type:", path.script_type);
|
|
1458
1452
|
const pathQuery = {
|
|
1459
1453
|
symbol: "BTC",
|
|
1460
1454
|
coin: "Bitcoin",
|
|
@@ -1462,26 +1456,58 @@ var getPubkey = async (networkId, path, sdk, context) => {
|
|
|
1462
1456
|
address_n: path.addressNList,
|
|
1463
1457
|
showDisplay: false
|
|
1464
1458
|
};
|
|
1459
|
+
console.log("\uD83D\uDD11 [XPUB] Calling sdk.system.info.getPublicKey with:", JSON.stringify(pathQuery, null, 2));
|
|
1465
1460
|
const xpubTimeout = setTimeout(() => {
|
|
1466
|
-
console.error("getPublicKey timeout after 20 seconds");
|
|
1461
|
+
console.error("⏰ [XPUB TIMEOUT] getPublicKey timeout after 20 seconds");
|
|
1462
|
+
console.error("⏰ [XPUB TIMEOUT] Path:", addressNListToBIP32(path.addressNList));
|
|
1463
|
+
console.error("⏰ [XPUB TIMEOUT] This is a CRITICAL FAILURE - UTXO balances require xpubs");
|
|
1467
1464
|
}, 20000);
|
|
1468
1465
|
try {
|
|
1466
|
+
console.log("\uD83D\uDD11 [XPUB] Calling getPublicKey...");
|
|
1469
1467
|
const responsePubkey = await sdk.system.info.getPublicKey(pathQuery);
|
|
1470
1468
|
clearTimeout(xpubTimeout);
|
|
1469
|
+
console.log("✅ [XPUB] getPublicKey SUCCESS");
|
|
1470
|
+
console.log("✅ [XPUB] Response:", JSON.stringify(responsePubkey, null, 2));
|
|
1471
|
+
if (!responsePubkey || !responsePubkey.xpub) {
|
|
1472
|
+
const error = new Error("FAIL FAST: getPublicKey returned null or missing xpub");
|
|
1473
|
+
console.error("❌ [XPUB] CRITICAL:", error.message);
|
|
1474
|
+
console.error("❌ [XPUB] Response was:", responsePubkey);
|
|
1475
|
+
throw error;
|
|
1476
|
+
}
|
|
1471
1477
|
if (path.script_type === "p2wpkh") {
|
|
1478
|
+
console.log("\uD83D\uDD11 [XPUB] Converting xpub to zpub for native segwit");
|
|
1472
1479
|
responsePubkey.xpub = xpubConvert(responsePubkey.xpub, "zpub");
|
|
1473
1480
|
} else if (path.script_type === "p2sh-p2wpkh") {
|
|
1481
|
+
console.log("\uD83D\uDD11 [XPUB] Converting xpub to ypub for wrapped segwit");
|
|
1474
1482
|
responsePubkey.xpub = xpubConvert(responsePubkey.xpub, "ypub");
|
|
1475
1483
|
}
|
|
1484
|
+
console.log("✅ [XPUB] Final xpub:", responsePubkey.xpub.substring(0, 20) + "...");
|
|
1476
1485
|
pubkey.pubkey = responsePubkey.xpub;
|
|
1477
1486
|
pubkey.path = addressNListToBIP32(path.addressNList);
|
|
1478
1487
|
pubkey.pathMaster = addressNListToBIP32(path.addressNListMaster);
|
|
1488
|
+
console.log("✅ [XPUB] Xpub retrieval COMPLETE for", path.note || path.type);
|
|
1479
1489
|
} catch (xpubError) {
|
|
1480
1490
|
clearTimeout(xpubTimeout);
|
|
1481
|
-
console.error("getPublicKey failed
|
|
1482
|
-
|
|
1491
|
+
console.error("❌ [XPUB] CRITICAL FAILURE - getPublicKey failed");
|
|
1492
|
+
console.error("❌ [XPUB] Error:", xpubError);
|
|
1493
|
+
console.error("❌ [XPUB] Error message:", xpubError.message);
|
|
1494
|
+
console.error("❌ [XPUB] Error stack:", xpubError.stack);
|
|
1495
|
+
console.error("❌ [XPUB] Path:", addressNListToBIP32(path.addressNList));
|
|
1496
|
+
console.error("❌ [XPUB] Network:", networkId);
|
|
1497
|
+
console.error("❌ [XPUB] Query:", JSON.stringify(pathQuery, null, 2));
|
|
1498
|
+
console.error("❌ [XPUB] SDK available:", !!sdk);
|
|
1499
|
+
console.error("❌ [XPUB] SDK.system available:", !!sdk?.system);
|
|
1500
|
+
console.error("❌ [XPUB] SDK.system.info available:", !!sdk?.system?.info);
|
|
1501
|
+
console.error("❌ [XPUB] SDK.system.info.getPublicKey available:", !!sdk?.system?.info?.getPublicKey);
|
|
1502
|
+
console.error("");
|
|
1503
|
+
console.error("\uD83D\uDEA8 FAIL FAST: Cannot proceed without xpub for UTXO chains");
|
|
1504
|
+
console.error("\uD83D\uDEA8 UTXO balance queries REQUIRE extended public keys (xpubs)");
|
|
1505
|
+
console.error("\uD83D\uDEA8 This is a device communication or SDK issue that must be resolved");
|
|
1506
|
+
console.error("");
|
|
1507
|
+
throw new Error(`FAIL FAST - xpub retrieval failed for ${networkId} at ${addressNListToBIP32(path.addressNList)}: ${xpubError.message}`);
|
|
1483
1508
|
}
|
|
1484
1509
|
} else {
|
|
1510
|
+
console.log("\uD83D\uDD11 [PUBKEY] Non-xpub path (address-based), using address as pubkey");
|
|
1485
1511
|
pubkey.pubkey = address;
|
|
1486
1512
|
pubkey.path = addressNListToBIP32(path.addressNList);
|
|
1487
1513
|
pubkey.pathMaster = addressNListToBIP32(path.addressNListMaster);
|
|
@@ -1891,13 +1917,16 @@ async function fetchTokenPriceInUsd(contractAddress) {
|
|
|
1891
1917
|
}
|
|
1892
1918
|
return price;
|
|
1893
1919
|
}
|
|
1894
|
-
async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer,
|
|
1920
|
+
async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pubkeyContext, isMax, feeLevel = 5) {
|
|
1895
1921
|
const tag5 = TAG + " | createUnsignedEvmTx | ";
|
|
1896
1922
|
try {
|
|
1897
1923
|
if (!pioneer)
|
|
1898
1924
|
throw new Error("Failed to initialize Pioneer");
|
|
1899
1925
|
const networkId = caipToNetworkId(caip);
|
|
1900
1926
|
const chainId = extractChainIdFromNetworkId(networkId);
|
|
1927
|
+
if (!pubkeyContext) {
|
|
1928
|
+
throw new Error(`No pubkey context provided for networkId: ${networkId}`);
|
|
1929
|
+
}
|
|
1901
1930
|
const isValidForNetwork = (pubkey) => {
|
|
1902
1931
|
if (!pubkey?.networks)
|
|
1903
1932
|
return false;
|
|
@@ -1906,43 +1935,83 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, kee
|
|
|
1906
1935
|
}
|
|
1907
1936
|
return pubkey.networks.includes(networkId);
|
|
1908
1937
|
};
|
|
1909
|
-
if (!
|
|
1910
|
-
|
|
1911
|
-
keepKeySdk.pubkeyContext = pubkeys.find((pk) => isValidForNetwork(pk));
|
|
1912
|
-
} else {
|
|
1913
|
-
console.log(tag5, "Current context networks:", keepKeySdk.pubkeyContext.networks, "For networkId:", networkId);
|
|
1914
|
-
if (!isValidForNetwork(keepKeySdk.pubkeyContext)) {
|
|
1915
|
-
console.log(tag5, "Auto-correcting context - wrong network detected");
|
|
1916
|
-
keepKeySdk.pubkeyContext = pubkeys.find((pk) => isValidForNetwork(pk));
|
|
1917
|
-
} else {
|
|
1918
|
-
console.log(tag5, "Context is valid for this network - using existing context");
|
|
1919
|
-
}
|
|
1938
|
+
if (!isValidForNetwork(pubkeyContext)) {
|
|
1939
|
+
throw new Error(`Pubkey context is for wrong network. Expected ${networkId}, got ${pubkeyContext.networks}`);
|
|
1920
1940
|
}
|
|
1921
|
-
const address =
|
|
1922
|
-
console.log(tag5, "✅ Using FROM address from pubkeyContext:", address, "note:",
|
|
1941
|
+
const address = pubkeyContext.address || pubkeyContext.pubkey;
|
|
1942
|
+
console.log(tag5, "✅ Using FROM address from pubkeyContext:", address, "note:", pubkeyContext.note);
|
|
1923
1943
|
if (!address)
|
|
1924
1944
|
throw new Error("No address found for the specified network");
|
|
1925
1945
|
const gasPriceData = await pioneer.GetGasPriceByNetwork({ networkId });
|
|
1926
|
-
|
|
1927
|
-
const MIN_GAS_PRICE_WEI = BigInt(10000000000);
|
|
1928
|
-
if (BigInt(gasPriceData.data) < MIN_GAS_PRICE_WEI) {
|
|
1929
|
-
console.log(tag5, "Gas price from API too low:", gasPriceData.data, "wei - using minimum:", MIN_GAS_PRICE_WEI.toString());
|
|
1930
|
-
baseGasPrice = MIN_GAS_PRICE_WEI;
|
|
1931
|
-
} else {
|
|
1932
|
-
baseGasPrice = BigInt(gasPriceData.data);
|
|
1933
|
-
}
|
|
1946
|
+
console.log(tag5, "Gas price data from API:", JSON.stringify(gasPriceData.data));
|
|
1934
1947
|
let gasPrice;
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1948
|
+
const defaultGasPrices = {
|
|
1949
|
+
1: 30,
|
|
1950
|
+
56: 3,
|
|
1951
|
+
137: 50,
|
|
1952
|
+
43114: 25,
|
|
1953
|
+
8453: 0.1,
|
|
1954
|
+
10: 0.1
|
|
1955
|
+
};
|
|
1956
|
+
const fallbackGasGwei = defaultGasPrices[chainId] || 20;
|
|
1957
|
+
const MIN_GAS_PRICE_WEI = BigInt(fallbackGasGwei * 1e9);
|
|
1958
|
+
if (typeof gasPriceData.data === "object" && gasPriceData.data !== null && !Array.isArray(gasPriceData.data)) {
|
|
1959
|
+
let selectedGasPrice;
|
|
1960
|
+
if (feeLevel <= 2) {
|
|
1961
|
+
selectedGasPrice = gasPriceData.data.slow || gasPriceData.data.average || gasPriceData.data.fastest;
|
|
1962
|
+
console.log(tag5, "Selecting SLOW gas price from API");
|
|
1963
|
+
} else if (feeLevel >= 8) {
|
|
1964
|
+
selectedGasPrice = gasPriceData.data.fastest || gasPriceData.data.fast || gasPriceData.data.average;
|
|
1965
|
+
console.log(tag5, "Selecting FAST gas price from API");
|
|
1966
|
+
} else {
|
|
1967
|
+
selectedGasPrice = gasPriceData.data.average || gasPriceData.data.fast || gasPriceData.data.fastest;
|
|
1968
|
+
console.log(tag5, "Selecting AVERAGE gas price from API");
|
|
1969
|
+
}
|
|
1970
|
+
let gasPriceNum;
|
|
1971
|
+
if (selectedGasPrice === undefined || selectedGasPrice === null) {
|
|
1972
|
+
console.warn(tag5, "No valid gas price found in API response, using fallback:", fallbackGasGwei, "gwei");
|
|
1973
|
+
gasPriceNum = fallbackGasGwei;
|
|
1974
|
+
} else {
|
|
1975
|
+
gasPriceNum = typeof selectedGasPrice === "string" ? parseFloat(selectedGasPrice) : selectedGasPrice;
|
|
1976
|
+
if (isNaN(gasPriceNum) || !isFinite(gasPriceNum)) {
|
|
1977
|
+
console.warn(tag5, "Invalid gas price (NaN or Infinite):", selectedGasPrice, "- using fallback:", fallbackGasGwei, "gwei");
|
|
1978
|
+
gasPriceNum = fallbackGasGwei;
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
gasPrice = BigInt(Math.round(gasPriceNum * 1e9));
|
|
1982
|
+
if (gasPrice < MIN_GAS_PRICE_WEI) {
|
|
1983
|
+
console.warn(tag5, "Gas price from API too low:", gasPrice.toString(), "wei - using minimum:", MIN_GAS_PRICE_WEI.toString());
|
|
1984
|
+
gasPrice = MIN_GAS_PRICE_WEI;
|
|
1985
|
+
}
|
|
1941
1986
|
} else {
|
|
1942
|
-
|
|
1943
|
-
|
|
1987
|
+
let gasPriceNum;
|
|
1988
|
+
if (gasPriceData.data === undefined || gasPriceData.data === null) {
|
|
1989
|
+
console.warn(tag5, "Gas price API returned null/undefined, using fallback:", fallbackGasGwei, "gwei");
|
|
1990
|
+
gasPriceNum = fallbackGasGwei;
|
|
1991
|
+
} else {
|
|
1992
|
+
gasPriceNum = typeof gasPriceData.data === "string" ? parseFloat(gasPriceData.data) : gasPriceData.data;
|
|
1993
|
+
if (isNaN(gasPriceNum) || !isFinite(gasPriceNum)) {
|
|
1994
|
+
console.warn(tag5, "Invalid gas price (NaN or Infinite):", gasPriceData.data, "- using fallback:", fallbackGasGwei, "gwei");
|
|
1995
|
+
gasPriceNum = fallbackGasGwei;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
const baseGasPrice = BigInt(Math.round(gasPriceNum * 1e9));
|
|
1999
|
+
if (feeLevel <= 2) {
|
|
2000
|
+
gasPrice = baseGasPrice * BigInt(80) / BigInt(100);
|
|
2001
|
+
console.log(tag5, "Using SLOW gas price (80% of base)");
|
|
2002
|
+
} else if (feeLevel >= 8) {
|
|
2003
|
+
gasPrice = baseGasPrice * BigInt(150) / BigInt(100);
|
|
2004
|
+
console.log(tag5, "Using FAST gas price (150% of base)");
|
|
2005
|
+
} else {
|
|
2006
|
+
gasPrice = baseGasPrice;
|
|
2007
|
+
console.log(tag5, "Using AVERAGE gas price (100% of base)");
|
|
2008
|
+
}
|
|
2009
|
+
if (gasPrice < MIN_GAS_PRICE_WEI) {
|
|
2010
|
+
console.warn(tag5, "Gas price too low:", gasPrice.toString(), "wei - using minimum:", MIN_GAS_PRICE_WEI.toString());
|
|
2011
|
+
gasPrice = MIN_GAS_PRICE_WEI;
|
|
2012
|
+
}
|
|
1944
2013
|
}
|
|
1945
|
-
console.log(tag5, "
|
|
2014
|
+
console.log(tag5, "Final gasPrice:", gasPrice.toString(), "wei (", Number(gasPrice) / 1e9, "gwei)");
|
|
1946
2015
|
let nonce;
|
|
1947
2016
|
try {
|
|
1948
2017
|
const nonceData = await pioneer.GetNonceByNetwork({ networkId, address });
|
|
@@ -2133,18 +2202,18 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, kee
|
|
|
2133
2202
|
throw new Error(`Unsupported asset type for CAIP ${caip}`);
|
|
2134
2203
|
}
|
|
2135
2204
|
}
|
|
2136
|
-
if (
|
|
2137
|
-
unsignedTx.addressNList =
|
|
2205
|
+
if (pubkeyContext.addressNListMaster) {
|
|
2206
|
+
unsignedTx.addressNList = pubkeyContext.addressNListMaster;
|
|
2138
2207
|
console.log(tag5, "✅ Using addressNListMaster from pubkey context:", unsignedTx.addressNList, "for address:", address);
|
|
2139
|
-
} else if (
|
|
2140
|
-
unsignedTx.addressNList = bip32ToAddressNList(
|
|
2141
|
-
console.log(tag5, "✅ Converted pathMaster to addressNList:",
|
|
2142
|
-
} else if (
|
|
2143
|
-
unsignedTx.addressNList =
|
|
2208
|
+
} else if (pubkeyContext.pathMaster) {
|
|
2209
|
+
unsignedTx.addressNList = bip32ToAddressNList(pubkeyContext.pathMaster);
|
|
2210
|
+
console.log(tag5, "✅ Converted pathMaster to addressNList:", pubkeyContext.pathMaster, "→", unsignedTx.addressNList);
|
|
2211
|
+
} else if (pubkeyContext.addressNList) {
|
|
2212
|
+
unsignedTx.addressNList = pubkeyContext.addressNList;
|
|
2144
2213
|
console.log(tag5, "✅ Using addressNList from pubkey context:", unsignedTx.addressNList);
|
|
2145
|
-
} else if (
|
|
2146
|
-
unsignedTx.addressNList = bip32ToAddressNList(
|
|
2147
|
-
console.log(tag5, "⚠️ Using regular path (not master):",
|
|
2214
|
+
} else if (pubkeyContext.path) {
|
|
2215
|
+
unsignedTx.addressNList = bip32ToAddressNList(pubkeyContext.path);
|
|
2216
|
+
console.log(tag5, "⚠️ Using regular path (not master):", pubkeyContext.path, "→", unsignedTx.addressNList);
|
|
2148
2217
|
} else {
|
|
2149
2218
|
unsignedTx.addressNList = [2147483648 + 44, 2147483648 + 60, 2147483648, 0, 0];
|
|
2150
2219
|
console.warn(tag5, "⚠️ No path info in pubkey context, using default account 0");
|
|
@@ -2159,19 +2228,22 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, kee
|
|
|
2159
2228
|
// src/txbuilder/createUnsignedRippleTx.ts
|
|
2160
2229
|
import { caipToNetworkId as caipToNetworkId2 } from "@pioneer-platform/pioneer-caip";
|
|
2161
2230
|
var TAG2 = " | createUnsignedUxtoTx | ";
|
|
2162
|
-
async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer,
|
|
2231
|
+
async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer, pubkeyContext, isMax) {
|
|
2163
2232
|
let tag5 = TAG2 + " | createUnsignedRippleTx | ";
|
|
2164
2233
|
try {
|
|
2165
2234
|
if (!pioneer)
|
|
2166
2235
|
throw new Error("Failed to init! pioneer");
|
|
2167
2236
|
const networkId = caipToNetworkId2(caip);
|
|
2168
|
-
if (!
|
|
2169
|
-
|
|
2237
|
+
if (!pubkeyContext) {
|
|
2238
|
+
throw new Error(`No pubkey context provided for networkId: ${networkId}`);
|
|
2170
2239
|
}
|
|
2171
|
-
if (!
|
|
2172
|
-
throw new Error(`
|
|
2240
|
+
if (!pubkeyContext.networks?.includes(networkId)) {
|
|
2241
|
+
throw new Error(`Pubkey context is for wrong network. Expected ${networkId}, got ${pubkeyContext.networks}`);
|
|
2173
2242
|
}
|
|
2174
|
-
|
|
2243
|
+
console.log(tag5, `✅ Using pubkeyContext for network ${networkId}:`, {
|
|
2244
|
+
address: pubkeyContext.address
|
|
2245
|
+
});
|
|
2246
|
+
const fromAddress = pubkeyContext.address || pubkeyContext.pubkey;
|
|
2175
2247
|
let accountInfo = await pioneer.GetAccountInfo({
|
|
2176
2248
|
address: fromAddress,
|
|
2177
2249
|
network: "ripple"
|
|
@@ -2269,6 +2341,7 @@ var cosmosTransferTemplate = (params) => ({
|
|
|
2269
2341
|
// src/txbuilder/templates/mayachain.ts
|
|
2270
2342
|
var mayachainTransferTemplate = (params) => ({
|
|
2271
2343
|
signerAddress: params.from_address,
|
|
2344
|
+
addressNList: params.addressNList,
|
|
2272
2345
|
signDoc: {
|
|
2273
2346
|
account_number: params.account_number,
|
|
2274
2347
|
chain_id: params.chain_id,
|
|
@@ -2374,18 +2447,22 @@ var thorchainDepositTemplate = (params) => ({
|
|
|
2374
2447
|
|
|
2375
2448
|
// src/txbuilder/createUnsignedTendermintTx.ts
|
|
2376
2449
|
var TAG3 = " | createUnsignedTendermintTx | ";
|
|
2377
|
-
async function createUnsignedTendermintTx(caip, type, amount, memo, pubkeys, pioneer,
|
|
2450
|
+
async function createUnsignedTendermintTx(caip, type, amount, memo, pubkeys, pioneer, pubkeyContext, isMax, to) {
|
|
2378
2451
|
const tag5 = TAG3 + " | createUnsignedTendermintTx | ";
|
|
2379
2452
|
try {
|
|
2380
2453
|
if (!pioneer)
|
|
2381
2454
|
throw new Error("Failed to init! pioneer");
|
|
2382
2455
|
const networkId = caipToNetworkId3(caip);
|
|
2383
|
-
if (!
|
|
2384
|
-
|
|
2456
|
+
if (!pubkeyContext) {
|
|
2457
|
+
throw new Error(`No pubkey context provided for networkId: ${networkId}`);
|
|
2385
2458
|
}
|
|
2386
|
-
if (!
|
|
2387
|
-
throw new Error(`
|
|
2459
|
+
if (!pubkeyContext.networks?.includes(networkId)) {
|
|
2460
|
+
throw new Error(`Pubkey context is for wrong network. Expected ${networkId}, got ${pubkeyContext.networks}`);
|
|
2388
2461
|
}
|
|
2462
|
+
console.log(tag5, `✅ Using pubkeyContext for network ${networkId}:`, {
|
|
2463
|
+
address: pubkeyContext.address,
|
|
2464
|
+
addressNList: pubkeyContext.addressNList || pubkeyContext.addressNListMaster
|
|
2465
|
+
});
|
|
2389
2466
|
let chain;
|
|
2390
2467
|
switch (networkId) {
|
|
2391
2468
|
case "cosmos:thorchain-mainnet-v1":
|
|
@@ -2403,10 +2480,13 @@ async function createUnsignedTendermintTx(caip, type, amount, memo, pubkeys, pio
|
|
|
2403
2480
|
default:
|
|
2404
2481
|
throw new Error(`Unhandled networkId: ${networkId}`);
|
|
2405
2482
|
}
|
|
2406
|
-
const fromAddress =
|
|
2483
|
+
const fromAddress = pubkeyContext.address || pubkeyContext.pubkey;
|
|
2407
2484
|
let asset = caip.split(":")[1];
|
|
2485
|
+
console.log(tag5, `\uD83D\uDD0D Fetching account info for address: ${fromAddress}`);
|
|
2408
2486
|
const accountInfo = (await pioneer.GetAccountInfo({ network: chain, address: fromAddress })).data;
|
|
2487
|
+
console.log(tag5, "\uD83D\uDCCB accountInfo:", JSON.stringify(accountInfo, null, 2));
|
|
2409
2488
|
let balanceInfo = await pioneer.GetPubkeyBalance({ asset: chain, pubkey: fromAddress });
|
|
2489
|
+
console.log(tag5, `\uD83D\uDCB0 balanceInfo:`, balanceInfo);
|
|
2410
2490
|
let account_number, sequence;
|
|
2411
2491
|
if (networkId === "cosmos:cosmoshub-4" || networkId === "cosmos:osmosis-1") {
|
|
2412
2492
|
account_number = accountInfo.account.account_number || "0";
|
|
@@ -2415,9 +2495,17 @@ async function createUnsignedTendermintTx(caip, type, amount, memo, pubkeys, pio
|
|
|
2415
2495
|
account_number = accountInfo.result.value.account_number || "0";
|
|
2416
2496
|
sequence = accountInfo.result.value.sequence || "0";
|
|
2417
2497
|
}
|
|
2498
|
+
console.log(tag5, `\uD83D\uDCCA Extracted account_number: ${account_number}, sequence: ${sequence}`);
|
|
2499
|
+
if (account_number === "0" || account_number === 0) {
|
|
2500
|
+
console.log(tag5, `⚠️ WARNING: Account number is 0 from Pioneer API`);
|
|
2501
|
+
console.log(tag5, ` This is likely due to stale Pioneer API cache`);
|
|
2502
|
+
console.log(tag5, ` The mayachain-network module queries nodes directly but Pioneer API may be cached`);
|
|
2503
|
+
console.log(tag5, ` Proceeding with account_number: 0 but transaction will likely fail`);
|
|
2504
|
+
console.log(tag5, ` TODO: Fix Pioneer API to use fresh data from mayachain-network module`);
|
|
2505
|
+
}
|
|
2418
2506
|
const fees = {
|
|
2419
2507
|
"cosmos:thorchain-mainnet-v1": 0.02,
|
|
2420
|
-
"cosmos:mayachain-mainnet-v1": 0
|
|
2508
|
+
"cosmos:mayachain-mainnet-v1": 0,
|
|
2421
2509
|
"cosmos:cosmoshub-4": 0.005,
|
|
2422
2510
|
"cosmos:osmosis-1": 0.035
|
|
2423
2511
|
};
|
|
@@ -2476,11 +2564,12 @@ async function createUnsignedTendermintTx(caip, type, amount, memo, pubkeys, pio
|
|
|
2476
2564
|
} else {
|
|
2477
2565
|
throw new Error(`Unsupported Maya chain CAIP: ${caip}`);
|
|
2478
2566
|
}
|
|
2567
|
+
const decimals = mayaAsset === "maya" ? 1e4 : 10000000000;
|
|
2479
2568
|
if (isMax) {
|
|
2480
|
-
const fee = Math.floor(fees[networkId] *
|
|
2481
|
-
amount = Math.max(0, Math.floor(balanceInfo.data *
|
|
2569
|
+
const fee = Math.floor(fees[networkId] * decimals);
|
|
2570
|
+
amount = Math.max(0, Math.floor(balanceInfo.data * decimals) - fee);
|
|
2482
2571
|
} else {
|
|
2483
|
-
amount = Math.max(Math.floor(amount *
|
|
2572
|
+
amount = Math.max(Math.floor(amount * decimals), 0);
|
|
2484
2573
|
}
|
|
2485
2574
|
return to ? mayachainTransferTemplate({
|
|
2486
2575
|
account_number,
|
|
@@ -2499,7 +2588,8 @@ async function createUnsignedTendermintTx(caip, type, amount, memo, pubkeys, pio
|
|
|
2499
2588
|
asset: mayaAsset,
|
|
2500
2589
|
amount: amount.toString(),
|
|
2501
2590
|
memo,
|
|
2502
|
-
sequence
|
|
2591
|
+
sequence,
|
|
2592
|
+
addressNList: pubkeyContext.addressNList || pubkeyContext.addressNListMaster
|
|
2503
2593
|
}) : mayachainDepositTemplate({
|
|
2504
2594
|
account_number,
|
|
2505
2595
|
chain_id: "mayachain-mainnet-v1",
|
|
@@ -2572,54 +2662,52 @@ async function createUnsignedTendermintTx(caip, type, amount, memo, pubkeys, pio
|
|
|
2572
2662
|
}
|
|
2573
2663
|
|
|
2574
2664
|
// src/txbuilder/createUnsignedUxtoTx.ts
|
|
2665
|
+
var import_coinselect = __toESM(require_coinselect(), 1);
|
|
2666
|
+
var import_split = __toESM(require_split(), 1);
|
|
2575
2667
|
import { caipToNetworkId as caipToNetworkId4, NetworkIdToChain } from "@pioneer-platform/pioneer-caip";
|
|
2576
|
-
import { bip32ToAddressNList as bip32ToAddressNList2 } from "@pioneer-platform/pioneer-coins";
|
|
2577
|
-
|
|
2668
|
+
import { bip32ToAddressNList as bip32ToAddressNList2, SLIP_44_BY_LONG, COIN_MAP_LONG } from "@pioneer-platform/pioneer-coins";
|
|
2669
|
+
function getCoinTypeFromNetworkId(networkId) {
|
|
2670
|
+
const chain = NetworkIdToChain[networkId];
|
|
2671
|
+
if (!chain) {
|
|
2672
|
+
console.warn(`No chain mapping found for ${networkId}, defaulting to Bitcoin coin type 0`);
|
|
2673
|
+
return 0;
|
|
2674
|
+
}
|
|
2675
|
+
const blockchainName = COIN_MAP_LONG[chain]?.toLowerCase();
|
|
2676
|
+
if (!blockchainName) {
|
|
2677
|
+
console.warn(`No blockchain name found for chain ${chain}, defaulting to Bitcoin coin type 0`);
|
|
2678
|
+
return 0;
|
|
2679
|
+
}
|
|
2680
|
+
const coinType = SLIP_44_BY_LONG[blockchainName];
|
|
2681
|
+
if (coinType === undefined) {
|
|
2682
|
+
console.warn(`No SLIP-44 coin type found for ${blockchainName}, defaulting to Bitcoin coin type 0`);
|
|
2683
|
+
return 0;
|
|
2684
|
+
}
|
|
2685
|
+
return coinType;
|
|
2686
|
+
}
|
|
2687
|
+
async function createUnsignedUxtoTx(caip, to, amount, memo, pubkeys, pioneer, pubkeyContext, isMax, feeLevel = 5, changeScriptType) {
|
|
2578
2688
|
let tag5 = " | createUnsignedUxtoTx | ";
|
|
2579
2689
|
try {
|
|
2580
2690
|
if (!pioneer)
|
|
2581
2691
|
throw Error("Failed to init! pioneer");
|
|
2582
2692
|
const networkId = caipToNetworkId4(caip);
|
|
2583
|
-
if (!
|
|
2584
|
-
|
|
2693
|
+
if (!pubkeyContext) {
|
|
2694
|
+
throw new Error(`No pubkey context provided for networkId: ${networkId}`);
|
|
2585
2695
|
}
|
|
2696
|
+
if (!pubkeyContext.networks?.includes(networkId)) {
|
|
2697
|
+
throw new Error(`Pubkey context is for wrong network. Expected ${networkId}, got ${pubkeyContext.networks}`);
|
|
2698
|
+
}
|
|
2699
|
+
console.log(tag5, `✅ Using pubkeyContext for network ${networkId}:`, {
|
|
2700
|
+
address: pubkeyContext.address,
|
|
2701
|
+
scriptType: pubkeyContext.scriptType
|
|
2702
|
+
});
|
|
2586
2703
|
const relevantPubkeys = pubkeys.filter((e) => e.networks && Array.isArray(e.networks) && e.networks.includes(networkId));
|
|
2587
2704
|
const segwitNetworks = [
|
|
2588
2705
|
"bip122:000000000019d6689c085ae165831e93"
|
|
2589
2706
|
];
|
|
2590
2707
|
const isSegwit = segwitNetworks.includes(networkId);
|
|
2591
2708
|
let chain = NetworkIdToChain[networkId];
|
|
2592
|
-
const
|
|
2593
|
-
console.log(`${tag5}: Using
|
|
2594
|
-
const changeXpub = relevantPubkeys.find((pk) => pk.scriptType === actualChangeScriptType)?.pubkey || relevantPubkeys.find((pk) => pk.scriptType === "p2wpkh")?.pubkey || relevantPubkeys[0].pubkey;
|
|
2595
|
-
console.log(`${tag5}: Change xpub selected for ${actualChangeScriptType}:`, changeXpub?.substring(0, 10) + "...");
|
|
2596
|
-
let changeAddressIndex = await pioneer.GetChangeAddress({
|
|
2597
|
-
network: chain,
|
|
2598
|
-
xpub: changeXpub
|
|
2599
|
-
});
|
|
2600
|
-
changeAddressIndex = changeAddressIndex.data.changeIndex;
|
|
2601
|
-
let bipPath;
|
|
2602
|
-
switch (actualChangeScriptType) {
|
|
2603
|
-
case "p2pkh":
|
|
2604
|
-
bipPath = `m/44'/0'/0'/1/${changeAddressIndex}`;
|
|
2605
|
-
break;
|
|
2606
|
-
case "p2sh-p2wpkh":
|
|
2607
|
-
bipPath = `m/49'/0'/0'/1/${changeAddressIndex}`;
|
|
2608
|
-
break;
|
|
2609
|
-
case "p2wpkh":
|
|
2610
|
-
default:
|
|
2611
|
-
bipPath = `m/84'/0'/0'/1/${changeAddressIndex}`;
|
|
2612
|
-
break;
|
|
2613
|
-
}
|
|
2614
|
-
const path = bipPath;
|
|
2615
|
-
console.log(`${tag5}: Change address path: ${path} (index: ${changeAddressIndex})`);
|
|
2616
|
-
const changeAddress = {
|
|
2617
|
-
path,
|
|
2618
|
-
isChange: true,
|
|
2619
|
-
index: changeAddressIndex,
|
|
2620
|
-
addressNList: bip32ToAddressNList2(path),
|
|
2621
|
-
scriptType: actualChangeScriptType
|
|
2622
|
-
};
|
|
2709
|
+
const coinType = getCoinTypeFromNetworkId(networkId);
|
|
2710
|
+
console.log(`${tag5}: Using SLIP-44 coin type ${coinType} for ${chain}`);
|
|
2623
2711
|
const utxos = [];
|
|
2624
2712
|
for (const pubkey of relevantPubkeys) {
|
|
2625
2713
|
try {
|
|
@@ -2645,6 +2733,48 @@ async function createUnsignedUxtoTx(caip, to, amount, memo, pubkeys, pioneer, ke
|
|
|
2645
2733
|
for (const utxo of utxos) {
|
|
2646
2734
|
utxo.value = Number(utxo.value);
|
|
2647
2735
|
}
|
|
2736
|
+
const inputScriptTypes = utxos.map((u) => u.scriptType).filter(Boolean);
|
|
2737
|
+
const scriptTypeCount = inputScriptTypes.reduce((acc, type) => {
|
|
2738
|
+
acc[type] = (acc[type] || 0) + 1;
|
|
2739
|
+
return acc;
|
|
2740
|
+
}, {});
|
|
2741
|
+
const mostCommonInputType = Object.entries(scriptTypeCount).sort(([, a2], [, b3]) => b3 - a2)[0]?.[0] || "p2pkh";
|
|
2742
|
+
const actualChangeScriptType = changeScriptType || mostCommonInputType || relevantPubkeys[0]?.scriptType || "p2pkh";
|
|
2743
|
+
console.log(`${tag5}: Input script types:`, scriptTypeCount);
|
|
2744
|
+
console.log(`${tag5}: Using change script type: ${actualChangeScriptType} (matches inputs: ${mostCommonInputType})`);
|
|
2745
|
+
const changeXpubInfo = relevantPubkeys.find((pk) => pk.scriptType === actualChangeScriptType);
|
|
2746
|
+
if (!changeXpubInfo) {
|
|
2747
|
+
throw new Error(`No ${actualChangeScriptType} xpub available for change address. ` + `Available types: ${relevantPubkeys.map((pk) => pk.scriptType).join(", ")}. ` + `Cannot create change output with mismatched script type.`);
|
|
2748
|
+
}
|
|
2749
|
+
const changeXpub = changeXpubInfo.pubkey;
|
|
2750
|
+
console.log(`${tag5}: Change xpub selected for ${actualChangeScriptType}:`, changeXpub?.substring(0, 10) + "...");
|
|
2751
|
+
let changeAddressIndex = await pioneer.GetChangeAddress({
|
|
2752
|
+
network: chain,
|
|
2753
|
+
xpub: changeXpub
|
|
2754
|
+
});
|
|
2755
|
+
changeAddressIndex = changeAddressIndex.data.changeIndex;
|
|
2756
|
+
let bipPath;
|
|
2757
|
+
switch (actualChangeScriptType) {
|
|
2758
|
+
case "p2pkh":
|
|
2759
|
+
bipPath = `m/44'/${coinType}'/0'/1/${changeAddressIndex}`;
|
|
2760
|
+
break;
|
|
2761
|
+
case "p2sh-p2wpkh":
|
|
2762
|
+
bipPath = `m/49'/${coinType}'/0'/1/${changeAddressIndex}`;
|
|
2763
|
+
break;
|
|
2764
|
+
case "p2wpkh":
|
|
2765
|
+
default:
|
|
2766
|
+
bipPath = `m/84'/${coinType}'/0'/1/${changeAddressIndex}`;
|
|
2767
|
+
break;
|
|
2768
|
+
}
|
|
2769
|
+
const path = bipPath;
|
|
2770
|
+
console.log(`${tag5}: Change address path: ${path} (coin type: ${coinType}, index: ${changeAddressIndex})`);
|
|
2771
|
+
const changeAddress = {
|
|
2772
|
+
path,
|
|
2773
|
+
isChange: true,
|
|
2774
|
+
index: changeAddressIndex,
|
|
2775
|
+
addressNList: bip32ToAddressNList2(path),
|
|
2776
|
+
scriptType: actualChangeScriptType
|
|
2777
|
+
};
|
|
2648
2778
|
let feeRateFromNode;
|
|
2649
2779
|
if (networkId === "bip122:00000000001a91e3dace36e2be3bf030") {
|
|
2650
2780
|
console.log(`${tag5}: Using hardcoded fees for DOGE (10 sat/byte)`);
|
|
@@ -2762,11 +2892,9 @@ async function createUnsignedUxtoTx(caip, to, amount, memo, pubkeys, pioneer, ke
|
|
|
2762
2892
|
})));
|
|
2763
2893
|
let result;
|
|
2764
2894
|
if (isMax) {
|
|
2765
|
-
|
|
2766
|
-
result = coinSelectSplit(utxos, [{ address: to }], effectiveFeeRate);
|
|
2895
|
+
result = import_split.default(utxos, [{ address: to }], effectiveFeeRate);
|
|
2767
2896
|
} else {
|
|
2768
|
-
|
|
2769
|
-
result = coinSelect(utxos, [{ address: to, value: amount }], effectiveFeeRate);
|
|
2897
|
+
result = import_coinselect.default(utxos, [{ address: to, value: amount }], effectiveFeeRate);
|
|
2770
2898
|
}
|
|
2771
2899
|
console.log(tag5, "coinSelect result object:", result);
|
|
2772
2900
|
console.log(tag5, "coinSelect result.inputs:", result?.inputs);
|
|
@@ -2883,6 +3011,7 @@ class TransactionManager {
|
|
|
2883
3011
|
assetContext;
|
|
2884
3012
|
balances;
|
|
2885
3013
|
pubkeys;
|
|
3014
|
+
pubkeyContext;
|
|
2886
3015
|
nodes;
|
|
2887
3016
|
pioneer;
|
|
2888
3017
|
keepKeySdk;
|
|
@@ -2892,6 +3021,7 @@ class TransactionManager {
|
|
|
2892
3021
|
this.assetContext = dependencies.assetContext;
|
|
2893
3022
|
this.balances = dependencies.balances;
|
|
2894
3023
|
this.pubkeys = dependencies.pubkeys;
|
|
3024
|
+
this.pubkeyContext = dependencies.pubkeyContext;
|
|
2895
3025
|
this.nodes = dependencies.nodes;
|
|
2896
3026
|
this.pioneer = dependencies.pioneer;
|
|
2897
3027
|
this.keepKeySdk = dependencies.keepKeySdk;
|
|
@@ -2925,20 +3055,20 @@ class TransactionManager {
|
|
|
2925
3055
|
let unsignedTx;
|
|
2926
3056
|
switch (type) {
|
|
2927
3057
|
case "UTXO": {
|
|
2928
|
-
unsignedTx = await createUnsignedUxtoTx(caip, to, amount, memo, this.pubkeys, this.pioneer, this.
|
|
3058
|
+
unsignedTx = await createUnsignedUxtoTx(caip, to, amount, memo, this.pubkeys, this.pioneer, this.pubkeyContext, isMax, feeLevel, changeScriptType);
|
|
2929
3059
|
break;
|
|
2930
3060
|
}
|
|
2931
3061
|
case "TENDERMINT": {
|
|
2932
3062
|
const txType = "transfer";
|
|
2933
|
-
unsignedTx = await createUnsignedTendermintTx(caip, txType, amount, memo, this.pubkeys, this.pioneer, this.
|
|
3063
|
+
unsignedTx = await createUnsignedTendermintTx(caip, txType, amount, memo, this.pubkeys, this.pioneer, this.pubkeyContext, isMax, to);
|
|
2934
3064
|
break;
|
|
2935
3065
|
}
|
|
2936
3066
|
case "EIP155": {
|
|
2937
|
-
unsignedTx = await createUnsignedEvmTx(caip, to, amount, memo, this.pubkeys, this.pioneer, this.
|
|
3067
|
+
unsignedTx = await createUnsignedEvmTx(caip, to, amount, memo, this.pubkeys, this.pioneer, this.pubkeyContext, isMax, feeLevel);
|
|
2938
3068
|
break;
|
|
2939
3069
|
}
|
|
2940
3070
|
case "OTHER": {
|
|
2941
|
-
unsignedTx = await createUnsignedRippleTx(caip, to, amount, memo, this.pubkeys, this.pioneer, this.
|
|
3071
|
+
unsignedTx = await createUnsignedRippleTx(caip, to, amount, memo, this.pubkeys, this.pioneer, this.pubkeyContext, isMax);
|
|
2942
3072
|
break;
|
|
2943
3073
|
}
|
|
2944
3074
|
default: {
|
|
@@ -3037,9 +3167,20 @@ class TransactionManager {
|
|
|
3037
3167
|
}
|
|
3038
3168
|
case "cosmos:mayachain-mainnet-v1/slip44:931":
|
|
3039
3169
|
case "cosmos:mayachain-mainnet-v1/denom:maya": {
|
|
3170
|
+
console.log(tag5, "\uD83D\uDD0D ===== MAYACHAIN SIGNING AUDIT =====");
|
|
3171
|
+
console.log(tag5, "\uD83D\uDCCB unsignedTx:", JSON.stringify(unsignedTx, null, 2));
|
|
3172
|
+
console.log(tag5, "\uD83D\uDD11 unsignedTx.addressNList:", unsignedTx.addressNList);
|
|
3173
|
+
console.log(tag5, "\uD83D\uDCCD unsignedTx.signerAddress:", unsignedTx.signerAddress);
|
|
3174
|
+
console.log(tag5, "\uD83C\uDF10 pubkeyContext:", this.pubkeyContext);
|
|
3175
|
+
console.log(tag5, "\uD83D\uDD10 pubkeyContext.addressNList:", this.pubkeyContext?.addressNList);
|
|
3176
|
+
console.log(tag5, "\uD83D\uDD10 pubkeyContext.addressNListMaster:", this.pubkeyContext?.addressNListMaster);
|
|
3177
|
+
console.log(tag5, "\uD83D\uDCEC pubkeyContext.address:", this.pubkeyContext?.address);
|
|
3178
|
+
console.log(tag5, "=======================================");
|
|
3040
3179
|
if (unsignedTx.signDoc.msgs[0].type === "mayachain/MsgSend") {
|
|
3041
3180
|
const responseSign = await this.keepKeySdk.mayachain.mayachainSignAminoTransfer(unsignedTx);
|
|
3042
3181
|
signedTx = responseSign.serialized;
|
|
3182
|
+
console.log(tag5, "✅ Signing completed");
|
|
3183
|
+
console.log(tag5, "\uD83D\uDCE6 responseSign:", responseSign);
|
|
3043
3184
|
} else if (unsignedTx.signDoc.msgs[0].type === "mayachain/MsgDeposit") {
|
|
3044
3185
|
const responseSign = await this.keepKeySdk.mayachain.mayachainSignAminoDeposit(unsignedTx);
|
|
3045
3186
|
signedTx = responseSign.serialized;
|
|
@@ -3231,18 +3372,21 @@ var cosmosClaimAllRewardsTemplate = (params) => ({
|
|
|
3231
3372
|
|
|
3232
3373
|
// src/txbuilder/createUnsignedStakingTx.ts
|
|
3233
3374
|
var TAG5 = " | createUnsignedStakingTx | ";
|
|
3234
|
-
async function createUnsignedStakingTx(caip, params, pubkeys, pioneer,
|
|
3375
|
+
async function createUnsignedStakingTx(caip, params, pubkeys, pioneer, pubkeyContext) {
|
|
3235
3376
|
const tag5 = TAG5 + " | createUnsignedStakingTx | ";
|
|
3236
3377
|
try {
|
|
3237
3378
|
if (!pioneer)
|
|
3238
3379
|
throw new Error("Failed to init! pioneer");
|
|
3239
3380
|
const networkId = caipToNetworkId5(caip);
|
|
3240
|
-
if (!
|
|
3241
|
-
|
|
3381
|
+
if (!pubkeyContext) {
|
|
3382
|
+
throw new Error(`No pubkey context provided for networkId: ${networkId}`);
|
|
3242
3383
|
}
|
|
3243
|
-
if (!
|
|
3244
|
-
throw new Error(`
|
|
3384
|
+
if (!pubkeyContext.networks?.includes(networkId)) {
|
|
3385
|
+
throw new Error(`Pubkey context is for wrong network. Expected ${networkId}, got ${pubkeyContext.networks}`);
|
|
3245
3386
|
}
|
|
3387
|
+
console.log(tag5, `✅ Using pubkeyContext for network ${networkId}:`, {
|
|
3388
|
+
address: pubkeyContext.address
|
|
3389
|
+
});
|
|
3246
3390
|
let chain;
|
|
3247
3391
|
let chainId;
|
|
3248
3392
|
let denom;
|
|
@@ -3273,7 +3417,7 @@ async function createUnsignedStakingTx(caip, params, pubkeys, pioneer, keepKeySd
|
|
|
3273
3417
|
throw new Error(`Unsupported networkId for staking: ${networkId}`);
|
|
3274
3418
|
}
|
|
3275
3419
|
console.log(tag5, `Building ${params.type} transaction for ${chain}`);
|
|
3276
|
-
const fromAddress =
|
|
3420
|
+
const fromAddress = pubkeyContext.address || pubkeyContext.pubkey;
|
|
3277
3421
|
const accountInfo = (await pioneer.GetAccountInfo({ network: chain, address: fromAddress })).data;
|
|
3278
3422
|
console.log(tag5, "accountInfo: ", accountInfo);
|
|
3279
3423
|
let account_number;
|
|
@@ -3396,6 +3540,12 @@ function getNetworkName(networkId) {
|
|
|
3396
3540
|
};
|
|
3397
3541
|
return networkNames[networkId] || networkId;
|
|
3398
3542
|
}
|
|
3543
|
+
function withTimeout(promise, timeoutMs) {
|
|
3544
|
+
return Promise.race([
|
|
3545
|
+
promise,
|
|
3546
|
+
new Promise((_2, reject) => setTimeout(() => reject(new Error("Request timeout")), timeoutMs))
|
|
3547
|
+
]);
|
|
3548
|
+
}
|
|
3399
3549
|
async function getFees(pioneer, networkId) {
|
|
3400
3550
|
const tag5 = TAG6 + " | getFees | ";
|
|
3401
3551
|
try {
|
|
@@ -3405,10 +3555,6 @@ async function getFees(pioneer, networkId) {
|
|
|
3405
3555
|
console.log(tag5, "Using hardcoded fees for Cosmos network:", networkId);
|
|
3406
3556
|
return getCosmosFees(networkId);
|
|
3407
3557
|
}
|
|
3408
|
-
if (networkType === "RIPPLE") {
|
|
3409
|
-
console.log(tag5, "Using hardcoded fees for Ripple:", networkId);
|
|
3410
|
-
return getRippleFees(networkId);
|
|
3411
|
-
}
|
|
3412
3558
|
if (networkId === "bip122:00000000001a91e3dace36e2be3bf030") {
|
|
3413
3559
|
console.log(tag5, "Using hardcoded fees for Dogecoin: 10 sat/byte");
|
|
3414
3560
|
return {
|
|
@@ -3441,15 +3587,51 @@ async function getFees(pioneer, networkId) {
|
|
|
3441
3587
|
raw: { hardcoded: true, reason: "DOGE fee estimation unreliable" }
|
|
3442
3588
|
};
|
|
3443
3589
|
}
|
|
3444
|
-
|
|
3590
|
+
let feeResponse;
|
|
3591
|
+
if (networkId === "bip122:000007d91d1254d60e2dd1ae58038307") {
|
|
3592
|
+
try {
|
|
3593
|
+
const apiCall = pioneer.GetFeeRateByNetwork ? pioneer.GetFeeRateByNetwork({ networkId }) : pioneer.GetFeeRate({ networkId });
|
|
3594
|
+
feeResponse = await withTimeout(apiCall, 3000);
|
|
3595
|
+
} catch (timeoutError) {
|
|
3596
|
+
console.warn(tag5, "Dash fee API timeout, using fallback fees");
|
|
3597
|
+
return {
|
|
3598
|
+
slow: {
|
|
3599
|
+
label: "Economy",
|
|
3600
|
+
value: "5",
|
|
3601
|
+
unit: "sat/byte",
|
|
3602
|
+
description: "Low priority - 30+ minutes",
|
|
3603
|
+
estimatedTime: "~30 minutes",
|
|
3604
|
+
priority: "low"
|
|
3605
|
+
},
|
|
3606
|
+
average: {
|
|
3607
|
+
label: "Standard",
|
|
3608
|
+
value: "8",
|
|
3609
|
+
unit: "sat/byte",
|
|
3610
|
+
description: "Normal priority - 10-30 minutes",
|
|
3611
|
+
estimatedTime: "~15 minutes",
|
|
3612
|
+
priority: "medium"
|
|
3613
|
+
},
|
|
3614
|
+
fastest: {
|
|
3615
|
+
label: "Priority",
|
|
3616
|
+
value: "10",
|
|
3617
|
+
unit: "sat/byte",
|
|
3618
|
+
description: "High priority - next block",
|
|
3619
|
+
estimatedTime: "~5 minutes",
|
|
3620
|
+
priority: "high"
|
|
3621
|
+
},
|
|
3622
|
+
networkId,
|
|
3623
|
+
networkType: "UTXO",
|
|
3624
|
+
raw: { hardcoded: true, reason: "Dash API timeout, using conservative fallback fees" }
|
|
3625
|
+
};
|
|
3626
|
+
}
|
|
3627
|
+
} else {
|
|
3628
|
+
feeResponse = await (pioneer.GetFeeRateByNetwork ? pioneer.GetFeeRateByNetwork({ networkId }) : pioneer.GetFeeRate({ networkId }));
|
|
3629
|
+
}
|
|
3445
3630
|
if (!feeResponse || !feeResponse.data) {
|
|
3446
3631
|
throw new Error(`No fee data returned for ${networkId}`);
|
|
3447
3632
|
}
|
|
3448
3633
|
const feeData = feeResponse.data;
|
|
3449
3634
|
console.log(tag5, "Raw fee data:", feeData);
|
|
3450
|
-
if (feeData.success === false || feeData.error) {
|
|
3451
|
-
throw new Error(feeData.error || `API error for ${networkId}`);
|
|
3452
|
-
}
|
|
3453
3635
|
const networkName = getNetworkName(networkId);
|
|
3454
3636
|
let normalizedFees = normalizeFeeData(feeData, networkType, networkName, networkId);
|
|
3455
3637
|
normalizedFees = ensureFeeDifferentiation(normalizedFees, networkType);
|
|
@@ -3655,7 +3837,7 @@ function getCosmosFees(networkId) {
|
|
|
3655
3837
|
const networkName = getNetworkName(networkId);
|
|
3656
3838
|
const cosmosFeesMap = {
|
|
3657
3839
|
"cosmos:thorchain-mainnet-v1": { base: 0.02, unit: "RUNE", denom: "rune" },
|
|
3658
|
-
"cosmos:mayachain-mainnet-v1": { base: 0.
|
|
3840
|
+
"cosmos:mayachain-mainnet-v1": { base: 0.5, unit: "CACAO", denom: "cacao" },
|
|
3659
3841
|
"cosmos:cosmoshub-4": { base: 0.005, unit: "ATOM", denom: "uatom" },
|
|
3660
3842
|
"cosmos:osmosis-1": { base: 0.035, unit: "OSMO", denom: "uosmo" }
|
|
3661
3843
|
};
|
|
@@ -3693,39 +3875,6 @@ function getCosmosFees(networkId) {
|
|
|
3693
3875
|
raw: { hardcoded: true, base: feeConfig.base, unit: feeConfig.unit, denom: feeConfig.denom }
|
|
3694
3876
|
};
|
|
3695
3877
|
}
|
|
3696
|
-
function getRippleFees(networkId) {
|
|
3697
|
-
const networkName = getNetworkName(networkId);
|
|
3698
|
-
const baseFee = "0.00001";
|
|
3699
|
-
return {
|
|
3700
|
-
slow: {
|
|
3701
|
-
label: "Standard",
|
|
3702
|
-
value: baseFee,
|
|
3703
|
-
unit: "XRP",
|
|
3704
|
-
description: `Fixed network fee for ${networkName}. All transactions use the same fee.`,
|
|
3705
|
-
estimatedTime: "~4 seconds",
|
|
3706
|
-
priority: "low"
|
|
3707
|
-
},
|
|
3708
|
-
average: {
|
|
3709
|
-
label: "Standard",
|
|
3710
|
-
value: baseFee,
|
|
3711
|
-
unit: "XRP",
|
|
3712
|
-
description: `Fixed network fee for ${networkName}. All transactions use the same fee.`,
|
|
3713
|
-
estimatedTime: "~4 seconds",
|
|
3714
|
-
priority: "medium"
|
|
3715
|
-
},
|
|
3716
|
-
fastest: {
|
|
3717
|
-
label: "Standard",
|
|
3718
|
-
value: baseFee,
|
|
3719
|
-
unit: "XRP",
|
|
3720
|
-
description: `Fixed network fee for ${networkName}. All transactions use the same fee.`,
|
|
3721
|
-
estimatedTime: "~4 seconds",
|
|
3722
|
-
priority: "high"
|
|
3723
|
-
},
|
|
3724
|
-
networkId,
|
|
3725
|
-
networkType: "RIPPLE",
|
|
3726
|
-
raw: { hardcoded: true, baseFee, reason: "Ripple uses fixed network fees" }
|
|
3727
|
-
};
|
|
3728
|
-
}
|
|
3729
3878
|
function getFallbackFees(networkId) {
|
|
3730
3879
|
const networkType = getNetworkType(networkId);
|
|
3731
3880
|
const networkName = getNetworkName(networkId);
|
|
@@ -3799,9 +3948,10 @@ function estimateTransactionFee(feeRate, unit, networkType, txSize) {
|
|
|
3799
3948
|
}
|
|
3800
3949
|
}
|
|
3801
3950
|
|
|
3802
|
-
// src/
|
|
3951
|
+
// src/index.ts
|
|
3952
|
+
var TAG7 = " | Pioneer-sdk | ";
|
|
3803
3953
|
async function detectKkApiAvailability(forceLocalhost) {
|
|
3804
|
-
const tag5 =
|
|
3954
|
+
const tag5 = `${TAG7} | detectKkApiAvailability | `;
|
|
3805
3955
|
try {
|
|
3806
3956
|
const isTauri = typeof window !== "undefined" && "__TAURI__" in window;
|
|
3807
3957
|
const isBrowser = typeof window !== "undefined";
|
|
@@ -3848,8 +3998,6 @@ async function detectKkApiAvailability(forceLocalhost) {
|
|
|
3848
3998
|
};
|
|
3849
3999
|
}
|
|
3850
4000
|
}
|
|
3851
|
-
|
|
3852
|
-
// src/utils/format-time.ts
|
|
3853
4001
|
function formatTime(durationMs) {
|
|
3854
4002
|
let seconds = Math.floor(durationMs / 1000 % 60);
|
|
3855
4003
|
let minutes = Math.floor(durationMs / (1000 * 60) % 60);
|
|
@@ -3863,150 +4011,6 @@ function formatTime(durationMs) {
|
|
|
3863
4011
|
return formatted.trim();
|
|
3864
4012
|
}
|
|
3865
4013
|
|
|
3866
|
-
// src/utils/build-dashboard.ts
|
|
3867
|
-
import { caipToNetworkId as caipToNetworkId6, networkIdToCaip } from "@pioneer-platform/pioneer-caip";
|
|
3868
|
-
var TAG7 = " | build-dashboard | ";
|
|
3869
|
-
function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
3870
|
-
console.log(TAG7, "[DASHBOARD] Building dashboard from cached balances...");
|
|
3871
|
-
const dashboardData = {
|
|
3872
|
-
networks: [],
|
|
3873
|
-
totalValueUsd: 0,
|
|
3874
|
-
networkPercentages: []
|
|
3875
|
-
};
|
|
3876
|
-
let totalPortfolioValue = 0;
|
|
3877
|
-
const networksTemp = [];
|
|
3878
|
-
console.log(TAG7, "balances: ", balances);
|
|
3879
|
-
for (const blockchain of blockchains) {
|
|
3880
|
-
const filteredBalances = balances.filter((b3) => {
|
|
3881
|
-
const networkId = caipToNetworkId6(b3.caip);
|
|
3882
|
-
return networkId === blockchain || blockchain === "eip155:*" && networkId.startsWith("eip155:");
|
|
3883
|
-
});
|
|
3884
|
-
const balanceMap = new Map;
|
|
3885
|
-
const isBitcoin = blockchain.includes("bip122:000000000019d6689c085ae165831e93");
|
|
3886
|
-
if (isBitcoin) {
|
|
3887
|
-
console.log(TAG7, "Bitcoin network detected - checking for duplicate balances");
|
|
3888
|
-
const bitcoinByValue = new Map;
|
|
3889
|
-
filteredBalances.forEach((balance) => {
|
|
3890
|
-
const valueKey = `${balance.balance}_${balance.valueUsd}`;
|
|
3891
|
-
if (!bitcoinByValue.has(valueKey)) {
|
|
3892
|
-
bitcoinByValue.set(valueKey, []);
|
|
3893
|
-
}
|
|
3894
|
-
bitcoinByValue.get(valueKey).push(balance);
|
|
3895
|
-
});
|
|
3896
|
-
for (const [valueKey, balances2] of bitcoinByValue.entries()) {
|
|
3897
|
-
if (balances2.length === 3 && parseFloat(balances2[0].valueUsd || "0") > 0) {
|
|
3898
|
-
console.log(TAG7, "BITCOIN API BUG DETECTED: All 3 address types have same balance, keeping only xpub");
|
|
3899
|
-
const xpubBalance = balances2.find((b3) => b3.pubkey?.startsWith("xpub")) || balances2[0];
|
|
3900
|
-
const key = `${xpubBalance.caip}_${xpubBalance.pubkey || "default"}`;
|
|
3901
|
-
balanceMap.set(key, xpubBalance);
|
|
3902
|
-
} else {
|
|
3903
|
-
balances2.forEach((balance) => {
|
|
3904
|
-
const key = `${balance.caip}_${balance.pubkey || "default"}`;
|
|
3905
|
-
balanceMap.set(key, balance);
|
|
3906
|
-
});
|
|
3907
|
-
}
|
|
3908
|
-
}
|
|
3909
|
-
} else {
|
|
3910
|
-
filteredBalances.forEach((balance) => {
|
|
3911
|
-
const key = `${balance.caip}_${balance.pubkey || "default"}`;
|
|
3912
|
-
if (!balanceMap.has(key) || parseFloat(balance.valueUsd || "0") > parseFloat(balanceMap.get(key).valueUsd || "0")) {
|
|
3913
|
-
balanceMap.set(key, balance);
|
|
3914
|
-
}
|
|
3915
|
-
});
|
|
3916
|
-
}
|
|
3917
|
-
const networkBalances = Array.from(balanceMap.values());
|
|
3918
|
-
const networkTotal = networkBalances.reduce((sum, balance, idx) => {
|
|
3919
|
-
const valueUsd = typeof balance.valueUsd === "string" ? parseFloat(balance.valueUsd) : balance.valueUsd || 0;
|
|
3920
|
-
if (blockchain.includes("bip122:000000000019d6689c085ae165831e93")) {
|
|
3921
|
-
console.log(TAG7, `[BITCOIN DEBUG ${idx}] pubkey:`, balance.pubkey?.substring(0, 10) + "...", "| balance:", balance.balance, "| valueUsd:", balance.valueUsd, "→ parsed:", valueUsd, "| running sum:", sum + valueUsd);
|
|
3922
|
-
}
|
|
3923
|
-
return sum + valueUsd;
|
|
3924
|
-
}, 0);
|
|
3925
|
-
const nativeAssetCaip = networkIdToCaip(blockchain);
|
|
3926
|
-
const gasAsset = networkBalances.find((b3) => b3.caip === nativeAssetCaip);
|
|
3927
|
-
const totalNativeBalance = networkBalances.filter((b3) => b3.caip === nativeAssetCaip).reduce((sum, balance) => {
|
|
3928
|
-
const balanceNum = typeof balance.balance === "string" ? parseFloat(balance.balance) : balance.balance || 0;
|
|
3929
|
-
return sum + balanceNum;
|
|
3930
|
-
}, 0).toString();
|
|
3931
|
-
const assetInfo = nativeAssetCaip ? assetsMap.get(nativeAssetCaip) : null;
|
|
3932
|
-
networksTemp.push({
|
|
3933
|
-
networkId: blockchain,
|
|
3934
|
-
totalValueUsd: networkTotal,
|
|
3935
|
-
gasAssetCaip: nativeAssetCaip || null,
|
|
3936
|
-
gasAssetSymbol: gasAsset?.ticker || gasAsset?.symbol || assetInfo?.symbol || null,
|
|
3937
|
-
icon: gasAsset?.icon || assetInfo?.icon || null,
|
|
3938
|
-
color: gasAsset?.color || assetInfo?.color || null,
|
|
3939
|
-
totalNativeBalance
|
|
3940
|
-
});
|
|
3941
|
-
totalPortfolioValue += networkTotal;
|
|
3942
|
-
}
|
|
3943
|
-
dashboardData.networks = networksTemp.sort((a2, b3) => b3.totalValueUsd - a2.totalValueUsd);
|
|
3944
|
-
dashboardData.totalValueUsd = totalPortfolioValue;
|
|
3945
|
-
dashboardData.networkPercentages = dashboardData.networks.map((network) => ({
|
|
3946
|
-
networkId: network.networkId,
|
|
3947
|
-
percentage: totalPortfolioValue > 0 ? Number((network.totalValueUsd / totalPortfolioValue * 100).toFixed(2)) : 0
|
|
3948
|
-
})).filter((entry) => entry.percentage > 0);
|
|
3949
|
-
console.log(`[FAST DASHBOARD] ✅ Built dashboard: ${dashboardData.networks.length} networks, $${totalPortfolioValue.toFixed(2)} total`);
|
|
3950
|
-
return dashboardData;
|
|
3951
|
-
}
|
|
3952
|
-
|
|
3953
|
-
// src/utils/pubkey-helpers.ts
|
|
3954
|
-
function getPubkeyKey(pubkey) {
|
|
3955
|
-
return `${pubkey.pubkey}_${pubkey.pathMaster}`;
|
|
3956
|
-
}
|
|
3957
|
-
function deduplicatePubkeys(pubkeys) {
|
|
3958
|
-
const seen = new Set;
|
|
3959
|
-
const deduped = pubkeys.filter((pubkey) => {
|
|
3960
|
-
const key = getPubkeyKey(pubkey);
|
|
3961
|
-
if (seen.has(key)) {
|
|
3962
|
-
return false;
|
|
3963
|
-
}
|
|
3964
|
-
seen.add(key);
|
|
3965
|
-
return true;
|
|
3966
|
-
});
|
|
3967
|
-
return deduped;
|
|
3968
|
-
}
|
|
3969
|
-
function validatePubkey(pubkey) {
|
|
3970
|
-
return !!(pubkey.pubkey && pubkey.pathMaster);
|
|
3971
|
-
}
|
|
3972
|
-
|
|
3973
|
-
class PubkeyManager {
|
|
3974
|
-
pubkeys = [];
|
|
3975
|
-
pubkeySet = new Set;
|
|
3976
|
-
addPubkey(pubkey) {
|
|
3977
|
-
if (!validatePubkey(pubkey)) {
|
|
3978
|
-
return false;
|
|
3979
|
-
}
|
|
3980
|
-
const key = getPubkeyKey(pubkey);
|
|
3981
|
-
if (this.pubkeySet.has(key)) {
|
|
3982
|
-
return false;
|
|
3983
|
-
}
|
|
3984
|
-
this.pubkeys.push(pubkey);
|
|
3985
|
-
this.pubkeySet.add(key);
|
|
3986
|
-
return true;
|
|
3987
|
-
}
|
|
3988
|
-
setPubkeys(newPubkeys) {
|
|
3989
|
-
this.pubkeys = [];
|
|
3990
|
-
this.pubkeySet.clear();
|
|
3991
|
-
let added = 0;
|
|
3992
|
-
for (const pubkey of newPubkeys) {
|
|
3993
|
-
if (this.addPubkey(pubkey)) {
|
|
3994
|
-
added++;
|
|
3995
|
-
}
|
|
3996
|
-
}
|
|
3997
|
-
}
|
|
3998
|
-
getPubkeys() {
|
|
3999
|
-
return this.pubkeys;
|
|
4000
|
-
}
|
|
4001
|
-
clear() {
|
|
4002
|
-
this.pubkeys = [];
|
|
4003
|
-
this.pubkeySet.clear();
|
|
4004
|
-
}
|
|
4005
|
-
}
|
|
4006
|
-
|
|
4007
|
-
// src/index.ts
|
|
4008
|
-
var TAG8 = " | Pioneer-sdk | ";
|
|
4009
|
-
|
|
4010
4014
|
class SDK {
|
|
4011
4015
|
status;
|
|
4012
4016
|
username;
|
|
@@ -4030,7 +4034,7 @@ class SDK {
|
|
|
4030
4034
|
charts;
|
|
4031
4035
|
paths;
|
|
4032
4036
|
pubkeys = [];
|
|
4033
|
-
|
|
4037
|
+
pubkeySet = new Set;
|
|
4034
4038
|
wallets;
|
|
4035
4039
|
balances;
|
|
4036
4040
|
nodes;
|
|
@@ -4107,11 +4111,10 @@ class SDK {
|
|
|
4107
4111
|
if (config.blockchains && config.blockchains.length !== this.blockchains.length) {
|
|
4108
4112
|
}
|
|
4109
4113
|
if (config.pubkeys && config.pubkeys.length > 0) {
|
|
4110
|
-
this.
|
|
4111
|
-
this.pubkeys = this.pubkeyManager.getPubkeys();
|
|
4114
|
+
this.setPubkeys(config.pubkeys);
|
|
4112
4115
|
} else {
|
|
4113
4116
|
this.pubkeys = [];
|
|
4114
|
-
this.
|
|
4117
|
+
this.pubkeySet.clear();
|
|
4115
4118
|
}
|
|
4116
4119
|
this.balances = config.balances || [];
|
|
4117
4120
|
this.nodes = config.nodes || [];
|
|
@@ -4127,7 +4130,7 @@ class SDK {
|
|
|
4127
4130
|
this.outboundBlockchainContext = null;
|
|
4128
4131
|
this.outboundPubkeyContext = null;
|
|
4129
4132
|
this.wallets = [];
|
|
4130
|
-
this.events = new
|
|
4133
|
+
this.events = new A;
|
|
4131
4134
|
this.transactions = null;
|
|
4132
4135
|
this.ethplorerApiKey = config.ethplorerApiKey;
|
|
4133
4136
|
this.covalentApiKey = config.covalentApiKey;
|
|
@@ -4142,21 +4145,46 @@ class SDK {
|
|
|
4142
4145
|
this.pairWallet = async (options) => {
|
|
4143
4146
|
return Promise.resolve({});
|
|
4144
4147
|
};
|
|
4145
|
-
this.getPubkeyKey =
|
|
4146
|
-
|
|
4148
|
+
this.getPubkeyKey = (pubkey) => {
|
|
4149
|
+
return `${pubkey.pubkey}_${pubkey.pathMaster}`;
|
|
4150
|
+
};
|
|
4151
|
+
this.deduplicatePubkeys = (pubkeys) => {
|
|
4152
|
+
const seen = new Set;
|
|
4153
|
+
const deduped = pubkeys.filter((pubkey) => {
|
|
4154
|
+
const key = this.getPubkeyKey(pubkey);
|
|
4155
|
+
if (seen.has(key)) {
|
|
4156
|
+
return false;
|
|
4157
|
+
}
|
|
4158
|
+
seen.add(key);
|
|
4159
|
+
return true;
|
|
4160
|
+
});
|
|
4161
|
+
return deduped;
|
|
4162
|
+
};
|
|
4147
4163
|
this.addPubkey = (pubkey) => {
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4164
|
+
if (!pubkey.pubkey || !pubkey.pathMaster) {
|
|
4165
|
+
return false;
|
|
4166
|
+
}
|
|
4167
|
+
const key = this.getPubkeyKey(pubkey);
|
|
4168
|
+
if (this.pubkeySet.has(key)) {
|
|
4169
|
+
return false;
|
|
4151
4170
|
}
|
|
4152
|
-
|
|
4171
|
+
this.pubkeys.push(pubkey);
|
|
4172
|
+
this.pubkeySet.add(key);
|
|
4173
|
+
return true;
|
|
4153
4174
|
};
|
|
4154
4175
|
this.setPubkeys = (newPubkeys) => {
|
|
4155
|
-
|
|
4156
|
-
this.pubkeys =
|
|
4176
|
+
const tag5 = `${TAG7} | setPubkeys | `;
|
|
4177
|
+
this.pubkeys = [];
|
|
4178
|
+
this.pubkeySet.clear();
|
|
4179
|
+
let added = 0;
|
|
4180
|
+
for (const pubkey of newPubkeys) {
|
|
4181
|
+
if (this.addPubkey(pubkey)) {
|
|
4182
|
+
added++;
|
|
4183
|
+
}
|
|
4184
|
+
}
|
|
4157
4185
|
};
|
|
4158
4186
|
this.getUnifiedPortfolio = async function() {
|
|
4159
|
-
const tag5 = `${
|
|
4187
|
+
const tag5 = `${TAG7} | getUnifiedPortfolio | `;
|
|
4160
4188
|
try {
|
|
4161
4189
|
const startTime = performance.now();
|
|
4162
4190
|
try {
|
|
@@ -4188,9 +4216,8 @@ class SDK {
|
|
|
4188
4216
|
this.events.emit("SET_BALANCES", this.balances);
|
|
4189
4217
|
}
|
|
4190
4218
|
if (portfolioData.pubkeys && portfolioData.pubkeys.length > 0) {
|
|
4191
|
-
const convertedPubkeys = portfolioData.pubkeys;
|
|
4192
|
-
this.
|
|
4193
|
-
this.pubkeys = this.pubkeyManager.getPubkeys();
|
|
4219
|
+
const convertedPubkeys = this.convertVaultPubkeysToPioneerFormat(portfolioData.pubkeys);
|
|
4220
|
+
this.setPubkeys(convertedPubkeys);
|
|
4194
4221
|
this.events.emit("SET_PUBKEYS", this.pubkeys);
|
|
4195
4222
|
}
|
|
4196
4223
|
if (portfolioData.devices && portfolioData.devices.length > 0) {
|
|
@@ -4240,7 +4267,7 @@ class SDK {
|
|
|
4240
4267
|
this.events.emit("SET_DASHBOARD", this.dashboard);
|
|
4241
4268
|
} else {
|
|
4242
4269
|
console.warn("[CACHE VALIDATION] ❌ Cache data corrupted, building dashboard from cached balances");
|
|
4243
|
-
const dashboardData = buildDashboardFromBalances(
|
|
4270
|
+
const dashboardData = this.buildDashboardFromBalances();
|
|
4244
4271
|
this.dashboard = dashboardData;
|
|
4245
4272
|
this.events.emit("SET_DASHBOARD", this.dashboard);
|
|
4246
4273
|
}
|
|
@@ -4265,7 +4292,7 @@ class SDK {
|
|
|
4265
4292
|
}
|
|
4266
4293
|
};
|
|
4267
4294
|
this.init = async function(walletsVerbose, setup) {
|
|
4268
|
-
const tag5 = `${
|
|
4295
|
+
const tag5 = `${TAG7} | init | `;
|
|
4269
4296
|
try {
|
|
4270
4297
|
if (!this.username)
|
|
4271
4298
|
throw Error("username required!");
|
|
@@ -4282,7 +4309,7 @@ class SDK {
|
|
|
4282
4309
|
const pioneerConfig = {
|
|
4283
4310
|
...config
|
|
4284
4311
|
};
|
|
4285
|
-
const PioneerClient = new import_pioneer_client.
|
|
4312
|
+
const PioneerClient = new import_pioneer_client.default(this.spec, pioneerConfig);
|
|
4286
4313
|
this.pioneer = await PioneerClient.init();
|
|
4287
4314
|
if (!this.pioneer)
|
|
4288
4315
|
throw Error("Failed to init pioneer server!");
|
|
@@ -4352,11 +4379,92 @@ class SDK {
|
|
|
4352
4379
|
throw e;
|
|
4353
4380
|
}
|
|
4354
4381
|
};
|
|
4355
|
-
this.buildDashboardFromBalances = ()
|
|
4356
|
-
|
|
4382
|
+
this.buildDashboardFromBalances = function() {
|
|
4383
|
+
const tag5 = `${TAG7} | buildDashboardFromBalances | `;
|
|
4384
|
+
console.log(tag5, "[DASHBOARD] Building dashboard from cached balances...");
|
|
4385
|
+
const dashboardData = {
|
|
4386
|
+
networks: [],
|
|
4387
|
+
totalValueUsd: 0,
|
|
4388
|
+
networkPercentages: []
|
|
4389
|
+
};
|
|
4390
|
+
let totalPortfolioValue = 0;
|
|
4391
|
+
const networksTemp = [];
|
|
4392
|
+
console.log(tag5, "this.balances: ", this.balances);
|
|
4393
|
+
for (const blockchain of this.blockchains) {
|
|
4394
|
+
const filteredBalances = this.balances.filter((b3) => {
|
|
4395
|
+
const networkId = caipToNetworkId6(b3.caip);
|
|
4396
|
+
return networkId === blockchain || blockchain === "eip155:*" && networkId.startsWith("eip155:");
|
|
4397
|
+
});
|
|
4398
|
+
const balanceMap = new Map;
|
|
4399
|
+
const isBitcoin = blockchain.includes("bip122:000000000019d6689c085ae165831e93");
|
|
4400
|
+
if (isBitcoin) {
|
|
4401
|
+
console.log(tag5, "Bitcoin network detected - checking for duplicate balances");
|
|
4402
|
+
const bitcoinByValue = new Map;
|
|
4403
|
+
filteredBalances.forEach((balance) => {
|
|
4404
|
+
const valueKey = `${balance.balance}_${balance.valueUsd}`;
|
|
4405
|
+
if (!bitcoinByValue.has(valueKey)) {
|
|
4406
|
+
bitcoinByValue.set(valueKey, []);
|
|
4407
|
+
}
|
|
4408
|
+
bitcoinByValue.get(valueKey).push(balance);
|
|
4409
|
+
});
|
|
4410
|
+
for (const [valueKey, balances] of bitcoinByValue.entries()) {
|
|
4411
|
+
if (balances.length === 3 && parseFloat(balances[0].valueUsd || "0") > 0) {
|
|
4412
|
+
console.log(tag5, "BITCOIN API BUG DETECTED: All 3 address types have same balance, keeping only xpub");
|
|
4413
|
+
const xpubBalance = balances.find((b3) => b3.pubkey?.startsWith("xpub")) || balances[0];
|
|
4414
|
+
const key = `${xpubBalance.caip}_${xpubBalance.pubkey || "default"}`;
|
|
4415
|
+
balanceMap.set(key, xpubBalance);
|
|
4416
|
+
} else {
|
|
4417
|
+
balances.forEach((balance) => {
|
|
4418
|
+
const key = `${balance.caip}_${balance.pubkey || "default"}`;
|
|
4419
|
+
balanceMap.set(key, balance);
|
|
4420
|
+
});
|
|
4421
|
+
}
|
|
4422
|
+
}
|
|
4423
|
+
} else {
|
|
4424
|
+
filteredBalances.forEach((balance) => {
|
|
4425
|
+
const key = `${balance.caip}_${balance.pubkey || "default"}`;
|
|
4426
|
+
if (!balanceMap.has(key) || parseFloat(balance.valueUsd || "0") > parseFloat(balanceMap.get(key).valueUsd || "0")) {
|
|
4427
|
+
balanceMap.set(key, balance);
|
|
4428
|
+
}
|
|
4429
|
+
});
|
|
4430
|
+
}
|
|
4431
|
+
const networkBalances = Array.from(balanceMap.values());
|
|
4432
|
+
const networkTotal = networkBalances.reduce((sum, balance, idx) => {
|
|
4433
|
+
const valueUsd = typeof balance.valueUsd === "string" ? parseFloat(balance.valueUsd) : balance.valueUsd || 0;
|
|
4434
|
+
if (blockchain.includes("bip122:000000000019d6689c085ae165831e93")) {
|
|
4435
|
+
console.log(tag5, `[BITCOIN DEBUG ${idx}] pubkey:`, balance.pubkey?.substring(0, 10) + "...", "| balance:", balance.balance, "| valueUsd:", balance.valueUsd, "→ parsed:", valueUsd, "| running sum:", sum + valueUsd);
|
|
4436
|
+
}
|
|
4437
|
+
return sum + valueUsd;
|
|
4438
|
+
}, 0);
|
|
4439
|
+
const nativeAssetCaip = networkIdToCaip(blockchain);
|
|
4440
|
+
const gasAsset = networkBalances.find((b3) => b3.caip === nativeAssetCaip);
|
|
4441
|
+
const totalNativeBalance = networkBalances.filter((b3) => b3.caip === nativeAssetCaip).reduce((sum, balance) => {
|
|
4442
|
+
const balanceNum = typeof balance.balance === "string" ? parseFloat(balance.balance) : balance.balance || 0;
|
|
4443
|
+
return sum + balanceNum;
|
|
4444
|
+
}, 0).toString();
|
|
4445
|
+
const assetInfo = nativeAssetCaip ? this.assetsMap.get(nativeAssetCaip) : null;
|
|
4446
|
+
networksTemp.push({
|
|
4447
|
+
networkId: blockchain,
|
|
4448
|
+
totalValueUsd: networkTotal,
|
|
4449
|
+
gasAssetCaip: nativeAssetCaip || null,
|
|
4450
|
+
gasAssetSymbol: gasAsset?.ticker || gasAsset?.symbol || assetInfo?.symbol || null,
|
|
4451
|
+
icon: gasAsset?.icon || assetInfo?.icon || null,
|
|
4452
|
+
color: gasAsset?.color || assetInfo?.color || null,
|
|
4453
|
+
totalNativeBalance
|
|
4454
|
+
});
|
|
4455
|
+
totalPortfolioValue += networkTotal;
|
|
4456
|
+
}
|
|
4457
|
+
dashboardData.networks = networksTemp.sort((a2, b3) => b3.totalValueUsd - a2.totalValueUsd);
|
|
4458
|
+
dashboardData.totalValueUsd = totalPortfolioValue;
|
|
4459
|
+
dashboardData.networkPercentages = dashboardData.networks.map((network) => ({
|
|
4460
|
+
networkId: network.networkId,
|
|
4461
|
+
percentage: totalPortfolioValue > 0 ? Number((network.totalValueUsd / totalPortfolioValue * 100).toFixed(2)) : 0
|
|
4462
|
+
})).filter((entry) => entry.percentage > 0);
|
|
4463
|
+
console.log(`[FAST DASHBOARD] ✅ Built dashboard: ${dashboardData.networks.length} networks, $${totalPortfolioValue.toFixed(2)} total`);
|
|
4464
|
+
return dashboardData;
|
|
4357
4465
|
};
|
|
4358
4466
|
this.syncMarket = async function() {
|
|
4359
|
-
const tag5 = `${
|
|
4467
|
+
const tag5 = `${TAG7} | syncMarket | `;
|
|
4360
4468
|
try {
|
|
4361
4469
|
const invalidBalances = this.balances.filter((b3) => !b3 || !b3.caip || typeof b3.caip !== "string" || !b3.caip.includes(":"));
|
|
4362
4470
|
if (invalidBalances.length > 0) {
|
|
@@ -4407,7 +4515,7 @@ class SDK {
|
|
|
4407
4515
|
}
|
|
4408
4516
|
};
|
|
4409
4517
|
this.sync = async function() {
|
|
4410
|
-
const tag5 = `${
|
|
4518
|
+
const tag5 = `${TAG7} | sync | `;
|
|
4411
4519
|
try {
|
|
4412
4520
|
const matchesNetwork = (item, networkId) => {
|
|
4413
4521
|
if (!item.networks || !Array.isArray(item.networks))
|
|
@@ -4462,7 +4570,7 @@ class SDK {
|
|
|
4462
4570
|
console.log(tag5, "uniqueBlockchains: ", uniqueBlockchains);
|
|
4463
4571
|
for (const blockchain of uniqueBlockchains) {
|
|
4464
4572
|
const filteredBalances = this.balances.filter((b3) => {
|
|
4465
|
-
const networkId =
|
|
4573
|
+
const networkId = caipToNetworkId6(b3.caip);
|
|
4466
4574
|
return networkId === blockchain || blockchain === "eip155:*" && networkId.startsWith("eip155:");
|
|
4467
4575
|
});
|
|
4468
4576
|
console.log(tag5, `Filtering for blockchain: ${blockchain}`);
|
|
@@ -4520,7 +4628,7 @@ class SDK {
|
|
|
4520
4628
|
return sum + valueUsd;
|
|
4521
4629
|
}, 0);
|
|
4522
4630
|
console.log("Final networkTotal:", networkTotal);
|
|
4523
|
-
const nativeAssetCaip =
|
|
4631
|
+
const nativeAssetCaip = networkIdToCaip(blockchain);
|
|
4524
4632
|
const gasAsset = networkBalances.find((b3) => b3.caip === nativeAssetCaip);
|
|
4525
4633
|
const totalNativeBalance = networkBalances.filter((b3) => b3.caip === nativeAssetCaip).reduce((sum, balance) => {
|
|
4526
4634
|
const balanceNum = typeof balance.balance === "string" ? parseFloat(balance.balance) : balance.balance || 0;
|
|
@@ -4560,7 +4668,7 @@ class SDK {
|
|
|
4560
4668
|
}
|
|
4561
4669
|
};
|
|
4562
4670
|
this.buildTx = async function(sendPayload) {
|
|
4563
|
-
let tag5 =
|
|
4671
|
+
let tag5 = TAG7 + " | buildTx | ";
|
|
4564
4672
|
try {
|
|
4565
4673
|
const transactionDependencies = {
|
|
4566
4674
|
context: this.context,
|
|
@@ -4568,6 +4676,7 @@ class SDK {
|
|
|
4568
4676
|
balances: this.balances,
|
|
4569
4677
|
pioneer: this.pioneer,
|
|
4570
4678
|
pubkeys: this.pubkeys,
|
|
4679
|
+
pubkeyContext: this.pubkeyContext,
|
|
4571
4680
|
nodes: this.nodes,
|
|
4572
4681
|
keepKeySdk: this.keepKeySdk
|
|
4573
4682
|
};
|
|
@@ -4581,13 +4690,13 @@ class SDK {
|
|
|
4581
4690
|
}
|
|
4582
4691
|
};
|
|
4583
4692
|
this.buildDelegateTx = async function(caip, params) {
|
|
4584
|
-
let tag5 =
|
|
4693
|
+
let tag5 = TAG7 + " | buildDelegateTx | ";
|
|
4585
4694
|
try {
|
|
4586
4695
|
const delegateParams = {
|
|
4587
4696
|
...params,
|
|
4588
4697
|
type: "delegate"
|
|
4589
4698
|
};
|
|
4590
|
-
let unsignedTx = await createUnsignedStakingTx(caip, delegateParams, this.pubkeys, this.pioneer, this.
|
|
4699
|
+
let unsignedTx = await createUnsignedStakingTx(caip, delegateParams, this.pubkeys, this.pioneer, this.pubkeyContext);
|
|
4591
4700
|
console.log(tag5, "unsignedTx: ", unsignedTx);
|
|
4592
4701
|
return unsignedTx;
|
|
4593
4702
|
} catch (e) {
|
|
@@ -4596,13 +4705,13 @@ class SDK {
|
|
|
4596
4705
|
}
|
|
4597
4706
|
};
|
|
4598
4707
|
this.buildUndelegateTx = async function(caip, params) {
|
|
4599
|
-
let tag5 =
|
|
4708
|
+
let tag5 = TAG7 + " | buildUndelegateTx | ";
|
|
4600
4709
|
try {
|
|
4601
4710
|
const undelegateParams = {
|
|
4602
4711
|
...params,
|
|
4603
4712
|
type: "undelegate"
|
|
4604
4713
|
};
|
|
4605
|
-
let unsignedTx = await createUnsignedStakingTx(caip, undelegateParams, this.pubkeys, this.pioneer, this.
|
|
4714
|
+
let unsignedTx = await createUnsignedStakingTx(caip, undelegateParams, this.pubkeys, this.pioneer, this.pubkeyContext);
|
|
4606
4715
|
console.log(tag5, "unsignedTx: ", unsignedTx);
|
|
4607
4716
|
return unsignedTx;
|
|
4608
4717
|
} catch (e) {
|
|
@@ -4611,13 +4720,13 @@ class SDK {
|
|
|
4611
4720
|
}
|
|
4612
4721
|
};
|
|
4613
4722
|
this.buildClaimRewardsTx = async function(caip, params) {
|
|
4614
|
-
let tag5 =
|
|
4723
|
+
let tag5 = TAG7 + " | buildClaimRewardsTx | ";
|
|
4615
4724
|
try {
|
|
4616
4725
|
const claimParams = {
|
|
4617
4726
|
...params,
|
|
4618
4727
|
type: "claim_rewards"
|
|
4619
4728
|
};
|
|
4620
|
-
let unsignedTx = await createUnsignedStakingTx(caip, claimParams, this.pubkeys, this.pioneer, this.
|
|
4729
|
+
let unsignedTx = await createUnsignedStakingTx(caip, claimParams, this.pubkeys, this.pioneer, this.pubkeyContext);
|
|
4621
4730
|
console.log(tag5, "unsignedTx: ", unsignedTx);
|
|
4622
4731
|
return unsignedTx;
|
|
4623
4732
|
} catch (e) {
|
|
@@ -4626,13 +4735,13 @@ class SDK {
|
|
|
4626
4735
|
}
|
|
4627
4736
|
};
|
|
4628
4737
|
this.buildClaimAllRewardsTx = async function(caip, params) {
|
|
4629
|
-
let tag5 =
|
|
4738
|
+
let tag5 = TAG7 + " | buildClaimAllRewardsTx | ";
|
|
4630
4739
|
try {
|
|
4631
4740
|
const claimAllParams = {
|
|
4632
4741
|
...params,
|
|
4633
4742
|
type: "claim_all_rewards"
|
|
4634
4743
|
};
|
|
4635
|
-
let unsignedTx = await createUnsignedStakingTx(caip, claimAllParams, this.pubkeys, this.pioneer, this.
|
|
4744
|
+
let unsignedTx = await createUnsignedStakingTx(caip, claimAllParams, this.pubkeys, this.pioneer, this.pubkeyContext);
|
|
4636
4745
|
return unsignedTx;
|
|
4637
4746
|
} catch (e) {
|
|
4638
4747
|
console.error(e);
|
|
@@ -4640,7 +4749,7 @@ class SDK {
|
|
|
4640
4749
|
}
|
|
4641
4750
|
};
|
|
4642
4751
|
this.signTx = async function(unsignedTx) {
|
|
4643
|
-
let tag5 =
|
|
4752
|
+
let tag5 = TAG7 + " | signTx | ";
|
|
4644
4753
|
try {
|
|
4645
4754
|
const transactionDependencies = {
|
|
4646
4755
|
context: this.context,
|
|
@@ -4648,6 +4757,7 @@ class SDK {
|
|
|
4648
4757
|
balances: this.balances,
|
|
4649
4758
|
pioneer: this.pioneer,
|
|
4650
4759
|
pubkeys: this.pubkeys,
|
|
4760
|
+
pubkeyContext: this.pubkeyContext,
|
|
4651
4761
|
nodes: this.nodes,
|
|
4652
4762
|
keepKeySdk: this.keepKeySdk
|
|
4653
4763
|
};
|
|
@@ -4660,7 +4770,7 @@ class SDK {
|
|
|
4660
4770
|
}
|
|
4661
4771
|
};
|
|
4662
4772
|
this.broadcastTx = async function(caip, signedTx) {
|
|
4663
|
-
let tag5 =
|
|
4773
|
+
let tag5 = TAG7 + " | broadcastTx | ";
|
|
4664
4774
|
try {
|
|
4665
4775
|
const transactionDependencies = {
|
|
4666
4776
|
context: this.context,
|
|
@@ -4673,7 +4783,7 @@ class SDK {
|
|
|
4673
4783
|
};
|
|
4674
4784
|
let txManager = new TransactionManager(transactionDependencies, this.events);
|
|
4675
4785
|
let payload = {
|
|
4676
|
-
networkId:
|
|
4786
|
+
networkId: caipToNetworkId6(caip),
|
|
4677
4787
|
serialized: signedTx
|
|
4678
4788
|
};
|
|
4679
4789
|
let txid = await txManager.broadcast(payload);
|
|
@@ -4684,7 +4794,7 @@ class SDK {
|
|
|
4684
4794
|
}
|
|
4685
4795
|
};
|
|
4686
4796
|
this.swap = async function(swapPayload) {
|
|
4687
|
-
let tag5 = `${
|
|
4797
|
+
let tag5 = `${TAG7} | swap | `;
|
|
4688
4798
|
try {
|
|
4689
4799
|
if (!swapPayload)
|
|
4690
4800
|
throw Error("swapPayload required!");
|
|
@@ -4819,7 +4929,7 @@ class SDK {
|
|
|
4819
4929
|
}
|
|
4820
4930
|
};
|
|
4821
4931
|
this.transfer = async function(sendPayload) {
|
|
4822
|
-
let tag5 = `${
|
|
4932
|
+
let tag5 = `${TAG7} | transfer | `;
|
|
4823
4933
|
try {
|
|
4824
4934
|
if (!sendPayload)
|
|
4825
4935
|
throw Error("sendPayload required!");
|
|
@@ -4846,7 +4956,7 @@ class SDK {
|
|
|
4846
4956
|
if (!signedTx)
|
|
4847
4957
|
throw Error("Failed to sign transaction!");
|
|
4848
4958
|
let payload = {
|
|
4849
|
-
networkId:
|
|
4959
|
+
networkId: caipToNetworkId6(caip),
|
|
4850
4960
|
serialized: signedTx
|
|
4851
4961
|
};
|
|
4852
4962
|
let txid = await txManager.broadcast(payload);
|
|
@@ -4875,7 +4985,7 @@ class SDK {
|
|
|
4875
4985
|
while (!isConfirmed) {
|
|
4876
4986
|
try {
|
|
4877
4987
|
const response = await this.pioneer.LookupTx({
|
|
4878
|
-
networkId:
|
|
4988
|
+
networkId: caipToNetworkId6(caip),
|
|
4879
4989
|
txid
|
|
4880
4990
|
});
|
|
4881
4991
|
if (response?.data?.data) {
|
|
@@ -4914,7 +5024,7 @@ class SDK {
|
|
|
4914
5024
|
}
|
|
4915
5025
|
};
|
|
4916
5026
|
this.setBlockchains = async function(blockchains) {
|
|
4917
|
-
const tag5 = `${
|
|
5027
|
+
const tag5 = `${TAG7} | setBlockchains | `;
|
|
4918
5028
|
try {
|
|
4919
5029
|
if (!blockchains)
|
|
4920
5030
|
throw Error("blockchains required!");
|
|
@@ -4930,7 +5040,7 @@ class SDK {
|
|
|
4930
5040
|
}
|
|
4931
5041
|
};
|
|
4932
5042
|
this.addAsset = async function(caip, data) {
|
|
4933
|
-
let tag5 =
|
|
5043
|
+
let tag5 = TAG7 + " | addAsset | ";
|
|
4934
5044
|
try {
|
|
4935
5045
|
let success = false;
|
|
4936
5046
|
if (!caip)
|
|
@@ -4968,7 +5078,7 @@ class SDK {
|
|
|
4968
5078
|
}
|
|
4969
5079
|
};
|
|
4970
5080
|
this.clearWalletState = async function() {
|
|
4971
|
-
const tag5 = `${
|
|
5081
|
+
const tag5 = `${TAG7} | clearWalletState | `;
|
|
4972
5082
|
try {
|
|
4973
5083
|
this.context = null;
|
|
4974
5084
|
this.paths = [];
|
|
@@ -4982,15 +5092,62 @@ class SDK {
|
|
|
4982
5092
|
throw e;
|
|
4983
5093
|
}
|
|
4984
5094
|
};
|
|
5095
|
+
this.addPath = async function(path) {
|
|
5096
|
+
const tag5 = `${TAG7} | addPath | `;
|
|
5097
|
+
try {
|
|
5098
|
+
this.paths.push(path);
|
|
5099
|
+
const pubkey = await getPubkey(path.networks[0], path, this.keepKeySdk, this.context);
|
|
5100
|
+
this.addPubkey(pubkey);
|
|
5101
|
+
await this.getBalancesForNetworks(path.networks);
|
|
5102
|
+
this.buildDashboardFromBalances();
|
|
5103
|
+
return { success: true, pubkey };
|
|
5104
|
+
} catch (e) {
|
|
5105
|
+
console.error(tag5, "Failed:", e);
|
|
5106
|
+
throw e;
|
|
5107
|
+
}
|
|
5108
|
+
};
|
|
5109
|
+
this.addPaths = async function(paths) {
|
|
5110
|
+
const tag5 = `${TAG7} | addPaths | `;
|
|
5111
|
+
try {
|
|
5112
|
+
console.log(tag5, `Adding ${paths.length} paths in batch mode...`);
|
|
5113
|
+
this.paths.push(...paths);
|
|
5114
|
+
const newPubkeys = [];
|
|
5115
|
+
for (const path of paths) {
|
|
5116
|
+
try {
|
|
5117
|
+
const pubkey = await getPubkey(path.networks[0], path, this.keepKeySdk, this.context);
|
|
5118
|
+
this.addPubkey(pubkey);
|
|
5119
|
+
newPubkeys.push(pubkey);
|
|
5120
|
+
} catch (error) {
|
|
5121
|
+
console.warn(tag5, `Failed to get pubkey for path ${path.note}:`, error.message);
|
|
5122
|
+
}
|
|
5123
|
+
}
|
|
5124
|
+
console.log(tag5, `Successfully added ${newPubkeys.length} pubkeys`);
|
|
5125
|
+
const networkSet = new Set;
|
|
5126
|
+
for (const path of paths) {
|
|
5127
|
+
if (path.networks && Array.isArray(path.networks)) {
|
|
5128
|
+
path.networks.forEach((net) => networkSet.add(net));
|
|
5129
|
+
}
|
|
5130
|
+
}
|
|
5131
|
+
const uniqueNetworks = [...networkSet];
|
|
5132
|
+
console.log(tag5, `Fetching balances for ${uniqueNetworks.length} unique networks in single API call...`);
|
|
5133
|
+
await this.getBalancesForNetworks(uniqueNetworks);
|
|
5134
|
+
this.buildDashboardFromBalances();
|
|
5135
|
+
console.log(tag5, `Batch add complete: ${paths.length} paths, ${newPubkeys.length} pubkeys, ${this.balances?.length || 0} balances`);
|
|
5136
|
+
return { success: true, pubkeys: newPubkeys };
|
|
5137
|
+
} catch (e) {
|
|
5138
|
+
console.error(tag5, "Failed:", e);
|
|
5139
|
+
throw e;
|
|
5140
|
+
}
|
|
5141
|
+
};
|
|
4985
5142
|
this.getAssets = async function() {
|
|
4986
5143
|
return this.getGasAssets();
|
|
4987
5144
|
};
|
|
4988
5145
|
this.getGasAssets = async function() {
|
|
4989
|
-
const tag5 = `${
|
|
5146
|
+
const tag5 = `${TAG7} | getGasAssets | `;
|
|
4990
5147
|
try {
|
|
4991
5148
|
for (let i = 0;i < this.blockchains.length; i++) {
|
|
4992
5149
|
let networkId = this.blockchains[i];
|
|
4993
|
-
let caip =
|
|
5150
|
+
let caip = networkIdToCaip(networkId);
|
|
4994
5151
|
let asset = await assetData2[caip.toLowerCase()];
|
|
4995
5152
|
if (asset) {
|
|
4996
5153
|
asset.caip = caip.toLowerCase();
|
|
@@ -5029,7 +5186,7 @@ class SDK {
|
|
|
5029
5186
|
}
|
|
5030
5187
|
};
|
|
5031
5188
|
this.getPubkeys = async function() {
|
|
5032
|
-
const tag5 = `${
|
|
5189
|
+
const tag5 = `${TAG7} | getPubkeys | `;
|
|
5033
5190
|
try {
|
|
5034
5191
|
if (this.paths.length === 0)
|
|
5035
5192
|
throw new Error("No paths found!");
|
|
@@ -5050,7 +5207,7 @@ class SDK {
|
|
|
5050
5207
|
}
|
|
5051
5208
|
};
|
|
5052
5209
|
this.getBalancesForNetworks = async function(networkIds) {
|
|
5053
|
-
const tag5 = `${
|
|
5210
|
+
const tag5 = `${TAG7} | getBalancesForNetworks | `;
|
|
5054
5211
|
try {
|
|
5055
5212
|
if (!this.pioneer) {
|
|
5056
5213
|
console.error(tag5, "ERROR: Pioneer client not initialized! this.pioneer is:", this.pioneer);
|
|
@@ -5068,7 +5225,7 @@ class SDK {
|
|
|
5068
5225
|
return network.startsWith("eip155:");
|
|
5069
5226
|
return network === adjustedNetworkId;
|
|
5070
5227
|
}));
|
|
5071
|
-
const caipNative = await
|
|
5228
|
+
const caipNative = await networkIdToCaip(networkId);
|
|
5072
5229
|
for (const pubkey of pubkeys) {
|
|
5073
5230
|
assetQuery.push({ caip: caipNative, pubkey: pubkey.pubkey });
|
|
5074
5231
|
}
|
|
@@ -5077,14 +5234,6 @@ class SDK {
|
|
|
5077
5234
|
try {
|
|
5078
5235
|
let marketInfo = await this.pioneer.GetPortfolioBalances(assetQuery);
|
|
5079
5236
|
console.timeEnd("GetPortfolioBalances Response Time");
|
|
5080
|
-
if (!marketInfo || !marketInfo.data) {
|
|
5081
|
-
console.error(tag5, "Invalid response structure:", marketInfo);
|
|
5082
|
-
throw new Error("GetPortfolioBalances returned invalid response: missing data field");
|
|
5083
|
-
}
|
|
5084
|
-
if (!Array.isArray(marketInfo.data)) {
|
|
5085
|
-
console.error(tag5, "GetPortfolioBalances returned non-array data:", typeof marketInfo.data, marketInfo.data);
|
|
5086
|
-
throw new Error(`GetPortfolioBalances returned invalid data type: expected array, got ${typeof marketInfo.data}`);
|
|
5087
|
-
}
|
|
5088
5237
|
let balances = marketInfo.data;
|
|
5089
5238
|
const bitcoinBalances = balances.filter((b3) => b3.caip === "bip122:000000000019d6689c085ae165831e93/slip44:0");
|
|
5090
5239
|
if (bitcoinBalances.length > 0) {
|
|
@@ -5094,7 +5243,7 @@ class SDK {
|
|
|
5094
5243
|
if (!assetInfo)
|
|
5095
5244
|
continue;
|
|
5096
5245
|
Object.assign(balance, assetInfo, {
|
|
5097
|
-
networkId:
|
|
5246
|
+
networkId: caipToNetworkId6(balance.caip),
|
|
5098
5247
|
icon: assetInfo.icon || "https://pioneers.dev/coins/etherum.png",
|
|
5099
5248
|
identifier: `${balance.caip}:${balance.pubkey}`
|
|
5100
5249
|
});
|
|
@@ -5113,7 +5262,7 @@ class SDK {
|
|
|
5113
5262
|
}
|
|
5114
5263
|
};
|
|
5115
5264
|
this.getBalances = async function() {
|
|
5116
|
-
const tag5 = `${
|
|
5265
|
+
const tag5 = `${TAG7} | getBalances | `;
|
|
5117
5266
|
try {
|
|
5118
5267
|
return await this.getBalancesForNetworks(this.blockchains);
|
|
5119
5268
|
} catch (e) {
|
|
@@ -5122,10 +5271,10 @@ class SDK {
|
|
|
5122
5271
|
}
|
|
5123
5272
|
};
|
|
5124
5273
|
this.getBalance = async function(networkId) {
|
|
5125
|
-
const tag5 = `${
|
|
5274
|
+
const tag5 = `${TAG7} | getBalance | `;
|
|
5126
5275
|
try {
|
|
5127
5276
|
const results = await this.getBalancesForNetworks([networkId]);
|
|
5128
|
-
const filtered = results.filter(async (b3) => b3.networkId === await
|
|
5277
|
+
const filtered = results.filter(async (b3) => b3.networkId === await networkIdToCaip(networkId));
|
|
5129
5278
|
return filtered;
|
|
5130
5279
|
} catch (e) {
|
|
5131
5280
|
console.error(tag5, "Error: ", e);
|
|
@@ -5133,7 +5282,7 @@ class SDK {
|
|
|
5133
5282
|
}
|
|
5134
5283
|
};
|
|
5135
5284
|
this.getFees = async function(networkId) {
|
|
5136
|
-
const tag5 = `${
|
|
5285
|
+
const tag5 = `${TAG7} | getFees | `;
|
|
5137
5286
|
try {
|
|
5138
5287
|
if (!this.pioneer) {
|
|
5139
5288
|
throw new Error("Pioneer client not initialized. Call init() first.");
|
|
@@ -5148,7 +5297,7 @@ class SDK {
|
|
|
5148
5297
|
return estimateTransactionFee(feeRate, unit, networkType, txSize);
|
|
5149
5298
|
};
|
|
5150
5299
|
this.getCharts = async function() {
|
|
5151
|
-
const tag5 = `${
|
|
5300
|
+
const tag5 = `${TAG7} | getCharts | `;
|
|
5152
5301
|
try {
|
|
5153
5302
|
console.log(tag5, "Fetching charts");
|
|
5154
5303
|
const newBalances = await getCharts(this.blockchains, this.pioneer, this.pubkeys, this.context);
|
|
@@ -5170,7 +5319,7 @@ class SDK {
|
|
|
5170
5319
|
}
|
|
5171
5320
|
};
|
|
5172
5321
|
this.setContext = async (context) => {
|
|
5173
|
-
const tag5 = `${
|
|
5322
|
+
const tag5 = `${TAG7} | setContext | `;
|
|
5174
5323
|
try {
|
|
5175
5324
|
if (!context)
|
|
5176
5325
|
throw Error("context required!");
|
|
@@ -5183,7 +5332,7 @@ class SDK {
|
|
|
5183
5332
|
}
|
|
5184
5333
|
};
|
|
5185
5334
|
this.setContextType = async (contextType) => {
|
|
5186
|
-
const tag5 = `${
|
|
5335
|
+
const tag5 = `${TAG7} | setContextType | `;
|
|
5187
5336
|
try {
|
|
5188
5337
|
if (!contextType)
|
|
5189
5338
|
throw Error("contextType required!");
|
|
@@ -5196,7 +5345,7 @@ class SDK {
|
|
|
5196
5345
|
}
|
|
5197
5346
|
};
|
|
5198
5347
|
this.refresh = async () => {
|
|
5199
|
-
const tag5 = `${
|
|
5348
|
+
const tag5 = `${TAG7} | refresh | `;
|
|
5200
5349
|
try {
|
|
5201
5350
|
await this.sync();
|
|
5202
5351
|
return this.balances;
|
|
@@ -5206,7 +5355,7 @@ class SDK {
|
|
|
5206
5355
|
}
|
|
5207
5356
|
};
|
|
5208
5357
|
this.setAssetContext = async function(asset) {
|
|
5209
|
-
const tag5 = `${
|
|
5358
|
+
const tag5 = `${TAG7} | setAssetContext | `;
|
|
5210
5359
|
try {
|
|
5211
5360
|
if (!asset) {
|
|
5212
5361
|
this.assetContext = null;
|
|
@@ -5215,7 +5364,7 @@ class SDK {
|
|
|
5215
5364
|
if (!asset.caip)
|
|
5216
5365
|
throw Error("Invalid Asset! missing caip!");
|
|
5217
5366
|
if (!asset.networkId)
|
|
5218
|
-
asset.networkId =
|
|
5367
|
+
asset.networkId = caipToNetworkId6(asset.caip);
|
|
5219
5368
|
if (!this.pubkeys || this.pubkeys.length === 0) {
|
|
5220
5369
|
const errorMsg = `Cannot set asset context for ${asset.caip} - no pubkeys loaded. Please initialize wallet first.`;
|
|
5221
5370
|
console.error(tag5, errorMsg);
|
|
@@ -5323,7 +5472,7 @@ class SDK {
|
|
|
5323
5472
|
console.log(tag5, `Aggregated balance: ${totalBalance} (${totalValueUsd.toFixed(2)} USD)`);
|
|
5324
5473
|
}
|
|
5325
5474
|
const assetBalances = this.balances.filter((b3) => b3.caip === asset.caip);
|
|
5326
|
-
const assetPubkeys = this.pubkeys.filter((p2) => p2.networks && Array.isArray(p2.networks) && p2.networks.includes(
|
|
5475
|
+
const assetPubkeys = this.pubkeys.filter((p2) => p2.networks && Array.isArray(p2.networks) && p2.networks.includes(caipToNetworkId6(asset.caip)) || caipToNetworkId6(asset.caip).includes("eip155") && p2.networks && Array.isArray(p2.networks) && p2.networks.some((n2) => n2.startsWith("eip155")));
|
|
5327
5476
|
const finalAssetContext = {
|
|
5328
5477
|
...assetInfo,
|
|
5329
5478
|
...asset,
|
|
@@ -5383,16 +5532,19 @@ class SDK {
|
|
|
5383
5532
|
}
|
|
5384
5533
|
}
|
|
5385
5534
|
if (asset.caip) {
|
|
5386
|
-
this.blockchainContext =
|
|
5535
|
+
this.blockchainContext = caipToNetworkId6(asset.caip);
|
|
5387
5536
|
} else if (asset.networkId) {
|
|
5388
5537
|
this.blockchainContext = asset.networkId;
|
|
5389
5538
|
}
|
|
5390
5539
|
if (assetPubkeys && assetPubkeys.length > 0) {
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5540
|
+
const networkId = caipToNetworkId6(asset.caip || asset.networkId);
|
|
5541
|
+
const currentContextValid = this.pubkeyContext?.networks?.includes(networkId);
|
|
5542
|
+
if (!this.pubkeyContext || !currentContextValid) {
|
|
5543
|
+
this.pubkeyContext = assetPubkeys[0];
|
|
5544
|
+
console.log(tag5, "Auto-set pubkey context for network:", this.pubkeyContext.address || this.pubkeyContext.pubkey);
|
|
5545
|
+
} else {
|
|
5546
|
+
console.log(tag5, "Preserving existing pubkey context for network:", this.pubkeyContext.address || this.pubkeyContext.pubkey, `(addressNList: [${(this.pubkeyContext.addressNList || this.pubkeyContext.addressNListMaster).join(", ")}])`);
|
|
5394
5547
|
}
|
|
5395
|
-
console.log(tag5, "Auto-set pubkey context for network:", this.pubkeyContext.address || this.pubkeyContext.pubkey);
|
|
5396
5548
|
}
|
|
5397
5549
|
this.events.emit("SET_ASSET_CONTEXT", this.assetContext);
|
|
5398
5550
|
return this.assetContext;
|
|
@@ -5402,7 +5554,7 @@ class SDK {
|
|
|
5402
5554
|
}
|
|
5403
5555
|
};
|
|
5404
5556
|
this.setPubkeyContext = async function(pubkey) {
|
|
5405
|
-
let tag5 = `${
|
|
5557
|
+
let tag5 = `${TAG7} | setPubkeyContext | `;
|
|
5406
5558
|
try {
|
|
5407
5559
|
if (!pubkey)
|
|
5408
5560
|
throw Error("pubkey is required");
|
|
@@ -5413,10 +5565,7 @@ class SDK {
|
|
|
5413
5565
|
console.warn(tag5, "Pubkey not found in current pubkeys array");
|
|
5414
5566
|
}
|
|
5415
5567
|
this.pubkeyContext = pubkey;
|
|
5416
|
-
|
|
5417
|
-
this.keepKeySdk.pubkeyContext = pubkey;
|
|
5418
|
-
}
|
|
5419
|
-
console.log(tag5, "Pubkey context set to:", pubkey.address || pubkey.pubkey, "note:", pubkey.note);
|
|
5568
|
+
console.log(tag5, "Pubkey context set to:", pubkey.address || pubkey.pubkey, "note:", pubkey.note, "addressNList:", pubkey.addressNList || pubkey.addressNListMaster);
|
|
5420
5569
|
return true;
|
|
5421
5570
|
} catch (e) {
|
|
5422
5571
|
console.error(tag5, "e: ", e);
|
|
@@ -5424,7 +5573,7 @@ class SDK {
|
|
|
5424
5573
|
}
|
|
5425
5574
|
};
|
|
5426
5575
|
this.setOutboundAssetContext = async function(asset) {
|
|
5427
|
-
const tag5 = `${
|
|
5576
|
+
const tag5 = `${TAG7} | setOutputAssetContext | `;
|
|
5428
5577
|
try {
|
|
5429
5578
|
console.log(tag5, "0. asset: ", asset);
|
|
5430
5579
|
if (!asset) {
|
|
@@ -5435,7 +5584,7 @@ class SDK {
|
|
|
5435
5584
|
if (!asset.caip)
|
|
5436
5585
|
throw Error("Invalid Asset! missing caip!");
|
|
5437
5586
|
if (!asset.networkId)
|
|
5438
|
-
asset.networkId =
|
|
5587
|
+
asset.networkId = caipToNetworkId6(asset.caip);
|
|
5439
5588
|
console.log(tag5, "networkId: ", asset.networkId);
|
|
5440
5589
|
console.log(tag5, "this.pubkeys: ", this.pubkeys);
|
|
5441
5590
|
const pubkey = this.pubkeys.find((p2) => {
|
|
@@ -5516,7 +5665,7 @@ class SDK {
|
|
|
5516
5665
|
console.log(tag5, "CHECKPOINT 3");
|
|
5517
5666
|
console.log(tag5, "outboundAssetContext: assetInfo: ", assetInfo);
|
|
5518
5667
|
if (asset.caip) {
|
|
5519
|
-
this.outboundBlockchainContext =
|
|
5668
|
+
this.outboundBlockchainContext = caipToNetworkId6(asset.caip);
|
|
5520
5669
|
} else if (asset.networkId) {
|
|
5521
5670
|
this.outboundBlockchainContext = asset.networkId;
|
|
5522
5671
|
}
|