@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.
@@ -2906,49 +2906,33 @@ function normalizeNumber(value) {
2906
2906
  }
2907
2907
  return void 0;
2908
2908
  }
2909
- function normalizeApr(value) {
2910
- const numeric = normalizeNumber(value);
2911
- if (numeric === void 0) {
2912
- if (typeof value === "string") {
2913
- const trimmed = value.trim();
2914
- return trimmed.length > 0 ? trimmed : void 0;
2915
- }
2916
- return void 0;
2917
- }
2918
- return numeric.toString();
2919
- }
2920
2909
  function parseToken(rawToken) {
2921
2910
  if (!rawToken || typeof rawToken !== "object") {
2922
2911
  return void 0;
2923
2912
  }
2924
2913
  const token = rawToken;
2925
- const symbol = normalizeString(token.symbol) ?? normalizeString(token.asset) ?? normalizeString(token.name);
2926
- if (!symbol) {
2927
- return void 0;
2928
- }
2929
- const normalizedSymbol = symbol.toUpperCase();
2930
- const title = normalizeString(token.title) ?? normalizeString(token.display) ?? normalizeString(token.label) ?? normalizeString(token.friendlyName) ?? normalizeString(token.name) ?? normalizedSymbol;
2931
- const price = normalizeNumber(token.fiatRate) ?? 0;
2932
- const apr = normalizeApr(token.apr) ?? normalizeApr(token.aprPercent) ?? normalizeApr(token.metrics?.apr) ?? normalizeApr(
2933
- token.metrics?.aprPercent
2934
- );
2935
- const accountBalance = normalizeNumber(token.balance) ?? normalizeNumber(token.accountBalance) ?? normalizeNumber(token.totalBalance) ?? normalizeNumber(token.total) ?? normalizeNumber(token.amount) ?? 0;
2936
- const layer = normalizeString(token.layer) ?? normalizeString(token.chain) ?? normalizeString(token.category) ?? normalizeString(token.type);
2937
- const pendingRewards = normalizeNumber(token.pendingRewards);
2938
- const savings = normalizeNumber(token.savings);
2939
2914
  return {
2940
- symbol: normalizedSymbol,
2941
- name: normalizedSymbol,
2942
- title,
2943
- price,
2944
- accountBalance,
2945
- apr: apr ? Number.parseFloat(apr) : void 0,
2946
- layer: layer ?? void 0,
2947
- pendingRewards: pendingRewards ?? void 0,
2948
- savings: savings ?? void 0,
2949
- actions: token.actions ?? token.available_actions ?? token.availableActions ?? token.operations ?? token.supportedActions,
2950
- fiatRate: normalizeNumber(token.fiatRate) ?? void 0,
2951
- fiatCurrency: normalizeString(token.fiatCurrency) ?? void 0
2915
+ name: normalizeString(token.name) ?? "",
2916
+ symbol: normalizeString(token.symbol) ?? "",
2917
+ layer: normalizeString(token.layer) ?? "hive",
2918
+ balance: normalizeNumber(token.balance) ?? 0,
2919
+ fiatRate: normalizeNumber(token.fiatRate) ?? 0,
2920
+ currency: normalizeString(token.currency) ?? "usd",
2921
+ precision: normalizeNumber(token.precision) ?? 3,
2922
+ address: normalizeString(token.address),
2923
+ error: normalizeString(token.error),
2924
+ pendingRewards: normalizeNumber(token.pendingRewards),
2925
+ pendingRewardsFiat: normalizeNumber(token.pendingRewardsFiat),
2926
+ liquid: normalizeNumber(token.liquid),
2927
+ liquidFiat: normalizeNumber(token.liquidFiat),
2928
+ savings: normalizeNumber(token.savings),
2929
+ savingsFiat: normalizeNumber(token.savingsFiat),
2930
+ staked: normalizeNumber(token.staked),
2931
+ stakedFiat: normalizeNumber(token.stakedFiat),
2932
+ iconUrl: normalizeString(token.iconUrl),
2933
+ actions: token.actions ?? [],
2934
+ extraData: token.extraData ?? [],
2935
+ apr: normalizeNumber(token.apr)
2952
2936
  };
2953
2937
  }
2954
2938
  function extractTokens(payload) {
@@ -3012,7 +2996,7 @@ function getVisionPortfolioQueryOptions(username, currency = "usd") {
3012
2996
  if (!username) {
3013
2997
  throw new Error("[SDK][Wallets] \u2013 username is required");
3014
2998
  }
3015
- if (!CONFIG.privateApiHost) {
2999
+ if (CONFIG.privateApiHost === void 0 || CONFIG.privateApiHost === null) {
3016
3000
  throw new Error(
3017
3001
  "[SDK][Wallets] \u2013 privateApiHost isn't configured for portfolio"
3018
3002
  );
@@ -3105,7 +3089,7 @@ function getAccountWalletListQueryOptions(username, currency = "usd") {
3105
3089
  try {
3106
3090
  const portfolio = await queryClient.fetchQuery(portfolioQuery);
3107
3091
  const tokensFromPortfolio = portfolio.wallets.map(
3108
- (asset) => asset.name
3092
+ (asset) => asset.symbol
3109
3093
  );
3110
3094
  if (tokensFromPortfolio.length > 0) {
3111
3095
  const visibleTokens = tokensFromPortfolio.map((token) => token?.toUpperCase?.()).filter((token) => Boolean(token)).filter(isTokenVisible);
@@ -3579,14 +3563,14 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
3579
3563
  try {
3580
3564
  const portfolio = await queryClient.fetchQuery(portfolioQuery);
3581
3565
  const assetInfo = portfolio.wallets.find(
3582
- (assetItem) => assetItem.name === asset.toUpperCase()
3566
+ (assetItem) => assetItem.symbol.toUpperCase() === asset.toUpperCase()
3583
3567
  );
3584
3568
  if (!assetInfo) return void 0;
3585
3569
  return {
3586
- name: assetInfo.name,
3587
- title: assetInfo.title ?? assetInfo.name,
3588
- price: assetInfo.price ?? assetInfo.fiatRate ?? 0,
3589
- accountBalance: assetInfo.accountBalance ?? 0,
3570
+ name: assetInfo.symbol,
3571
+ title: assetInfo.name,
3572
+ price: assetInfo.fiatRate,
3573
+ accountBalance: assetInfo.balance,
3590
3574
  apr: assetInfo.apr?.toString(),
3591
3575
  layer: assetInfo.layer,
3592
3576
  pendingRewards: assetInfo.pendingRewards
@@ -3663,7 +3647,7 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
3663
3647
  getVisionPortfolioQueryOptions(username, currency)
3664
3648
  );
3665
3649
  const assetEntry = portfolio.wallets.find(
3666
- (assetItem) => assetItem.symbol?.toUpperCase() === normalizedToken || assetItem.name?.toUpperCase() === normalizedToken
3650
+ (assetItem) => assetItem.symbol.toUpperCase() === normalizedToken
3667
3651
  );
3668
3652
  if (!assetEntry) {
3669
3653
  return [];