@ecency/wallets 1.5.11 → 1.5.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.
@@ -1815,22 +1815,36 @@ declare function getTokenOperationsQueryOptions(token: string, username: string,
1815
1815
 
1816
1816
  declare function useWalletsCacheQuery(username?: string): _tanstack_react_query.DefinedUseQueryResult<Map<EcencyWalletCurrency, EcencyTokenMetadata>, Error>;
1817
1817
 
1818
+ type PortfolioLayer = "points" | "hive" | "chain" | "spk" | "engine";
1819
+ interface TokenAction {
1820
+ id: string;
1821
+ [key: string]: unknown;
1822
+ }
1818
1823
  interface VisionPortfolioWalletItem {
1819
- symbol: string;
1820
1824
  name: string;
1821
- title?: string;
1822
- price?: number;
1823
- accountBalance?: number;
1824
- apr?: number;
1825
- layer?: string;
1825
+ symbol: string;
1826
+ layer: PortfolioLayer;
1827
+ balance: number;
1828
+ fiatRate: number;
1829
+ currency: string;
1830
+ precision: number;
1831
+ address?: string;
1832
+ error?: string;
1826
1833
  pendingRewards?: number;
1834
+ pendingRewardsFiat?: number;
1835
+ liquid?: number;
1836
+ liquidFiat?: number;
1827
1837
  savings?: number;
1828
- actions?: Array<{
1829
- id: string;
1830
- [key: string]: unknown;
1831
- } | string>;
1832
- fiatRate?: number;
1833
- fiatCurrency?: string;
1838
+ savingsFiat?: number;
1839
+ staked?: number;
1840
+ stakedFiat?: number;
1841
+ iconUrl?: string;
1842
+ actions?: TokenAction[];
1843
+ extraData?: Array<{
1844
+ dataKey: string;
1845
+ value: any;
1846
+ }>;
1847
+ apr?: number;
1834
1848
  }
1835
1849
  interface VisionPortfolioResponse {
1836
1850
  username: string;
@@ -2908,49 +2908,33 @@ function normalizeNumber(value) {
2908
2908
  }
2909
2909
  return void 0;
2910
2910
  }
2911
- function normalizeApr(value) {
2912
- const numeric = normalizeNumber(value);
2913
- if (numeric === void 0) {
2914
- if (typeof value === "string") {
2915
- const trimmed = value.trim();
2916
- return trimmed.length > 0 ? trimmed : void 0;
2917
- }
2918
- return void 0;
2919
- }
2920
- return numeric.toString();
2921
- }
2922
2911
  function parseToken(rawToken) {
2923
2912
  if (!rawToken || typeof rawToken !== "object") {
2924
2913
  return void 0;
2925
2914
  }
2926
2915
  const token = rawToken;
2927
- const symbol = normalizeString(token.symbol) ?? normalizeString(token.asset) ?? normalizeString(token.name);
2928
- if (!symbol) {
2929
- return void 0;
2930
- }
2931
- const normalizedSymbol = symbol.toUpperCase();
2932
- const title = normalizeString(token.title) ?? normalizeString(token.display) ?? normalizeString(token.label) ?? normalizeString(token.friendlyName) ?? normalizeString(token.name) ?? normalizedSymbol;
2933
- const price = normalizeNumber(token.fiatRate) ?? 0;
2934
- const apr = normalizeApr(token.apr) ?? normalizeApr(token.aprPercent) ?? normalizeApr(token.metrics?.apr) ?? normalizeApr(
2935
- token.metrics?.aprPercent
2936
- );
2937
- const accountBalance = normalizeNumber(token.balance) ?? normalizeNumber(token.accountBalance) ?? normalizeNumber(token.totalBalance) ?? normalizeNumber(token.total) ?? normalizeNumber(token.amount) ?? 0;
2938
- const layer = normalizeString(token.layer) ?? normalizeString(token.chain) ?? normalizeString(token.category) ?? normalizeString(token.type);
2939
- const pendingRewards = normalizeNumber(token.pendingRewards);
2940
- const savings = normalizeNumber(token.savings);
2941
2916
  return {
2942
- symbol: normalizedSymbol,
2943
- name: normalizedSymbol,
2944
- title,
2945
- price,
2946
- accountBalance,
2947
- apr: apr ? Number.parseFloat(apr) : void 0,
2948
- layer: layer ?? void 0,
2949
- pendingRewards: pendingRewards ?? void 0,
2950
- savings: savings ?? void 0,
2951
- actions: token.actions ?? token.available_actions ?? token.availableActions ?? token.operations ?? token.supportedActions,
2952
- fiatRate: normalizeNumber(token.fiatRate) ?? void 0,
2953
- fiatCurrency: normalizeString(token.fiatCurrency) ?? void 0
2917
+ name: normalizeString(token.name) ?? "",
2918
+ symbol: normalizeString(token.symbol) ?? "",
2919
+ layer: normalizeString(token.layer) ?? "hive",
2920
+ balance: normalizeNumber(token.balance) ?? 0,
2921
+ fiatRate: normalizeNumber(token.fiatRate) ?? 0,
2922
+ currency: normalizeString(token.currency) ?? "usd",
2923
+ precision: normalizeNumber(token.precision) ?? 3,
2924
+ address: normalizeString(token.address),
2925
+ error: normalizeString(token.error),
2926
+ pendingRewards: normalizeNumber(token.pendingRewards),
2927
+ pendingRewardsFiat: normalizeNumber(token.pendingRewardsFiat),
2928
+ liquid: normalizeNumber(token.liquid),
2929
+ liquidFiat: normalizeNumber(token.liquidFiat),
2930
+ savings: normalizeNumber(token.savings),
2931
+ savingsFiat: normalizeNumber(token.savingsFiat),
2932
+ staked: normalizeNumber(token.staked),
2933
+ stakedFiat: normalizeNumber(token.stakedFiat),
2934
+ iconUrl: normalizeString(token.iconUrl),
2935
+ actions: token.actions ?? [],
2936
+ extraData: token.extraData ?? [],
2937
+ apr: normalizeNumber(token.apr)
2954
2938
  };
2955
2939
  }
2956
2940
  function extractTokens(payload) {
@@ -3014,7 +2998,7 @@ function getVisionPortfolioQueryOptions(username, currency = "usd") {
3014
2998
  if (!username) {
3015
2999
  throw new Error("[SDK][Wallets] \u2013 username is required");
3016
3000
  }
3017
- if (!CONFIG.privateApiHost) {
3001
+ if (CONFIG.privateApiHost === void 0 || CONFIG.privateApiHost === null) {
3018
3002
  throw new Error(
3019
3003
  "[SDK][Wallets] \u2013 privateApiHost isn't configured for portfolio"
3020
3004
  );
@@ -3107,7 +3091,7 @@ function getAccountWalletListQueryOptions(username, currency = "usd") {
3107
3091
  try {
3108
3092
  const portfolio = await queryClient.fetchQuery(portfolioQuery);
3109
3093
  const tokensFromPortfolio = portfolio.wallets.map(
3110
- (asset) => asset.name
3094
+ (asset) => asset.symbol
3111
3095
  );
3112
3096
  if (tokensFromPortfolio.length > 0) {
3113
3097
  const visibleTokens = tokensFromPortfolio.map((token) => token?.toUpperCase?.()).filter((token) => Boolean(token)).filter(isTokenVisible);
@@ -3581,14 +3565,14 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
3581
3565
  try {
3582
3566
  const portfolio = await queryClient.fetchQuery(portfolioQuery);
3583
3567
  const assetInfo = portfolio.wallets.find(
3584
- (assetItem) => assetItem.name === asset.toUpperCase()
3568
+ (assetItem) => assetItem.symbol.toUpperCase() === asset.toUpperCase()
3585
3569
  );
3586
3570
  if (!assetInfo) return void 0;
3587
3571
  return {
3588
- name: assetInfo.name,
3589
- title: assetInfo.title ?? assetInfo.name,
3590
- price: assetInfo.price ?? assetInfo.fiatRate ?? 0,
3591
- accountBalance: assetInfo.accountBalance ?? 0,
3572
+ name: assetInfo.symbol,
3573
+ title: assetInfo.name,
3574
+ price: assetInfo.fiatRate,
3575
+ accountBalance: assetInfo.balance,
3592
3576
  apr: assetInfo.apr?.toString(),
3593
3577
  layer: assetInfo.layer,
3594
3578
  pendingRewards: assetInfo.pendingRewards
@@ -3665,7 +3649,7 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
3665
3649
  getVisionPortfolioQueryOptions(username, currency)
3666
3650
  );
3667
3651
  const assetEntry = portfolio.wallets.find(
3668
- (assetItem) => assetItem.symbol?.toUpperCase() === normalizedToken || assetItem.name?.toUpperCase() === normalizedToken
3652
+ (assetItem) => assetItem.symbol.toUpperCase() === normalizedToken
3669
3653
  );
3670
3654
  if (!assetEntry) {
3671
3655
  return [];