diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index 7d90c177c..fa4e543ed 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -411,7 +411,18 @@ class ExchangePage extends BasePage { buttonAction: () => Navigator.of(context).pop()); }); } else { - exchangeViewModel.createTrade(); + exchangeViewModel.isValidAmount() + ? exchangeViewModel.createTrade() + : showPopUp( + context: context, + builder: (BuildContext context) { + return AlertWithOneAction( + alertTitle: 'XMR.TO error', + alertContent: 'Invalid amount. Maximum limit 8 digits after the decimal point ', + buttonText: S.of(context).ok, + buttonAction: () => + Navigator.of(context).pop()); + }); } } }, diff --git a/lib/view_model/exchange/exchange_view_model.dart b/lib/view_model/exchange/exchange_view_model.dart index 8c001260c..28be7b6a3 100644 --- a/lib/view_model/exchange/exchange_view_model.dart +++ b/lib/view_model/exchange/exchange_view_model.dart @@ -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 providersForCurrentPair() { return _providersForPair(from: depositCurrency, to: receiveCurrency); }