@pioneer-platform/pioneer-sdk 4.20.3 → 4.20.5

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
@@ -40,7 +40,7 @@ var __export = (target, all) => {
40
40
  });
41
41
  };
42
42
 
43
- // ../../../node_modules/coinselect/utils.js
43
+ // node_modules/coinselect/utils.js
44
44
  var require_utils = __commonJS((exports2, module2) => {
45
45
  var TX_EMPTY_SIZE = 4 + 1 + 1 + 4;
46
46
  var TX_INPUT_BASE = 32 + 4 + 1 + 4;
@@ -113,7 +113,7 @@ var require_utils = __commonJS((exports2, module2) => {
113
113
  };
114
114
  });
115
115
 
116
- // ../../../node_modules/coinselect/accumulative.js
116
+ // node_modules/coinselect/accumulative.js
117
117
  var require_accumulative = __commonJS((exports2, module2) => {
118
118
  var utils = require_utils();
119
119
  module2.exports = function accumulative(utxos, outputs, feeRate) {
@@ -145,7 +145,7 @@ var require_accumulative = __commonJS((exports2, module2) => {
145
145
  };
146
146
  });
147
147
 
148
- // ../../../node_modules/coinselect/blackjack.js
148
+ // node_modules/coinselect/blackjack.js
149
149
  var require_blackjack = __commonJS((exports2, module2) => {
150
150
  var utils = require_utils();
151
151
  module2.exports = function blackjack(utxos, outputs, feeRate) {
@@ -174,7 +174,7 @@ var require_blackjack = __commonJS((exports2, module2) => {
174
174
  };
175
175
  });
176
176
 
177
- // ../../../node_modules/coinselect/index.js
177
+ // node_modules/coinselect/index.js
178
178
  var require_coinselect = __commonJS((exports2, module2) => {
179
179
  var accumulative = require_accumulative();
180
180
  var blackjack = require_blackjack();
@@ -193,7 +193,7 @@ var require_coinselect = __commonJS((exports2, module2) => {
193
193
  };
194
194
  });
195
195
 
196
- // ../../../node_modules/coinselect/split.js
196
+ // node_modules/coinselect/split.js
197
197
  var require_split = __commonJS((exports2, module2) => {
198
198
  var utils = require_utils();
199
199
  module2.exports = function split(utxos, outputs, feeRate) {
@@ -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_caip6 = require("@pioneer-platform/pioneer-caip");
247
+ var import_pioneer_caip7 = require("@pioneer-platform/pioneer-caip");
248
248
  var import_pioneer_client = __toESM(require("@pioneer-platform/pioneer-client"));
249
249
  var import_pioneer_coins4 = require("@pioneer-platform/pioneer-coins");
250
250
  var import_pioneer_discovery2 = require("@pioneer-platform/pioneer-discovery");
@@ -590,7 +590,7 @@ var getCharts = async (blockchains, pioneer, pubkeys, context) => {
590
590
  }
591
591
  };
592
592
 
593
- // ../../../node_modules/@coinmasters/types/dist/index.es.js
593
+ // node_modules/@coinmasters/types/dist/index.es.js
594
594
  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 || {});
595
595
  var b = {
596
596
  [n.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
@@ -3380,10 +3380,9 @@ function estimateTransactionFee(feeRate, unit, networkType, txSize) {
3380
3380
  }
3381
3381
  }
3382
3382
 
3383
- // src/index.ts
3384
- var TAG7 = " | Pioneer-sdk | ";
3383
+ // src/utils/kkapi-detection.ts
3385
3384
  async function detectKkApiAvailability(forceLocalhost) {
3386
- const tag5 = `${TAG7} | detectKkApiAvailability | `;
3385
+ const tag5 = " | detectKkApiAvailability | ";
3387
3386
  try {
3388
3387
  const isTauri = typeof window !== "undefined" && "__TAURI__" in window;
3389
3388
  const isBrowser = typeof window !== "undefined";
@@ -3430,6 +3429,8 @@ async function detectKkApiAvailability(forceLocalhost) {
3430
3429
  };
3431
3430
  }
3432
3431
  }
3432
+
3433
+ // src/utils/format-time.ts
3433
3434
  function formatTime(durationMs) {
3434
3435
  let seconds = Math.floor(durationMs / 1000 % 60);
3435
3436
  let minutes = Math.floor(durationMs / (1000 * 60) % 60);
@@ -3443,6 +3444,96 @@ function formatTime(durationMs) {
3443
3444
  return formatted.trim();
3444
3445
  }
3445
3446
 
3447
+ // src/utils/build-dashboard.ts
3448
+ var import_pioneer_caip6 = require("@pioneer-platform/pioneer-caip");
3449
+ var TAG7 = " | build-dashboard | ";
3450
+ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3451
+ console.log(TAG7, "[DASHBOARD] Building dashboard from cached balances...");
3452
+ const dashboardData = {
3453
+ networks: [],
3454
+ totalValueUsd: 0,
3455
+ networkPercentages: []
3456
+ };
3457
+ let totalPortfolioValue = 0;
3458
+ const networksTemp = [];
3459
+ console.log(TAG7, "balances: ", balances);
3460
+ for (const blockchain of blockchains) {
3461
+ const filteredBalances = balances.filter((b2) => {
3462
+ const networkId = import_pioneer_caip6.caipToNetworkId(b2.caip);
3463
+ return networkId === blockchain || blockchain === "eip155:*" && networkId.startsWith("eip155:");
3464
+ });
3465
+ const balanceMap = new Map;
3466
+ const isBitcoin = blockchain.includes("bip122:000000000019d6689c085ae165831e93");
3467
+ if (isBitcoin) {
3468
+ console.log(TAG7, "Bitcoin network detected - checking for duplicate balances");
3469
+ const bitcoinByValue = new Map;
3470
+ filteredBalances.forEach((balance) => {
3471
+ const valueKey = `${balance.balance}_${balance.valueUsd}`;
3472
+ if (!bitcoinByValue.has(valueKey)) {
3473
+ bitcoinByValue.set(valueKey, []);
3474
+ }
3475
+ bitcoinByValue.get(valueKey).push(balance);
3476
+ });
3477
+ for (const [valueKey, balances2] of bitcoinByValue.entries()) {
3478
+ if (balances2.length === 3 && parseFloat(balances2[0].valueUsd || "0") > 0) {
3479
+ console.log(TAG7, "BITCOIN API BUG DETECTED: All 3 address types have same balance, keeping only xpub");
3480
+ const xpubBalance = balances2.find((b2) => b2.pubkey?.startsWith("xpub")) || balances2[0];
3481
+ const key = `${xpubBalance.caip}_${xpubBalance.pubkey || "default"}`;
3482
+ balanceMap.set(key, xpubBalance);
3483
+ } else {
3484
+ balances2.forEach((balance) => {
3485
+ const key = `${balance.caip}_${balance.pubkey || "default"}`;
3486
+ balanceMap.set(key, balance);
3487
+ });
3488
+ }
3489
+ }
3490
+ } else {
3491
+ filteredBalances.forEach((balance) => {
3492
+ const key = `${balance.caip}_${balance.pubkey || "default"}`;
3493
+ if (!balanceMap.has(key) || parseFloat(balance.valueUsd || "0") > parseFloat(balanceMap.get(key).valueUsd || "0")) {
3494
+ balanceMap.set(key, balance);
3495
+ }
3496
+ });
3497
+ }
3498
+ const networkBalances = Array.from(balanceMap.values());
3499
+ const networkTotal = networkBalances.reduce((sum, balance, idx) => {
3500
+ const valueUsd = typeof balance.valueUsd === "string" ? parseFloat(balance.valueUsd) : balance.valueUsd || 0;
3501
+ if (blockchain.includes("bip122:000000000019d6689c085ae165831e93")) {
3502
+ console.log(TAG7, `[BITCOIN DEBUG ${idx}] pubkey:`, balance.pubkey?.substring(0, 10) + "...", "| balance:", balance.balance, "| valueUsd:", balance.valueUsd, "→ parsed:", valueUsd, "| running sum:", sum + valueUsd);
3503
+ }
3504
+ return sum + valueUsd;
3505
+ }, 0);
3506
+ const nativeAssetCaip = import_pioneer_caip6.networkIdToCaip(blockchain);
3507
+ const gasAsset = networkBalances.find((b2) => b2.caip === nativeAssetCaip);
3508
+ const totalNativeBalance = networkBalances.filter((b2) => b2.caip === nativeAssetCaip).reduce((sum, balance) => {
3509
+ const balanceNum = typeof balance.balance === "string" ? parseFloat(balance.balance) : balance.balance || 0;
3510
+ return sum + balanceNum;
3511
+ }, 0).toString();
3512
+ const assetInfo = nativeAssetCaip ? assetsMap.get(nativeAssetCaip) : null;
3513
+ networksTemp.push({
3514
+ networkId: blockchain,
3515
+ totalValueUsd: networkTotal,
3516
+ gasAssetCaip: nativeAssetCaip || null,
3517
+ gasAssetSymbol: gasAsset?.ticker || gasAsset?.symbol || assetInfo?.symbol || null,
3518
+ icon: gasAsset?.icon || assetInfo?.icon || null,
3519
+ color: gasAsset?.color || assetInfo?.color || null,
3520
+ totalNativeBalance
3521
+ });
3522
+ totalPortfolioValue += networkTotal;
3523
+ }
3524
+ dashboardData.networks = networksTemp.sort((a, b2) => b2.totalValueUsd - a.totalValueUsd);
3525
+ dashboardData.totalValueUsd = totalPortfolioValue;
3526
+ dashboardData.networkPercentages = dashboardData.networks.map((network) => ({
3527
+ networkId: network.networkId,
3528
+ percentage: totalPortfolioValue > 0 ? Number((network.totalValueUsd / totalPortfolioValue * 100).toFixed(2)) : 0
3529
+ })).filter((entry) => entry.percentage > 0);
3530
+ console.log(`[FAST DASHBOARD] ✅ Built dashboard: ${dashboardData.networks.length} networks, $${totalPortfolioValue.toFixed(2)} total`);
3531
+ return dashboardData;
3532
+ }
3533
+
3534
+ // src/index.ts
3535
+ var TAG8 = " | Pioneer-sdk | ";
3536
+
3446
3537
  class SDK {
3447
3538
  status;
3448
3539
  username;
@@ -3605,7 +3696,7 @@ class SDK {
3605
3696
  return true;
3606
3697
  };
3607
3698
  this.setPubkeys = (newPubkeys) => {
3608
- const tag5 = `${TAG7} | setPubkeys | `;
3699
+ const tag5 = `${TAG8} | setPubkeys | `;
3609
3700
  this.pubkeys = [];
3610
3701
  this.pubkeySet.clear();
3611
3702
  let added = 0;
@@ -3616,7 +3707,7 @@ class SDK {
3616
3707
  }
3617
3708
  };
3618
3709
  this.getUnifiedPortfolio = async function() {
3619
- const tag5 = `${TAG7} | getUnifiedPortfolio | `;
3710
+ const tag5 = `${TAG8} | getUnifiedPortfolio | `;
3620
3711
  try {
3621
3712
  const startTime = performance.now();
3622
3713
  try {
@@ -3724,7 +3815,7 @@ class SDK {
3724
3815
  }
3725
3816
  };
3726
3817
  this.init = async function(walletsVerbose, setup) {
3727
- const tag5 = `${TAG7} | init | `;
3818
+ const tag5 = `${TAG8} | init | `;
3728
3819
  try {
3729
3820
  if (!this.username)
3730
3821
  throw Error("username required!");
@@ -3812,91 +3903,10 @@ class SDK {
3812
3903
  }
3813
3904
  };
3814
3905
  this.buildDashboardFromBalances = function() {
3815
- const tag5 = `${TAG7} | buildDashboardFromBalances | `;
3816
- console.log(tag5, "[DASHBOARD] Building dashboard from cached balances...");
3817
- const dashboardData = {
3818
- networks: [],
3819
- totalValueUsd: 0,
3820
- networkPercentages: []
3821
- };
3822
- let totalPortfolioValue = 0;
3823
- const networksTemp = [];
3824
- console.log(tag5, "this.balances: ", this.balances);
3825
- for (const blockchain of this.blockchains) {
3826
- const filteredBalances = this.balances.filter((b2) => {
3827
- const networkId = import_pioneer_caip6.caipToNetworkId(b2.caip);
3828
- return networkId === blockchain || blockchain === "eip155:*" && networkId.startsWith("eip155:");
3829
- });
3830
- const balanceMap = new Map;
3831
- const isBitcoin = blockchain.includes("bip122:000000000019d6689c085ae165831e93");
3832
- if (isBitcoin) {
3833
- console.log(tag5, "Bitcoin network detected - checking for duplicate balances");
3834
- const bitcoinByValue = new Map;
3835
- filteredBalances.forEach((balance) => {
3836
- const valueKey = `${balance.balance}_${balance.valueUsd}`;
3837
- if (!bitcoinByValue.has(valueKey)) {
3838
- bitcoinByValue.set(valueKey, []);
3839
- }
3840
- bitcoinByValue.get(valueKey).push(balance);
3841
- });
3842
- for (const [valueKey, balances] of bitcoinByValue.entries()) {
3843
- if (balances.length === 3 && parseFloat(balances[0].valueUsd || "0") > 0) {
3844
- console.log(tag5, "BITCOIN API BUG DETECTED: All 3 address types have same balance, keeping only xpub");
3845
- const xpubBalance = balances.find((b2) => b2.pubkey?.startsWith("xpub")) || balances[0];
3846
- const key = `${xpubBalance.caip}_${xpubBalance.pubkey || "default"}`;
3847
- balanceMap.set(key, xpubBalance);
3848
- } else {
3849
- balances.forEach((balance) => {
3850
- const key = `${balance.caip}_${balance.pubkey || "default"}`;
3851
- balanceMap.set(key, balance);
3852
- });
3853
- }
3854
- }
3855
- } else {
3856
- filteredBalances.forEach((balance) => {
3857
- const key = `${balance.caip}_${balance.pubkey || "default"}`;
3858
- if (!balanceMap.has(key) || parseFloat(balance.valueUsd || "0") > parseFloat(balanceMap.get(key).valueUsd || "0")) {
3859
- balanceMap.set(key, balance);
3860
- }
3861
- });
3862
- }
3863
- const networkBalances = Array.from(balanceMap.values());
3864
- const networkTotal = networkBalances.reduce((sum, balance, idx) => {
3865
- const valueUsd = typeof balance.valueUsd === "string" ? parseFloat(balance.valueUsd) : balance.valueUsd || 0;
3866
- if (blockchain.includes("bip122:000000000019d6689c085ae165831e93")) {
3867
- console.log(tag5, `[BITCOIN DEBUG ${idx}] pubkey:`, balance.pubkey?.substring(0, 10) + "...", "| balance:", balance.balance, "| valueUsd:", balance.valueUsd, "→ parsed:", valueUsd, "| running sum:", sum + valueUsd);
3868
- }
3869
- return sum + valueUsd;
3870
- }, 0);
3871
- const nativeAssetCaip = import_pioneer_caip6.networkIdToCaip(blockchain);
3872
- const gasAsset = networkBalances.find((b2) => b2.caip === nativeAssetCaip);
3873
- const totalNativeBalance = networkBalances.filter((b2) => b2.caip === nativeAssetCaip).reduce((sum, balance) => {
3874
- const balanceNum = typeof balance.balance === "string" ? parseFloat(balance.balance) : balance.balance || 0;
3875
- return sum + balanceNum;
3876
- }, 0).toString();
3877
- const assetInfo = nativeAssetCaip ? this.assetsMap.get(nativeAssetCaip) : null;
3878
- networksTemp.push({
3879
- networkId: blockchain,
3880
- totalValueUsd: networkTotal,
3881
- gasAssetCaip: nativeAssetCaip || null,
3882
- gasAssetSymbol: gasAsset?.ticker || gasAsset?.symbol || assetInfo?.symbol || null,
3883
- icon: gasAsset?.icon || assetInfo?.icon || null,
3884
- color: gasAsset?.color || assetInfo?.color || null,
3885
- totalNativeBalance
3886
- });
3887
- totalPortfolioValue += networkTotal;
3888
- }
3889
- dashboardData.networks = networksTemp.sort((a, b2) => b2.totalValueUsd - a.totalValueUsd);
3890
- dashboardData.totalValueUsd = totalPortfolioValue;
3891
- dashboardData.networkPercentages = dashboardData.networks.map((network) => ({
3892
- networkId: network.networkId,
3893
- percentage: totalPortfolioValue > 0 ? Number((network.totalValueUsd / totalPortfolioValue * 100).toFixed(2)) : 0
3894
- })).filter((entry) => entry.percentage > 0);
3895
- console.log(`[FAST DASHBOARD] ✅ Built dashboard: ${dashboardData.networks.length} networks, $${totalPortfolioValue.toFixed(2)} total`);
3896
- return dashboardData;
3906
+ return buildDashboardFromBalances(this.balances, this.blockchains, this.assetsMap);
3897
3907
  };
3898
3908
  this.syncMarket = async function() {
3899
- const tag5 = `${TAG7} | syncMarket | `;
3909
+ const tag5 = `${TAG8} | syncMarket | `;
3900
3910
  try {
3901
3911
  const invalidBalances = this.balances.filter((b2) => !b2 || !b2.caip || typeof b2.caip !== "string" || !b2.caip.includes(":"));
3902
3912
  if (invalidBalances.length > 0) {
@@ -3947,7 +3957,7 @@ class SDK {
3947
3957
  }
3948
3958
  };
3949
3959
  this.sync = async function() {
3950
- const tag5 = `${TAG7} | sync | `;
3960
+ const tag5 = `${TAG8} | sync | `;
3951
3961
  try {
3952
3962
  const matchesNetwork = (item, networkId) => {
3953
3963
  if (!item.networks || !Array.isArray(item.networks))
@@ -4002,7 +4012,7 @@ class SDK {
4002
4012
  console.log(tag5, "uniqueBlockchains: ", uniqueBlockchains);
4003
4013
  for (const blockchain of uniqueBlockchains) {
4004
4014
  const filteredBalances = this.balances.filter((b2) => {
4005
- const networkId = import_pioneer_caip6.caipToNetworkId(b2.caip);
4015
+ const networkId = import_pioneer_caip7.caipToNetworkId(b2.caip);
4006
4016
  return networkId === blockchain || blockchain === "eip155:*" && networkId.startsWith("eip155:");
4007
4017
  });
4008
4018
  console.log(tag5, `Filtering for blockchain: ${blockchain}`);
@@ -4060,7 +4070,7 @@ class SDK {
4060
4070
  return sum + valueUsd;
4061
4071
  }, 0);
4062
4072
  console.log("Final networkTotal:", networkTotal);
4063
- const nativeAssetCaip = import_pioneer_caip6.networkIdToCaip(blockchain);
4073
+ const nativeAssetCaip = import_pioneer_caip7.networkIdToCaip(blockchain);
4064
4074
  const gasAsset = networkBalances.find((b2) => b2.caip === nativeAssetCaip);
4065
4075
  const totalNativeBalance = networkBalances.filter((b2) => b2.caip === nativeAssetCaip).reduce((sum, balance) => {
4066
4076
  const balanceNum = typeof balance.balance === "string" ? parseFloat(balance.balance) : balance.balance || 0;
@@ -4100,7 +4110,7 @@ class SDK {
4100
4110
  }
4101
4111
  };
4102
4112
  this.buildTx = async function(sendPayload) {
4103
- let tag5 = TAG7 + " | buildTx | ";
4113
+ let tag5 = TAG8 + " | buildTx | ";
4104
4114
  try {
4105
4115
  const transactionDependencies = {
4106
4116
  context: this.context,
@@ -4122,7 +4132,7 @@ class SDK {
4122
4132
  }
4123
4133
  };
4124
4134
  this.buildDelegateTx = async function(caip, params) {
4125
- let tag5 = TAG7 + " | buildDelegateTx | ";
4135
+ let tag5 = TAG8 + " | buildDelegateTx | ";
4126
4136
  try {
4127
4137
  const delegateParams = {
4128
4138
  ...params,
@@ -4137,7 +4147,7 @@ class SDK {
4137
4147
  }
4138
4148
  };
4139
4149
  this.buildUndelegateTx = async function(caip, params) {
4140
- let tag5 = TAG7 + " | buildUndelegateTx | ";
4150
+ let tag5 = TAG8 + " | buildUndelegateTx | ";
4141
4151
  try {
4142
4152
  const undelegateParams = {
4143
4153
  ...params,
@@ -4152,7 +4162,7 @@ class SDK {
4152
4162
  }
4153
4163
  };
4154
4164
  this.buildClaimRewardsTx = async function(caip, params) {
4155
- let tag5 = TAG7 + " | buildClaimRewardsTx | ";
4165
+ let tag5 = TAG8 + " | buildClaimRewardsTx | ";
4156
4166
  try {
4157
4167
  const claimParams = {
4158
4168
  ...params,
@@ -4167,7 +4177,7 @@ class SDK {
4167
4177
  }
4168
4178
  };
4169
4179
  this.buildClaimAllRewardsTx = async function(caip, params) {
4170
- let tag5 = TAG7 + " | buildClaimAllRewardsTx | ";
4180
+ let tag5 = TAG8 + " | buildClaimAllRewardsTx | ";
4171
4181
  try {
4172
4182
  const claimAllParams = {
4173
4183
  ...params,
@@ -4181,7 +4191,7 @@ class SDK {
4181
4191
  }
4182
4192
  };
4183
4193
  this.signTx = async function(unsignedTx) {
4184
- let tag5 = TAG7 + " | signTx | ";
4194
+ let tag5 = TAG8 + " | signTx | ";
4185
4195
  try {
4186
4196
  const transactionDependencies = {
4187
4197
  context: this.context,
@@ -4202,7 +4212,7 @@ class SDK {
4202
4212
  }
4203
4213
  };
4204
4214
  this.broadcastTx = async function(caip, signedTx) {
4205
- let tag5 = TAG7 + " | broadcastTx | ";
4215
+ let tag5 = TAG8 + " | broadcastTx | ";
4206
4216
  try {
4207
4217
  const transactionDependencies = {
4208
4218
  context: this.context,
@@ -4215,7 +4225,7 @@ class SDK {
4215
4225
  };
4216
4226
  let txManager = new TransactionManager(transactionDependencies, this.events);
4217
4227
  let payload = {
4218
- networkId: import_pioneer_caip6.caipToNetworkId(caip),
4228
+ networkId: import_pioneer_caip7.caipToNetworkId(caip),
4219
4229
  serialized: signedTx
4220
4230
  };
4221
4231
  let txid = await txManager.broadcast(payload);
@@ -4226,7 +4236,7 @@ class SDK {
4226
4236
  }
4227
4237
  };
4228
4238
  this.swap = async function(swapPayload) {
4229
- let tag5 = `${TAG7} | swap | `;
4239
+ let tag5 = `${TAG8} | swap | `;
4230
4240
  try {
4231
4241
  if (!swapPayload)
4232
4242
  throw Error("swapPayload required!");
@@ -4361,7 +4371,7 @@ class SDK {
4361
4371
  }
4362
4372
  };
4363
4373
  this.transfer = async function(sendPayload) {
4364
- let tag5 = `${TAG7} | transfer | `;
4374
+ let tag5 = `${TAG8} | transfer | `;
4365
4375
  try {
4366
4376
  if (!sendPayload)
4367
4377
  throw Error("sendPayload required!");
@@ -4388,7 +4398,7 @@ class SDK {
4388
4398
  if (!signedTx)
4389
4399
  throw Error("Failed to sign transaction!");
4390
4400
  let payload = {
4391
- networkId: import_pioneer_caip6.caipToNetworkId(caip),
4401
+ networkId: import_pioneer_caip7.caipToNetworkId(caip),
4392
4402
  serialized: signedTx
4393
4403
  };
4394
4404
  let txid = await txManager.broadcast(payload);
@@ -4417,7 +4427,7 @@ class SDK {
4417
4427
  while (!isConfirmed) {
4418
4428
  try {
4419
4429
  const response = await this.pioneer.LookupTx({
4420
- networkId: import_pioneer_caip6.caipToNetworkId(caip),
4430
+ networkId: import_pioneer_caip7.caipToNetworkId(caip),
4421
4431
  txid
4422
4432
  });
4423
4433
  if (response?.data?.data) {
@@ -4456,7 +4466,7 @@ class SDK {
4456
4466
  }
4457
4467
  };
4458
4468
  this.setBlockchains = async function(blockchains) {
4459
- const tag5 = `${TAG7} | setBlockchains | `;
4469
+ const tag5 = `${TAG8} | setBlockchains | `;
4460
4470
  try {
4461
4471
  if (!blockchains)
4462
4472
  throw Error("blockchains required!");
@@ -4472,7 +4482,7 @@ class SDK {
4472
4482
  }
4473
4483
  };
4474
4484
  this.addAsset = async function(caip, data) {
4475
- let tag5 = TAG7 + " | addAsset | ";
4485
+ let tag5 = TAG8 + " | addAsset | ";
4476
4486
  try {
4477
4487
  let success = false;
4478
4488
  if (!caip)
@@ -4510,7 +4520,7 @@ class SDK {
4510
4520
  }
4511
4521
  };
4512
4522
  this.clearWalletState = async function() {
4513
- const tag5 = `${TAG7} | clearWalletState | `;
4523
+ const tag5 = `${TAG8} | clearWalletState | `;
4514
4524
  try {
4515
4525
  this.context = null;
4516
4526
  this.paths = [];
@@ -4525,7 +4535,7 @@ class SDK {
4525
4535
  }
4526
4536
  };
4527
4537
  this.addPath = async function(path) {
4528
- const tag5 = `${TAG7} | addPath | `;
4538
+ const tag5 = `${TAG8} | addPath | `;
4529
4539
  try {
4530
4540
  this.paths.push(path);
4531
4541
  const pubkey = await getPubkey(path.networks[0], path, this.keepKeySdk, this.context);
@@ -4539,7 +4549,7 @@ class SDK {
4539
4549
  }
4540
4550
  };
4541
4551
  this.addPaths = async function(paths) {
4542
- const tag5 = `${TAG7} | addPaths | `;
4552
+ const tag5 = `${TAG8} | addPaths | `;
4543
4553
  try {
4544
4554
  console.log(tag5, `Adding ${paths.length} paths in batch mode...`);
4545
4555
  this.paths.push(...paths);
@@ -4575,11 +4585,11 @@ class SDK {
4575
4585
  return this.getGasAssets();
4576
4586
  };
4577
4587
  this.getGasAssets = async function() {
4578
- const tag5 = `${TAG7} | getGasAssets | `;
4588
+ const tag5 = `${TAG8} | getGasAssets | `;
4579
4589
  try {
4580
4590
  for (let i = 0;i < this.blockchains.length; i++) {
4581
4591
  let networkId = this.blockchains[i];
4582
- let caip = import_pioneer_caip6.networkIdToCaip(networkId);
4592
+ let caip = import_pioneer_caip7.networkIdToCaip(networkId);
4583
4593
  let asset = await import_pioneer_discovery2.assetData[caip.toLowerCase()];
4584
4594
  if (asset) {
4585
4595
  asset.caip = caip.toLowerCase();
@@ -4618,7 +4628,7 @@ class SDK {
4618
4628
  }
4619
4629
  };
4620
4630
  this.getPubkeys = async function() {
4621
- const tag5 = `${TAG7} | getPubkeys | `;
4631
+ const tag5 = `${TAG8} | getPubkeys | `;
4622
4632
  try {
4623
4633
  if (this.paths.length === 0)
4624
4634
  throw new Error("No paths found!");
@@ -4639,7 +4649,7 @@ class SDK {
4639
4649
  }
4640
4650
  };
4641
4651
  this.getBalancesForNetworks = async function(networkIds) {
4642
- const tag5 = `${TAG7} | getBalancesForNetworks | `;
4652
+ const tag5 = `${TAG8} | getBalancesForNetworks | `;
4643
4653
  try {
4644
4654
  if (!this.pioneer) {
4645
4655
  console.error(tag5, "ERROR: Pioneer client not initialized! this.pioneer is:", this.pioneer);
@@ -4657,7 +4667,7 @@ class SDK {
4657
4667
  return network.startsWith("eip155:");
4658
4668
  return network === adjustedNetworkId;
4659
4669
  }));
4660
- const caipNative = await import_pioneer_caip6.networkIdToCaip(networkId);
4670
+ const caipNative = await import_pioneer_caip7.networkIdToCaip(networkId);
4661
4671
  for (const pubkey of pubkeys) {
4662
4672
  assetQuery.push({ caip: caipNative, pubkey: pubkey.pubkey });
4663
4673
  }
@@ -4675,7 +4685,7 @@ class SDK {
4675
4685
  if (!assetInfo)
4676
4686
  continue;
4677
4687
  Object.assign(balance, assetInfo, {
4678
- networkId: import_pioneer_caip6.caipToNetworkId(balance.caip),
4688
+ networkId: import_pioneer_caip7.caipToNetworkId(balance.caip),
4679
4689
  icon: assetInfo.icon || "https://pioneers.dev/coins/etherum.png",
4680
4690
  identifier: `${balance.caip}:${balance.pubkey}`
4681
4691
  });
@@ -4694,7 +4704,7 @@ class SDK {
4694
4704
  }
4695
4705
  };
4696
4706
  this.getBalances = async function() {
4697
- const tag5 = `${TAG7} | getBalances | `;
4707
+ const tag5 = `${TAG8} | getBalances | `;
4698
4708
  try {
4699
4709
  return await this.getBalancesForNetworks(this.blockchains);
4700
4710
  } catch (e) {
@@ -4703,10 +4713,10 @@ class SDK {
4703
4713
  }
4704
4714
  };
4705
4715
  this.getBalance = async function(networkId) {
4706
- const tag5 = `${TAG7} | getBalance | `;
4716
+ const tag5 = `${TAG8} | getBalance | `;
4707
4717
  try {
4708
4718
  const results = await this.getBalancesForNetworks([networkId]);
4709
- const filtered = results.filter(async (b2) => b2.networkId === await import_pioneer_caip6.networkIdToCaip(networkId));
4719
+ const filtered = results.filter(async (b2) => b2.networkId === await import_pioneer_caip7.networkIdToCaip(networkId));
4710
4720
  return filtered;
4711
4721
  } catch (e) {
4712
4722
  console.error(tag5, "Error: ", e);
@@ -4714,7 +4724,7 @@ class SDK {
4714
4724
  }
4715
4725
  };
4716
4726
  this.getFees = async function(networkId) {
4717
- const tag5 = `${TAG7} | getFees | `;
4727
+ const tag5 = `${TAG8} | getFees | `;
4718
4728
  try {
4719
4729
  if (!this.pioneer) {
4720
4730
  throw new Error("Pioneer client not initialized. Call init() first.");
@@ -4729,7 +4739,7 @@ class SDK {
4729
4739
  return estimateTransactionFee(feeRate, unit, networkType, txSize);
4730
4740
  };
4731
4741
  this.getCharts = async function() {
4732
- const tag5 = `${TAG7} | getCharts | `;
4742
+ const tag5 = `${TAG8} | getCharts | `;
4733
4743
  try {
4734
4744
  console.log(tag5, "Fetching charts");
4735
4745
  const newBalances = await getCharts(this.blockchains, this.pioneer, this.pubkeys, this.context);
@@ -4751,7 +4761,7 @@ class SDK {
4751
4761
  }
4752
4762
  };
4753
4763
  this.setContext = async (context) => {
4754
- const tag5 = `${TAG7} | setContext | `;
4764
+ const tag5 = `${TAG8} | setContext | `;
4755
4765
  try {
4756
4766
  if (!context)
4757
4767
  throw Error("context required!");
@@ -4764,7 +4774,7 @@ class SDK {
4764
4774
  }
4765
4775
  };
4766
4776
  this.setContextType = async (contextType) => {
4767
- const tag5 = `${TAG7} | setContextType | `;
4777
+ const tag5 = `${TAG8} | setContextType | `;
4768
4778
  try {
4769
4779
  if (!contextType)
4770
4780
  throw Error("contextType required!");
@@ -4777,7 +4787,7 @@ class SDK {
4777
4787
  }
4778
4788
  };
4779
4789
  this.refresh = async () => {
4780
- const tag5 = `${TAG7} | refresh | `;
4790
+ const tag5 = `${TAG8} | refresh | `;
4781
4791
  try {
4782
4792
  await this.sync();
4783
4793
  return this.balances;
@@ -4787,7 +4797,7 @@ class SDK {
4787
4797
  }
4788
4798
  };
4789
4799
  this.setAssetContext = async function(asset) {
4790
- const tag5 = `${TAG7} | setAssetContext | `;
4800
+ const tag5 = `${TAG8} | setAssetContext | `;
4791
4801
  try {
4792
4802
  if (!asset) {
4793
4803
  this.assetContext = null;
@@ -4796,7 +4806,7 @@ class SDK {
4796
4806
  if (!asset.caip)
4797
4807
  throw Error("Invalid Asset! missing caip!");
4798
4808
  if (!asset.networkId)
4799
- asset.networkId = import_pioneer_caip6.caipToNetworkId(asset.caip);
4809
+ asset.networkId = import_pioneer_caip7.caipToNetworkId(asset.caip);
4800
4810
  if (!this.pubkeys || this.pubkeys.length === 0) {
4801
4811
  const errorMsg = `Cannot set asset context for ${asset.caip} - no pubkeys loaded. Please initialize wallet first.`;
4802
4812
  console.error(tag5, errorMsg);
@@ -4904,7 +4914,7 @@ class SDK {
4904
4914
  console.log(tag5, `Aggregated balance: ${totalBalance} (${totalValueUsd.toFixed(2)} USD)`);
4905
4915
  }
4906
4916
  const assetBalances = this.balances.filter((b2) => b2.caip === asset.caip);
4907
- const assetPubkeys = this.pubkeys.filter((p2) => p2.networks && Array.isArray(p2.networks) && p2.networks.includes(import_pioneer_caip6.caipToNetworkId(asset.caip)) || import_pioneer_caip6.caipToNetworkId(asset.caip).includes("eip155") && p2.networks && Array.isArray(p2.networks) && p2.networks.some((n2) => n2.startsWith("eip155")));
4917
+ 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")));
4908
4918
  const finalAssetContext = {
4909
4919
  ...assetInfo,
4910
4920
  ...asset,
@@ -4964,12 +4974,12 @@ class SDK {
4964
4974
  }
4965
4975
  }
4966
4976
  if (asset.caip) {
4967
- this.blockchainContext = import_pioneer_caip6.caipToNetworkId(asset.caip);
4977
+ this.blockchainContext = import_pioneer_caip7.caipToNetworkId(asset.caip);
4968
4978
  } else if (asset.networkId) {
4969
4979
  this.blockchainContext = asset.networkId;
4970
4980
  }
4971
4981
  if (assetPubkeys && assetPubkeys.length > 0) {
4972
- const networkId = import_pioneer_caip6.caipToNetworkId(asset.caip || asset.networkId);
4982
+ const networkId = import_pioneer_caip7.caipToNetworkId(asset.caip || asset.networkId);
4973
4983
  const currentContextValid = this.pubkeyContext?.networks?.includes(networkId);
4974
4984
  if (!this.pubkeyContext || !currentContextValid) {
4975
4985
  this.pubkeyContext = assetPubkeys[0];
@@ -4986,7 +4996,7 @@ class SDK {
4986
4996
  }
4987
4997
  };
4988
4998
  this.setPubkeyContext = async function(pubkey) {
4989
- let tag5 = `${TAG7} | setPubkeyContext | `;
4999
+ let tag5 = `${TAG8} | setPubkeyContext | `;
4990
5000
  try {
4991
5001
  if (!pubkey)
4992
5002
  throw Error("pubkey is required");
@@ -5005,7 +5015,7 @@ class SDK {
5005
5015
  }
5006
5016
  };
5007
5017
  this.setOutboundAssetContext = async function(asset) {
5008
- const tag5 = `${TAG7} | setOutputAssetContext | `;
5018
+ const tag5 = `${TAG8} | setOutputAssetContext | `;
5009
5019
  try {
5010
5020
  console.log(tag5, "0. asset: ", asset);
5011
5021
  if (!asset) {
@@ -5016,7 +5026,7 @@ class SDK {
5016
5026
  if (!asset.caip)
5017
5027
  throw Error("Invalid Asset! missing caip!");
5018
5028
  if (!asset.networkId)
5019
- asset.networkId = import_pioneer_caip6.caipToNetworkId(asset.caip);
5029
+ asset.networkId = import_pioneer_caip7.caipToNetworkId(asset.caip);
5020
5030
  console.log(tag5, "networkId: ", asset.networkId);
5021
5031
  console.log(tag5, "this.pubkeys: ", this.pubkeys);
5022
5032
  const pubkey = this.pubkeys.find((p2) => {
@@ -5097,7 +5107,7 @@ class SDK {
5097
5107
  console.log(tag5, "CHECKPOINT 3");
5098
5108
  console.log(tag5, "outboundAssetContext: assetInfo: ", assetInfo);
5099
5109
  if (asset.caip) {
5100
- this.outboundBlockchainContext = import_pioneer_caip6.caipToNetworkId(asset.caip);
5110
+ this.outboundBlockchainContext = import_pioneer_caip7.caipToNetworkId(asset.caip);
5101
5111
  } else if (asset.networkId) {
5102
5112
  this.outboundBlockchainContext = asset.networkId;
5103
5113
  }