Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Token list should respect hideZeroBalance setting #29058

Merged
merged 18 commits into from
Dec 11, 2024
Merged
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions ui/components/app/assets/token-list/token-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ export default function TokenList({
const dispatch = useDispatch();
const currentNetwork = useSelector(getCurrentNetwork);
const allNetworks = useSelector(getNetworkConfigurationIdByChainId);
const { tokenSortConfig, tokenNetworkFilter, privacyMode } =
useSelector(getPreferences);
const {
tokenSortConfig,
tokenNetworkFilter,
privacyMode,
hideZeroBalanceTokens,
} = useSelector(getPreferences);
const selectedAccount = useSelector(getSelectedAccount);
const conversionRate = useSelector(getConversionRate);
const contractExchangeRates = useSelector(
Expand Down Expand Up @@ -147,14 +151,18 @@ export default function TokenList({
currencyRates,
});

// Append processed token with balance and fiat amount
tokensWithBalance.push({
...token,
balance,
tokenFiatAmount,
chainId,
string: String(balance),
});
// respect hide zero balance setting
// native tokens should still show zero balance regardless
// erc20s with zero balances should be hidden
if (!hideZeroBalanceTokens || token.isNative || balance !== '0') {
gambinish marked this conversation as resolved.
Show resolved Hide resolved
tokensWithBalance.push({
...token,
balance,
tokenFiatAmount,
chainId,
string: String(balance),
});
}
});
},
);
Expand Down
Loading