Skip to content

Commit

Permalink
Merge pull request #1508 from cmgustavo/bug/check-coin-from-credentia…
Browse files Browse the repository at this point in the history
…ls-01

Fix: GlobalSelect should check coin/chain from credentials instead CurrencyAbbreviation
  • Loading branch information
JohnathanWhite authored Jan 6, 2025
2 parents 4bb3282 + c187981 commit 676de65
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
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

0 comments on commit 676de65

Please sign in to comment.