@pioneer-platform/pioneer-sdk 8.15.38 → 8.15.41

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
@@ -472,6 +472,14 @@ function processPortfolioBalance(balance, primaryAddress, context, blockchains)
472
472
  valueUsd: balance.valueUsd.toString(),
473
473
  updated: new Date().getTime()
474
474
  };
475
+ if (balance.caip === "cosmos:cosmoshub-4/slip44:118" || balance.caip === "cosmos:osmosis-1/slip44:118") {
476
+ console.log(tag2, `\uD83D\uDCCA [CHART CREATED] ${assetInfo?.symbol || balance.symbol}:`, {
477
+ caip: balance.caip,
478
+ decimal: chartBalance.decimal,
479
+ decimals: chartBalance.decimals,
480
+ precision: chartBalance.precision
481
+ });
482
+ }
475
483
  if (balance.display) {
476
484
  chartBalance.icon = ["multi", chartBalance.icon, balance.display.toString()].toString();
477
485
  }
@@ -4463,6 +4471,13 @@ function enrichBalancesWithAssetInfo(balances, assetsMap, caipToNetworkId7) {
4463
4471
  valueUsd: balance.valueUsd,
4464
4472
  priceUsd: balance.priceUsd
4465
4473
  });
4474
+ if (balance.caip === "cosmos:cosmoshub-4/slip44:118" || balance.caip === "cosmos:osmosis-1/slip44:118") {
4475
+ console.log(tag, `✅ [DEBUG] Enriched ${balance.symbol}:`, {
4476
+ caip: balance.caip,
4477
+ decimals: balance.decimals,
4478
+ precision: balance.precision
4479
+ });
4480
+ }
4466
4481
  enrichedBalances.push(balance);
4467
4482
  }
4468
4483
  if (enrichedBalances.length < balances.length) {
@@ -5776,16 +5791,29 @@ class SDK {
5776
5791
  throw e;
5777
5792
  }
5778
5793
  };
5779
- this.getBalances = async function(forceRefresh, caip) {
5794
+ this.getBalances = async function(forceRefreshOrOptions, caip) {
5780
5795
  const tag6 = `${TAG12} | getBalances | `;
5781
5796
  try {
5782
- if (caip) {
5783
- console.log(tag6, `\uD83C\uDFAF Refreshing single asset: ${caip}`);
5784
- const networkId = caip.split("/")[0];
5785
- console.log(tag6, `\uD83D\uDCCD Target network: ${networkId}`);
5797
+ let forceRefresh = false;
5798
+ let networkId;
5799
+ if (typeof forceRefreshOrOptions === "object") {
5800
+ networkId = forceRefreshOrOptions.networkId;
5801
+ forceRefresh = forceRefreshOrOptions.forceRefresh ?? false;
5802
+ console.log(tag6, `\uD83D\uDCCD New signature - networkId: ${networkId}, forceRefresh: ${forceRefresh}`);
5803
+ } else {
5804
+ forceRefresh = forceRefreshOrOptions ?? false;
5805
+ if (caip) {
5806
+ console.log(tag6, `\uD83C\uDFAF Old signature - Refreshing single asset: ${caip}`);
5807
+ networkId = caip.split("/")[0];
5808
+ console.log(tag6, `\uD83D\uDCCD Extracted networkId: ${networkId}`);
5809
+ }
5810
+ }
5811
+ if (networkId) {
5812
+ console.log(tag6, `\uD83C\uDFAF Refreshing specific network: ${networkId}`);
5786
5813
  const results = await this.getBalancesForNetworks([networkId], forceRefresh);
5787
- return results.filter((b) => b.caip === caip || b.networkId === networkId);
5814
+ return results.filter((b) => b.networkId === networkId || b.caip?.startsWith(networkId));
5788
5815
  }
5816
+ console.log(tag6, `\uD83C\uDF10 Refreshing all blockchains (${this.blockchains.length} networks)`);
5789
5817
  return await this.getBalancesForNetworks(this.blockchains, forceRefresh);
5790
5818
  } catch (e) {
5791
5819
  console.error(tag6, "Error in getBalances: ", e);
@@ -5825,7 +5853,7 @@ class SDK {
5825
5853
  const { getCharts: getChartsModular } = await Promise.resolve().then(() => (init_charts(), exports_charts));
5826
5854
  const newBalances = await getChartsModular(this.blockchains, this.pioneer, this.pubkeys, this.context);
5827
5855
  console.log(tag6, `Modular charts returned ${newBalances.length} balances (native + tokens + staking)`);
5828
- const uniqueBalances = new Map([...this.balances, ...newBalances].map((balance) => [
5856
+ const uniqueBalances = new Map([...newBalances, ...this.balances].map((balance) => [
5829
5857
  balance.identifier || `${balance.caip}:${balance.pubkey}`,
5830
5858
  {
5831
5859
  ...balance,
package/dist/index.es.js CHANGED
@@ -463,6 +463,14 @@ function processPortfolioBalance(balance, primaryAddress, context, blockchains)
463
463
  valueUsd: balance.valueUsd.toString(),
464
464
  updated: new Date().getTime()
465
465
  };
466
+ if (balance.caip === "cosmos:cosmoshub-4/slip44:118" || balance.caip === "cosmos:osmosis-1/slip44:118") {
467
+ console.log(tag2, `\uD83D\uDCCA [CHART CREATED] ${assetInfo?.symbol || balance.symbol}:`, {
468
+ caip: balance.caip,
469
+ decimal: chartBalance.decimal,
470
+ decimals: chartBalance.decimals,
471
+ precision: chartBalance.precision
472
+ });
473
+ }
466
474
  if (balance.display) {
467
475
  chartBalance.icon = ["multi", chartBalance.icon, balance.display.toString()].toString();
468
476
  }
@@ -4647,6 +4655,13 @@ function enrichBalancesWithAssetInfo(balances, assetsMap, caipToNetworkId7) {
4647
4655
  valueUsd: balance.valueUsd,
4648
4656
  priceUsd: balance.priceUsd
4649
4657
  });
4658
+ if (balance.caip === "cosmos:cosmoshub-4/slip44:118" || balance.caip === "cosmos:osmosis-1/slip44:118") {
4659
+ console.log(tag, `✅ [DEBUG] Enriched ${balance.symbol}:`, {
4660
+ caip: balance.caip,
4661
+ decimals: balance.decimals,
4662
+ precision: balance.precision
4663
+ });
4664
+ }
4650
4665
  enrichedBalances.push(balance);
4651
4666
  }
4652
4667
  if (enrichedBalances.length < balances.length) {
@@ -5960,16 +5975,29 @@ class SDK {
5960
5975
  throw e;
5961
5976
  }
5962
5977
  };
5963
- this.getBalances = async function(forceRefresh, caip) {
5978
+ this.getBalances = async function(forceRefreshOrOptions, caip) {
5964
5979
  const tag6 = `${TAG12} | getBalances | `;
5965
5980
  try {
5966
- if (caip) {
5967
- console.log(tag6, `\uD83C\uDFAF Refreshing single asset: ${caip}`);
5968
- const networkId = caip.split("/")[0];
5969
- console.log(tag6, `\uD83D\uDCCD Target network: ${networkId}`);
5981
+ let forceRefresh = false;
5982
+ let networkId;
5983
+ if (typeof forceRefreshOrOptions === "object") {
5984
+ networkId = forceRefreshOrOptions.networkId;
5985
+ forceRefresh = forceRefreshOrOptions.forceRefresh ?? false;
5986
+ console.log(tag6, `\uD83D\uDCCD New signature - networkId: ${networkId}, forceRefresh: ${forceRefresh}`);
5987
+ } else {
5988
+ forceRefresh = forceRefreshOrOptions ?? false;
5989
+ if (caip) {
5990
+ console.log(tag6, `\uD83C\uDFAF Old signature - Refreshing single asset: ${caip}`);
5991
+ networkId = caip.split("/")[0];
5992
+ console.log(tag6, `\uD83D\uDCCD Extracted networkId: ${networkId}`);
5993
+ }
5994
+ }
5995
+ if (networkId) {
5996
+ console.log(tag6, `\uD83C\uDFAF Refreshing specific network: ${networkId}`);
5970
5997
  const results = await this.getBalancesForNetworks([networkId], forceRefresh);
5971
- return results.filter((b2) => b2.caip === caip || b2.networkId === networkId);
5998
+ return results.filter((b2) => b2.networkId === networkId || b2.caip?.startsWith(networkId));
5972
5999
  }
6000
+ console.log(tag6, `\uD83C\uDF10 Refreshing all blockchains (${this.blockchains.length} networks)`);
5973
6001
  return await this.getBalancesForNetworks(this.blockchains, forceRefresh);
5974
6002
  } catch (e) {
5975
6003
  console.error(tag6, "Error in getBalances: ", e);
@@ -6009,7 +6037,7 @@ class SDK {
6009
6037
  const { getCharts: getChartsModular } = await Promise.resolve().then(() => (init_charts(), exports_charts));
6010
6038
  const newBalances = await getChartsModular(this.blockchains, this.pioneer, this.pubkeys, this.context);
6011
6039
  console.log(tag6, `Modular charts returned ${newBalances.length} balances (native + tokens + staking)`);
6012
- const uniqueBalances = new Map([...this.balances, ...newBalances].map((balance) => [
6040
+ const uniqueBalances = new Map([...newBalances, ...this.balances].map((balance) => [
6013
6041
  balance.identifier || `${balance.caip}:${balance.pubkey}`,
6014
6042
  {
6015
6043
  ...balance,
package/dist/index.js CHANGED
@@ -463,6 +463,14 @@ function processPortfolioBalance(balance, primaryAddress, context, blockchains)
463
463
  valueUsd: balance.valueUsd.toString(),
464
464
  updated: new Date().getTime()
465
465
  };
466
+ if (balance.caip === "cosmos:cosmoshub-4/slip44:118" || balance.caip === "cosmos:osmosis-1/slip44:118") {
467
+ console.log(tag2, `\uD83D\uDCCA [CHART CREATED] ${assetInfo?.symbol || balance.symbol}:`, {
468
+ caip: balance.caip,
469
+ decimal: chartBalance.decimal,
470
+ decimals: chartBalance.decimals,
471
+ precision: chartBalance.precision
472
+ });
473
+ }
466
474
  if (balance.display) {
467
475
  chartBalance.icon = ["multi", chartBalance.icon, balance.display.toString()].toString();
468
476
  }
@@ -4647,6 +4655,13 @@ function enrichBalancesWithAssetInfo(balances, assetsMap, caipToNetworkId7) {
4647
4655
  valueUsd: balance.valueUsd,
4648
4656
  priceUsd: balance.priceUsd
4649
4657
  });
4658
+ if (balance.caip === "cosmos:cosmoshub-4/slip44:118" || balance.caip === "cosmos:osmosis-1/slip44:118") {
4659
+ console.log(tag, `✅ [DEBUG] Enriched ${balance.symbol}:`, {
4660
+ caip: balance.caip,
4661
+ decimals: balance.decimals,
4662
+ precision: balance.precision
4663
+ });
4664
+ }
4650
4665
  enrichedBalances.push(balance);
4651
4666
  }
4652
4667
  if (enrichedBalances.length < balances.length) {
@@ -5960,16 +5975,29 @@ class SDK {
5960
5975
  throw e;
5961
5976
  }
5962
5977
  };
5963
- this.getBalances = async function(forceRefresh, caip) {
5978
+ this.getBalances = async function(forceRefreshOrOptions, caip) {
5964
5979
  const tag6 = `${TAG12} | getBalances | `;
5965
5980
  try {
5966
- if (caip) {
5967
- console.log(tag6, `\uD83C\uDFAF Refreshing single asset: ${caip}`);
5968
- const networkId = caip.split("/")[0];
5969
- console.log(tag6, `\uD83D\uDCCD Target network: ${networkId}`);
5981
+ let forceRefresh = false;
5982
+ let networkId;
5983
+ if (typeof forceRefreshOrOptions === "object") {
5984
+ networkId = forceRefreshOrOptions.networkId;
5985
+ forceRefresh = forceRefreshOrOptions.forceRefresh ?? false;
5986
+ console.log(tag6, `\uD83D\uDCCD New signature - networkId: ${networkId}, forceRefresh: ${forceRefresh}`);
5987
+ } else {
5988
+ forceRefresh = forceRefreshOrOptions ?? false;
5989
+ if (caip) {
5990
+ console.log(tag6, `\uD83C\uDFAF Old signature - Refreshing single asset: ${caip}`);
5991
+ networkId = caip.split("/")[0];
5992
+ console.log(tag6, `\uD83D\uDCCD Extracted networkId: ${networkId}`);
5993
+ }
5994
+ }
5995
+ if (networkId) {
5996
+ console.log(tag6, `\uD83C\uDFAF Refreshing specific network: ${networkId}`);
5970
5997
  const results = await this.getBalancesForNetworks([networkId], forceRefresh);
5971
- return results.filter((b2) => b2.caip === caip || b2.networkId === networkId);
5998
+ return results.filter((b2) => b2.networkId === networkId || b2.caip?.startsWith(networkId));
5972
5999
  }
6000
+ console.log(tag6, `\uD83C\uDF10 Refreshing all blockchains (${this.blockchains.length} networks)`);
5973
6001
  return await this.getBalancesForNetworks(this.blockchains, forceRefresh);
5974
6002
  } catch (e) {
5975
6003
  console.error(tag6, "Error in getBalances: ", e);
@@ -6009,7 +6037,7 @@ class SDK {
6009
6037
  const { getCharts: getChartsModular } = await Promise.resolve().then(() => (init_charts(), exports_charts));
6010
6038
  const newBalances = await getChartsModular(this.blockchains, this.pioneer, this.pubkeys, this.context);
6011
6039
  console.log(tag6, `Modular charts returned ${newBalances.length} balances (native + tokens + staking)`);
6012
- const uniqueBalances = new Map([...this.balances, ...newBalances].map((balance) => [
6040
+ const uniqueBalances = new Map([...newBalances, ...this.balances].map((balance) => [
6013
6041
  balance.identifier || `${balance.caip}:${balance.pubkey}`,
6014
6042
  {
6015
6043
  ...balance,
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "author": "highlander",
3
3
  "name": "@pioneer-platform/pioneer-sdk",
4
- "version": "8.15.38",
4
+ "version": "8.15.41",
5
5
  "dependencies": {
6
6
  "@keepkey/keepkey-sdk": "^0.2.62",
7
- "@pioneer-platform/pioneer-caip": "^9.10.15",
8
- "@pioneer-platform/pioneer-client": "^9.10.21",
9
- "@pioneer-platform/pioneer-coins": "^9.11.15",
10
- "@pioneer-platform/pioneer-discovery": "^8.15.38",
11
- "@pioneer-platform/pioneer-events": "^8.12.10",
7
+ "@pioneer-platform/pioneer-caip": "^9.10.18",
8
+ "@pioneer-platform/pioneer-client": "^9.10.24",
9
+ "@pioneer-platform/pioneer-coins": "^9.11.18",
10
+ "@pioneer-platform/pioneer-discovery": "^8.15.41",
11
+ "@pioneer-platform/pioneer-events": "^8.12.13",
12
12
  "coinselect": "^3.1.13",
13
13
  "eventemitter3": "^5.0.1",
14
14
  "neotraverse": "^0.6.8",
package/src/charts/evm.ts CHANGED
@@ -120,6 +120,7 @@ export async function getEvmCharts(params: ChartParams): Promise<ChartBalance[]>
120
120
 
121
121
  for (const token of portfolio.tokens) {
122
122
  const processedToken = processPortfolioToken(token, primaryAddress, context, blockchains);
123
+
123
124
  if (processedToken && !checkDuplicateBalance(balances, processedToken.caip, processedToken.pubkey)) {
124
125
  balances.push(processedToken);
125
126
  }
@@ -224,6 +225,16 @@ function processPortfolioBalance(
224
225
  updated: new Date().getTime(),
225
226
  };
226
227
 
228
+ // DEBUG: Log ATOM and OSMO chart balance creation
229
+ if (balance.caip === 'cosmos:cosmoshub-4/slip44:118' || balance.caip === 'cosmos:osmosis-1/slip44:118') {
230
+ console.log(tag, `📊 [CHART CREATED] ${assetInfo?.symbol || balance.symbol}:`, {
231
+ caip: balance.caip,
232
+ decimal: chartBalance.decimal,
233
+ decimals: chartBalance.decimals,
234
+ precision: chartBalance.precision,
235
+ });
236
+ }
237
+
227
238
  // Handle display icon for multi-asset icons
228
239
  if (balance.display) {
229
240
  chartBalance.icon = ['multi', chartBalance.icon, balance.display.toString()].toString();
@@ -15,6 +15,8 @@ export interface ChartBalance {
15
15
  type: string;
16
16
  token?: boolean; // Indicates if this is a token balance
17
17
  decimal?: number;
18
+ decimals?: number; // Number of decimal places (NEW standard)
19
+ precision?: number; // Precision for the asset (alias for decimals)
18
20
  balance: string;
19
21
  priceUsd: number;
20
22
  valueUsd: number | string;
package/src/index.ts CHANGED
@@ -1672,20 +1672,41 @@ export class SDK {
1672
1672
  throw e;
1673
1673
  }
1674
1674
  };
1675
- this.getBalances = async function (forceRefresh?: boolean, caip?: string) {
1675
+ this.getBalances = async function (
1676
+ forceRefreshOrOptions?: boolean | { networkId?: string; forceRefresh?: boolean },
1677
+ caip?: string
1678
+ ) {
1676
1679
  const tag = `${TAG} | getBalances | `;
1677
1680
  try {
1678
- // If CAIP is provided, refresh only that specific asset
1679
- if (caip) {
1680
- console.log(tag, `🎯 Refreshing single asset: ${caip}`);
1681
- const networkId = caip.split('/')[0];
1682
- console.log(tag, `📍 Target network: ${networkId}`);
1681
+ // Parse parameters - support both old and new signatures
1682
+ let forceRefresh = false;
1683
+ let networkId: string | undefined;
1684
+
1685
+ if (typeof forceRefreshOrOptions === 'object') {
1686
+ // New signature: getBalances({ networkId, forceRefresh })
1687
+ networkId = forceRefreshOrOptions.networkId;
1688
+ forceRefresh = forceRefreshOrOptions.forceRefresh ?? false;
1689
+ console.log(tag, `📍 New signature - networkId: ${networkId}, forceRefresh: ${forceRefresh}`);
1690
+ } else {
1691
+ // Old signature: getBalances(forceRefresh, caip)
1692
+ forceRefresh = forceRefreshOrOptions ?? false;
1693
+
1694
+ if (caip) {
1695
+ console.log(tag, `🎯 Old signature - Refreshing single asset: ${caip}`);
1696
+ networkId = caip.split('/')[0];
1697
+ console.log(tag, `📍 Extracted networkId: ${networkId}`);
1698
+ }
1699
+ }
1683
1700
 
1701
+ // If networkId is provided, refresh only that network
1702
+ if (networkId) {
1703
+ console.log(tag, `🎯 Refreshing specific network: ${networkId}`);
1684
1704
  const results = await this.getBalancesForNetworks([networkId], forceRefresh);
1685
- return results.filter((b) => b.caip === caip || b.networkId === networkId);
1705
+ return results.filter((b) => b.networkId === networkId || b.caip?.startsWith(networkId));
1686
1706
  }
1687
1707
 
1688
1708
  // Default: refresh all blockchains
1709
+ console.log(tag, `🌐 Refreshing all blockchains (${this.blockchains.length} networks)`);
1689
1710
  return await this.getBalancesForNetworks(this.blockchains, forceRefresh);
1690
1711
  } catch (e) {
1691
1712
  console.error(tag, 'Error in getBalances: ', e);
@@ -1755,8 +1776,10 @@ export class SDK {
1755
1776
  console.log(tag, `Modular charts returned ${newBalances.length} balances (native + tokens + staking)`);
1756
1777
 
1757
1778
  // Deduplicate balances using a Map with `identifier` as the key
1779
+ // CRITICAL: Put newBalances FIRST so this.balances (with enriched data) override incomplete newBalances
1780
+ // When Map is constructed from an array with duplicate keys, the LAST occurrence wins
1758
1781
  const uniqueBalances = new Map(
1759
- [...this.balances, ...newBalances].map((balance: any) => [
1782
+ [...newBalances, ...this.balances].map((balance: any) => [
1760
1783
  balance.identifier || `${balance.caip}:${balance.pubkey}`,
1761
1784
  {
1762
1785
  ...balance,
@@ -376,6 +376,15 @@ export function enrichBalancesWithAssetInfo(
376
376
  priceUsd: balance.priceUsd,
377
377
  });
378
378
 
379
+ // DEBUG: Verify ATOM and OSMO after enrichment
380
+ if (balance.caip === 'cosmos:cosmoshub-4/slip44:118' || balance.caip === 'cosmos:osmosis-1/slip44:118') {
381
+ console.log(tag, `✅ [DEBUG] Enriched ${balance.symbol}:`, {
382
+ caip: balance.caip,
383
+ decimals: balance.decimals,
384
+ precision: balance.precision,
385
+ });
386
+ }
387
+
379
388
  enrichedBalances.push(balance);
380
389
  }
381
390