@pioneer-platform/pioneer-sdk 4.21.11 → 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 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, b2) {
187
- return utxoScore(b2, feeRate) - utxoScore(a, feeRate);
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 import_pioneer_caip7 = require("@pioneer-platform/pioneer-caip");
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 = V[networkId];
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((p2) => p2.path));
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 import_pioneer_caip = require("@pioneer-platform/pioneer-caip");
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 = import_pioneer_caip.caipToNetworkId(caip);
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 import_pioneer_caip2 = require("@pioneer-platform/pioneer-caip");
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 = import_pioneer_caip2.caipToNetworkId(caip);
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 import_pioneer_caip3 = require("@pioneer-platform/pioneer-caip");
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 = import_pioneer_caip3.caipToNetworkId(caip);
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 import_pioneer_caip4 = require("@pioneer-platform/pioneer-caip");
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 = import_pioneer_caip4.NetworkIdToChain[networkId];
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 = import_pioneer_caip4.caipToNetworkId(caip);
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 = import_pioneer_caip4.NetworkIdToChain[networkId];
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], [, b2]) => b2 - a)[0]?.[0] || "p2pkh";
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})`);
@@ -2752,7 +2543,27 @@ class TransactionManager {
2752
2543
  this.events = events;
2753
2544
  }
2754
2545
  async classifyCaip(caip) {
2755
- const caipString = typeof caip === "string" ? caip : String(caip);
2546
+ let caipString;
2547
+ if (typeof caip === "string") {
2548
+ caipString = caip;
2549
+ } else if (caip && typeof caip === "object") {
2550
+ if (caip.caip && typeof caip.caip === "string") {
2551
+ caipString = caip.caip;
2552
+ } else if (caip.toString && typeof caip.toString === "function") {
2553
+ caipString = caip.toString();
2554
+ if (caipString === "[object Object]") {
2555
+ if (caip.chainId && caip.network) {
2556
+ caipString = `${caip.chainId}:${caip.network}`;
2557
+ } else {
2558
+ throw new Error(`Cannot extract CAIP string from object: ${JSON.stringify(caip)}`);
2559
+ }
2560
+ }
2561
+ } else {
2562
+ throw new Error(`Cannot extract CAIP string from object: ${JSON.stringify(caip)}`);
2563
+ }
2564
+ } else {
2565
+ throw new Error(`Invalid CAIP parameter: ${caip}`);
2566
+ }
2756
2567
  if (SUPPORTED_CAIPS.UTXO.includes(caipString))
2757
2568
  return "UTXO";
2758
2569
  if (SUPPORTED_CAIPS.TENDERMINT.includes(caipString))
@@ -2986,7 +2797,7 @@ class TransactionManager {
2986
2797
  }
2987
2798
 
2988
2799
  // src/txbuilder/createUnsignedStakingTx.ts
2989
- var import_pioneer_caip5 = require("@pioneer-platform/pioneer-caip");
2800
+ var import_pioneer_caip6 = require("@pioneer-platform/pioneer-caip");
2990
2801
 
2991
2802
  // src/txbuilder/templates/cosmos-staking.ts
2992
2803
  var cosmosDelegateTemplate = (params) => ({
@@ -3103,7 +2914,7 @@ async function createUnsignedStakingTx(caip, params, pubkeys, pioneer, pubkeyCon
3103
2914
  try {
3104
2915
  if (!pioneer)
3105
2916
  throw new Error("Failed to init! pioneer");
3106
- const networkId = import_pioneer_caip5.caipToNetworkId(caip);
2917
+ const networkId = import_pioneer_caip6.caipToNetworkId(caip);
3107
2918
  if (!pubkeyContext) {
3108
2919
  throw new Error(`No pubkey context provided for networkId: ${networkId}`);
3109
2920
  }
@@ -3745,10 +3556,8 @@ function formatTime(durationMs) {
3745
3556
  }
3746
3557
 
3747
3558
  // src/utils/build-dashboard.ts
3748
- var import_pioneer_caip6 = require("@pioneer-platform/pioneer-caip");
3749
- var TAG8 = " | build-dashboard | ";
3559
+ var import_pioneer_caip7 = require("@pioneer-platform/pioneer-caip");
3750
3560
  function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3751
- console.log(TAG8, "[DASHBOARD] Building dashboard from cached balances...");
3752
3561
  const dashboardData = {
3753
3562
  networks: [],
3754
3563
  totalValueUsd: 0,
@@ -3756,16 +3565,14 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3756
3565
  };
3757
3566
  let totalPortfolioValue = 0;
3758
3567
  const networksTemp = [];
3759
- console.log(TAG8, "balances: ", balances);
3760
3568
  for (const blockchain of blockchains) {
3761
- const filteredBalances = balances.filter((b2) => {
3762
- const networkId = import_pioneer_caip6.caipToNetworkId(b2.caip);
3569
+ const filteredBalances = balances.filter((b) => {
3570
+ const networkId = import_pioneer_caip7.caipToNetworkId(b.caip);
3763
3571
  return networkId === blockchain || blockchain === "eip155:*" && networkId.startsWith("eip155:");
3764
3572
  });
3765
3573
  const balanceMap = new Map;
3766
3574
  const isBitcoin = blockchain.includes("bip122:000000000019d6689c085ae165831e93");
3767
3575
  if (isBitcoin) {
3768
- console.log(TAG8, "Bitcoin network detected - checking for duplicate balances");
3769
3576
  const bitcoinByValue = new Map;
3770
3577
  filteredBalances.forEach((balance) => {
3771
3578
  const valueKey = `${balance.balance}_${balance.valueUsd}`;
@@ -3776,8 +3583,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3776
3583
  });
3777
3584
  for (const [valueKey, balances2] of bitcoinByValue.entries()) {
3778
3585
  if (balances2.length === 3 && parseFloat(balances2[0].valueUsd || "0") > 0) {
3779
- console.log(TAG8, "BITCOIN API BUG DETECTED: All 3 address types have same balance, keeping only xpub");
3780
- const xpubBalance = balances2.find((b2) => b2.pubkey?.startsWith("xpub")) || balances2[0];
3586
+ const xpubBalance = balances2.find((b) => b.pubkey?.startsWith("xpub")) || balances2[0];
3781
3587
  const key = `${xpubBalance.caip}_${xpubBalance.pubkey || "default"}`;
3782
3588
  balanceMap.set(key, xpubBalance);
3783
3589
  } else {
@@ -3798,23 +3604,15 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3798
3604
  const networkBalances = Array.from(balanceMap.values());
3799
3605
  const networkTotal = networkBalances.reduce((sum, balance, idx) => {
3800
3606
  const valueUsd = typeof balance.valueUsd === "string" ? parseFloat(balance.valueUsd) : balance.valueUsd || 0;
3801
- if (blockchain.includes("bip122:000000000019d6689c085ae165831e93")) {
3802
- console.log(TAG8, `[BITCOIN DEBUG ${idx}] pubkey:`, balance.pubkey?.substring(0, 10) + "...", "| balance:", balance.balance, "| valueUsd:", balance.valueUsd, "→ parsed:", valueUsd, "| running sum:", sum + valueUsd);
3803
- }
3804
3607
  return sum + valueUsd;
3805
3608
  }, 0);
3806
- const nativeAssetCaip = import_pioneer_caip6.networkIdToCaip(blockchain);
3807
- const gasAsset = networkBalances.find((b2) => b2.caip === nativeAssetCaip);
3808
- const totalNativeBalance = networkBalances.filter((b2) => b2.caip === nativeAssetCaip).reduce((sum, balance) => {
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) => {
3809
3612
  const balanceNum = typeof balance.balance === "string" ? parseFloat(balance.balance) : balance.balance || 0;
3810
3613
  return sum + balanceNum;
3811
3614
  }, 0).toString();
3812
3615
  const assetInfo = nativeAssetCaip ? assetsMap.get(nativeAssetCaip) : null;
3813
- console.log(TAG8, `[DEBUG] Network: ${blockchain}`);
3814
- console.log(TAG8, `[DEBUG] nativeAssetCaip: ${nativeAssetCaip}`);
3815
- console.log(TAG8, `[DEBUG] assetInfo:`, assetInfo);
3816
- console.log(TAG8, `[DEBUG] gasAsset:`, gasAsset);
3817
- console.log(TAG8, `[DEBUG] Resolved name: ${gasAsset?.name || assetInfo?.name || "NO NAME"}`);
3818
3616
  networksTemp.push({
3819
3617
  networkId: blockchain,
3820
3618
  totalValueUsd: networkTotal,
@@ -3827,7 +3625,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3827
3625
  });
3828
3626
  totalPortfolioValue += networkTotal;
3829
3627
  }
3830
- dashboardData.networks = networksTemp.sort((a, b2) => b2.totalValueUsd - a.totalValueUsd);
3628
+ dashboardData.networks = networksTemp.sort((a, b) => b.totalValueUsd - a.totalValueUsd);
3831
3629
  dashboardData.totalValueUsd = totalPortfolioValue;
3832
3630
  dashboardData.networkPercentages = dashboardData.networks.map((network) => ({
3833
3631
  networkId: network.networkId,
@@ -3838,20 +3636,20 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3838
3636
  }
3839
3637
 
3840
3638
  // src/utils/sync-market.ts
3841
- var TAG9 = " | sync-market | ";
3639
+ var TAG8 = " | sync-market | ";
3842
3640
  async function syncMarket(balances, pioneer) {
3843
- const tag6 = `${TAG9} | syncMarket | `;
3641
+ const tag6 = `${TAG8} | syncMarket | `;
3844
3642
  try {
3845
- const invalidBalances = balances.filter((b2) => !b2 || !b2.caip || typeof b2.caip !== "string" || !b2.caip.includes(":"));
3643
+ const invalidBalances = balances.filter((b) => !b || !b.caip || typeof b.caip !== "string" || !b.caip.includes(":"));
3846
3644
  if (invalidBalances.length > 0) {
3847
- console.warn(tag6, `Found ${invalidBalances.length} balances with invalid CAIPs:`, invalidBalances.map((b2) => ({
3848
- caip: b2?.caip,
3849
- type: typeof b2?.caip,
3850
- symbol: b2?.symbol,
3851
- balance: b2?.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
3852
3650
  })));
3853
3651
  }
3854
- let allCaips = balances.filter((b2) => b2 && b2.caip && typeof b2.caip === "string" && b2.caip.trim().length > 0).map((b2) => b2.caip);
3652
+ let allCaips = balances.filter((b) => b && b.caip && typeof b.caip === "string" && b.caip.trim().length > 0).map((b) => b.caip);
3855
3653
  allCaips = [...new Set(allCaips)];
3856
3654
  allCaips = allCaips.filter((caip) => caip && typeof caip === "string" && caip.trim().length > 0 && caip.includes(":"));
3857
3655
  console.log("GetMarketInfo: payload: ", allCaips);
@@ -3892,7 +3690,7 @@ async function syncMarket(balances, pioneer) {
3892
3690
  }
3893
3691
 
3894
3692
  // src/index.ts
3895
- var TAG10 = " | Pioneer-sdk | ";
3693
+ var TAG9 = " | Pioneer-sdk | ";
3896
3694
 
3897
3695
  class SDK {
3898
3696
  status;
@@ -4050,7 +3848,7 @@ class SDK {
4050
3848
  return true;
4051
3849
  };
4052
3850
  this.setPubkeys = (newPubkeys) => {
4053
- const tag6 = `${TAG10} | setPubkeys | `;
3851
+ const tag6 = `${TAG9} | setPubkeys | `;
4054
3852
  this.pubkeys = [];
4055
3853
  this.pubkeySet.clear();
4056
3854
  let added = 0;
@@ -4067,7 +3865,7 @@ class SDK {
4067
3865
  this.pubkeySet.clear();
4068
3866
  }
4069
3867
  this.getUnifiedPortfolio = async function() {
4070
- const tag6 = `${TAG10} | getUnifiedPortfolio | `;
3868
+ const tag6 = `${TAG9} | getUnifiedPortfolio | `;
4071
3869
  try {
4072
3870
  const startTime = performance.now();
4073
3871
  try {
@@ -4122,7 +3920,7 @@ class SDK {
4122
3920
  console.error(`[CACHE VALIDATION] CORRUPTED: ${portfolioData2.networks.length} networks (should be < 50)`);
4123
3921
  return false;
4124
3922
  }
4125
- const validNetworks = portfolioData2.networks.filter((n2) => n2.networkId && n2.totalValueUsd !== undefined && n2.gasAssetSymbol);
3923
+ const validNetworks = portfolioData2.networks.filter((n) => n.networkId && n.totalValueUsd !== undefined && n.gasAssetSymbol);
4126
3924
  if (validNetworks.length === 0 && portfolioData2.networks.length > 0) {
4127
3925
  console.error("[CACHE VALIDATION] CORRUPTED: No networks have required fields");
4128
3926
  return false;
@@ -4175,7 +3973,7 @@ class SDK {
4175
3973
  }
4176
3974
  };
4177
3975
  this.init = async function(walletsVerbose, setup) {
4178
- const tag6 = `${TAG10} | init | `;
3976
+ const tag6 = `${TAG9} | init | `;
4179
3977
  try {
4180
3978
  if (!this.username)
4181
3979
  throw Error("username required!");
@@ -4269,7 +4067,7 @@ class SDK {
4269
4067
  return syncMarket(this.balances, this.pioneer);
4270
4068
  };
4271
4069
  this.sync = async function() {
4272
- const tag6 = `${TAG10} | sync | `;
4070
+ const tag6 = `${TAG9} | sync | `;
4273
4071
  try {
4274
4072
  const matchesNetwork = (item, networkId) => {
4275
4073
  if (!item.networks || !Array.isArray(item.networks))
@@ -4321,26 +4119,14 @@ class SDK {
4321
4119
  let totalPortfolioValue = 0;
4322
4120
  const networksTemp = [];
4323
4121
  const uniqueBlockchains = [...new Set(this.blockchains)];
4324
- console.log(tag6, "uniqueBlockchains: ", uniqueBlockchains);
4325
4122
  for (const blockchain of uniqueBlockchains) {
4326
- const filteredBalances = this.balances.filter((b2) => {
4327
- const networkId = import_pioneer_caip7.caipToNetworkId(b2.caip);
4123
+ const filteredBalances = this.balances.filter((b) => {
4124
+ const networkId = import_pioneer_caip8.caipToNetworkId(b.caip);
4328
4125
  return networkId === blockchain || blockchain === "eip155:*" && networkId.startsWith("eip155:");
4329
4126
  });
4330
- console.log(tag6, `Filtering for blockchain: ${blockchain}`);
4331
- console.log(tag6, `Found ${filteredBalances.length} balances before deduplication`);
4332
- filteredBalances.forEach((balance, idx) => {
4333
- console.log(tag6, `Balance[${idx}]:`, {
4334
- caip: balance.caip,
4335
- pubkey: balance.pubkey,
4336
- balance: balance.balance,
4337
- valueUsd: balance.valueUsd
4338
- });
4339
- });
4340
4127
  const balanceMap = new Map;
4341
4128
  const isBitcoin = blockchain.includes("bip122:000000000019d6689c085ae165831e93");
4342
4129
  if (isBitcoin) {
4343
- console.log(tag6, "Bitcoin network detected - checking for duplicate balances");
4344
4130
  const bitcoinByValue = new Map;
4345
4131
  filteredBalances.forEach((balance) => {
4346
4132
  const valueKey = `${balance.balance}_${balance.valueUsd}`;
@@ -4351,8 +4137,7 @@ class SDK {
4351
4137
  });
4352
4138
  for (const [valueKey, balances] of bitcoinByValue.entries()) {
4353
4139
  if (balances.length === 3 && parseFloat(balances[0].valueUsd || "0") > 0) {
4354
- console.log(tag6, "BITCOIN API BUG DETECTED: All 3 address types have same balance, keeping only xpub");
4355
- const xpubBalance = balances.find((b2) => b2.pubkey?.startsWith("xpub")) || balances[0];
4140
+ const xpubBalance = balances.find((b) => b.pubkey?.startsWith("xpub")) || balances[0];
4356
4141
  const key = `${xpubBalance.caip}_${xpubBalance.pubkey || "default"}`;
4357
4142
  balanceMap.set(key, xpubBalance);
4358
4143
  } else {
@@ -4371,20 +4156,13 @@ class SDK {
4371
4156
  });
4372
4157
  }
4373
4158
  const networkBalances = Array.from(balanceMap.values());
4374
- console.log(tag6, "networkBalances (deduplicated): ", networkBalances);
4375
- console.log(tag6, "networkBalances count: ", networkBalances.length);
4376
4159
  const networkTotal = networkBalances.reduce((sum, balance, idx) => {
4377
4160
  const valueUsd = typeof balance.valueUsd === "string" ? parseFloat(balance.valueUsd) : balance.valueUsd || 0;
4378
- console.log(tag6, `[${idx}] valueUsd:`, balance.valueUsd, "→ parsed:", valueUsd, "| running sum:", sum + valueUsd);
4379
- if (blockchain.includes("bip122:000000000019d6689c085ae165831e93")) {
4380
- console.log(tag6, `[BITCOIN DEBUG ${idx}] pubkey:`, balance.pubkey?.substring(0, 10) + "...", "| balance:", balance.balance, "| valueUsd:", balance.valueUsd, "→ parsed:", valueUsd);
4381
- }
4382
4161
  return sum + valueUsd;
4383
4162
  }, 0);
4384
- console.log("Final networkTotal:", networkTotal);
4385
- const nativeAssetCaip = import_pioneer_caip7.networkIdToCaip(blockchain);
4386
- const gasAsset = networkBalances.find((b2) => b2.caip === nativeAssetCaip);
4387
- 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) => {
4388
4166
  const balanceNum = typeof balance.balance === "string" ? parseFloat(balance.balance) : balance.balance || 0;
4389
4167
  return sum + balanceNum;
4390
4168
  }, 0).toString();
@@ -4399,7 +4177,7 @@ class SDK {
4399
4177
  });
4400
4178
  totalPortfolioValue += networkTotal;
4401
4179
  }
4402
- dashboardData.networks = networksTemp.sort((a, b2) => b2.totalValueUsd - a.totalValueUsd);
4180
+ dashboardData.networks = networksTemp.sort((a, b) => b.totalValueUsd - a.totalValueUsd);
4403
4181
  dashboardData.totalValueUsd = totalPortfolioValue;
4404
4182
  dashboardData.networkPercentages = dashboardData.networks.map((network) => ({
4405
4183
  networkId: network.networkId,
@@ -4422,7 +4200,7 @@ class SDK {
4422
4200
  }
4423
4201
  };
4424
4202
  this.buildTx = async function(sendPayload) {
4425
- let tag6 = TAG10 + " | buildTx | ";
4203
+ let tag6 = TAG9 + " | buildTx | ";
4426
4204
  try {
4427
4205
  const transactionDependencies = {
4428
4206
  context: this.context,
@@ -4444,7 +4222,7 @@ class SDK {
4444
4222
  }
4445
4223
  };
4446
4224
  this.buildDelegateTx = async function(caip, params) {
4447
- let tag6 = TAG10 + " | buildDelegateTx | ";
4225
+ let tag6 = TAG9 + " | buildDelegateTx | ";
4448
4226
  try {
4449
4227
  const delegateParams = {
4450
4228
  ...params,
@@ -4459,7 +4237,7 @@ class SDK {
4459
4237
  }
4460
4238
  };
4461
4239
  this.buildUndelegateTx = async function(caip, params) {
4462
- let tag6 = TAG10 + " | buildUndelegateTx | ";
4240
+ let tag6 = TAG9 + " | buildUndelegateTx | ";
4463
4241
  try {
4464
4242
  const undelegateParams = {
4465
4243
  ...params,
@@ -4474,7 +4252,7 @@ class SDK {
4474
4252
  }
4475
4253
  };
4476
4254
  this.buildClaimRewardsTx = async function(caip, params) {
4477
- let tag6 = TAG10 + " | buildClaimRewardsTx | ";
4255
+ let tag6 = TAG9 + " | buildClaimRewardsTx | ";
4478
4256
  try {
4479
4257
  const claimParams = {
4480
4258
  ...params,
@@ -4489,7 +4267,7 @@ class SDK {
4489
4267
  }
4490
4268
  };
4491
4269
  this.buildClaimAllRewardsTx = async function(caip, params) {
4492
- let tag6 = TAG10 + " | buildClaimAllRewardsTx | ";
4270
+ let tag6 = TAG9 + " | buildClaimAllRewardsTx | ";
4493
4271
  try {
4494
4272
  const claimAllParams = {
4495
4273
  ...params,
@@ -4503,7 +4281,7 @@ class SDK {
4503
4281
  }
4504
4282
  };
4505
4283
  this.signTx = async function(caip, unsignedTx) {
4506
- let tag6 = TAG10 + " | signTx | ";
4284
+ let tag6 = TAG9 + " | signTx | ";
4507
4285
  try {
4508
4286
  const transactionDependencies = {
4509
4287
  context: this.context,
@@ -4524,7 +4302,7 @@ class SDK {
4524
4302
  }
4525
4303
  };
4526
4304
  this.broadcastTx = async function(caip, signedTx) {
4527
- let tag6 = TAG10 + " | broadcastTx | ";
4305
+ let tag6 = TAG9 + " | broadcastTx | ";
4528
4306
  try {
4529
4307
  const transactionDependencies = {
4530
4308
  context: this.context,
@@ -4537,7 +4315,7 @@ class SDK {
4537
4315
  };
4538
4316
  let txManager = new TransactionManager(transactionDependencies, this.events);
4539
4317
  let payload = {
4540
- networkId: import_pioneer_caip7.caipToNetworkId(caip),
4318
+ networkId: import_pioneer_caip8.caipToNetworkId(caip),
4541
4319
  serialized: signedTx
4542
4320
  };
4543
4321
  let txid = await txManager.broadcast(payload);
@@ -4548,7 +4326,7 @@ class SDK {
4548
4326
  }
4549
4327
  };
4550
4328
  this.swap = async function(swapPayload) {
4551
- let tag6 = `${TAG10} | swap | `;
4329
+ let tag6 = `${TAG9} | swap | `;
4552
4330
  try {
4553
4331
  if (!swapPayload)
4554
4332
  throw Error("swapPayload required!");
@@ -4687,7 +4465,7 @@ class SDK {
4687
4465
  }
4688
4466
  };
4689
4467
  this.transfer = async function(sendPayload) {
4690
- let tag6 = `${TAG10} | transfer | `;
4468
+ let tag6 = `${TAG9} | transfer | `;
4691
4469
  try {
4692
4470
  if (!sendPayload)
4693
4471
  throw Error("sendPayload required!");
@@ -4714,7 +4492,7 @@ class SDK {
4714
4492
  if (!signedTx)
4715
4493
  throw Error("Failed to sign transaction!");
4716
4494
  let payload = {
4717
- networkId: import_pioneer_caip7.caipToNetworkId(caip),
4495
+ networkId: import_pioneer_caip8.caipToNetworkId(caip),
4718
4496
  serialized: signedTx
4719
4497
  };
4720
4498
  let txid = await txManager.broadcast(payload);
@@ -4743,7 +4521,7 @@ class SDK {
4743
4521
  while (!isConfirmed) {
4744
4522
  try {
4745
4523
  const response = await this.pioneer.LookupTx({
4746
- networkId: import_pioneer_caip7.caipToNetworkId(caip),
4524
+ networkId: import_pioneer_caip8.caipToNetworkId(caip),
4747
4525
  txid
4748
4526
  });
4749
4527
  if (response?.data?.data) {
@@ -4782,7 +4560,7 @@ class SDK {
4782
4560
  }
4783
4561
  };
4784
4562
  this.setBlockchains = async function(blockchains) {
4785
- const tag6 = `${TAG10} | setBlockchains | `;
4563
+ const tag6 = `${TAG9} | setBlockchains | `;
4786
4564
  try {
4787
4565
  if (!blockchains)
4788
4566
  throw Error("blockchains required!");
@@ -4798,7 +4576,7 @@ class SDK {
4798
4576
  }
4799
4577
  };
4800
4578
  this.addAsset = async function(caip, data) {
4801
- let tag6 = TAG10 + " | addAsset | ";
4579
+ let tag6 = TAG9 + " | addAsset | ";
4802
4580
  try {
4803
4581
  let success = false;
4804
4582
  if (!caip)
@@ -4836,7 +4614,7 @@ class SDK {
4836
4614
  }
4837
4615
  };
4838
4616
  this.clearWalletState = async function() {
4839
- const tag6 = `${TAG10} | clearWalletState | `;
4617
+ const tag6 = `${TAG9} | clearWalletState | `;
4840
4618
  try {
4841
4619
  this.context = null;
4842
4620
  this.paths = [];
@@ -4851,7 +4629,7 @@ class SDK {
4851
4629
  }
4852
4630
  };
4853
4631
  this.addPath = async function(path) {
4854
- const tag6 = `${TAG10} | addPath | `;
4632
+ const tag6 = `${TAG9} | addPath | `;
4855
4633
  try {
4856
4634
  this.paths.push(path);
4857
4635
  const pubkey = await getPubkey(path.networks[0], path, this.keepKeySdk, this.context);
@@ -4865,7 +4643,7 @@ class SDK {
4865
4643
  }
4866
4644
  };
4867
4645
  this.addPaths = async function(paths) {
4868
- const tag6 = `${TAG10} | addPaths | `;
4646
+ const tag6 = `${TAG9} | addPaths | `;
4869
4647
  try {
4870
4648
  console.log(tag6, `Adding ${paths.length} paths in batch mode...`);
4871
4649
  this.paths.push(...paths);
@@ -4901,11 +4679,11 @@ class SDK {
4901
4679
  return this.getGasAssets();
4902
4680
  };
4903
4681
  this.getGasAssets = async function() {
4904
- const tag6 = `${TAG10} | getGasAssets | `;
4682
+ const tag6 = `${TAG9} | getGasAssets | `;
4905
4683
  try {
4906
4684
  for (let i = 0;i < this.blockchains.length; i++) {
4907
4685
  let networkId = this.blockchains[i];
4908
- let caip = import_pioneer_caip7.networkIdToCaip(networkId);
4686
+ let caip = import_pioneer_caip8.networkIdToCaip(networkId);
4909
4687
  let asset = await import_pioneer_discovery2.assetData[caip.toLowerCase()];
4910
4688
  if (asset) {
4911
4689
  asset.caip = caip.toLowerCase();
@@ -4944,7 +4722,7 @@ class SDK {
4944
4722
  }
4945
4723
  };
4946
4724
  this.getPubkeys = async function() {
4947
- const tag6 = `${TAG10} | getPubkeys | `;
4725
+ const tag6 = `${TAG9} | getPubkeys | `;
4948
4726
  try {
4949
4727
  if (this.paths.length === 0)
4950
4728
  throw new Error("No paths found!");
@@ -4965,7 +4743,7 @@ class SDK {
4965
4743
  }
4966
4744
  };
4967
4745
  this.getBalancesForNetworks = async function(networkIds) {
4968
- const tag6 = `${TAG10} | getBalancesForNetworks | `;
4746
+ const tag6 = `${TAG9} | getBalancesForNetworks | `;
4969
4747
  try {
4970
4748
  if (!this.pioneer) {
4971
4749
  console.error(tag6, "ERROR: Pioneer client not initialized! this.pioneer is:", this.pioneer);
@@ -4983,7 +4761,7 @@ class SDK {
4983
4761
  return network.startsWith("eip155:");
4984
4762
  return network === adjustedNetworkId;
4985
4763
  }));
4986
- const caipNative = await import_pioneer_caip7.networkIdToCaip(networkId);
4764
+ const caipNative = await import_pioneer_caip8.networkIdToCaip(networkId);
4987
4765
  for (const pubkey of pubkeys) {
4988
4766
  assetQuery.push({ caip: caipNative, pubkey: pubkey.pubkey });
4989
4767
  }
@@ -4993,20 +4771,17 @@ class SDK {
4993
4771
  let marketInfo = await this.pioneer.GetPortfolioBalances(assetQuery);
4994
4772
  console.timeEnd("GetPortfolioBalances Response Time");
4995
4773
  let balances = marketInfo.data;
4996
- const bitcoinBalances = balances.filter((b2) => b2.caip === "bip122:000000000019d6689c085ae165831e93/slip44:0");
4997
- if (bitcoinBalances.length > 0) {
4998
- }
4999
4774
  for (let balance of balances) {
5000
4775
  const assetInfo = this.assetsMap.get(balance.caip);
5001
4776
  if (!assetInfo)
5002
4777
  continue;
5003
4778
  Object.assign(balance, assetInfo, {
5004
- networkId: import_pioneer_caip7.caipToNetworkId(balance.caip),
4779
+ networkId: import_pioneer_caip8.caipToNetworkId(balance.caip),
5005
4780
  icon: assetInfo.icon || "https://pioneers.dev/coins/etherum.png",
5006
- identifier: `${balance.caip}:${balance.pubkey}`
4781
+ identifier: `${balance.caip}:${balance.pubkey}`,
4782
+ updated: Date.now()
5007
4783
  });
5008
4784
  }
5009
- console.log(tag6, "balances: ", balances);
5010
4785
  this.balances = balances;
5011
4786
  this.events.emit("SET_BALANCES", this.balances);
5012
4787
  return this.balances;
@@ -5020,7 +4795,7 @@ class SDK {
5020
4795
  }
5021
4796
  };
5022
4797
  this.getBalances = async function() {
5023
- const tag6 = `${TAG10} | getBalances | `;
4798
+ const tag6 = `${TAG9} | getBalances | `;
5024
4799
  try {
5025
4800
  return await this.getBalancesForNetworks(this.blockchains);
5026
4801
  } catch (e) {
@@ -5029,10 +4804,10 @@ class SDK {
5029
4804
  }
5030
4805
  };
5031
4806
  this.getBalance = async function(networkId) {
5032
- const tag6 = `${TAG10} | getBalance | `;
4807
+ const tag6 = `${TAG9} | getBalance | `;
5033
4808
  try {
5034
4809
  const results = await this.getBalancesForNetworks([networkId]);
5035
- const filtered = results.filter(async (b2) => b2.networkId === await import_pioneer_caip7.networkIdToCaip(networkId));
4810
+ const filtered = results.filter(async (b) => b.networkId === await import_pioneer_caip8.networkIdToCaip(networkId));
5036
4811
  return filtered;
5037
4812
  } catch (e) {
5038
4813
  console.error(tag6, "Error: ", e);
@@ -5040,7 +4815,7 @@ class SDK {
5040
4815
  }
5041
4816
  };
5042
4817
  this.getFees = async function(networkId) {
5043
- const tag6 = `${TAG10} | getFees | `;
4818
+ const tag6 = `${TAG9} | getFees | `;
5044
4819
  try {
5045
4820
  if (!this.pioneer) {
5046
4821
  throw new Error("Pioneer client not initialized. Call init() first.");
@@ -5055,7 +4830,7 @@ class SDK {
5055
4830
  return estimateTransactionFee(feeRate, unit, networkType, txSize);
5056
4831
  };
5057
4832
  this.getCharts = async function() {
5058
- const tag6 = `${TAG10} | getCharts | `;
4833
+ const tag6 = `${TAG9} | getCharts | `;
5059
4834
  try {
5060
4835
  console.log(tag6, "Fetching charts");
5061
4836
  const newBalances = await getCharts(this.blockchains, this.pioneer, this.pubkeys, this.context);
@@ -5077,7 +4852,7 @@ class SDK {
5077
4852
  }
5078
4853
  };
5079
4854
  this.setContext = async (context) => {
5080
- const tag6 = `${TAG10} | setContext | `;
4855
+ const tag6 = `${TAG9} | setContext | `;
5081
4856
  try {
5082
4857
  if (!context)
5083
4858
  throw Error("context required!");
@@ -5090,7 +4865,7 @@ class SDK {
5090
4865
  }
5091
4866
  };
5092
4867
  this.setContextType = async (contextType) => {
5093
- const tag6 = `${TAG10} | setContextType | `;
4868
+ const tag6 = `${TAG9} | setContextType | `;
5094
4869
  try {
5095
4870
  if (!contextType)
5096
4871
  throw Error("contextType required!");
@@ -5103,7 +4878,7 @@ class SDK {
5103
4878
  }
5104
4879
  };
5105
4880
  this.refresh = async () => {
5106
- const tag6 = `${TAG10} | refresh | `;
4881
+ const tag6 = `${TAG9} | refresh | `;
5107
4882
  try {
5108
4883
  await this.sync();
5109
4884
  return this.balances;
@@ -5113,7 +4888,7 @@ class SDK {
5113
4888
  }
5114
4889
  };
5115
4890
  this.setAssetContext = async function(asset) {
5116
- const tag6 = `${TAG10} | setAssetContext | `;
4891
+ const tag6 = `${TAG9} | setAssetContext | `;
5117
4892
  try {
5118
4893
  if (!asset) {
5119
4894
  this.assetContext = null;
@@ -5122,7 +4897,7 @@ class SDK {
5122
4897
  if (!asset.caip)
5123
4898
  throw Error("Invalid Asset! missing caip!");
5124
4899
  if (!asset.networkId)
5125
- asset.networkId = import_pioneer_caip7.caipToNetworkId(asset.caip);
4900
+ asset.networkId = import_pioneer_caip8.caipToNetworkId(asset.caip);
5126
4901
  if (!this.pubkeys || this.pubkeys.length === 0) {
5127
4902
  const errorMsg = `Cannot set asset context for ${asset.caip} - no pubkeys loaded. Please initialize wallet first.`;
5128
4903
  console.error(tag6, errorMsg);
@@ -5142,20 +4917,20 @@ class SDK {
5142
4917
  const errorMsg = `Cannot set asset context for ${asset.caip} - no address/xpub found for network ${asset.networkId}`;
5143
4918
  console.error(tag6, errorMsg);
5144
4919
  console.error(tag6, "Available networks in pubkeys:", [
5145
- ...new Set(this.pubkeys.flatMap((p2) => p2.networks || []))
4920
+ ...new Set(this.pubkeys.flatMap((p) => p.networks || []))
5146
4921
  ]);
5147
4922
  throw new Error(errorMsg);
5148
4923
  }
5149
4924
  const isUtxoChain = asset.networkId.startsWith("bip122:");
5150
4925
  if (isUtxoChain) {
5151
- const xpubFound = pubkeysForNetwork.some((p2) => p2.type === "xpub" && p2.pubkey);
4926
+ const xpubFound = pubkeysForNetwork.some((p) => p.type === "xpub" && p.pubkey);
5152
4927
  if (!xpubFound) {
5153
4928
  const errorMsg = `Cannot set asset context for UTXO chain ${asset.caip} - xpub required but not found`;
5154
4929
  console.error(tag6, errorMsg);
5155
4930
  throw new Error(errorMsg);
5156
4931
  }
5157
4932
  }
5158
- const hasValidAddress = pubkeysForNetwork.some((p2) => p2.address || p2.master || p2.pubkey);
4933
+ const hasValidAddress = pubkeysForNetwork.some((p) => p.address || p.master || p.pubkey);
5159
4934
  if (!hasValidAddress) {
5160
4935
  const errorMsg = `Cannot set asset context for ${asset.caip} - no valid address found in pubkeys`;
5161
4936
  console.error(tag6, errorMsg);
@@ -5196,7 +4971,7 @@ class SDK {
5196
4971
  icon: asset.icon || "https://pioneers.dev/coins/ethereum.png"
5197
4972
  };
5198
4973
  }
5199
- const matchingBalances = this.balances.filter((b2) => b2.caip === asset.caip);
4974
+ const matchingBalances = this.balances.filter((b) => b.caip === asset.caip);
5200
4975
  if (matchingBalances.length > 0) {
5201
4976
  let priceValue = matchingBalances[0].priceUsd || matchingBalances[0].price;
5202
4977
  if ((!priceValue || priceValue === 0) && matchingBalances[0].valueUsd && matchingBalances[0].balance) {
@@ -5229,8 +5004,8 @@ class SDK {
5229
5004
  assetInfo.valueUsd = totalValueUsd.toFixed(2);
5230
5005
  console.log(tag6, `Aggregated balance: ${totalBalance} (${totalValueUsd.toFixed(2)} USD)`);
5231
5006
  }
5232
- const assetBalances = this.balances.filter((b2) => b2.caip === asset.caip);
5233
- const assetPubkeys = this.pubkeys.filter((p2) => p2.networks && Array.isArray(p2.networks) && p2.networks.includes(import_pioneer_caip7.caipToNetworkId(asset.caip)) || import_pioneer_caip7.caipToNetworkId(asset.caip).includes("eip155") && p2.networks && Array.isArray(p2.networks) && p2.networks.some((n2) => n2.startsWith("eip155")));
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")));
5234
5009
  const finalAssetContext = {
5235
5010
  ...assetInfo,
5236
5011
  ...asset,
@@ -5281,7 +5056,7 @@ class SDK {
5281
5056
  }
5282
5057
  this.assetContext.nativeSymbol = nativeSymbol;
5283
5058
  if (nativeCaip) {
5284
- const nativeBalance = this.balances.find((b2) => b2.caip === nativeCaip);
5059
+ const nativeBalance = this.balances.find((b) => b.caip === nativeCaip);
5285
5060
  if (nativeBalance) {
5286
5061
  this.assetContext.nativeBalance = nativeBalance.balance || "0";
5287
5062
  } else {
@@ -5290,12 +5065,12 @@ class SDK {
5290
5065
  }
5291
5066
  }
5292
5067
  if (asset.caip) {
5293
- this.blockchainContext = import_pioneer_caip7.caipToNetworkId(asset.caip);
5068
+ this.blockchainContext = import_pioneer_caip8.caipToNetworkId(asset.caip);
5294
5069
  } else if (asset.networkId) {
5295
5070
  this.blockchainContext = asset.networkId;
5296
5071
  }
5297
5072
  if (assetPubkeys && assetPubkeys.length > 0) {
5298
- const networkId = import_pioneer_caip7.caipToNetworkId(asset.caip || asset.networkId);
5073
+ const networkId = import_pioneer_caip8.caipToNetworkId(asset.caip || asset.networkId);
5299
5074
  const currentContextValid = this.pubkeyContext?.networks?.includes(networkId);
5300
5075
  if (!this.pubkeyContext || !currentContextValid) {
5301
5076
  this.pubkeyContext = assetPubkeys[0];
@@ -5312,7 +5087,7 @@ class SDK {
5312
5087
  }
5313
5088
  };
5314
5089
  this.setPubkeyContext = async function(pubkey) {
5315
- let tag6 = `${TAG10} | setPubkeyContext | `;
5090
+ let tag6 = `${TAG9} | setPubkeyContext | `;
5316
5091
  try {
5317
5092
  if (!pubkey)
5318
5093
  throw Error("pubkey is required");
@@ -5331,7 +5106,7 @@ class SDK {
5331
5106
  }
5332
5107
  };
5333
5108
  this.setOutboundAssetContext = async function(asset) {
5334
- const tag6 = `${TAG10} | setOutputAssetContext | `;
5109
+ const tag6 = `${TAG9} | setOutputAssetContext | `;
5335
5110
  try {
5336
5111
  console.log(tag6, "0. asset: ", asset);
5337
5112
  if (!asset) {
@@ -5342,15 +5117,15 @@ class SDK {
5342
5117
  if (!asset.caip)
5343
5118
  throw Error("Invalid Asset! missing caip!");
5344
5119
  if (!asset.networkId)
5345
- asset.networkId = import_pioneer_caip7.caipToNetworkId(asset.caip);
5120
+ asset.networkId = import_pioneer_caip8.caipToNetworkId(asset.caip);
5346
5121
  console.log(tag6, "networkId: ", asset.networkId);
5347
5122
  console.log(tag6, "this.pubkeys: ", this.pubkeys);
5348
- const pubkey = this.pubkeys.find((p2) => {
5349
- if (!p2.networks || !Array.isArray(p2.networks))
5123
+ const pubkey = this.pubkeys.find((p) => {
5124
+ if (!p.networks || !Array.isArray(p.networks))
5350
5125
  return false;
5351
- if (p2.networks.includes(asset.networkId))
5126
+ if (p.networks.includes(asset.networkId))
5352
5127
  return true;
5353
- if (asset.networkId.startsWith("eip155:") && p2.networks.includes("eip155:*"))
5128
+ if (asset.networkId.startsWith("eip155:") && p.networks.includes("eip155:*"))
5354
5129
  return true;
5355
5130
  return false;
5356
5131
  });
@@ -5385,7 +5160,7 @@ class SDK {
5385
5160
  icon: asset.icon || "https://pioneers.dev/coins/ethereum.png"
5386
5161
  };
5387
5162
  }
5388
- const matchingBalances = this.balances.filter((b2) => b2.caip === asset.caip);
5163
+ const matchingBalances = this.balances.filter((b) => b.caip === asset.caip);
5389
5164
  if (matchingBalances.length > 0) {
5390
5165
  let priceValue = matchingBalances[0].priceUsd || matchingBalances[0].price;
5391
5166
  if ((!priceValue || priceValue === 0) && matchingBalances[0].valueUsd && matchingBalances[0].balance) {
@@ -5423,7 +5198,7 @@ class SDK {
5423
5198
  console.log(tag6, "CHECKPOINT 3");
5424
5199
  console.log(tag6, "outboundAssetContext: assetInfo: ", assetInfo);
5425
5200
  if (asset.caip) {
5426
- this.outboundBlockchainContext = import_pioneer_caip7.caipToNetworkId(asset.caip);
5201
+ this.outboundBlockchainContext = import_pioneer_caip8.caipToNetworkId(asset.caip);
5427
5202
  } else if (asset.networkId) {
5428
5203
  this.outboundBlockchainContext = asset.networkId;
5429
5204
  }