From 3c51e22a4e2ba20b684c4afb3fefcef0de99f320 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Fri, 20 Dec 2024 12:15:41 -0300 Subject: [PATCH 1/2] Fix: GlobalSelect should check coin/chain from credentials instead --- .../wallet/screens/GlobalSelect.tsx | 21 ++++++++++++------- src/store/wallet/utils/wallet.ts | 2 -- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/navigation/wallet/screens/GlobalSelect.tsx b/src/navigation/wallet/screens/GlobalSelect.tsx index eed2f6647..c113880a5 100644 --- a/src/navigation/wallet/screens/GlobalSelect.tsx +++ b/src/navigation/wallet/screens/GlobalSelect.tsx @@ -641,10 +641,10 @@ const GlobalSelect: React.FC = ({ 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.coin]), ); } if (recipient?.network) { @@ -665,7 +665,7 @@ const GlobalSelect: React.FC = ({ ), ]; wallets = wallets.filter(wallet => - supportedCurrencies.includes(wallet.currencyAbbreviation), + supportedCurrencies.includes(wallet.credentials.coin), ); } @@ -700,7 +700,10 @@ const GlobalSelect: React.FC = ({ _filterByCustomWallets = wallets.filter( w => allCurrencies.includes( - getExternalServiceSymbol(w.currencyAbbreviation, w.chain), + getExternalServiceSymbol( + w.credentials.coin, + w.credentials.chain, + ), ) && w.keyId === key.id, ); } else { @@ -708,7 +711,10 @@ const GlobalSelect: React.FC = ({ 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; @@ -879,8 +885,7 @@ const GlobalSelect: React.FC = ({ 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) => { diff --git a/src/store/wallet/utils/wallet.ts b/src/store/wallet/utils/wallet.ts index 2c322df12..2d91d235a 100644 --- a/src/store/wallet/utils/wallet.ts +++ b/src/store/wallet/utils/wallet.ts @@ -15,7 +15,6 @@ import { BitpaySupportedMaticTokens, BitpaySupportedUtxoCoins, OtherBitpaySupportedCoins, - SUPPORTED_CURRENCIES, } from '../../../constants/currencies'; import {CurrencyListIcons} from '../../../constants/SupportedCurrencyOptions'; import {BwcProvider} from '../../../lib/bwc'; @@ -25,7 +24,6 @@ import { GetProtocolPrefix, IsERCToken, IsEVMChain, - IsUtxoChain, } from './currency'; import { addTokenChainSuffix, From c1879813712d57737172d79b96e154785c38796b Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Fri, 3 Jan 2025 15:27:09 -0300 Subject: [PATCH 2/2] Fix Send to This Contact and BitpaySupportedEvmCoins --- .../tabs/contacts/screens/ContactsDetails.tsx | 41 ++++++++++--------- .../wallet/screens/GlobalSelect.tsx | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/navigation/tabs/contacts/screens/ContactsDetails.tsx b/src/navigation/tabs/contacts/screens/ContactsDetails.tsx index ea073189b..438a32c4b 100644 --- a/src/navigation/tabs/contacts/screens/ContactsDetails.tsx +++ b/src/navigation/tabs/contacts/screens/ContactsDetails.tsx @@ -173,27 +173,28 @@ const ContactsDetails = ({ // Remove prefix newAddress = ToCashAddress(contact.address, false); } - if (!IsEVMChain(contact.chain)) { - contactOptions.push({ - img: theme.dark ? : , - 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 ? : , + 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({ diff --git a/src/navigation/wallet/screens/GlobalSelect.tsx b/src/navigation/wallet/screens/GlobalSelect.tsx index c113880a5..a1d310df5 100644 --- a/src/navigation/wallet/screens/GlobalSelect.tsx +++ b/src/navigation/wallet/screens/GlobalSelect.tsx @@ -644,7 +644,7 @@ const GlobalSelect: React.FC = ({ (wallet.credentials.coin === recipient?.currency && wallet.credentials.chain === recipient?.chain) || (recipient?.opts?.showEVMWalletsAndTokens && - BitpaySupportedEvmCoins[wallet.credentials.coin]), + BitpaySupportedEvmCoins[wallet.credentials.chain]), ); } if (recipient?.network) {