mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-19 05:58:50 +02:00
Cw 995 buy sell issues (#2127)
* add not supported warning * warning localisation * providers depend on the selected pair
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user