revert amount_converter changes

This commit is contained in:
Serhii 2024-02-02 13:05:02 +02:00
parent 2a0d8f9692
commit a941014fc2

View file

@ -81,7 +81,6 @@ class AmountConverter {
return _moneroAmountToString(amount); return _moneroAmountToString(amount);
case CryptoCurrency.btc: case CryptoCurrency.btc:
case CryptoCurrency.bch: case CryptoCurrency.bch:
case CryptoCurrency.ltc:
return _bitcoinAmountToString(amount); return _bitcoinAmountToString(amount);
case CryptoCurrency.xhv: case CryptoCurrency.xhv:
case CryptoCurrency.xag: case CryptoCurrency.xag:
@ -103,44 +102,27 @@ class AmountConverter {
} }
} }
static int amountToSmallestUnit(
{required CryptoCurrency cryptoCurrency, required double amount}) {
switch (cryptoCurrency) {
case CryptoCurrency.btc:
return (amount * _bitcoinAmountDivider).toInt();
case CryptoCurrency.eth:
return (amount * _ethereumAmountDivider).toInt();
case CryptoCurrency.bch:
return (amount * _bitcoinCashAmountDivider).toInt();
case CryptoCurrency.ltc:
return (amount * _litecoinAmountDivider).toInt();
case CryptoCurrency.dash:
return (amount * _dashAmountDivider).toInt();
case CryptoCurrency.xmr:
return (amount * _moneroAmountDivider).toInt();
default:
return 0;
}
}
static double cryptoAmountToDouble({required num amount, required num divider}) => static double cryptoAmountToDouble({required num amount, required num divider}) =>
amount / divider; amount / divider;
static String _moneroAmountToString(int amount) => _moneroAmountFormat static String _moneroAmountToString(int amount) => _moneroAmountFormat.format(
.format(cryptoAmountToDouble(amount: amount, divider: _moneroAmountDivider)); cryptoAmountToDouble(amount: amount, divider: _moneroAmountDivider));
static double _moneroAmountToDouble(int amount) => static double _moneroAmountToDouble(int amount) =>
cryptoAmountToDouble(amount: amount, divider: _moneroAmountDivider); cryptoAmountToDouble(amount: amount, divider: _moneroAmountDivider);
static int _moneroParseAmount(String amount) => _moneroAmountFormat.parse(amount).toInt(); static int _moneroParseAmount(String amount) =>
_moneroAmountFormat.parse(amount).toInt();
static String _bitcoinAmountToString(int amount) => _bitcoinAmountFormat static String _bitcoinAmountToString(int amount) =>
.format(cryptoAmountToDouble(amount: amount, divider: _bitcoinAmountDivider)); _bitcoinAmountFormat.format(
cryptoAmountToDouble(amount: amount, divider: _bitcoinAmountDivider));
static double _bitcoinAmountToDouble(int amount) => static double _bitcoinAmountToDouble(int amount) =>
cryptoAmountToDouble(amount: amount, divider: _bitcoinAmountDivider); cryptoAmountToDouble(amount: amount, divider: _bitcoinAmountDivider);
static int _doubleToBitcoinAmount(double amount) => (amount * _bitcoinAmountDivider).toInt(); static int _doubleToBitcoinAmount(double amount) =>
(amount * _bitcoinAmountDivider).toInt();
static double _bitcoinCashAmountToDouble(int amount) => static double _bitcoinCashAmountToDouble(int amount) =>
cryptoAmountToDouble(amount: amount, divider: _bitcoinCashAmountDivider); cryptoAmountToDouble(amount: amount, divider: _bitcoinCashAmountDivider);