forked from leather-io/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
61 additions
and
54 deletions.
There are no files selected for viewing
File renamed without changes.
46 changes: 46 additions & 0 deletions
46
src/app/components/crypto-assets/bitcoin/brc20-token-asset-list/brc20-token-asset-list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { RouteUrls } from '@shared/route-urls'; | ||
import { noop } from '@shared/utils'; | ||
|
||
import { Brc20TokenAssetItem } from '@app/components/crypto-assets/bitcoin/brc20-token-asset-list/components/brc20-token-asset-item'; | ||
import { Tooltip } from '@app/components/tooltip'; | ||
import { useNativeSegwitBalance } from '@app/query/bitcoin/balance/bitcoin-balances.query'; | ||
import { Brc20Token } from '@app/query/bitcoin/ordinals/brc20/brc20-tokens.query'; | ||
import { useCurrentAccountNativeSegwitAddressIndexZero } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks'; | ||
|
||
export function Brc20TokenAssetList(props: { brc20Tokens?: Brc20Token[] }) { | ||
const navigate = useNavigate(); | ||
const currentAccountBtcAddress = useCurrentAccountNativeSegwitAddressIndexZero(); | ||
const btcCryptoCurrencyAssetBalance = useNativeSegwitBalance(currentAccountBtcAddress); | ||
|
||
const hasPositiveBtcBalanceForFees = | ||
btcCryptoCurrencyAssetBalance.balance.amount.isGreaterThan(0); | ||
|
||
function navigateToBrc20SendForm(token: Brc20Token) { | ||
const { tick, available_balance } = token; | ||
navigate(RouteUrls.SendBrc20SendForm.replace(':ticker', tick), { | ||
state: { balance: available_balance, tick }, | ||
}); | ||
} | ||
|
||
return ( | ||
<> | ||
{props.brc20Tokens?.map(token => ( | ||
<Tooltip | ||
disabled={hasPositiveBtcBalanceForFees} | ||
key={token.tick} | ||
placement="top" | ||
label={'Not enough BTC in balance'} | ||
hideOnClick={false} | ||
> | ||
<Brc20TokenAssetItem | ||
token={token} | ||
isPressable={hasPositiveBtcBalanceForFees} | ||
onClick={hasPositiveBtcBalanceForFees ? () => navigateToBrc20SendForm(token) : noop} | ||
/> | ||
</Tooltip> | ||
))} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/features/balances-list/components/bitcoin-fungible-tokens-asset-list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 1 addition & 41 deletions
42
src/app/pages/send/choose-crypto-asset/components/crypto-asset-list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,17 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import type { AllTransferableCryptoAssetBalances } from '@shared/models/crypto-asset-balance.model'; | ||
import { RouteUrls } from '@shared/route-urls'; | ||
import { noop } from '@shared/utils'; | ||
|
||
import { Brc20TokenAssetItem } from '@app/components/crypto-assets/bitcoin/brc20-token-asset/brc20-token-asset-item'; | ||
import { Tooltip } from '@app/components/tooltip'; | ||
import { useNativeSegwitBalance } from '@app/query/bitcoin/balance/bitcoin-balances.query'; | ||
import { Brc20Token } from '@app/query/bitcoin/ordinals/brc20/brc20-tokens.query'; | ||
import { useCurrentAccountNativeSegwitAddressIndexZero } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks'; | ||
|
||
import { CryptoAssetListItem } from './crypto-asset-list-item'; | ||
import { CryptoAssetListLayout } from './crypto-asset-list.layout'; | ||
|
||
interface CryptoAssetListProps { | ||
cryptoAssetBalances: AllTransferableCryptoAssetBalances[]; | ||
brc20Tokens: Brc20Token[]; | ||
} | ||
export function CryptoAssetList({ cryptoAssetBalances, brc20Tokens }: CryptoAssetListProps) { | ||
const navigate = useNavigate(); | ||
const currentAccountBtcAddress = useCurrentAccountNativeSegwitAddressIndexZero(); | ||
const btcCryptoCurrencyAssetBalance = useNativeSegwitBalance(currentAccountBtcAddress); | ||
|
||
const hasPositiveBtcBalanceForFees = | ||
btcCryptoCurrencyAssetBalance.balance.amount.isGreaterThan(0); | ||
|
||
function navigateToBrc20SendForm(token: Brc20Token) { | ||
const { tick, available_balance } = token; | ||
navigate(RouteUrls.SendBrc20SendForm.replace(':ticker', tick), { | ||
state: { balance: available_balance, tick }, | ||
}); | ||
} | ||
|
||
export function CryptoAssetList({ cryptoAssetBalances }: CryptoAssetListProps) { | ||
return ( | ||
<CryptoAssetListLayout> | ||
{cryptoAssetBalances.map(assetBalance => ( | ||
<CryptoAssetListItem assetBalance={assetBalance} key={assetBalance.asset.name} /> | ||
))} | ||
{brc20Tokens.map(token => ( | ||
<Tooltip | ||
disabled={hasPositiveBtcBalanceForFees} | ||
key={token.tick} | ||
placement="top" | ||
label={'Not enough BTC in balance'} | ||
hideOnClick={false} | ||
> | ||
<Brc20TokenAssetItem | ||
token={token} | ||
isPressable={hasPositiveBtcBalanceForFees} | ||
onClick={hasPositiveBtcBalanceForFees ? () => navigateToBrc20SendForm(token) : noop} | ||
/> | ||
</Tooltip> | ||
))} | ||
</CryptoAssetListLayout> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters