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: GlobalSelect should check coin/chain from credentials instead CurrencyAbbreviation #1508

Merged
Merged
Show file tree
Hide file tree
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
41 changes: 21 additions & 20 deletions src/navigation/tabs/contacts/screens/ContactsDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,28 @@ const ContactsDetails = ({
// Remove prefix
newAddress = ToCashAddress(contact.address, false);
}
if (!IsEVMChain(contact.chain)) {
contactOptions.push({
img: theme.dark ? <SendIconWhite /> : <SendIcon />,
title: t('Send ') + contact.coin.toUpperCase(),
onPress: async () => {
setShowIconOptions(false);
await sleep(500);
navigation.navigate('GlobalSelect', {
context: 'contact',
recipient: {
name: contact.name,
address: newAddress,
currency: contact.coin,
chain: contact.chain,
network: contact.network,
destinationTag: contact.tag || contact.destinationTag,
contactOptions.push({
img: theme.dark ? <SendIconWhite /> : <SendIcon />,
title: t('Send to this contact'),
onPress: async () => {
setShowIconOptions(false);
await sleep(500);
navigation.navigate('GlobalSelect', {
context: 'contact',
recipient: {
name: contact.name,
address: newAddress,
currency: contact.coin,
chain: contact.chain,
network: contact.network,
destinationTag: contact.tag || contact.destinationTag,
opts: {
showEVMWalletsAndTokens: true,
},
});
},
});
}
},
});
},
});
}

contactOptions.push({
Expand Down
21 changes: 13 additions & 8 deletions src/navigation/wallet/screens/GlobalSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,10 @@ const GlobalSelect: React.FC<GlobalSelectScreenProps | GlobalSelectProps> = ({
if (recipient.currency && recipient.chain) {
wallets = wallets.filter(
wallet =>
(wallet.currencyAbbreviation === recipient?.currency &&
wallet.chain === recipient?.chain) ||
(wallet.credentials.coin === recipient?.currency &&
wallet.credentials.chain === recipient?.chain) ||
(recipient?.opts?.showEVMWalletsAndTokens &&
BitpaySupportedEvmCoins[wallet.currencyAbbreviation]),
BitpaySupportedEvmCoins[wallet.credentials.chain]),
);
}
if (recipient?.network) {
Expand All @@ -665,7 +665,7 @@ const GlobalSelect: React.FC<GlobalSelectScreenProps | GlobalSelectProps> = ({
),
];
wallets = wallets.filter(wallet =>
supportedCurrencies.includes(wallet.currencyAbbreviation),
supportedCurrencies.includes(wallet.credentials.coin),
);
}

Expand Down Expand Up @@ -700,15 +700,21 @@ const GlobalSelect: React.FC<GlobalSelectScreenProps | GlobalSelectProps> = ({
_filterByCustomWallets = wallets.filter(
w =>
allCurrencies.includes(
getExternalServiceSymbol(w.currencyAbbreviation, w.chain),
getExternalServiceSymbol(
w.credentials.coin,
w.credentials.chain,
),
) && w.keyId === key.id,
);
} else {
_filterByCustomWallets = wallets.filter(w => {
const isContextValid =
!['coinbaseDeposit'].includes(context) ||
allCurrencies.includes(
getCurrencyAbbreviation(w.currencyAbbreviation, w.chain),
getCurrencyAbbreviation(
w.credentials.coin,
w.credentials.chain,
),
);

return isContextValid && w.keyId === key.id;
Expand Down Expand Up @@ -879,8 +885,7 @@ const GlobalSelect: React.FC<GlobalSelectScreenProps | GlobalSelectProps> = ({
wallet,
sendTo,
sendMaxEnabled: ['contact', 'scanner'].includes(context),
cryptoCurrencyAbbreviation:
wallet.currencyAbbreviation.toUpperCase(),
cryptoCurrencyAbbreviation: wallet.credentials.coin.toUpperCase(),
chain: wallet.chain,
tokenAddress: wallet.tokenAddress,
onAmountSelected: async (amount, setButtonState, opts) => {
Expand Down
2 changes: 0 additions & 2 deletions src/store/wallet/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
BitpaySupportedMaticTokens,
BitpaySupportedUtxoCoins,
OtherBitpaySupportedCoins,
SUPPORTED_CURRENCIES,
} from '../../../constants/currencies';
import {CurrencyListIcons} from '../../../constants/SupportedCurrencyOptions';
import {BwcProvider} from '../../../lib/bwc';
Expand All @@ -25,7 +24,6 @@ import {
GetProtocolPrefix,
IsERCToken,
IsEVMChain,
IsUtxoChain,
} from './currency';
import {
addTokenChainSuffix,
Expand Down