cake_wallet/cw_nano/lib/nano_balance.dart

41 lines
1.2 KiB
Dart
Raw Normal View History

2023-07-24 16:56:20 +00:00
import 'package:cw_core/balance.dart';
import 'package:cw_core/currency.dart';
import 'package:cw_core/monero_amount_format.dart';
2023-07-28 13:30:11 +00:00
import 'package:cw_nano/nano_util.dart';
2023-07-24 16:56:20 +00:00
String rawToFormattedAmount(BigInt amount, Currency currency) {
return "";
}
2023-07-27 17:02:10 +00:00
BigInt stringAmountToBigInt(String amount) {
return BigInt.zero;
}
2023-07-24 16:56:20 +00:00
class NanoBalance extends Balance {
final BigInt currentBalance;
final BigInt receivableBalance;
late String formattedCurrentBalance;
late String formattedReceivableBalance;
2023-07-24 18:09:28 +00:00
NanoBalance({required this.currentBalance, required this.receivableBalance}) : super(0, 0) {
2023-07-24 16:56:20 +00:00
this.formattedCurrentBalance = "";
this.formattedReceivableBalance = "";
}
2023-07-27 17:02:10 +00:00
NanoBalance.fromString(
{required this.formattedCurrentBalance, required this.formattedReceivableBalance})
: currentBalance = stringAmountToBigInt(formattedCurrentBalance),
receivableBalance = stringAmountToBigInt(formattedReceivableBalance),
super(0, 0);
2023-07-24 18:09:28 +00:00
@override
2023-07-27 17:02:10 +00:00
String get formattedAvailableBalance {
2023-07-28 13:30:11 +00:00
return NanoUtil.getRawAsUsableString(currentBalance.toString(), NanoUtil.rawPerNano);
2023-07-27 17:02:10 +00:00
}
2023-07-24 18:09:28 +00:00
@override
2023-07-27 17:02:10 +00:00
String get formattedAdditionalBalance {
2023-07-28 13:30:11 +00:00
return NanoUtil.getRawAsUsableString(receivableBalance.toString(), NanoUtil.rawPerNano);
2023-07-27 17:02:10 +00:00
}
2023-07-24 16:56:20 +00:00
}