CAKE-296 | removed xmr to xrp and xmr to xlm exchange pairs from ChangeNow pair list; disabled exchange button when pair is not exists

OleksandrSobol committed Apr 1, 2021 at 21:08 UTC 753d164d6e4be165d09e0a6f07ad515f3a5239a6
3 files changed +25 -8
lib/exchange/changenow/changenow_exchange_provider.dart
+13 -2
@@ -17,12 +17,23 @@ import 'package:cake_wallet/exchange/trade_not_created_exeption.dart';
17 class ChangeNowExchangeProvider extends ExchangeProvider {
18 ChangeNowExchangeProvider()
19 : super(
20 - pairList: CryptoCurrency.all
20 + /*pairList: CryptoCurrency.all
21 .map((i) => CryptoCurrency.all
22 .map((k) => ExchangePair(from: i, to: k, reverse: true))
23 .where((c) => c != null))
24 .expand((i) => i)
25 - .toList());
25 + .toList());*/
26 + pairList: CryptoCurrency.all
27 + .map((i) => CryptoCurrency.all
28 + .map((k) {
29 + if ((i != CryptoCurrency.xmr)||
30 + ((k != CryptoCurrency.xrp)&&(k != CryptoCurrency.xlm))) {
31 + return ExchangePair(from: i, to: k, reverse: true);
32 + }
33 + })
34 + .where((c) => c != null))
35 + .expand((i) => i)
36 + .toList());
37
38 static const apiUri = 'https://changenow.io/api/v1';
39 static const apiKey = secrets.changeNowApiKey;
lib/src/screens/exchange/exchange_page.dart
+1
@@ -464,6 +464,7 @@ class ExchangePage extends BasePage {
464 },
465 color: Theme.of(context).accentTextTheme.body2.color,
466 textColor: Colors.white,
467 + isDisabled: exchangeViewModel.isDisabledExchangeButton,
468 isLoading:
469 exchangeViewModel.tradeState is TradeIsCreating)),
470 ]),
lib/view_model/exchange/exchange_view_model.dart
+11 -6
@@ -60,6 +60,7 @@ abstract class ExchangeViewModelBase with Store {
60 _defineIsReceiveAmountEditable();
61 isFixedRateMode = false;
62 isReceiveAmountEntered = false;
63 + isDisabledExchangeButton = false;
64 loadLimits();
65 }
66
@@ -113,6 +114,9 @@ abstract class ExchangeViewModelBase with Store {
114 @observable
115 bool isFixedRateMode;
116
117 + @observable
118 + bool isDisabledExchangeButton;
119 +
120 @computed
121 SyncStatus get status => wallet.syncStatus;
122
@@ -369,19 +373,20 @@ abstract class ExchangeViewModelBase with Store {
373 pair.from == depositCurrency && pair.to == receiveCurrency)
374 .isNotEmpty;
375
372 - if (!isPairExist) {
376 + if (isPairExist) {
377 final provider =
378 _providerForPair(from: depositCurrency, to: receiveCurrency);
379
380 if (provider != null) {
381 + isDisabledExchangeButton = false;
382 changeProvider(provider: provider);
383 }
384 + } else {
385 + isDisabledExchangeButton = true;
386 + depositAmount = '';
387 + receiveAmount = '';
388 + limitsState = LimitsLoadedFailure(error: 'Pair is not exists');
389 }
380 -
381 - _defineIsReceiveAmountEditable();
382 - depositAmount = '';
383 - receiveAmount = '';
384 - loadLimits();
390 }
391
392 ExchangeProvider _providerForPair({CryptoCurrency from, CryptoCurrency to}) {