2021-12-24 12:52:08 +00:00
|
|
|
import 'package:cw_core/balance.dart';
|
2022-03-30 15:57:04 +00:00
|
|
|
import 'package:cw_core/monero_amount_format.dart';
|
2021-12-24 12:52:08 +00:00
|
|
|
|
|
|
|
class MoneroBalance extends Balance {
|
2023-08-24 13:54:05 +00:00
|
|
|
MoneroBalance({required this.fullBalance, required this.unlockedBalance, this.frozenBalance = 0})
|
2024-12-04 12:01:49 +00:00
|
|
|
: formattedFullBalance = moneroAmountToString(amount: frozenBalance + fullBalance),
|
|
|
|
formattedUnlockedBalance = moneroAmountToString(amount: unlockedBalance),
|
2023-11-16 23:22:10 +00:00
|
|
|
formattedLockedBalance =
|
|
|
|
moneroAmountToString(amount: frozenBalance + fullBalance - unlockedBalance),
|
2021-12-24 12:52:08 +00:00
|
|
|
super(unlockedBalance, fullBalance);
|
|
|
|
|
|
|
|
MoneroBalance.fromString(
|
2022-10-12 17:09:57 +00:00
|
|
|
{required this.formattedFullBalance,
|
2023-08-24 13:54:05 +00:00
|
|
|
required this.formattedUnlockedBalance,
|
2023-11-16 23:22:10 +00:00
|
|
|
this.formattedLockedBalance = '0.0'})
|
2021-12-24 12:52:08 +00:00
|
|
|
: fullBalance = moneroParseAmount(amount: formattedFullBalance),
|
|
|
|
unlockedBalance = moneroParseAmount(amount: formattedUnlockedBalance),
|
2023-11-16 23:22:10 +00:00
|
|
|
frozenBalance = moneroParseAmount(amount: formattedLockedBalance),
|
2021-12-24 12:52:08 +00:00
|
|
|
super(moneroParseAmount(amount: formattedUnlockedBalance),
|
|
|
|
moneroParseAmount(amount: formattedFullBalance));
|
|
|
|
|
|
|
|
final int fullBalance;
|
|
|
|
final int unlockedBalance;
|
2023-08-24 13:54:05 +00:00
|
|
|
final int frozenBalance;
|
2021-12-24 12:52:08 +00:00
|
|
|
final String formattedFullBalance;
|
|
|
|
final String formattedUnlockedBalance;
|
2023-11-16 23:22:10 +00:00
|
|
|
final String formattedLockedBalance;
|
2023-08-24 13:54:05 +00:00
|
|
|
|
|
|
|
@override
|
2023-11-16 23:22:10 +00:00
|
|
|
String get formattedUnAvailableBalance =>
|
|
|
|
formattedLockedBalance == '0.0' ? '' : formattedLockedBalance;
|
2021-12-24 12:52:08 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
String get formattedAvailableBalance => formattedUnlockedBalance;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String get formattedAdditionalBalance => formattedFullBalance;
|
|
|
|
}
|