cake_wallet/cw_zano/lib/api/model/balance.dart

32 lines
990 B
Dart
Raw Normal View History

2024-03-19 15:51:08 +00:00
import 'package:cw_zano/model/zano_asset.dart';
2024-08-07 12:32:47 +00:00
import 'package:cw_zano/zano_formatter.dart';
2023-12-02 09:42:00 +00:00
class Balance {
2024-03-15 12:42:27 +00:00
final ZanoAsset assetInfo;
2024-08-07 12:32:47 +00:00
final BigInt awaitingIn;
final BigInt awaitingOut;
final BigInt total;
final BigInt unlocked;
2023-12-02 09:42:00 +00:00
Balance(
{required this.assetInfo,
required this.awaitingIn,
required this.awaitingOut,
required this.total,
required this.unlocked});
2024-04-06 10:03:11 +00:00
String get assetId => assetInfo.assetId;
2023-12-02 09:42:00 +00:00
2024-03-15 12:42:27 +00:00
@override
String toString() => '$assetInfo: $total/$unlocked';
2024-03-15 12:42:27 +00:00
2023-12-02 09:42:00 +00:00
factory Balance.fromJson(Map<String, dynamic> json) => Balance(
assetInfo:
2024-03-15 12:42:27 +00:00
ZanoAsset.fromJson(json['asset_info'] as Map<String, dynamic>? ?? {}),
2024-08-07 12:32:47 +00:00
awaitingIn: ZanoFormatter.bigIntFromDynamic(json['awaiting_in']),
awaitingOut: ZanoFormatter.bigIntFromDynamic(json['awaiting_out']),
total: ZanoFormatter.bigIntFromDynamic(json['total']),
unlocked: ZanoFormatter.bigIntFromDynamic(json['unlocked']),
2023-12-02 09:42:00 +00:00
);
}