mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
baad7f7469
* init * updates * nano updates * updates * updates * [skipci] wip deep link changes * fix deep links * minor fix * add reminder message on buy and exchange routes * [skip ci] font fixes * review updates * [skip ci] minor fix * save * fixes * minor code cleanup * minor potential fix
35 lines
1.3 KiB
Dart
35 lines
1.3 KiB
Dart
import 'package:cw_core/balance.dart';
|
|
import 'package:nanoutil/nanoutil.dart';
|
|
|
|
BigInt stringAmountToBigIntBanano(String amount) {
|
|
return BigInt.parse(NanoAmounts.getAmountAsRaw(amount, NanoAmounts.rawPerBanano));
|
|
}
|
|
|
|
class BananoBalance extends Balance {
|
|
final BigInt currentBalance;
|
|
final BigInt receivableBalance;
|
|
|
|
BananoBalance({required this.currentBalance, required this.receivableBalance}) : super(0, 0);
|
|
|
|
BananoBalance.fromFormattedString(
|
|
{required String formattedCurrentBalance, required String formattedReceivableBalance})
|
|
: currentBalance = stringAmountToBigIntBanano(formattedCurrentBalance),
|
|
receivableBalance = stringAmountToBigIntBanano(formattedReceivableBalance),
|
|
super(0, 0);
|
|
|
|
BananoBalance.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.rawPerBanano);
|
|
}
|
|
|
|
@override
|
|
String get formattedAdditionalBalance {
|
|
return NanoAmounts.getRawAsUsableString(receivableBalance.toString(), NanoAmounts.rawPerBanano);
|
|
}
|
|
}
|