Cw 995 buy sell issues (#2127)

* add not supported warning

* warning localisation

* providers depend on the selected pair
This commit is contained in:
Serhii
2025-03-29 07:46:16 +02:00
committed by GitHub
parent 48fa647a8c
commit eb136efb27
40 changed files with 268 additions and 94 deletions
+25 -3
View File
@@ -210,9 +210,12 @@ abstract class BuySellViewModelBase extends WalletChangeListenerViewModel with S
final enteredAmount = double.tryParse(amount.replaceAll(',', '.')) ?? 0;
if (!isReadyToTrade) {
if (!isReadyToTrade && !isBuySellQuotFailed) {
cryptoAmount = S.current.fetching;
return;
} else if (isBuySellQuotFailed) {
cryptoAmount = '';
return;
}
if (bestRateQuote != null) {
@@ -238,8 +241,12 @@ abstract class BuySellViewModelBase extends WalletChangeListenerViewModel with S
final enteredAmount = double.tryParse(amount.replaceAll(',', '.')) ?? 0;
if (!isReadyToTrade) {
if (!isReadyToTrade && !isBuySellQuotFailed) {
fiatAmount = S.current.fetching;
return;
} else if (isBuySellQuotFailed) {
fiatAmount = '';
return;
}
if (bestRateQuote != null) {
@@ -379,7 +386,22 @@ abstract class BuySellViewModelBase extends WalletChangeListenerViewModel with S
Future<void> calculateBestRate() async {
buySellQuotState = BuySellQuotLoading();
final result = await Future.wait<List<Quote>?>(providerList.map((element) => element
final List<BuyProvider> validProviders = providerList.where((provider) {
if (isBuyAction) {
return provider.supportedCryptoList.any((pair) =>
pair.from == cryptoCurrency && pair.to == fiatCurrency);
} else {
return provider.supportedFiatList.any((pair) =>
pair.from == fiatCurrency && pair.to == cryptoCurrency);
}
}).toList();
if (validProviders.isEmpty) {
buySellQuotState = BuySellQuotFailed();
return;
}
final result = await Future.wait<List<Quote>?>(validProviders.map((element) => element
.fetchQuote(
cryptoCurrency: cryptoCurrency,
fiatCurrency: fiatCurrency,