add general balance model to reduce clutter

This commit is contained in:
julian 2023-01-11 12:17:29 -06:00
parent 5937d92aee
commit e203da866d

39
lib/models/balance.dart Normal file
View file

@ -0,0 +1,39 @@
import 'package:decimal/decimal.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/format.dart';
class Balance {
final Coin coin;
final int total;
final int spendable;
final int blockedTotal;
final int pendingSpendable;
Balance({
required this.coin,
required this.total,
required this.spendable,
required this.blockedTotal,
required this.pendingSpendable,
});
Decimal getTotal({bool includeBlocked = false}) => Format.satoshisToAmount(
includeBlocked ? total : total - blockedTotal,
coin: coin,
);
Decimal getSpendable() => Format.satoshisToAmount(
spendable,
coin: coin,
);
Decimal getPending() => Format.satoshisToAmount(
pendingSpendable,
coin: coin,
);
Decimal getBlocked() => Format.satoshisToAmount(
blockedTotal,
coin: coin,
);
}