Skip to content

Commit

Permalink
fix: show brc20 token fiat balance, closes #5626
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Jul 16, 2024
1 parent 1b9f9a2 commit adf8c19
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Brc20AvatarIcon } from '@leather.io/ui';

import { RouteUrls } from '@shared/route-urls';

import { convertAssetBalanceToFiat } from '@app/common/asset-utils';
import { CryptoAssetItemLayout } from '@app/components/crypto-asset-item/crypto-asset-item.layout';
import type { AssetListVariant } from '@app/features/asset-list/asset-list';
import { useCurrentBtcCryptoAssetBalanceNativeSegwit } from '@app/query/bitcoin/balance/btc-balance-native-segwit.hooks';
Expand All @@ -23,6 +24,14 @@ interface Brc20TokenAssetListProps {
tokens: Brc20TokenAssetDetails[];
variant?: AssetListVariant;
}

function getBrc20TokenFiatBalance(token: Brc20TokenAssetDetails) {
return convertAssetBalanceToFiat({
balance: token.balance.availableBalance,
marketData: token.marketData,
});
}

export function Brc20TokenAssetList({ tokens, variant }: Brc20TokenAssetListProps) {
const navigate = useNavigate();
const { balance, isLoading } = useCurrentBtcCryptoAssetBalanceNativeSegwit();
Expand Down Expand Up @@ -56,6 +65,7 @@ export function Brc20TokenAssetList({ tokens, variant }: Brc20TokenAssetListProp
hasPositiveBtcBalanceForFees ? () => navigateToBrc20SendForm(token) : undefined
}
titleLeft={token.info.symbol}
fiatBalance={getBrc20TokenFiatBalance(token)}
/>
))}
</Stack>
Expand Down

0 comments on commit adf8c19

Please sign in to comment.