CAKE-185 | added validation of amount for xmr.to provider in the exchange_page.dart; added isValidAmount() to exchange_view_model.dart

This commit is contained in:
OleksandrSobol
2020-11-26 21:04:05 +02:00
parent dd71edd8c8
commit 4cb4ede2d3
2 changed files with 33 additions and 1 deletions
@@ -306,6 +306,27 @@ abstract class ExchangeViewModelBase with Store {
void removeTemplate({ExchangeTemplate template}) =>
_exchangeTemplateStore.remove(template: template);
bool isValidAmount() {
bool isValid = true;
if (provider is XMRTOExchangeProvider) {
final amount = isReceiveAmountEntered
? receiveAmount
: depositAmount;
final amountParts = amount.replaceAll(',', '.')
.split('.');
final numberOfFractionDigits =
amountParts.length > 1
? amountParts[1].length : 0;
isValid = !(numberOfFractionDigits > 8);
}
return isValid;
}
List<ExchangeProvider> providersForCurrentPair() {
return _providersForPair(from: depositCurrency, to: receiveCurrency);
}