34 lines
967 B
Dart
34 lines
967 B
Dart
/// User balance for a single wallet type.
|
|
///
|
|
/// Combines wallet metadata with available and locked amounts in raw units.
|
|
library;
|
|
|
|
import 'wallet_type_model.dart';
|
|
|
|
/// Balance snapshot for one asset, including nested wallet type details.
|
|
class BalanceModel {
|
|
const BalanceModel({
|
|
required this.walletType,
|
|
required this.available,
|
|
required this.locked,
|
|
});
|
|
|
|
final WalletTypeModel walletType;
|
|
|
|
/// Spendable balance in smallest units as a string.
|
|
final String available;
|
|
|
|
/// Locked balance (e.g. pending withdrawals) in smallest units.
|
|
final String locked;
|
|
|
|
/// Parses a balance entry from the `/api/v1/balances` response.
|
|
factory BalanceModel.fromJson(Map<String, dynamic> json) {
|
|
final wt = json['walletType'] as Map<String, dynamic>;
|
|
return BalanceModel(
|
|
walletType: WalletTypeModel.fromJson(wt),
|
|
available: (json['available'] ?? '0').toString(),
|
|
locked: (json['locked'] ?? '0').toString(),
|
|
);
|
|
}
|
|
}
|