| 1 | import 'package:intl/intl.dart'; |
| 2 | import 'package:cw_core/crypto_amount_format.dart'; |
| 3 | |
| 4 | const moneroAmountLength = 12; |
| 5 | const moneroAmountDivider = 1000000000000; |
| 6 | final moneroAmountFormat = NumberFormat() |
| 7 | ..maximumFractionDigits = moneroAmountLength |
| 8 | ..minimumFractionDigits = 1; |
| 9 | |
| 10 | String moneroAmountToString({required int amount}) => moneroAmountFormat |
| 11 | .format(cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider)) |
| 12 | .replaceAll(',', ''); |
| 13 | |
| 14 | double moneroAmountToDouble({required int amount}) => |
| 15 | cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider); |
| 16 | |
| 17 | int moneroParseAmount({required String amount}) => |
| 18 | (double.parse(amount) * moneroAmountDivider).round(); |