mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 01:37:40 +00:00
fe2e26f146
* fixes * refactors * fixes * more fixes * fixes for monero.com * update confirmed balance to receivable balance * fix balance display bug * remove print statements * prevent unnecessary writes * review fixes * forgot to add pubspec changes * fix * fix sync status desyncing on rpc fail * fix * update translations + txDetails fixes * squash balance bug * add source address on tx info * fix
35 lines
1.2 KiB
Dart
35 lines
1.2 KiB
Dart
import 'package:cw_core/balance.dart';
|
|
import 'package:nanoutil/nanoutil.dart';
|
|
|
|
BigInt stringAmountToBigInt(String amount) {
|
|
return BigInt.parse(NanoAmounts.getAmountAsRaw(amount, NanoAmounts.rawPerNano));
|
|
}
|
|
|
|
class NanoBalance extends Balance {
|
|
final BigInt currentBalance;
|
|
final BigInt receivableBalance;
|
|
|
|
NanoBalance({required this.currentBalance, required this.receivableBalance}) : super(0, 0);
|
|
|
|
NanoBalance.fromFormattedString(
|
|
{required String formattedCurrentBalance, required String formattedReceivableBalance})
|
|
: currentBalance = stringAmountToBigInt(formattedCurrentBalance),
|
|
receivableBalance = stringAmountToBigInt(formattedReceivableBalance),
|
|
super(0, 0);
|
|
|
|
NanoBalance.fromRawString(
|
|
{required String currentBalance, required String receivableBalance})
|
|
: currentBalance = BigInt.parse(currentBalance),
|
|
receivableBalance = BigInt.parse(receivableBalance),
|
|
super(0, 0);
|
|
|
|
@override
|
|
String get formattedAvailableBalance {
|
|
return NanoAmounts.getRawAsUsableString(currentBalance.toString(), NanoAmounts.rawPerNano);
|
|
}
|
|
|
|
@override
|
|
String get formattedAdditionalBalance {
|
|
return NanoAmounts.getRawAsUsableString(receivableBalance.toString(), NanoAmounts.rawPerNano);
|
|
}
|
|
}
|