@pioneer-platform/pioneer-sdk 4.21.12 → 4.21.13
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 +102 -347
- package/dist/index.es.js +78 -323
- package/dist/index.js +78 -323
- package/package.json +1 -1
- package/src/getPubkey.ts +2 -2
- package/src/index.ts +1 -56
- package/src/utils/build-dashboard.ts +0 -32
- package/src/utils/sync-portfolio.ts +8 -3
package/dist/index.cjs
CHANGED
|
@@ -183,8 +183,8 @@ var require_coinselect = __commonJS((exports2, module2) => {
|
|
|
183
183
|
return x.value - feeRate * utils.inputBytes(x);
|
|
184
184
|
}
|
|
185
185
|
module2.exports = function coinSelect(utxos, outputs, feeRate) {
|
|
186
|
-
utxos = utxos.concat().sort(function(a,
|
|
187
|
-
return utxoScore(
|
|
186
|
+
utxos = utxos.concat().sort(function(a, b) {
|
|
187
|
+
return utxoScore(b, feeRate) - utxoScore(a, feeRate);
|
|
188
188
|
});
|
|
189
189
|
var base = blackjack(utxos, outputs, feeRate);
|
|
190
190
|
if (base.inputs)
|
|
@@ -244,7 +244,7 @@ __export(exports_src, {
|
|
|
244
244
|
});
|
|
245
245
|
module.exports = __toCommonJS(exports_src);
|
|
246
246
|
var import_keepkey_sdk = require("@keepkey/keepkey-sdk");
|
|
247
|
-
var
|
|
247
|
+
var import_pioneer_caip8 = require("@pioneer-platform/pioneer-caip");
|
|
248
248
|
|
|
249
249
|
// ../pioneer-client/lib/index.js
|
|
250
250
|
var import_swagger_client = __toESM(require("swagger-client"));
|
|
@@ -855,216 +855,8 @@ var getCharts = async (blockchains, pioneer, pubkeys, context) => {
|
|
|
855
855
|
}
|
|
856
856
|
};
|
|
857
857
|
|
|
858
|
-
// ../../../node_modules/@coinmasters/types/dist/index.es.js
|
|
859
|
-
var n = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_0_100 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROFVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(n || {});
|
|
860
|
-
var b = {
|
|
861
|
-
[n.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
|
|
862
|
-
[n.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
|
|
863
|
-
[n.CANNOT_FIND_INBOUND_ADDRESS]: "Cannot find inbound address.",
|
|
864
|
-
[n.NO_INBOUND_ADDRESSES]: "No inbound addresses.",
|
|
865
|
-
[n.CHAIN_HALTED_OR_UNSUPPORTED]: "Chain {0} halted or unsupported.",
|
|
866
|
-
[n.MISSING_INPUT_PARAMETER]: "Missing input parameter: {0}.",
|
|
867
|
-
[n.INVALID_TYPE_GENERIC]: "Invalid type",
|
|
868
|
-
[n.INVALID_NUMBER_STRING]: "Invalid number string.",
|
|
869
|
-
[n.INVALID_NUMBER]: "Invalid number.",
|
|
870
|
-
[n.INVALID_BOOLEAN]: "Invalid boolean.",
|
|
871
|
-
[n.INVALID_OBJECT]: "Invalid object.",
|
|
872
|
-
[n.INVALID_ARRAY]: "Invalid array.",
|
|
873
|
-
[n.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Sell amount must be a positive integer.",
|
|
874
|
-
[n.SELL_BUY_ASSETS_ARE_THE_SAME]: "Sell and buy assets are the same.",
|
|
875
|
-
[n.MISSING_SOURCE_ADDRESS_FOR_SYNTH]: "Source address is required for synth quote.",
|
|
876
|
-
[n.AFF_ADDRESS_AND_BPS_OR_NEITHER]: "Must provide affiliateAddress and affiliateBasisPoints params, or neither.",
|
|
877
|
-
[n.AFF_ADDRESS_TOO_LONG]: "affiliateAddress too long: 3 characters max.",
|
|
878
|
-
[n.AFF_BPS_INTEGER_0_100]: "affiliateBasisPoints must be an integer between 0 and 100.",
|
|
879
|
-
[n.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN]: "Source address {0} invalid for sell chain.",
|
|
880
|
-
[n.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN]: "Destination address {0} invalid for buy chain.",
|
|
881
|
-
[n.PREFERRED_PROFVIDER_NOT_SUPPORTED]: "Preferred provider not supported.",
|
|
882
|
-
[n.DESTINATION_ADDRESS_SMART_CONTRACT]: "Destination address is a smart contract.",
|
|
883
|
-
[n.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Buy amount must be a positive integer.",
|
|
884
|
-
[n.INVALID_PROVIDER]: "Invalid provider {0}.",
|
|
885
|
-
[n.MISSING_CROSS_CHAIN_PROVIDER]: "Missing cross-chain provider.",
|
|
886
|
-
[n.MISSING_AVAX_PROVIDER]: "Missing AVAX provider.",
|
|
887
|
-
[n.MISSING_BSC_PROVIDER]: "Missing BSC provider.",
|
|
888
|
-
[n.MISSING_ETH_PROVIDER]: "Missing ETH provider.",
|
|
889
|
-
[n.MISSING_ARB_PROVIDER]: "Missing ARB provider.",
|
|
890
|
-
[n.INVALID_PROVIDER_FOR_SWAP_OUT]: "Invalid provider for swap out.",
|
|
891
|
-
[n.INVALID_CHAIN]: "Invalid chain {0}.",
|
|
892
|
-
[n.INVALID_ASSET]: "Invalid asset {0}.",
|
|
893
|
-
[n.UNSUPPORTED_CHAIN]: "Unsupported chain {0}.",
|
|
894
|
-
[n.UNSUPPORTED_ASSET]: "Unsupported asset {0}.",
|
|
895
|
-
[n.UNSUPPORTED_ASSET_FOR_SWAPOUT]: "Unsupported asset {0} for swap out.",
|
|
896
|
-
[n.THORNODE_QUOTE_GENERIC_ERROR]: "ThorNode quote generic error.",
|
|
897
|
-
[n.INVALID_SOURCE_ADDRESS]: "Invalid source address {0}",
|
|
898
|
-
[n.INVALID_DESTINATION_ADDRESS]: "Invalid destination address {0}",
|
|
899
|
-
[n.NOT_ENOUGH_SYNTH_BALANCE]: "Source address doesn't have enough synth balance for this quote.",
|
|
900
|
-
[n.SYNTH_MINTING_CAP_REACHED]: "Synth minting cap reached.",
|
|
901
|
-
[n.INVALID_QUOTE_MODE]: "Invalid quote mode.",
|
|
902
|
-
[n.NO_QUOTES]: "No quotes to service this request.",
|
|
903
|
-
[n.SERVICE_UNAVAILABLE_GENERIC]: "Service unavailable.",
|
|
904
|
-
[n.MISSING_GAS_DATA_GENERIC]: "Missing gas data.",
|
|
905
|
-
[n.MISSING_TOKEN_INFO_GENERIC]: "Missing token info.",
|
|
906
|
-
[n.CANT_FIND_TOKEN_LIST]: "Can't find tokenlist {0}.",
|
|
907
|
-
[n.NO_PRICE]: "No price for asset {0}.",
|
|
908
|
-
[n.PRICE_IS_STALE]: "Price is stale for asset {0}.",
|
|
909
|
-
[n.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
|
|
910
|
-
[n.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
|
|
911
|
-
};
|
|
912
|
-
var t = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Base = "BASE", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dash = "DASH", e.Digibyte = "DGB", e.Dogecoin = "DOGE", e.EOS = "EOS", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Mayachain = "MAYA", e.Optimism = "OP", e.Osmosis = "OSMO", e.Polygon = "MATIC", e.Ripple = "XRP", e.THORChain = "THOR", e.Zcash = "ZEC", e))(t || {});
|
|
913
|
-
var H = {
|
|
914
|
-
ARB: "eip155:42161",
|
|
915
|
-
AVAX: "eip155:43114",
|
|
916
|
-
BSC: "eip155:56",
|
|
917
|
-
BCH: "bip122:000000000000000000651ef99cb9fcbe",
|
|
918
|
-
BTC: "bip122:000000000019d6689c085ae165831e93",
|
|
919
|
-
BASE: "eip155:8453",
|
|
920
|
-
GAIA: "cosmos:cosmoshub-4",
|
|
921
|
-
DASH: "bip122:000007d91d1254d60e2dd1ae58038307",
|
|
922
|
-
DGB: "bip122:digibytes-hash",
|
|
923
|
-
DOGE: "bip122:00000000001a91e3dace36e2be3bf030",
|
|
924
|
-
KUJI: "cosmos:kaiyo-1",
|
|
925
|
-
EOS: "eos:cf057bbfb72640471fd910bcb67639c2",
|
|
926
|
-
ETH: "eip155:1",
|
|
927
|
-
LTC: "bip122:12a765e31ffd4059bada1e25190f6e98",
|
|
928
|
-
MAYA: "cosmos:mayachain-mainnet-v1",
|
|
929
|
-
OP: "eip155:10",
|
|
930
|
-
OSMO: "cosmos:osmosis-1",
|
|
931
|
-
MATIC: "eip155:137",
|
|
932
|
-
XRP: "ripple:4109c6f2045fc7eff4cde8f9905d19c2",
|
|
933
|
-
THOR: "cosmos:thorchain-mainnet-v1",
|
|
934
|
-
ZEC: "bip122:0000000000196a45"
|
|
935
|
-
};
|
|
936
|
-
var V = {};
|
|
937
|
-
for (const e in t) {
|
|
938
|
-
const a = H[t[e]];
|
|
939
|
-
V[a] = t[e];
|
|
940
|
-
}
|
|
941
|
-
var p = [
|
|
942
|
-
"ETH"
|
|
943
|
-
];
|
|
944
|
-
var T = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Base = "8453", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dash = "dash", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Mayachain = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Osmosis = "osmosis-1", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(T || {});
|
|
945
|
-
var E = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://avalanche-c-chain-rpc.publicnode.com", e.BinanceSmartChain = "https://binance.llamarpc.com", e.Base = "https://developer-access-mainnet.base.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://api.cosmos.shapeshift.com", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dash = "https://dash.nownodes.io", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://daemon.ethereum.shapeshift.com", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Mayachain = "https://mayanode.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Osmosis = "https://lcd-osmosis.keplr.app", e.Polygon = "https://polygon-rpc.com", e.Ripple = "https://xrplcluster.com", e.THORChain = "https://thornode.ninerealms.com", e.THORChainStagenet = "https://thornode.ninerealms.com", e))(E || {});
|
|
946
|
-
var d = Object.values(t);
|
|
947
|
-
var M = Object.keys(t);
|
|
948
|
-
var m = d.reduce((e, a) => {
|
|
949
|
-
const s = M.find((r) => t[r] === a);
|
|
950
|
-
return s && (e[a] = s), e;
|
|
951
|
-
}, {});
|
|
952
|
-
var Q = d.reduce((e, a) => (e[a] = T[m[a]], e), {});
|
|
953
|
-
var ee = d.reduce((e, a) => (e[a] = E[m[a]], e), {});
|
|
954
|
-
var te = d.reduce((e, a) => {
|
|
955
|
-
const s = `${m[a]}Hex`;
|
|
956
|
-
return e[a] = T[s], e;
|
|
957
|
-
}, {});
|
|
958
|
-
var X = [
|
|
959
|
-
t.Arbitrum,
|
|
960
|
-
t.Avalanche,
|
|
961
|
-
t.BinanceSmartChain,
|
|
962
|
-
t.Bitcoin,
|
|
963
|
-
t.BitcoinCash,
|
|
964
|
-
t.Cosmos,
|
|
965
|
-
t.Osmosis,
|
|
966
|
-
t.Ripple,
|
|
967
|
-
t.Dogecoin,
|
|
968
|
-
t.Dash,
|
|
969
|
-
t.Ethereum,
|
|
970
|
-
t.Litecoin,
|
|
971
|
-
t.Optimism,
|
|
972
|
-
t.Polygon,
|
|
973
|
-
t.THORChain
|
|
974
|
-
];
|
|
975
|
-
var se = {
|
|
976
|
-
BRAVE: p,
|
|
977
|
-
COINBASE_WEB: p,
|
|
978
|
-
KEPLR: [t.Cosmos],
|
|
979
|
-
KEYSTORE: [
|
|
980
|
-
t.Arbitrum,
|
|
981
|
-
t.Base,
|
|
982
|
-
t.Avalanche,
|
|
983
|
-
t.BinanceSmartChain,
|
|
984
|
-
t.Bitcoin,
|
|
985
|
-
t.BitcoinCash,
|
|
986
|
-
t.Cosmos,
|
|
987
|
-
t.Dogecoin,
|
|
988
|
-
t.Ethereum,
|
|
989
|
-
t.Litecoin,
|
|
990
|
-
t.Optimism,
|
|
991
|
-
t.Polygon,
|
|
992
|
-
t.THORChain
|
|
993
|
-
],
|
|
994
|
-
LEDGER: X,
|
|
995
|
-
TREZOR: [
|
|
996
|
-
t.Bitcoin,
|
|
997
|
-
t.BitcoinCash,
|
|
998
|
-
t.Litecoin,
|
|
999
|
-
t.Dogecoin,
|
|
1000
|
-
t.Ethereum
|
|
1001
|
-
],
|
|
1002
|
-
KEEPKEY: [
|
|
1003
|
-
t.Arbitrum,
|
|
1004
|
-
t.Avalanche,
|
|
1005
|
-
t.Base,
|
|
1006
|
-
t.BinanceSmartChain,
|
|
1007
|
-
t.Bitcoin,
|
|
1008
|
-
t.BitcoinCash,
|
|
1009
|
-
t.Cosmos,
|
|
1010
|
-
t.Osmosis,
|
|
1011
|
-
t.Ripple,
|
|
1012
|
-
t.Dogecoin,
|
|
1013
|
-
t.Dash,
|
|
1014
|
-
t.Mayachain,
|
|
1015
|
-
t.Ethereum,
|
|
1016
|
-
t.Litecoin,
|
|
1017
|
-
t.Optimism,
|
|
1018
|
-
t.Polygon,
|
|
1019
|
-
t.THORChain
|
|
1020
|
-
],
|
|
1021
|
-
METAMASK_SHAPESHIFT: [
|
|
1022
|
-
t.Arbitrum,
|
|
1023
|
-
t.Avalanche,
|
|
1024
|
-
t.BinanceSmartChain,
|
|
1025
|
-
t.Bitcoin,
|
|
1026
|
-
t.BitcoinCash,
|
|
1027
|
-
t.Cosmos,
|
|
1028
|
-
t.Dogecoin,
|
|
1029
|
-
t.Ethereum,
|
|
1030
|
-
t.Litecoin,
|
|
1031
|
-
t.Optimism,
|
|
1032
|
-
t.Polygon,
|
|
1033
|
-
t.THORChain
|
|
1034
|
-
],
|
|
1035
|
-
METAMASK: p,
|
|
1036
|
-
TRUSTWALLET_WEB: p,
|
|
1037
|
-
XDEFI: [
|
|
1038
|
-
t.Arbitrum,
|
|
1039
|
-
t.Avalanche,
|
|
1040
|
-
t.BinanceSmartChain,
|
|
1041
|
-
t.Bitcoin,
|
|
1042
|
-
t.BitcoinCash,
|
|
1043
|
-
t.Cosmos,
|
|
1044
|
-
t.Ripple,
|
|
1045
|
-
t.Dogecoin,
|
|
1046
|
-
t.Ethereum,
|
|
1047
|
-
t.Litecoin,
|
|
1048
|
-
t.Optimism,
|
|
1049
|
-
t.Polygon,
|
|
1050
|
-
t.THORChain
|
|
1051
|
-
],
|
|
1052
|
-
WALLETCONNECT: [
|
|
1053
|
-
t.Ethereum
|
|
1054
|
-
],
|
|
1055
|
-
OKX: [
|
|
1056
|
-
t.Ethereum,
|
|
1057
|
-
t.Avalanche,
|
|
1058
|
-
t.BinanceSmartChain,
|
|
1059
|
-
t.Bitcoin,
|
|
1060
|
-
t.Cosmos
|
|
1061
|
-
]
|
|
1062
|
-
};
|
|
1063
|
-
var ie = {
|
|
1064
|
-
KEEPKEY: [t.Bitcoin, t.Ethereum, t.Base]
|
|
1065
|
-
};
|
|
1066
|
-
|
|
1067
858
|
// src/getPubkey.ts
|
|
859
|
+
var import_pioneer_caip = require("@pioneer-platform/pioneer-caip");
|
|
1068
860
|
var import_pioneer_coins = require("@pioneer-platform/pioneer-coins");
|
|
1069
861
|
var getPubkey = async (networkId, path, sdk, context) => {
|
|
1070
862
|
try {
|
|
@@ -1073,7 +865,7 @@ var getPubkey = async (networkId, path, sdk, context) => {
|
|
|
1073
865
|
}
|
|
1074
866
|
if (networkId.indexOf("eip155") > -1)
|
|
1075
867
|
networkId = "eip155:*";
|
|
1076
|
-
let chain =
|
|
868
|
+
let chain = import_pioneer_caip.NetworkIdToChain[networkId];
|
|
1077
869
|
let pubkey = { type: path.type };
|
|
1078
870
|
let addressInfo = {
|
|
1079
871
|
address_n: path.addressNListMaster,
|
|
@@ -1204,7 +996,6 @@ var getPubkey = async (networkId, path, sdk, context) => {
|
|
|
1204
996
|
throw new Error(`FAIL FAST - xpub retrieval failed for ${networkId} at ${import_pioneer_coins.addressNListToBIP32(path.addressNList)}: ${xpubError.message}`);
|
|
1205
997
|
}
|
|
1206
998
|
} else {
|
|
1207
|
-
console.log("\uD83D\uDD11 [PUBKEY] Non-xpub path (address-based), using address as pubkey");
|
|
1208
999
|
pubkey.pubkey = address;
|
|
1209
1000
|
pubkey.path = import_pioneer_coins.addressNListToBIP32(path.addressNList);
|
|
1210
1001
|
pubkey.pathMaster = import_pioneer_coins.addressNListToBIP32(path.addressNListMaster);
|
|
@@ -1302,7 +1093,7 @@ async function optimizedGetPubkeys(blockchains, paths, keepKeySdk, context, getP
|
|
|
1302
1093
|
if (vaultHealth.available && vaultHealth.cached_pubkeys > 0) {
|
|
1303
1094
|
const batchResponse = await batchGetPubkeys(paths, context, baseUrl);
|
|
1304
1095
|
pubkeys = batchResponse.pubkeys;
|
|
1305
|
-
const cachedPaths = new Set(batchResponse.pubkeys.map((
|
|
1096
|
+
const cachedPaths = new Set(batchResponse.pubkeys.map((p) => p.path));
|
|
1306
1097
|
for (let i = 0;i < blockchains.length; i++) {
|
|
1307
1098
|
const blockchain = blockchains[i];
|
|
1308
1099
|
const pathsForChain = paths.filter((path) => path.networks && Array.isArray(path.networks) && path.networks.includes(blockchain));
|
|
@@ -1547,7 +1338,7 @@ var SUPPORTED_CAIPS = {
|
|
|
1547
1338
|
};
|
|
1548
1339
|
|
|
1549
1340
|
// src/txbuilder/createUnsignedEvmTx.ts
|
|
1550
|
-
var
|
|
1341
|
+
var import_pioneer_caip2 = require("@pioneer-platform/pioneer-caip");
|
|
1551
1342
|
var import_pioneer_coins2 = require("@pioneer-platform/pioneer-coins");
|
|
1552
1343
|
var TAG2 = " | createUnsignedEvmTx | ";
|
|
1553
1344
|
var toHex = (value) => {
|
|
@@ -1632,7 +1423,7 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
1632
1423
|
try {
|
|
1633
1424
|
if (!pioneer)
|
|
1634
1425
|
throw new Error("Failed to initialize Pioneer");
|
|
1635
|
-
const networkId =
|
|
1426
|
+
const networkId = import_pioneer_caip2.caipToNetworkId(caip);
|
|
1636
1427
|
const chainId = extractChainIdFromNetworkId(networkId);
|
|
1637
1428
|
if (!pubkeyContext) {
|
|
1638
1429
|
throw new Error(`No pubkey context provided for networkId: ${networkId}`);
|
|
@@ -1948,14 +1739,14 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
1948
1739
|
}
|
|
1949
1740
|
|
|
1950
1741
|
// src/txbuilder/createUnsignedRippleTx.ts
|
|
1951
|
-
var
|
|
1742
|
+
var import_pioneer_caip3 = require("@pioneer-platform/pioneer-caip");
|
|
1952
1743
|
var TAG3 = " | createUnsignedUxtoTx | ";
|
|
1953
1744
|
async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer, pubkeyContext, isMax) {
|
|
1954
1745
|
let tag6 = TAG3 + " | createUnsignedRippleTx | ";
|
|
1955
1746
|
try {
|
|
1956
1747
|
if (!pioneer)
|
|
1957
1748
|
throw new Error("Failed to init! pioneer");
|
|
1958
|
-
const networkId =
|
|
1749
|
+
const networkId = import_pioneer_caip3.caipToNetworkId(caip);
|
|
1959
1750
|
if (!pubkeyContext) {
|
|
1960
1751
|
throw new Error(`No pubkey context provided for networkId: ${networkId}`);
|
|
1961
1752
|
}
|
|
@@ -2036,7 +1827,7 @@ async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer,
|
|
|
2036
1827
|
}
|
|
2037
1828
|
|
|
2038
1829
|
// src/txbuilder/createUnsignedTendermintTx.ts
|
|
2039
|
-
var
|
|
1830
|
+
var import_pioneer_caip4 = require("@pioneer-platform/pioneer-caip");
|
|
2040
1831
|
|
|
2041
1832
|
// src/txbuilder/templates/cosmos.ts
|
|
2042
1833
|
var cosmosTransferTemplate = (params) => ({
|
|
@@ -2174,7 +1965,7 @@ async function createUnsignedTendermintTx(caip, type, amount, memo, pubkeys, pio
|
|
|
2174
1965
|
try {
|
|
2175
1966
|
if (!pioneer)
|
|
2176
1967
|
throw new Error("Failed to init! pioneer");
|
|
2177
|
-
const networkId =
|
|
1968
|
+
const networkId = import_pioneer_caip4.caipToNetworkId(caip);
|
|
2178
1969
|
if (!pubkeyContext) {
|
|
2179
1970
|
throw new Error(`No pubkey context provided for networkId: ${networkId}`);
|
|
2180
1971
|
}
|
|
@@ -2386,12 +2177,12 @@ async function createUnsignedTendermintTx(caip, type, amount, memo, pubkeys, pio
|
|
|
2386
2177
|
}
|
|
2387
2178
|
|
|
2388
2179
|
// src/txbuilder/createUnsignedUxtoTx.ts
|
|
2389
|
-
var
|
|
2180
|
+
var import_pioneer_caip5 = require("@pioneer-platform/pioneer-caip");
|
|
2390
2181
|
var import_pioneer_coins3 = require("@pioneer-platform/pioneer-coins");
|
|
2391
2182
|
var import_coinselect = __toESM(require_coinselect());
|
|
2392
2183
|
var import_split = __toESM(require_split());
|
|
2393
2184
|
function getCoinTypeFromNetworkId(networkId) {
|
|
2394
|
-
const chain =
|
|
2185
|
+
const chain = import_pioneer_caip5.NetworkIdToChain[networkId];
|
|
2395
2186
|
if (!chain) {
|
|
2396
2187
|
console.warn(`No chain mapping found for ${networkId}, defaulting to Bitcoin coin type 0`);
|
|
2397
2188
|
return 0;
|
|
@@ -2413,7 +2204,7 @@ async function createUnsignedUxtoTx(caip, to, amount, memo, pubkeys, pioneer, pu
|
|
|
2413
2204
|
try {
|
|
2414
2205
|
if (!pioneer)
|
|
2415
2206
|
throw Error("Failed to init! pioneer");
|
|
2416
|
-
const networkId =
|
|
2207
|
+
const networkId = import_pioneer_caip5.caipToNetworkId(caip);
|
|
2417
2208
|
if (!pubkeyContext) {
|
|
2418
2209
|
throw new Error(`No pubkey context provided for networkId: ${networkId}`);
|
|
2419
2210
|
}
|
|
@@ -2429,7 +2220,7 @@ async function createUnsignedUxtoTx(caip, to, amount, memo, pubkeys, pioneer, pu
|
|
|
2429
2220
|
"bip122:000000000019d6689c085ae165831e93"
|
|
2430
2221
|
];
|
|
2431
2222
|
const isSegwit = segwitNetworks.includes(networkId);
|
|
2432
|
-
let chain =
|
|
2223
|
+
let chain = import_pioneer_caip5.NetworkIdToChain[networkId];
|
|
2433
2224
|
const coinType = getCoinTypeFromNetworkId(networkId);
|
|
2434
2225
|
console.log(`${tag6}: Using SLIP-44 coin type ${coinType} for ${chain}`);
|
|
2435
2226
|
const utxos = [];
|
|
@@ -2462,7 +2253,7 @@ async function createUnsignedUxtoTx(caip, to, amount, memo, pubkeys, pioneer, pu
|
|
|
2462
2253
|
acc[type] = (acc[type] || 0) + 1;
|
|
2463
2254
|
return acc;
|
|
2464
2255
|
}, {});
|
|
2465
|
-
const mostCommonInputType = Object.entries(scriptTypeCount).sort(([, a], [,
|
|
2256
|
+
const mostCommonInputType = Object.entries(scriptTypeCount).sort(([, a], [, b]) => b - a)[0]?.[0] || "p2pkh";
|
|
2466
2257
|
const actualChangeScriptType = changeScriptType || mostCommonInputType || relevantPubkeys[0]?.scriptType || "p2pkh";
|
|
2467
2258
|
console.log(`${tag6}: Input script types:`, scriptTypeCount);
|
|
2468
2259
|
console.log(`${tag6}: Using change script type: ${actualChangeScriptType} (matches inputs: ${mostCommonInputType})`);
|
|
@@ -3006,7 +2797,7 @@ class TransactionManager {
|
|
|
3006
2797
|
}
|
|
3007
2798
|
|
|
3008
2799
|
// src/txbuilder/createUnsignedStakingTx.ts
|
|
3009
|
-
var
|
|
2800
|
+
var import_pioneer_caip6 = require("@pioneer-platform/pioneer-caip");
|
|
3010
2801
|
|
|
3011
2802
|
// src/txbuilder/templates/cosmos-staking.ts
|
|
3012
2803
|
var cosmosDelegateTemplate = (params) => ({
|
|
@@ -3123,7 +2914,7 @@ async function createUnsignedStakingTx(caip, params, pubkeys, pioneer, pubkeyCon
|
|
|
3123
2914
|
try {
|
|
3124
2915
|
if (!pioneer)
|
|
3125
2916
|
throw new Error("Failed to init! pioneer");
|
|
3126
|
-
const networkId =
|
|
2917
|
+
const networkId = import_pioneer_caip6.caipToNetworkId(caip);
|
|
3127
2918
|
if (!pubkeyContext) {
|
|
3128
2919
|
throw new Error(`No pubkey context provided for networkId: ${networkId}`);
|
|
3129
2920
|
}
|
|
@@ -3765,10 +3556,8 @@ function formatTime(durationMs) {
|
|
|
3765
3556
|
}
|
|
3766
3557
|
|
|
3767
3558
|
// src/utils/build-dashboard.ts
|
|
3768
|
-
var
|
|
3769
|
-
var TAG8 = " | build-dashboard | ";
|
|
3559
|
+
var import_pioneer_caip7 = require("@pioneer-platform/pioneer-caip");
|
|
3770
3560
|
function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
3771
|
-
console.log(TAG8, "[DASHBOARD] Building dashboard from cached balances...");
|
|
3772
3561
|
const dashboardData = {
|
|
3773
3562
|
networks: [],
|
|
3774
3563
|
totalValueUsd: 0,
|
|
@@ -3776,16 +3565,14 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
3776
3565
|
};
|
|
3777
3566
|
let totalPortfolioValue = 0;
|
|
3778
3567
|
const networksTemp = [];
|
|
3779
|
-
console.log(TAG8, "balances: ", balances);
|
|
3780
3568
|
for (const blockchain of blockchains) {
|
|
3781
|
-
const filteredBalances = balances.filter((
|
|
3782
|
-
const networkId =
|
|
3569
|
+
const filteredBalances = balances.filter((b) => {
|
|
3570
|
+
const networkId = import_pioneer_caip7.caipToNetworkId(b.caip);
|
|
3783
3571
|
return networkId === blockchain || blockchain === "eip155:*" && networkId.startsWith("eip155:");
|
|
3784
3572
|
});
|
|
3785
3573
|
const balanceMap = new Map;
|
|
3786
3574
|
const isBitcoin = blockchain.includes("bip122:000000000019d6689c085ae165831e93");
|
|
3787
3575
|
if (isBitcoin) {
|
|
3788
|
-
console.log(TAG8, "Bitcoin network detected - checking for duplicate balances");
|
|
3789
3576
|
const bitcoinByValue = new Map;
|
|
3790
3577
|
filteredBalances.forEach((balance) => {
|
|
3791
3578
|
const valueKey = `${balance.balance}_${balance.valueUsd}`;
|
|
@@ -3796,8 +3583,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
3796
3583
|
});
|
|
3797
3584
|
for (const [valueKey, balances2] of bitcoinByValue.entries()) {
|
|
3798
3585
|
if (balances2.length === 3 && parseFloat(balances2[0].valueUsd || "0") > 0) {
|
|
3799
|
-
|
|
3800
|
-
const xpubBalance = balances2.find((b2) => b2.pubkey?.startsWith("xpub")) || balances2[0];
|
|
3586
|
+
const xpubBalance = balances2.find((b) => b.pubkey?.startsWith("xpub")) || balances2[0];
|
|
3801
3587
|
const key = `${xpubBalance.caip}_${xpubBalance.pubkey || "default"}`;
|
|
3802
3588
|
balanceMap.set(key, xpubBalance);
|
|
3803
3589
|
} else {
|
|
@@ -3818,23 +3604,15 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
3818
3604
|
const networkBalances = Array.from(balanceMap.values());
|
|
3819
3605
|
const networkTotal = networkBalances.reduce((sum, balance, idx) => {
|
|
3820
3606
|
const valueUsd = typeof balance.valueUsd === "string" ? parseFloat(balance.valueUsd) : balance.valueUsd || 0;
|
|
3821
|
-
if (blockchain.includes("bip122:000000000019d6689c085ae165831e93")) {
|
|
3822
|
-
console.log(TAG8, `[BITCOIN DEBUG ${idx}] pubkey:`, balance.pubkey?.substring(0, 10) + "...", "| balance:", balance.balance, "| valueUsd:", balance.valueUsd, "→ parsed:", valueUsd, "| running sum:", sum + valueUsd);
|
|
3823
|
-
}
|
|
3824
3607
|
return sum + valueUsd;
|
|
3825
3608
|
}, 0);
|
|
3826
|
-
const nativeAssetCaip =
|
|
3827
|
-
const gasAsset = networkBalances.find((
|
|
3828
|
-
const totalNativeBalance = networkBalances.filter((
|
|
3609
|
+
const nativeAssetCaip = import_pioneer_caip7.networkIdToCaip(blockchain);
|
|
3610
|
+
const gasAsset = networkBalances.find((b) => b.caip === nativeAssetCaip);
|
|
3611
|
+
const totalNativeBalance = networkBalances.filter((b) => b.caip === nativeAssetCaip).reduce((sum, balance) => {
|
|
3829
3612
|
const balanceNum = typeof balance.balance === "string" ? parseFloat(balance.balance) : balance.balance || 0;
|
|
3830
3613
|
return sum + balanceNum;
|
|
3831
3614
|
}, 0).toString();
|
|
3832
3615
|
const assetInfo = nativeAssetCaip ? assetsMap.get(nativeAssetCaip) : null;
|
|
3833
|
-
console.log(TAG8, `[DEBUG] Network: ${blockchain}`);
|
|
3834
|
-
console.log(TAG8, `[DEBUG] nativeAssetCaip: ${nativeAssetCaip}`);
|
|
3835
|
-
console.log(TAG8, `[DEBUG] assetInfo:`, assetInfo);
|
|
3836
|
-
console.log(TAG8, `[DEBUG] gasAsset:`, gasAsset);
|
|
3837
|
-
console.log(TAG8, `[DEBUG] Resolved name: ${gasAsset?.name || assetInfo?.name || "NO NAME"}`);
|
|
3838
3616
|
networksTemp.push({
|
|
3839
3617
|
networkId: blockchain,
|
|
3840
3618
|
totalValueUsd: networkTotal,
|
|
@@ -3847,7 +3625,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
3847
3625
|
});
|
|
3848
3626
|
totalPortfolioValue += networkTotal;
|
|
3849
3627
|
}
|
|
3850
|
-
dashboardData.networks = networksTemp.sort((a,
|
|
3628
|
+
dashboardData.networks = networksTemp.sort((a, b) => b.totalValueUsd - a.totalValueUsd);
|
|
3851
3629
|
dashboardData.totalValueUsd = totalPortfolioValue;
|
|
3852
3630
|
dashboardData.networkPercentages = dashboardData.networks.map((network) => ({
|
|
3853
3631
|
networkId: network.networkId,
|
|
@@ -3858,20 +3636,20 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
3858
3636
|
}
|
|
3859
3637
|
|
|
3860
3638
|
// src/utils/sync-market.ts
|
|
3861
|
-
var
|
|
3639
|
+
var TAG8 = " | sync-market | ";
|
|
3862
3640
|
async function syncMarket(balances, pioneer) {
|
|
3863
|
-
const tag6 = `${
|
|
3641
|
+
const tag6 = `${TAG8} | syncMarket | `;
|
|
3864
3642
|
try {
|
|
3865
|
-
const invalidBalances = balances.filter((
|
|
3643
|
+
const invalidBalances = balances.filter((b) => !b || !b.caip || typeof b.caip !== "string" || !b.caip.includes(":"));
|
|
3866
3644
|
if (invalidBalances.length > 0) {
|
|
3867
|
-
console.warn(tag6, `Found ${invalidBalances.length} balances with invalid CAIPs:`, invalidBalances.map((
|
|
3868
|
-
caip:
|
|
3869
|
-
type: typeof
|
|
3870
|
-
symbol:
|
|
3871
|
-
balance:
|
|
3645
|
+
console.warn(tag6, `Found ${invalidBalances.length} balances with invalid CAIPs:`, invalidBalances.map((b) => ({
|
|
3646
|
+
caip: b?.caip,
|
|
3647
|
+
type: typeof b?.caip,
|
|
3648
|
+
symbol: b?.symbol,
|
|
3649
|
+
balance: b?.balance
|
|
3872
3650
|
})));
|
|
3873
3651
|
}
|
|
3874
|
-
let allCaips = balances.filter((
|
|
3652
|
+
let allCaips = balances.filter((b) => b && b.caip && typeof b.caip === "string" && b.caip.trim().length > 0).map((b) => b.caip);
|
|
3875
3653
|
allCaips = [...new Set(allCaips)];
|
|
3876
3654
|
allCaips = allCaips.filter((caip) => caip && typeof caip === "string" && caip.trim().length > 0 && caip.includes(":"));
|
|
3877
3655
|
console.log("GetMarketInfo: payload: ", allCaips);
|
|
@@ -3912,7 +3690,7 @@ async function syncMarket(balances, pioneer) {
|
|
|
3912
3690
|
}
|
|
3913
3691
|
|
|
3914
3692
|
// src/index.ts
|
|
3915
|
-
var
|
|
3693
|
+
var TAG9 = " | Pioneer-sdk | ";
|
|
3916
3694
|
|
|
3917
3695
|
class SDK {
|
|
3918
3696
|
status;
|
|
@@ -4070,7 +3848,7 @@ class SDK {
|
|
|
4070
3848
|
return true;
|
|
4071
3849
|
};
|
|
4072
3850
|
this.setPubkeys = (newPubkeys) => {
|
|
4073
|
-
const tag6 = `${
|
|
3851
|
+
const tag6 = `${TAG9} | setPubkeys | `;
|
|
4074
3852
|
this.pubkeys = [];
|
|
4075
3853
|
this.pubkeySet.clear();
|
|
4076
3854
|
let added = 0;
|
|
@@ -4087,7 +3865,7 @@ class SDK {
|
|
|
4087
3865
|
this.pubkeySet.clear();
|
|
4088
3866
|
}
|
|
4089
3867
|
this.getUnifiedPortfolio = async function() {
|
|
4090
|
-
const tag6 = `${
|
|
3868
|
+
const tag6 = `${TAG9} | getUnifiedPortfolio | `;
|
|
4091
3869
|
try {
|
|
4092
3870
|
const startTime = performance.now();
|
|
4093
3871
|
try {
|
|
@@ -4142,7 +3920,7 @@ class SDK {
|
|
|
4142
3920
|
console.error(`[CACHE VALIDATION] CORRUPTED: ${portfolioData2.networks.length} networks (should be < 50)`);
|
|
4143
3921
|
return false;
|
|
4144
3922
|
}
|
|
4145
|
-
const validNetworks = portfolioData2.networks.filter((
|
|
3923
|
+
const validNetworks = portfolioData2.networks.filter((n) => n.networkId && n.totalValueUsd !== undefined && n.gasAssetSymbol);
|
|
4146
3924
|
if (validNetworks.length === 0 && portfolioData2.networks.length > 0) {
|
|
4147
3925
|
console.error("[CACHE VALIDATION] CORRUPTED: No networks have required fields");
|
|
4148
3926
|
return false;
|
|
@@ -4195,7 +3973,7 @@ class SDK {
|
|
|
4195
3973
|
}
|
|
4196
3974
|
};
|
|
4197
3975
|
this.init = async function(walletsVerbose, setup) {
|
|
4198
|
-
const tag6 = `${
|
|
3976
|
+
const tag6 = `${TAG9} | init | `;
|
|
4199
3977
|
try {
|
|
4200
3978
|
if (!this.username)
|
|
4201
3979
|
throw Error("username required!");
|
|
@@ -4289,7 +4067,7 @@ class SDK {
|
|
|
4289
4067
|
return syncMarket(this.balances, this.pioneer);
|
|
4290
4068
|
};
|
|
4291
4069
|
this.sync = async function() {
|
|
4292
|
-
const tag6 = `${
|
|
4070
|
+
const tag6 = `${TAG9} | sync | `;
|
|
4293
4071
|
try {
|
|
4294
4072
|
const matchesNetwork = (item, networkId) => {
|
|
4295
4073
|
if (!item.networks || !Array.isArray(item.networks))
|
|
@@ -4341,26 +4119,14 @@ class SDK {
|
|
|
4341
4119
|
let totalPortfolioValue = 0;
|
|
4342
4120
|
const networksTemp = [];
|
|
4343
4121
|
const uniqueBlockchains = [...new Set(this.blockchains)];
|
|
4344
|
-
console.log(tag6, "uniqueBlockchains: ", uniqueBlockchains);
|
|
4345
4122
|
for (const blockchain of uniqueBlockchains) {
|
|
4346
|
-
const filteredBalances = this.balances.filter((
|
|
4347
|
-
const networkId =
|
|
4123
|
+
const filteredBalances = this.balances.filter((b) => {
|
|
4124
|
+
const networkId = import_pioneer_caip8.caipToNetworkId(b.caip);
|
|
4348
4125
|
return networkId === blockchain || blockchain === "eip155:*" && networkId.startsWith("eip155:");
|
|
4349
4126
|
});
|
|
4350
|
-
console.log(tag6, `Filtering for blockchain: ${blockchain}`);
|
|
4351
|
-
console.log(tag6, `Found ${filteredBalances.length} balances before deduplication`);
|
|
4352
|
-
filteredBalances.forEach((balance, idx) => {
|
|
4353
|
-
console.log(tag6, `Balance[${idx}]:`, {
|
|
4354
|
-
caip: balance.caip,
|
|
4355
|
-
pubkey: balance.pubkey,
|
|
4356
|
-
balance: balance.balance,
|
|
4357
|
-
valueUsd: balance.valueUsd
|
|
4358
|
-
});
|
|
4359
|
-
});
|
|
4360
4127
|
const balanceMap = new Map;
|
|
4361
4128
|
const isBitcoin = blockchain.includes("bip122:000000000019d6689c085ae165831e93");
|
|
4362
4129
|
if (isBitcoin) {
|
|
4363
|
-
console.log(tag6, "Bitcoin network detected - checking for duplicate balances");
|
|
4364
4130
|
const bitcoinByValue = new Map;
|
|
4365
4131
|
filteredBalances.forEach((balance) => {
|
|
4366
4132
|
const valueKey = `${balance.balance}_${balance.valueUsd}`;
|
|
@@ -4371,8 +4137,7 @@ class SDK {
|
|
|
4371
4137
|
});
|
|
4372
4138
|
for (const [valueKey, balances] of bitcoinByValue.entries()) {
|
|
4373
4139
|
if (balances.length === 3 && parseFloat(balances[0].valueUsd || "0") > 0) {
|
|
4374
|
-
|
|
4375
|
-
const xpubBalance = balances.find((b2) => b2.pubkey?.startsWith("xpub")) || balances[0];
|
|
4140
|
+
const xpubBalance = balances.find((b) => b.pubkey?.startsWith("xpub")) || balances[0];
|
|
4376
4141
|
const key = `${xpubBalance.caip}_${xpubBalance.pubkey || "default"}`;
|
|
4377
4142
|
balanceMap.set(key, xpubBalance);
|
|
4378
4143
|
} else {
|
|
@@ -4391,20 +4156,13 @@ class SDK {
|
|
|
4391
4156
|
});
|
|
4392
4157
|
}
|
|
4393
4158
|
const networkBalances = Array.from(balanceMap.values());
|
|
4394
|
-
console.log(tag6, "networkBalances (deduplicated): ", networkBalances);
|
|
4395
|
-
console.log(tag6, "networkBalances count: ", networkBalances.length);
|
|
4396
4159
|
const networkTotal = networkBalances.reduce((sum, balance, idx) => {
|
|
4397
4160
|
const valueUsd = typeof balance.valueUsd === "string" ? parseFloat(balance.valueUsd) : balance.valueUsd || 0;
|
|
4398
|
-
console.log(tag6, `[${idx}] valueUsd:`, balance.valueUsd, "→ parsed:", valueUsd, "| running sum:", sum + valueUsd);
|
|
4399
|
-
if (blockchain.includes("bip122:000000000019d6689c085ae165831e93")) {
|
|
4400
|
-
console.log(tag6, `[BITCOIN DEBUG ${idx}] pubkey:`, balance.pubkey?.substring(0, 10) + "...", "| balance:", balance.balance, "| valueUsd:", balance.valueUsd, "→ parsed:", valueUsd);
|
|
4401
|
-
}
|
|
4402
4161
|
return sum + valueUsd;
|
|
4403
4162
|
}, 0);
|
|
4404
|
-
|
|
4405
|
-
const
|
|
4406
|
-
const
|
|
4407
|
-
const totalNativeBalance = networkBalances.filter((b2) => b2.caip === nativeAssetCaip).reduce((sum, balance) => {
|
|
4163
|
+
const nativeAssetCaip = import_pioneer_caip8.networkIdToCaip(blockchain);
|
|
4164
|
+
const gasAsset = networkBalances.find((b) => b.caip === nativeAssetCaip);
|
|
4165
|
+
const totalNativeBalance = networkBalances.filter((b) => b.caip === nativeAssetCaip).reduce((sum, balance) => {
|
|
4408
4166
|
const balanceNum = typeof balance.balance === "string" ? parseFloat(balance.balance) : balance.balance || 0;
|
|
4409
4167
|
return sum + balanceNum;
|
|
4410
4168
|
}, 0).toString();
|
|
@@ -4419,7 +4177,7 @@ class SDK {
|
|
|
4419
4177
|
});
|
|
4420
4178
|
totalPortfolioValue += networkTotal;
|
|
4421
4179
|
}
|
|
4422
|
-
dashboardData.networks = networksTemp.sort((a,
|
|
4180
|
+
dashboardData.networks = networksTemp.sort((a, b) => b.totalValueUsd - a.totalValueUsd);
|
|
4423
4181
|
dashboardData.totalValueUsd = totalPortfolioValue;
|
|
4424
4182
|
dashboardData.networkPercentages = dashboardData.networks.map((network) => ({
|
|
4425
4183
|
networkId: network.networkId,
|
|
@@ -4442,7 +4200,7 @@ class SDK {
|
|
|
4442
4200
|
}
|
|
4443
4201
|
};
|
|
4444
4202
|
this.buildTx = async function(sendPayload) {
|
|
4445
|
-
let tag6 =
|
|
4203
|
+
let tag6 = TAG9 + " | buildTx | ";
|
|
4446
4204
|
try {
|
|
4447
4205
|
const transactionDependencies = {
|
|
4448
4206
|
context: this.context,
|
|
@@ -4464,7 +4222,7 @@ class SDK {
|
|
|
4464
4222
|
}
|
|
4465
4223
|
};
|
|
4466
4224
|
this.buildDelegateTx = async function(caip, params) {
|
|
4467
|
-
let tag6 =
|
|
4225
|
+
let tag6 = TAG9 + " | buildDelegateTx | ";
|
|
4468
4226
|
try {
|
|
4469
4227
|
const delegateParams = {
|
|
4470
4228
|
...params,
|
|
@@ -4479,7 +4237,7 @@ class SDK {
|
|
|
4479
4237
|
}
|
|
4480
4238
|
};
|
|
4481
4239
|
this.buildUndelegateTx = async function(caip, params) {
|
|
4482
|
-
let tag6 =
|
|
4240
|
+
let tag6 = TAG9 + " | buildUndelegateTx | ";
|
|
4483
4241
|
try {
|
|
4484
4242
|
const undelegateParams = {
|
|
4485
4243
|
...params,
|
|
@@ -4494,7 +4252,7 @@ class SDK {
|
|
|
4494
4252
|
}
|
|
4495
4253
|
};
|
|
4496
4254
|
this.buildClaimRewardsTx = async function(caip, params) {
|
|
4497
|
-
let tag6 =
|
|
4255
|
+
let tag6 = TAG9 + " | buildClaimRewardsTx | ";
|
|
4498
4256
|
try {
|
|
4499
4257
|
const claimParams = {
|
|
4500
4258
|
...params,
|
|
@@ -4509,7 +4267,7 @@ class SDK {
|
|
|
4509
4267
|
}
|
|
4510
4268
|
};
|
|
4511
4269
|
this.buildClaimAllRewardsTx = async function(caip, params) {
|
|
4512
|
-
let tag6 =
|
|
4270
|
+
let tag6 = TAG9 + " | buildClaimAllRewardsTx | ";
|
|
4513
4271
|
try {
|
|
4514
4272
|
const claimAllParams = {
|
|
4515
4273
|
...params,
|
|
@@ -4523,7 +4281,7 @@ class SDK {
|
|
|
4523
4281
|
}
|
|
4524
4282
|
};
|
|
4525
4283
|
this.signTx = async function(caip, unsignedTx) {
|
|
4526
|
-
let tag6 =
|
|
4284
|
+
let tag6 = TAG9 + " | signTx | ";
|
|
4527
4285
|
try {
|
|
4528
4286
|
const transactionDependencies = {
|
|
4529
4287
|
context: this.context,
|
|
@@ -4544,7 +4302,7 @@ class SDK {
|
|
|
4544
4302
|
}
|
|
4545
4303
|
};
|
|
4546
4304
|
this.broadcastTx = async function(caip, signedTx) {
|
|
4547
|
-
let tag6 =
|
|
4305
|
+
let tag6 = TAG9 + " | broadcastTx | ";
|
|
4548
4306
|
try {
|
|
4549
4307
|
const transactionDependencies = {
|
|
4550
4308
|
context: this.context,
|
|
@@ -4557,7 +4315,7 @@ class SDK {
|
|
|
4557
4315
|
};
|
|
4558
4316
|
let txManager = new TransactionManager(transactionDependencies, this.events);
|
|
4559
4317
|
let payload = {
|
|
4560
|
-
networkId:
|
|
4318
|
+
networkId: import_pioneer_caip8.caipToNetworkId(caip),
|
|
4561
4319
|
serialized: signedTx
|
|
4562
4320
|
};
|
|
4563
4321
|
let txid = await txManager.broadcast(payload);
|
|
@@ -4568,7 +4326,7 @@ class SDK {
|
|
|
4568
4326
|
}
|
|
4569
4327
|
};
|
|
4570
4328
|
this.swap = async function(swapPayload) {
|
|
4571
|
-
let tag6 = `${
|
|
4329
|
+
let tag6 = `${TAG9} | swap | `;
|
|
4572
4330
|
try {
|
|
4573
4331
|
if (!swapPayload)
|
|
4574
4332
|
throw Error("swapPayload required!");
|
|
@@ -4707,7 +4465,7 @@ class SDK {
|
|
|
4707
4465
|
}
|
|
4708
4466
|
};
|
|
4709
4467
|
this.transfer = async function(sendPayload) {
|
|
4710
|
-
let tag6 = `${
|
|
4468
|
+
let tag6 = `${TAG9} | transfer | `;
|
|
4711
4469
|
try {
|
|
4712
4470
|
if (!sendPayload)
|
|
4713
4471
|
throw Error("sendPayload required!");
|
|
@@ -4734,7 +4492,7 @@ class SDK {
|
|
|
4734
4492
|
if (!signedTx)
|
|
4735
4493
|
throw Error("Failed to sign transaction!");
|
|
4736
4494
|
let payload = {
|
|
4737
|
-
networkId:
|
|
4495
|
+
networkId: import_pioneer_caip8.caipToNetworkId(caip),
|
|
4738
4496
|
serialized: signedTx
|
|
4739
4497
|
};
|
|
4740
4498
|
let txid = await txManager.broadcast(payload);
|
|
@@ -4763,7 +4521,7 @@ class SDK {
|
|
|
4763
4521
|
while (!isConfirmed) {
|
|
4764
4522
|
try {
|
|
4765
4523
|
const response = await this.pioneer.LookupTx({
|
|
4766
|
-
networkId:
|
|
4524
|
+
networkId: import_pioneer_caip8.caipToNetworkId(caip),
|
|
4767
4525
|
txid
|
|
4768
4526
|
});
|
|
4769
4527
|
if (response?.data?.data) {
|
|
@@ -4802,7 +4560,7 @@ class SDK {
|
|
|
4802
4560
|
}
|
|
4803
4561
|
};
|
|
4804
4562
|
this.setBlockchains = async function(blockchains) {
|
|
4805
|
-
const tag6 = `${
|
|
4563
|
+
const tag6 = `${TAG9} | setBlockchains | `;
|
|
4806
4564
|
try {
|
|
4807
4565
|
if (!blockchains)
|
|
4808
4566
|
throw Error("blockchains required!");
|
|
@@ -4818,7 +4576,7 @@ class SDK {
|
|
|
4818
4576
|
}
|
|
4819
4577
|
};
|
|
4820
4578
|
this.addAsset = async function(caip, data) {
|
|
4821
|
-
let tag6 =
|
|
4579
|
+
let tag6 = TAG9 + " | addAsset | ";
|
|
4822
4580
|
try {
|
|
4823
4581
|
let success = false;
|
|
4824
4582
|
if (!caip)
|
|
@@ -4856,7 +4614,7 @@ class SDK {
|
|
|
4856
4614
|
}
|
|
4857
4615
|
};
|
|
4858
4616
|
this.clearWalletState = async function() {
|
|
4859
|
-
const tag6 = `${
|
|
4617
|
+
const tag6 = `${TAG9} | clearWalletState | `;
|
|
4860
4618
|
try {
|
|
4861
4619
|
this.context = null;
|
|
4862
4620
|
this.paths = [];
|
|
@@ -4871,7 +4629,7 @@ class SDK {
|
|
|
4871
4629
|
}
|
|
4872
4630
|
};
|
|
4873
4631
|
this.addPath = async function(path) {
|
|
4874
|
-
const tag6 = `${
|
|
4632
|
+
const tag6 = `${TAG9} | addPath | `;
|
|
4875
4633
|
try {
|
|
4876
4634
|
this.paths.push(path);
|
|
4877
4635
|
const pubkey = await getPubkey(path.networks[0], path, this.keepKeySdk, this.context);
|
|
@@ -4885,7 +4643,7 @@ class SDK {
|
|
|
4885
4643
|
}
|
|
4886
4644
|
};
|
|
4887
4645
|
this.addPaths = async function(paths) {
|
|
4888
|
-
const tag6 = `${
|
|
4646
|
+
const tag6 = `${TAG9} | addPaths | `;
|
|
4889
4647
|
try {
|
|
4890
4648
|
console.log(tag6, `Adding ${paths.length} paths in batch mode...`);
|
|
4891
4649
|
this.paths.push(...paths);
|
|
@@ -4921,11 +4679,11 @@ class SDK {
|
|
|
4921
4679
|
return this.getGasAssets();
|
|
4922
4680
|
};
|
|
4923
4681
|
this.getGasAssets = async function() {
|
|
4924
|
-
const tag6 = `${
|
|
4682
|
+
const tag6 = `${TAG9} | getGasAssets | `;
|
|
4925
4683
|
try {
|
|
4926
4684
|
for (let i = 0;i < this.blockchains.length; i++) {
|
|
4927
4685
|
let networkId = this.blockchains[i];
|
|
4928
|
-
let caip =
|
|
4686
|
+
let caip = import_pioneer_caip8.networkIdToCaip(networkId);
|
|
4929
4687
|
let asset = await import_pioneer_discovery2.assetData[caip.toLowerCase()];
|
|
4930
4688
|
if (asset) {
|
|
4931
4689
|
asset.caip = caip.toLowerCase();
|
|
@@ -4964,7 +4722,7 @@ class SDK {
|
|
|
4964
4722
|
}
|
|
4965
4723
|
};
|
|
4966
4724
|
this.getPubkeys = async function() {
|
|
4967
|
-
const tag6 = `${
|
|
4725
|
+
const tag6 = `${TAG9} | getPubkeys | `;
|
|
4968
4726
|
try {
|
|
4969
4727
|
if (this.paths.length === 0)
|
|
4970
4728
|
throw new Error("No paths found!");
|
|
@@ -4985,7 +4743,7 @@ class SDK {
|
|
|
4985
4743
|
}
|
|
4986
4744
|
};
|
|
4987
4745
|
this.getBalancesForNetworks = async function(networkIds) {
|
|
4988
|
-
const tag6 = `${
|
|
4746
|
+
const tag6 = `${TAG9} | getBalancesForNetworks | `;
|
|
4989
4747
|
try {
|
|
4990
4748
|
if (!this.pioneer) {
|
|
4991
4749
|
console.error(tag6, "ERROR: Pioneer client not initialized! this.pioneer is:", this.pioneer);
|
|
@@ -5003,7 +4761,7 @@ class SDK {
|
|
|
5003
4761
|
return network.startsWith("eip155:");
|
|
5004
4762
|
return network === adjustedNetworkId;
|
|
5005
4763
|
}));
|
|
5006
|
-
const caipNative = await
|
|
4764
|
+
const caipNative = await import_pioneer_caip8.networkIdToCaip(networkId);
|
|
5007
4765
|
for (const pubkey of pubkeys) {
|
|
5008
4766
|
assetQuery.push({ caip: caipNative, pubkey: pubkey.pubkey });
|
|
5009
4767
|
}
|
|
@@ -5013,20 +4771,17 @@ class SDK {
|
|
|
5013
4771
|
let marketInfo = await this.pioneer.GetPortfolioBalances(assetQuery);
|
|
5014
4772
|
console.timeEnd("GetPortfolioBalances Response Time");
|
|
5015
4773
|
let balances = marketInfo.data;
|
|
5016
|
-
const bitcoinBalances = balances.filter((b2) => b2.caip === "bip122:000000000019d6689c085ae165831e93/slip44:0");
|
|
5017
|
-
if (bitcoinBalances.length > 0) {
|
|
5018
|
-
}
|
|
5019
4774
|
for (let balance of balances) {
|
|
5020
4775
|
const assetInfo = this.assetsMap.get(balance.caip);
|
|
5021
4776
|
if (!assetInfo)
|
|
5022
4777
|
continue;
|
|
5023
4778
|
Object.assign(balance, assetInfo, {
|
|
5024
|
-
networkId:
|
|
4779
|
+
networkId: import_pioneer_caip8.caipToNetworkId(balance.caip),
|
|
5025
4780
|
icon: assetInfo.icon || "https://pioneers.dev/coins/etherum.png",
|
|
5026
|
-
identifier: `${balance.caip}:${balance.pubkey}
|
|
4781
|
+
identifier: `${balance.caip}:${balance.pubkey}`,
|
|
4782
|
+
updated: Date.now()
|
|
5027
4783
|
});
|
|
5028
4784
|
}
|
|
5029
|
-
console.log(tag6, "balances: ", balances);
|
|
5030
4785
|
this.balances = balances;
|
|
5031
4786
|
this.events.emit("SET_BALANCES", this.balances);
|
|
5032
4787
|
return this.balances;
|
|
@@ -5040,7 +4795,7 @@ class SDK {
|
|
|
5040
4795
|
}
|
|
5041
4796
|
};
|
|
5042
4797
|
this.getBalances = async function() {
|
|
5043
|
-
const tag6 = `${
|
|
4798
|
+
const tag6 = `${TAG9} | getBalances | `;
|
|
5044
4799
|
try {
|
|
5045
4800
|
return await this.getBalancesForNetworks(this.blockchains);
|
|
5046
4801
|
} catch (e) {
|
|
@@ -5049,10 +4804,10 @@ class SDK {
|
|
|
5049
4804
|
}
|
|
5050
4805
|
};
|
|
5051
4806
|
this.getBalance = async function(networkId) {
|
|
5052
|
-
const tag6 = `${
|
|
4807
|
+
const tag6 = `${TAG9} | getBalance | `;
|
|
5053
4808
|
try {
|
|
5054
4809
|
const results = await this.getBalancesForNetworks([networkId]);
|
|
5055
|
-
const filtered = results.filter(async (
|
|
4810
|
+
const filtered = results.filter(async (b) => b.networkId === await import_pioneer_caip8.networkIdToCaip(networkId));
|
|
5056
4811
|
return filtered;
|
|
5057
4812
|
} catch (e) {
|
|
5058
4813
|
console.error(tag6, "Error: ", e);
|
|
@@ -5060,7 +4815,7 @@ class SDK {
|
|
|
5060
4815
|
}
|
|
5061
4816
|
};
|
|
5062
4817
|
this.getFees = async function(networkId) {
|
|
5063
|
-
const tag6 = `${
|
|
4818
|
+
const tag6 = `${TAG9} | getFees | `;
|
|
5064
4819
|
try {
|
|
5065
4820
|
if (!this.pioneer) {
|
|
5066
4821
|
throw new Error("Pioneer client not initialized. Call init() first.");
|
|
@@ -5075,7 +4830,7 @@ class SDK {
|
|
|
5075
4830
|
return estimateTransactionFee(feeRate, unit, networkType, txSize);
|
|
5076
4831
|
};
|
|
5077
4832
|
this.getCharts = async function() {
|
|
5078
|
-
const tag6 = `${
|
|
4833
|
+
const tag6 = `${TAG9} | getCharts | `;
|
|
5079
4834
|
try {
|
|
5080
4835
|
console.log(tag6, "Fetching charts");
|
|
5081
4836
|
const newBalances = await getCharts(this.blockchains, this.pioneer, this.pubkeys, this.context);
|
|
@@ -5097,7 +4852,7 @@ class SDK {
|
|
|
5097
4852
|
}
|
|
5098
4853
|
};
|
|
5099
4854
|
this.setContext = async (context) => {
|
|
5100
|
-
const tag6 = `${
|
|
4855
|
+
const tag6 = `${TAG9} | setContext | `;
|
|
5101
4856
|
try {
|
|
5102
4857
|
if (!context)
|
|
5103
4858
|
throw Error("context required!");
|
|
@@ -5110,7 +4865,7 @@ class SDK {
|
|
|
5110
4865
|
}
|
|
5111
4866
|
};
|
|
5112
4867
|
this.setContextType = async (contextType) => {
|
|
5113
|
-
const tag6 = `${
|
|
4868
|
+
const tag6 = `${TAG9} | setContextType | `;
|
|
5114
4869
|
try {
|
|
5115
4870
|
if (!contextType)
|
|
5116
4871
|
throw Error("contextType required!");
|
|
@@ -5123,7 +4878,7 @@ class SDK {
|
|
|
5123
4878
|
}
|
|
5124
4879
|
};
|
|
5125
4880
|
this.refresh = async () => {
|
|
5126
|
-
const tag6 = `${
|
|
4881
|
+
const tag6 = `${TAG9} | refresh | `;
|
|
5127
4882
|
try {
|
|
5128
4883
|
await this.sync();
|
|
5129
4884
|
return this.balances;
|
|
@@ -5133,7 +4888,7 @@ class SDK {
|
|
|
5133
4888
|
}
|
|
5134
4889
|
};
|
|
5135
4890
|
this.setAssetContext = async function(asset) {
|
|
5136
|
-
const tag6 = `${
|
|
4891
|
+
const tag6 = `${TAG9} | setAssetContext | `;
|
|
5137
4892
|
try {
|
|
5138
4893
|
if (!asset) {
|
|
5139
4894
|
this.assetContext = null;
|
|
@@ -5142,7 +4897,7 @@ class SDK {
|
|
|
5142
4897
|
if (!asset.caip)
|
|
5143
4898
|
throw Error("Invalid Asset! missing caip!");
|
|
5144
4899
|
if (!asset.networkId)
|
|
5145
|
-
asset.networkId =
|
|
4900
|
+
asset.networkId = import_pioneer_caip8.caipToNetworkId(asset.caip);
|
|
5146
4901
|
if (!this.pubkeys || this.pubkeys.length === 0) {
|
|
5147
4902
|
const errorMsg = `Cannot set asset context for ${asset.caip} - no pubkeys loaded. Please initialize wallet first.`;
|
|
5148
4903
|
console.error(tag6, errorMsg);
|
|
@@ -5162,20 +4917,20 @@ class SDK {
|
|
|
5162
4917
|
const errorMsg = `Cannot set asset context for ${asset.caip} - no address/xpub found for network ${asset.networkId}`;
|
|
5163
4918
|
console.error(tag6, errorMsg);
|
|
5164
4919
|
console.error(tag6, "Available networks in pubkeys:", [
|
|
5165
|
-
...new Set(this.pubkeys.flatMap((
|
|
4920
|
+
...new Set(this.pubkeys.flatMap((p) => p.networks || []))
|
|
5166
4921
|
]);
|
|
5167
4922
|
throw new Error(errorMsg);
|
|
5168
4923
|
}
|
|
5169
4924
|
const isUtxoChain = asset.networkId.startsWith("bip122:");
|
|
5170
4925
|
if (isUtxoChain) {
|
|
5171
|
-
const xpubFound = pubkeysForNetwork.some((
|
|
4926
|
+
const xpubFound = pubkeysForNetwork.some((p) => p.type === "xpub" && p.pubkey);
|
|
5172
4927
|
if (!xpubFound) {
|
|
5173
4928
|
const errorMsg = `Cannot set asset context for UTXO chain ${asset.caip} - xpub required but not found`;
|
|
5174
4929
|
console.error(tag6, errorMsg);
|
|
5175
4930
|
throw new Error(errorMsg);
|
|
5176
4931
|
}
|
|
5177
4932
|
}
|
|
5178
|
-
const hasValidAddress = pubkeysForNetwork.some((
|
|
4933
|
+
const hasValidAddress = pubkeysForNetwork.some((p) => p.address || p.master || p.pubkey);
|
|
5179
4934
|
if (!hasValidAddress) {
|
|
5180
4935
|
const errorMsg = `Cannot set asset context for ${asset.caip} - no valid address found in pubkeys`;
|
|
5181
4936
|
console.error(tag6, errorMsg);
|
|
@@ -5216,7 +4971,7 @@ class SDK {
|
|
|
5216
4971
|
icon: asset.icon || "https://pioneers.dev/coins/ethereum.png"
|
|
5217
4972
|
};
|
|
5218
4973
|
}
|
|
5219
|
-
const matchingBalances = this.balances.filter((
|
|
4974
|
+
const matchingBalances = this.balances.filter((b) => b.caip === asset.caip);
|
|
5220
4975
|
if (matchingBalances.length > 0) {
|
|
5221
4976
|
let priceValue = matchingBalances[0].priceUsd || matchingBalances[0].price;
|
|
5222
4977
|
if ((!priceValue || priceValue === 0) && matchingBalances[0].valueUsd && matchingBalances[0].balance) {
|
|
@@ -5249,8 +5004,8 @@ class SDK {
|
|
|
5249
5004
|
assetInfo.valueUsd = totalValueUsd.toFixed(2);
|
|
5250
5005
|
console.log(tag6, `Aggregated balance: ${totalBalance} (${totalValueUsd.toFixed(2)} USD)`);
|
|
5251
5006
|
}
|
|
5252
|
-
const assetBalances = this.balances.filter((
|
|
5253
|
-
const assetPubkeys = this.pubkeys.filter((
|
|
5007
|
+
const assetBalances = this.balances.filter((b) => b.caip === asset.caip);
|
|
5008
|
+
const assetPubkeys = this.pubkeys.filter((p) => p.networks && Array.isArray(p.networks) && p.networks.includes(import_pioneer_caip8.caipToNetworkId(asset.caip)) || import_pioneer_caip8.caipToNetworkId(asset.caip).includes("eip155") && p.networks && Array.isArray(p.networks) && p.networks.some((n) => n.startsWith("eip155")));
|
|
5254
5009
|
const finalAssetContext = {
|
|
5255
5010
|
...assetInfo,
|
|
5256
5011
|
...asset,
|
|
@@ -5301,7 +5056,7 @@ class SDK {
|
|
|
5301
5056
|
}
|
|
5302
5057
|
this.assetContext.nativeSymbol = nativeSymbol;
|
|
5303
5058
|
if (nativeCaip) {
|
|
5304
|
-
const nativeBalance = this.balances.find((
|
|
5059
|
+
const nativeBalance = this.balances.find((b) => b.caip === nativeCaip);
|
|
5305
5060
|
if (nativeBalance) {
|
|
5306
5061
|
this.assetContext.nativeBalance = nativeBalance.balance || "0";
|
|
5307
5062
|
} else {
|
|
@@ -5310,12 +5065,12 @@ class SDK {
|
|
|
5310
5065
|
}
|
|
5311
5066
|
}
|
|
5312
5067
|
if (asset.caip) {
|
|
5313
|
-
this.blockchainContext =
|
|
5068
|
+
this.blockchainContext = import_pioneer_caip8.caipToNetworkId(asset.caip);
|
|
5314
5069
|
} else if (asset.networkId) {
|
|
5315
5070
|
this.blockchainContext = asset.networkId;
|
|
5316
5071
|
}
|
|
5317
5072
|
if (assetPubkeys && assetPubkeys.length > 0) {
|
|
5318
|
-
const networkId =
|
|
5073
|
+
const networkId = import_pioneer_caip8.caipToNetworkId(asset.caip || asset.networkId);
|
|
5319
5074
|
const currentContextValid = this.pubkeyContext?.networks?.includes(networkId);
|
|
5320
5075
|
if (!this.pubkeyContext || !currentContextValid) {
|
|
5321
5076
|
this.pubkeyContext = assetPubkeys[0];
|
|
@@ -5332,7 +5087,7 @@ class SDK {
|
|
|
5332
5087
|
}
|
|
5333
5088
|
};
|
|
5334
5089
|
this.setPubkeyContext = async function(pubkey) {
|
|
5335
|
-
let tag6 = `${
|
|
5090
|
+
let tag6 = `${TAG9} | setPubkeyContext | `;
|
|
5336
5091
|
try {
|
|
5337
5092
|
if (!pubkey)
|
|
5338
5093
|
throw Error("pubkey is required");
|
|
@@ -5351,7 +5106,7 @@ class SDK {
|
|
|
5351
5106
|
}
|
|
5352
5107
|
};
|
|
5353
5108
|
this.setOutboundAssetContext = async function(asset) {
|
|
5354
|
-
const tag6 = `${
|
|
5109
|
+
const tag6 = `${TAG9} | setOutputAssetContext | `;
|
|
5355
5110
|
try {
|
|
5356
5111
|
console.log(tag6, "0. asset: ", asset);
|
|
5357
5112
|
if (!asset) {
|
|
@@ -5362,15 +5117,15 @@ class SDK {
|
|
|
5362
5117
|
if (!asset.caip)
|
|
5363
5118
|
throw Error("Invalid Asset! missing caip!");
|
|
5364
5119
|
if (!asset.networkId)
|
|
5365
|
-
asset.networkId =
|
|
5120
|
+
asset.networkId = import_pioneer_caip8.caipToNetworkId(asset.caip);
|
|
5366
5121
|
console.log(tag6, "networkId: ", asset.networkId);
|
|
5367
5122
|
console.log(tag6, "this.pubkeys: ", this.pubkeys);
|
|
5368
|
-
const pubkey = this.pubkeys.find((
|
|
5369
|
-
if (!
|
|
5123
|
+
const pubkey = this.pubkeys.find((p) => {
|
|
5124
|
+
if (!p.networks || !Array.isArray(p.networks))
|
|
5370
5125
|
return false;
|
|
5371
|
-
if (
|
|
5126
|
+
if (p.networks.includes(asset.networkId))
|
|
5372
5127
|
return true;
|
|
5373
|
-
if (asset.networkId.startsWith("eip155:") &&
|
|
5128
|
+
if (asset.networkId.startsWith("eip155:") && p.networks.includes("eip155:*"))
|
|
5374
5129
|
return true;
|
|
5375
5130
|
return false;
|
|
5376
5131
|
});
|
|
@@ -5405,7 +5160,7 @@ class SDK {
|
|
|
5405
5160
|
icon: asset.icon || "https://pioneers.dev/coins/ethereum.png"
|
|
5406
5161
|
};
|
|
5407
5162
|
}
|
|
5408
|
-
const matchingBalances = this.balances.filter((
|
|
5163
|
+
const matchingBalances = this.balances.filter((b) => b.caip === asset.caip);
|
|
5409
5164
|
if (matchingBalances.length > 0) {
|
|
5410
5165
|
let priceValue = matchingBalances[0].priceUsd || matchingBalances[0].price;
|
|
5411
5166
|
if ((!priceValue || priceValue === 0) && matchingBalances[0].valueUsd && matchingBalances[0].balance) {
|
|
@@ -5443,7 +5198,7 @@ class SDK {
|
|
|
5443
5198
|
console.log(tag6, "CHECKPOINT 3");
|
|
5444
5199
|
console.log(tag6, "outboundAssetContext: assetInfo: ", assetInfo);
|
|
5445
5200
|
if (asset.caip) {
|
|
5446
|
-
this.outboundBlockchainContext =
|
|
5201
|
+
this.outboundBlockchainContext = import_pioneer_caip8.caipToNetworkId(asset.caip);
|
|
5447
5202
|
} else if (asset.networkId) {
|
|
5448
5203
|
this.outboundBlockchainContext = asset.networkId;
|
|
5449
5204
|
}
|