Merge pull request #855 from cake-tech/CW-340-Truncate-estimated-btc-amount-in-Exchange

CW-340-Truncate-estimated-btc-amount-in-Exchange
This commit is contained in:
Serhii 2023-03-31 15:43:37 +03:00 committed by GitHub
commit a081f6f829
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -97,7 +97,6 @@ abstract class ExchangeViewModelBase with Store {
receiveAddress = ''; receiveAddress = '';
depositAddress = depositCurrency == wallet.currency depositAddress = depositCurrency == wallet.currency
? wallet.walletAddresses.address : ''; ? wallet.walletAddresses.address : '';
_cryptoNumberFormat = NumberFormat()..maximumFractionDigits = wallet.type == WalletType.bitcoin ? 8 : 12;
provider = providersForCurrentPair().first; provider = providersForCurrentPair().first;
final initialProvider = provider; final initialProvider = provider;
provider!.checkIsAvailable().then((bool isAvailable) { provider!.checkIsAvailable().then((bool isAvailable) {
@ -287,6 +286,7 @@ abstract class ExchangeViewModelBase with Store {
await _calculateBestRate(); await _calculateBestRate();
} }
_cryptoNumberFormat.maximumFractionDigits = depositMaxDigits;
depositAmount = _cryptoNumberFormat depositAmount = _cryptoNumberFormat
.format(_enteredAmount / _bestRate) .format(_enteredAmount / _bestRate)
@ -312,6 +312,7 @@ abstract class ExchangeViewModelBase with Store {
await _calculateBestRate(); await _calculateBestRate();
} }
_cryptoNumberFormat.maximumFractionDigits = receiveMaxDigits;
receiveAmount = _cryptoNumberFormat receiveAmount = _cryptoNumberFormat
.format(_bestRate * _enteredAmount) .format(_bestRate * _enteredAmount)
@ -709,4 +710,8 @@ abstract class ExchangeViewModelBase with Store {
providerList = _allProviders; providerList = _allProviders;
} }
} }
int get depositMaxDigits => depositCurrency == CryptoCurrency.btc ? 8 : 12;
int get receiveMaxDigits => receiveCurrency == CryptoCurrency.btc ? 8 : 12;
} }