Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions src/navigation/wallet/screens/AddCustomToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {useCallback, useEffect, useLayoutEffect, useState} from 'react';
import {
BaseText,
H4,
H5,
HeaderTitle,
TextAlign,
Badge,
Expand Down Expand Up @@ -221,6 +222,7 @@ const AddCustomToken = ({
>();
const [invalidTokenAddress, setInvalidTokenAddress] =
useState<boolean>(false);
const [unverifiedToken, setUnverifiedToken] = useState<boolean>(false);

const DESCRIPTIONS: Record<string, string> = {
eth: t('TokensOnEthereumNetworkDescription'),
Expand Down Expand Up @@ -378,7 +380,13 @@ const AddCustomToken = ({
actions: [
{
text: t('OK'),
action: () => {},
action: () => {
setInvalidTokenAddress(false);
setUnverifiedToken(false);
setTokenAddress(undefined);
setCurrencyAbbreviation(undefined);
setCurrencyName(undefined);
},
primary: true,
},
],
Expand Down Expand Up @@ -457,7 +465,13 @@ const AddCustomToken = ({
actions: [
{
text: t('OK'),
action: () => {},
action: () => {
setInvalidTokenAddress(false);
setUnverifiedToken(false);
setTokenAddress(undefined);
setCurrencyAbbreviation(undefined);
setCurrencyName(undefined);
},
primary: true,
},
],
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -643,6 +674,15 @@ const AddCustomToken = ({
error={errors.walletName?.message || invalidTokenAddress}
value={tokenAddress}
/>
{unverifiedToken && (
<View style={{marginTop: 10}}>
<TextAlign align={'center'}>
<H5 style={{color: 'red', fontSize: 14}}>
{t('This token is not verified by BitPay. Please proceed with caution.')}
</H5>
</TextAlign>
</View>
)}
</View>

<SheetModal
Expand Down