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

wownero
OleksandrSobol 3 years ago
parent c0a12c6026
commit 753d164d6e

@ -17,12 +17,23 @@ import 'package:cake_wallet/exchange/trade_not_created_exeption.dart';
class ChangeNowExchangeProvider extends ExchangeProvider {
ChangeNowExchangeProvider()
: super(
pairList: CryptoCurrency.all
/*pairList: CryptoCurrency.all
.map((i) => CryptoCurrency.all
.map((k) => ExchangePair(from: i, to: k, reverse: true))
.where((c) => c != null))
.expand((i) => i)
.toList());
.toList());*/
pairList: CryptoCurrency.all
.map((i) => CryptoCurrency.all
.map((k) {
if ((i != CryptoCurrency.xmr)||
((k != CryptoCurrency.xrp)&&(k != CryptoCurrency.xlm))) {
return ExchangePair(from: i, to: k, reverse: true);
}
})
.where((c) => c != null))
.expand((i) => i)
.toList());
static const apiUri = 'https://changenow.io/api/v1';
static const apiKey = secrets.changeNowApiKey;

@ -464,6 +464,7 @@ class ExchangePage extends BasePage {
},
color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white,
isDisabled: exchangeViewModel.isDisabledExchangeButton,
isLoading:
exchangeViewModel.tradeState is TradeIsCreating)),
]),

@ -60,6 +60,7 @@ abstract class ExchangeViewModelBase with Store {
_defineIsReceiveAmountEditable();
isFixedRateMode = false;
isReceiveAmountEntered = false;
isDisabledExchangeButton = false;
loadLimits();
}
@ -113,6 +114,9 @@ abstract class ExchangeViewModelBase with Store {
@observable
bool isFixedRateMode;
@observable
bool isDisabledExchangeButton;
@computed
SyncStatus get status => wallet.syncStatus;
@ -369,19 +373,20 @@ abstract class ExchangeViewModelBase with Store {
pair.from == depositCurrency && pair.to == receiveCurrency)
.isNotEmpty;
if (!isPairExist) {
if (isPairExist) {
final provider =
_providerForPair(from: depositCurrency, to: receiveCurrency);
if (provider != null) {
isDisabledExchangeButton = false;
changeProvider(provider: provider);
}
} else {
isDisabledExchangeButton = true;
depositAmount = '';
receiveAmount = '';
limitsState = LimitsLoadedFailure(error: 'Pair is not exists');
}
_defineIsReceiveAmountEditable();
depositAmount = '';
receiveAmount = '';
loadLimits();
}
ExchangeProvider _providerForPair({CryptoCurrency from, CryptoCurrency to}) {

Loading…
Cancel
Save