Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: select the first token from the chain selected #2156

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ export const BuyWithCryptoModal = (props: Props) => {
manaTokenOnSelectedChain || getMANAToken(selectedChain)
) // if it's not in the providerTokens, create the object manually with the right conectract address
} catch (error) {
setSelectedToken(providerTokens[0])
const selectedChainTokens = providerTokens.filter(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pick the first token from the selected chain, otherwise it can belong to other one

t => t.chainId === selectedChain.toString()
)
setSelectedToken(selectedChainTokens[0])
}
}
}, [
Expand Down Expand Up @@ -796,7 +799,9 @@ export const BuyWithCryptoModal = (props: Props) => {
})}
</span>
) : null}
{!canBuyAsset && !isFetchingBalance && !isFetchingRoute ? (
{canBuyAsset === false &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

canBuyAsset must be computed, it starts at undefined, at that value, we don't know if it has funds or not for the tx

!isFetchingBalance &&
!isFetchingRoute ? (
<span className={styles.warning}>
{t('buy_with_crypto_modal.insufficient_funds', {
token: insufficientToken?.symbol || 'MANA'
Expand Down