cake_wallet/cw_zano/lib/model/zano_balance.dart

18 lines
806 B
Dart
Raw Normal View History

2023-11-17 17:40:23 +00:00
import 'package:cw_core/balance.dart';
import 'package:cw_zano/zano_formatter.dart';
2023-10-02 14:17:35 +00:00
2023-11-17 17:40:23 +00:00
class ZanoBalance extends Balance {
2024-08-07 12:32:47 +00:00
final BigInt total;
final BigInt unlocked;
final int decimalPoint;
2024-08-07 12:32:47 +00:00
ZanoBalance({required this.total, required this.unlocked, this.decimalPoint = ZanoFormatter.defaultDecimalPoint}) : super(unlocked.isValidInt ? unlocked.toInt() : 0, (total - unlocked).isValidInt ? (total - unlocked).toInt() : 0);
2024-04-06 10:03:11 +00:00
2024-08-07 12:32:47 +00:00
ZanoBalance.empty({this.decimalPoint = ZanoFormatter.defaultDecimalPoint}): total = BigInt.zero, unlocked = BigInt.zero, super(0, 0);
2023-12-14 04:51:16 +00:00
2023-11-17 17:40:23 +00:00
@override
2024-08-07 12:32:47 +00:00
String get formattedAdditionalBalance => ZanoFormatter.bigIntAmountToString(total - unlocked, decimalPoint);
2023-11-17 17:40:23 +00:00
@override
2024-08-07 12:32:47 +00:00
String get formattedAvailableBalance => ZanoFormatter.bigIntAmountToString(unlocked, decimalPoint);
2023-11-17 17:40:23 +00:00
}