Skip to content

Commit

Permalink
fix(wallet-utils): allow tokens without symbol and valid balance
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasklim committed Jul 15, 2024
1 parent ba6e397 commit 8f6e666
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions suite-common/wallet-utils/src/accountUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
HELP_CENTER_COINJOIN_URL,
HELP_CENTER_TAPROOT_URL,
} from '@trezor/urls';
import { formatTokenSymbol } from '@trezor/blockchain-link-utils';

import { toFiatCurrency } from './fiatConverterUtils';
import { getFiatRateKey } from './fiatRatesUtils';
Expand Down Expand Up @@ -451,14 +452,16 @@ export const countUniqueCoins = (accounts: Account[]) => {
export const enhanceTokens = (tokens: Account['tokens']) => {
if (!tokens) return [];

return tokens
.filter(t => t.symbol && t.balance)
.map(t => ({
return tokens.map(t => {
const symbol = formatTokenSymbol(t.symbol || t.contract);

return {
...t,
name: t.name || t.symbol,
symbol: t.symbol!.toLowerCase(),
balance: formatAmount(t.balance!, t.decimals),
}));
name: t.name || symbol,
symbol: symbol.toLowerCase(),
balance: formatAmount(t.balance || 0, t.decimals),
};
});
};

const countAddressTransfers = (transactions: AccountTransaction[]) =>
Expand Down

0 comments on commit 8f6e666

Please sign in to comment.