fix: Swap external send QR using trade currency instead of selected wallet (#3068)

David Adegoke committed Mar 13, 2026 at 01:32 UTC 8f7819be8205728dcc443bc1249ae895b29621d0
2 files changed +24 -12
lib/utils/token_utilities.dart
+9
@@ -231,6 +231,15 @@ class TokenUtilities {
231 return null;
232 }
233
234 + static Erc20Token? findErc20TokenForSwap(CryptoCurrency currency) {
235 + if (currency is Erc20Token) return currency;
236 +
237 + for (final token in loadDefaultEvmTokensForSwap()) {
238 + if (_matchesCurrency(token, currency)) return token;
239 + }
240 + return null;
241 + }
242 +
243 static bool isNativeToken(CryptoCurrency currency) {
244 final title = currency.title.toLowerCase();
245 final tag = currency.tag?.toLowerCase();
lib/view_model/exchange/exchange_trade_view_model.dart
+15 -12
@@ -478,7 +478,11 @@ abstract class ExchangeTradeViewModelBase with Store {
478 return null;
479 }
480
481 - switch (wallet.type) {
481 + // Using trade currency here so the external-send QR encodes the correct scheme
482 + final uriWalletType =
483 + cryptoCurrencyOrTokenToWalletType(fromCurrency) ?? wallet.type;
484 +
485 + switch (uriWalletType) {
486 case WalletType.bitcoin:
487 return BitcoinURI(address: inputAddress, amount: amount);
488 case WalletType.bitcoinCash:
@@ -524,17 +528,16 @@ abstract class ExchangeTradeViewModelBase with Store {
528 contractAddress: null,
529 );
530 } else {
527 - if (isEVMCompatibleChain(wallet.type)) {
528 - final erc20Token = TokenUtilities.findErc20Token(currency, wallet);
529 -
530 - if (erc20Token != null) {
531 - return ERC681URI(
532 - chainId: chainId,
533 - address: address,
534 - amount: amount,
535 - contractAddress: erc20Token.contractAddress,
536 - );
537 - }
531 + final erc20Token = TokenUtilities.findErc20Token(currency, wallet) ??
532 + TokenUtilities.findErc20TokenForSwap(currency);
533 +
534 + if (erc20Token != null) {
535 + return ERC681URI(
536 + chainId: chainId,
537 + address: address,
538 + amount: amount,
539 + contractAddress: erc20Token.contractAddress,
540 + );
541 }
542 return null;
543 }