Skip to content

Commit

Permalink
chore: only show relevant fund assets and deprecate tooltip for send …
Browse files Browse the repository at this point in the history
…BRC-20, ref #5071 #4949
  • Loading branch information
pete-watters committed Mar 21, 2024
1 parent 4cc2b3d commit 990ee0e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export function Brc20TokenAssetList(props: { brc20Tokens?: Brc20Token[] }) {
{props.brc20Tokens?.map(token => (
<Brc20TokenAssetItemLayout
key={token.ticker}
displayNotEnoughBalance={!hasPositiveBtcBalanceForFees}
token={token}
onClick={hasPositiveBtcBalanceForFees ? () => navigateToBrc20SendForm(token) : noop}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,33 @@ import { Pressable } from '@app/ui/pressable/pressable';
interface Brc20TokenAssetItemLayoutProps {
token: Brc20Token;
onClick?(): void;
displayNotEnoughBalance?: boolean;
}
export function Brc20TokenAssetItemLayout({
onClick,
displayNotEnoughBalance,

token,
}: Brc20TokenAssetItemLayoutProps) {
const balance = createMoney(Number(token.overall_balance), token.ticker, 0);
const formattedBalance = formatBalance(balance.amount.toString());

return (
<BasicTooltip
asChild
disabled={!displayNotEnoughBalance}
label="Not enough BTC in balance"
side="top"
>
<Pressable onClick={onClick} my="space.02">
<ItemLayout
flagImg={<Brc20AvatarIcon />}
titleLeft={token.ticker}
captionLeft="BRC-20"
titleRight={
<BasicTooltip
asChild
label={formattedBalance.isAbbreviated ? balance.amount.toString() : undefined}
side="left"
>
<styled.span data-testid={token.ticker} fontWeight={500} textStyle="label.02">
{formattedBalance.value}
</styled.span>
</BasicTooltip>
}
/>
</Pressable>
</BasicTooltip>
<Pressable onClick={onClick} my="space.02">
<ItemLayout
flagImg={<Brc20AvatarIcon />}
titleLeft={token.ticker}
captionLeft="BRC-20"
titleRight={
<BasicTooltip
asChild
label={formattedBalance.isAbbreviated ? balance.amount.toString() : undefined}
side="left"
>
<styled.span data-testid={token.ticker} fontWeight={500} textStyle="label.02">
{formattedBalance.value}
</styled.span>
</BasicTooltip>
}
/>
</Pressable>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ import { CryptoAssetListItem } from './crypto-asset-list-item';
interface CryptoAssetListProps {
cryptoAssetBalances: AllTransferableCryptoAssetBalances[];
onItemClick(cryptoAssetBalance: AllTransferableCryptoAssetBalances): void;
variant: 'send' | 'fund';
}
export function CryptoAssetList({ cryptoAssetBalances, onItemClick }: CryptoAssetListProps) {
export function CryptoAssetList({
cryptoAssetBalances,
onItemClick,
variant,
}: CryptoAssetListProps) {
const { whenWallet } = useWalletType();

return (
Expand Down Expand Up @@ -46,18 +51,19 @@ export function CryptoAssetList({ cryptoAssetBalances, onItemClick }: CryptoAsse
}
/>
))}
{whenWallet({
software: (
<BitcoinNativeSegwitAccountLoader current>
{() => (
<Brc20TokensLoader>
{brc20Tokens => <Brc20TokenAssetList brc20Tokens={brc20Tokens} />}
</Brc20TokensLoader>
)}
</BitcoinNativeSegwitAccountLoader>
),
ledger: null,
})}
{variant === 'send' &&
whenWallet({
software: (
<BitcoinNativeSegwitAccountLoader current>
{() => (
<Brc20TokensLoader>
{brc20Tokens => <Brc20TokenAssetList brc20Tokens={brc20Tokens} />}
</Brc20TokensLoader>
)}
</BitcoinNativeSegwitAccountLoader>
),
ledger: null,
})}
</Stack>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function ChooseCryptoAssetToFund() {
[stxCryptoCurrencyAssetBalance, checkBlockchainAvailable, whenWallet]
);

const navigateToSendForm = useCallback(
const navigateToFund = useCallback(
(cryptoAssetBalance: AllTransferableCryptoAssetBalances) => {
const { asset } = cryptoAssetBalance;

Expand All @@ -55,8 +55,9 @@ export function ChooseCryptoAssetToFund() {
>
<Box pb="space.04" px="space.03">
<CryptoAssetList
onItemClick={navigateToSendForm}
onItemClick={navigateToFund}
cryptoAssetBalances={filteredCryptoAssetBalances}
variant="fund"
/>
</Box>
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function ChooseCryptoAsset() {
software: true,
})
)}
variant="send"
/>
</Box>
</Card>
Expand Down

0 comments on commit 990ee0e

Please sign in to comment.