Skip to content

Commit

Permalink
fix: hide zero balance chains (#2563)
Browse files Browse the repository at this point in the history
  • Loading branch information
sokolova-an authored Oct 31, 2024
1 parent 2096b04 commit 55487ae
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,17 @@ function getChainWithBalance(
}

function hideZeroBalances(hideZeroBalance: boolean, activeTokensWithBalance: AssetByChains[]): AssetByChains[] {
return activeTokensWithBalance.filter((token) => {
return !hideZeroBalance || totalAmount(token.totalBalance) !== ZERO_BALANCE;
});
if (!hideZeroBalance) return activeTokensWithBalance;

return activeTokensWithBalance.reduce<AssetByChains[]>((acc, token) => {
if (totalAmount(token.totalBalance) === ZERO_BALANCE) return acc;

const chains = token.chains.filter((chain) => {
return totalAmount(chain.balance) !== ZERO_BALANCE;
});

return [...acc, { ...token, chains }];
}, []);
}

function sortTokensByBalance(
Expand Down

0 comments on commit 55487ae

Please sign in to comment.