mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
satoshi to decimal amount format function modified to take optional Coin parameter
This commit is contained in:
parent
d9b825b001
commit
99883d30ac
1 changed files with 31 additions and 5 deletions
|
@ -4,13 +4,39 @@ import 'package:decimal/decimal.dart';
|
|||
import 'package:intl/number_symbols.dart';
|
||||
import 'package:intl/number_symbols_data.dart' show numberFormatSymbols;
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
||||
import 'enums/backup_frequency_type.dart';
|
||||
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
|
||||
abstract class Format {
|
||||
static Decimal satoshisToAmount(int sats) =>
|
||||
(Decimal.fromInt(sats) / Decimal.fromInt(Constants.satsPerCoin))
|
||||
.toDecimal(scaleOnInfinitePrecision: Constants.decimalPlaces);
|
||||
static Decimal satoshisToAmount(int sats, {Coin? coin}) {
|
||||
late final int satsPerCoin;
|
||||
|
||||
switch (coin) {
|
||||
case Coin.wownero:
|
||||
satsPerCoin = Constants.satsPerCoinWownero;
|
||||
break;
|
||||
case Coin.monero:
|
||||
satsPerCoin = Constants.satsPerCoinMonero;
|
||||
break;
|
||||
case Coin.bitcoin:
|
||||
case Coin.bitcoincash:
|
||||
case Coin.dogecoin:
|
||||
case Coin.epicCash:
|
||||
case Coin.firo:
|
||||
case Coin.litecoin:
|
||||
case Coin.namecoin:
|
||||
case Coin.bitcoinTestNet:
|
||||
case Coin.litecoinTestNet:
|
||||
case Coin.bitcoincashTestnet:
|
||||
case Coin.dogecoinTestNet:
|
||||
case Coin.firoTestNet:
|
||||
default:
|
||||
satsPerCoin = Constants.satsPerCoin;
|
||||
}
|
||||
|
||||
return (Decimal.fromInt(sats) / Decimal.fromInt(satsPerCoin))
|
||||
.toDecimal(scaleOnInfinitePrecision: Constants.decimalPlaces);
|
||||
}
|
||||
|
||||
///
|
||||
static String satoshiAmountToPrettyString(int sats, String locale) {
|
||||
|
|
Loading…
Reference in a new issue