From 0fb6f29d36b563e6bf065d697e81d6a29e8b569e Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Tue, 17 Jun 2025 11:09:35 -0300 Subject: [PATCH] Fix: add warning for custom tokens --- .../wallet/screens/AddCustomToken.tsx | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/navigation/wallet/screens/AddCustomToken.tsx b/src/navigation/wallet/screens/AddCustomToken.tsx index 3a71769e1..19d6f96e2 100644 --- a/src/navigation/wallet/screens/AddCustomToken.tsx +++ b/src/navigation/wallet/screens/AddCustomToken.tsx @@ -2,6 +2,7 @@ import React, {useCallback, useEffect, useLayoutEffect, useState} from 'react'; import { BaseText, H4, + H5, HeaderTitle, TextAlign, Badge, @@ -221,6 +222,7 @@ const AddCustomToken = ({ >(); const [invalidTokenAddress, setInvalidTokenAddress] = useState(false); + const [unverifiedToken, setUnverifiedToken] = useState(false); const DESCRIPTIONS: Record = { eth: t('TokensOnEthereumNetworkDescription'), @@ -378,7 +380,13 @@ const AddCustomToken = ({ actions: [ { text: t('OK'), - action: () => {}, + action: () => { + setInvalidTokenAddress(false); + setUnverifiedToken(false); + setTokenAddress(undefined); + setCurrencyAbbreviation(undefined); + setCurrencyName(undefined); + }, primary: true, }, ], @@ -457,7 +465,13 @@ const AddCustomToken = ({ actions: [ { text: t('OK'), - action: () => {}, + action: () => { + setInvalidTokenAddress(false); + setUnverifiedToken(false); + setTokenAddress(undefined); + setCurrencyAbbreviation(undefined); + setCurrencyName(undefined); + }, primary: true, }, ], @@ -528,6 +542,23 @@ const AddCustomToken = ({ : tokenAddress?.toLowerCase(), // Solana addresses are case sensitive }; dispatch(addCustomTokenOption(customToken, chain)); + } else { + if ( + !BitpaySupportedTokenOptsByAddress[ + getCurrencyAbbreviation( + tokenContractInfo.address, + chain, + ).toLowerCase() + ] + ) { + dispatch( + LogActions.debug( + 'token address not present in BitpaySupportedTokenOptsByAddress', + ), + ); + // Show a warning if the token is not supported by BitPay + setUnverifiedToken(true); + } } setCurrencyAbbreviation(tokenContractInfo.symbol); setCurrencyName(tokenContractInfo.name); @@ -643,6 +674,15 @@ const AddCustomToken = ({ error={errors.walletName?.message || invalidTokenAddress} value={tokenAddress} /> + {unverifiedToken && ( + + +
+ {t('This token is not verified by BitPay. Please proceed with caution.')} +
+
+
+ )}