CAKE-43 | added the ability to enter an amount for xmr.to exchange in both currencies xmr and btc; added isReceiveAmountEntered to ExchangeViewModel; added receiveAmount and isBTCRequest to XMRTOTradeRequest; added isReceiveAmount to calculateAmount method of ExchangeProvider; fixed XMRTOExchangeProvider

This commit is contained in:
OleksandrSobol
2020-09-25 22:55:41 +03:00
parent dcbaf01118
commit bc85058ad8
8 changed files with 50 additions and 20 deletions
@@ -48,6 +48,7 @@ abstract class ExchangeViewModelBase with Store {
tradeState = ExchangeTradeStateInitial();
_cryptoNumberFormat = NumberFormat()..maximumFractionDigits = 12;
provider = providersForCurrentPair().first;
isReceiveAmountEntered = false;
loadLimits();
}
@@ -92,6 +93,8 @@ abstract class ExchangeViewModelBase with Store {
@observable
bool isReceiveAddressEnabled;
bool isReceiveAmountEntered;
Limits limits;
NumberFormat _cryptoNumberFormat;
@@ -138,7 +141,8 @@ abstract class ExchangeViewModelBase with Store {
provider
.calculateAmount(
from: depositCurrency, to: receiveCurrency, amount: _amount)
from: depositCurrency, to: receiveCurrency, amount: _amount,
isReceiveAmount: true)
.then((amount) => _cryptoNumberFormat
.format(amount)
.toString()
@@ -159,7 +163,8 @@ abstract class ExchangeViewModelBase with Store {
final _amount = double.parse(amount);
provider
.calculateAmount(
from: depositCurrency, to: receiveCurrency, amount: _amount)
from: depositCurrency, to: receiveCurrency, amount: _amount,
isReceiveAmount: false)
.then((amount) => _cryptoNumberFormat
.format(amount)
.toString()
@@ -191,8 +196,10 @@ abstract class ExchangeViewModelBase with Store {
from: depositCurrency,
to: receiveCurrency,
amount: depositAmount,
receiveAmount: receiveAmount,
address: receiveAddress,
refundAddress: depositAddress);
refundAddress: depositAddress,
isBTCRequest: isReceiveAmountEntered);
amount = depositAmount;
currency = depositCurrency;
}