truncate exchange amount
Serhii committed
Mar 31, 2023 at 12:45 UTC
3e43e899a58f18dd62964725f4f4495b1004c671
1 file changed
+6
lib/view_model/exchange/exchange_view_model.dart
+6
@@ -287,6 +287,7 @@ abstract class ExchangeViewModelBase with Store {
287
288
await _calculateBestRate();
289
}
290
+ _cryptoNumberFormat.maximumFractionDigits = depositMaxDigits;
291
292
depositAmount = _cryptoNumberFormat
293
.format(_enteredAmount / _bestRate)
@@ -312,6 +313,7 @@ abstract class ExchangeViewModelBase with Store {
313
314
await _calculateBestRate();
315
}
316
+ _cryptoNumberFormat.maximumFractionDigits = receiveMaxDigits;
317
318
receiveAmount = _cryptoNumberFormat
319
.format(_bestRate * _enteredAmount)
@@ -709,4 +711,8 @@ abstract class ExchangeViewModelBase with Store {
711
providerList = _allProviders;
712
}
713
}
714
+
715
+ int get depositMaxDigits => depositCurrency == CryptoCurrency.btc ? 8 : 12;
716
+
717
+ int get receiveMaxDigits => receiveCurrency == CryptoCurrency.btc ? 8 : 12;
718
}