Skip to content

Commit

Permalink
feat: don't display portfolio balances if no asset data (shapeshift#5323
Browse files Browse the repository at this point in the history
)
  • Loading branch information
gomesalexandre authored Sep 19, 2023
1 parent 49a9244 commit fc4bf1a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/state/slices/portfolioSlice/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,17 +462,22 @@ export const selectPortfolioAccountsUserCurrencyBalancesIncludingStaking =
const userCurrencyAccountEntries = Object.entries(portfolioAccountsCryptoBalances).reduce<{
[k: AccountId]: { [k: AssetId]: string }
}>((acc, [accountId, account]) => {
const entries: [AssetId, BigNumber][] = Object.entries(account).map(
([assetId, cryptoBalance]) => {
const entries: [AssetId, BigNumber][] = Object.entries(account).reduce(
(acc: [AssetId, BigNumber][], [assetId, cryptoBalance]) => {
const asset = assets?.[assetId]
if (!asset) return [assetId, bn(0)]
if (!asset) return acc

const { precision } = asset
const price = marketData[assetId]?.price ?? 0
return [
const calculatedValue: [AssetId, BigNumber] = [
assetId,
bnOrZero(fromBaseUnit(bnOrZero(cryptoBalance), precision)).times(price),
]

acc.push(calculatedValue)
return acc
},
[],
)

const fiatAccountSorted = Object.fromEntries(
Expand Down

0 comments on commit fc4bf1a

Please sign in to comment.