mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 09:47:35 +00:00
26 lines
596 B
Dart
26 lines
596 B
Dart
|
import 'package:intl/intl.dart';
|
||
|
|
||
|
const evmChainAmountLength = 12;
|
||
|
const evmChainAmountDivider = 1000000000000;
|
||
|
final evmChainAmountFormat = NumberFormat()
|
||
|
..maximumFractionDigits = evmChainAmountLength
|
||
|
..minimumFractionDigits = 1;
|
||
|
|
||
|
class EVMChainFormatter {
|
||
|
static int parseEVMChainAmount(String amount) {
|
||
|
try {
|
||
|
return (double.parse(amount) * evmChainAmountDivider).round();
|
||
|
} catch (_) {
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static double parseEVMChainAmountToDouble(int amount) {
|
||
|
try {
|
||
|
return amount / evmChainAmountDivider;
|
||
|
} catch (_) {
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
}
|