mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
fix: Swap external send QR using trade currency instead of selected wallet (#3068)
This commit is contained in:
@@ -231,6 +231,15 @@ class TokenUtilities {
|
||||
return null;
|
||||
}
|
||||
|
||||
static Erc20Token? findErc20TokenForSwap(CryptoCurrency currency) {
|
||||
if (currency is Erc20Token) return currency;
|
||||
|
||||
for (final token in loadDefaultEvmTokensForSwap()) {
|
||||
if (_matchesCurrency(token, currency)) return token;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static bool isNativeToken(CryptoCurrency currency) {
|
||||
final title = currency.title.toLowerCase();
|
||||
final tag = currency.tag?.toLowerCase();
|
||||
|
||||
@@ -478,7 +478,11 @@ abstract class ExchangeTradeViewModelBase with Store {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (wallet.type) {
|
||||
// Using trade currency here so the external-send QR encodes the correct scheme
|
||||
final uriWalletType =
|
||||
cryptoCurrencyOrTokenToWalletType(fromCurrency) ?? wallet.type;
|
||||
|
||||
switch (uriWalletType) {
|
||||
case WalletType.bitcoin:
|
||||
return BitcoinURI(address: inputAddress, amount: amount);
|
||||
case WalletType.bitcoinCash:
|
||||
@@ -524,17 +528,16 @@ abstract class ExchangeTradeViewModelBase with Store {
|
||||
contractAddress: null,
|
||||
);
|
||||
} else {
|
||||
if (isEVMCompatibleChain(wallet.type)) {
|
||||
final erc20Token = TokenUtilities.findErc20Token(currency, wallet);
|
||||
final erc20Token = TokenUtilities.findErc20Token(currency, wallet) ??
|
||||
TokenUtilities.findErc20TokenForSwap(currency);
|
||||
|
||||
if (erc20Token != null) {
|
||||
return ERC681URI(
|
||||
chainId: chainId,
|
||||
address: address,
|
||||
amount: amount,
|
||||
contractAddress: erc20Token.contractAddress,
|
||||
);
|
||||
}
|
||||
if (erc20Token != null) {
|
||||
return ERC681URI(
|
||||
chainId: chainId,
|
||||
address: address,
|
||||
amount: amount,
|
||||
contractAddress: erc20Token.contractAddress,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user