Skip to content

Commit

Permalink
fix: call setInsufficientToken when MANA is insufficient too
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo committed Mar 12, 2024
1 parent 2fcbeb9 commit 7c32179
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const BuyWithCryptoModal = (props: Props) => {
const [selectedToken, setSelectedToken] = useState<Token>(getMANAToken(asset.chainId))
const [canBuyAsset, setCanBuyAsset] = useState<boolean | undefined>()
const [insufficientToken, setInsufficientToken] = useState<Token | undefined>()
console.log('insufficientToken: ', insufficientToken);
const [showChainSelector, setShowChainSelector] = useState(false)
const [showTokenSelector, setShowTokenSelector] = useState(false)
const [crossChainProvider, setCrossChainProvider] = useState<CrossChainProvider>()
Expand Down Expand Up @@ -194,6 +195,9 @@ export const BuyWithCryptoModal = (props: Props) => {
} else {
canBuy = wallet.networks[asset.network].mana >= +ethers.utils.formatEther(price)
}
if (!canBuy) {
setInsufficientToken(selectedToken)
}
} else if (selectedTokenBalance && routeFeeCost) {
const balance = parseFloat(ethers.utils.formatUnits(selectedTokenBalance, selectedToken.decimals))

Expand Down
2 changes: 1 addition & 1 deletion webapp/src/modules/translation/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@
"cross_chain": "Estimated fee includes the network cost and the cross chain purchase fee that you have to pay directly with your wallet.",
"same_network": "Estimated fee includes the network cost that you have to pay directly with your wallet."
},
"insufficient_funds": "You don’t have enough funds in {token}. Try paying with other token or get MANA<card> or pay with card</card>.",
"insufficient_funds": "You don’t have enough funds in {token}. Try paying with other token or get MANA<card> or pay with card</card>.",
"token_and_chain_selector": {
"available_chains": "Available Chains",
"select_chain": "Select chain",
Expand Down

0 comments on commit 7c32179

Please sign in to comment.