mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
fix: Handle fiat amount edgecase that makes crypto amount decimal length greater than multiplier length (#3135)
* fix: Handle fiat amount edgecase that makes crypto amount decimal length greater than multiplier length * fix: Switch currency decimal for crypto conversion
This commit is contained in:
@@ -45,8 +45,7 @@ BigInt parseFixed(String value, int decimals) {
|
||||
var fraction = (comps.length == 2 ? comps[1] : "0").padRight(decimals, "0");
|
||||
|
||||
if (fraction.length > multiplier.length - 1) {
|
||||
throw FormatException(
|
||||
"fractional component exceeds decimals, underflow, parseFixed");
|
||||
throw FormatException("fractional component exceeds decimals, underflow, parseFixed");
|
||||
}
|
||||
|
||||
final wholeValue = BigInt.parse(whole);
|
||||
|
||||
@@ -763,7 +763,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
if (price == null || price == 0.0) return;
|
||||
|
||||
final crypto = _enteredAmount / price;
|
||||
final depositAmountTmp = crypto.toString().withMaxDecimals(receiveCurrency.decimals);
|
||||
final depositAmountTmp = crypto.toString().withMaxDecimals(depositCurrency.decimals);
|
||||
if (_depositAmount != depositAmountTmp) {
|
||||
changeDepositAmount(amount: depositAmountTmp, isCanonical: true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user