| 1 | import 'package:cw_core/zano_asset.dart'; |
| 2 | import 'package:cw_zano/model/zano_asset.dart'; |
| 3 | import 'package:cw_zano/zano_formatter.dart'; |
| 4 | |
| 5 | class Balance { |
| 6 | final ZanoAsset assetInfo; |
| 7 | final BigInt awaitingIn; |
| 8 | final BigInt awaitingOut; |
| 9 | final BigInt total; |
| 10 | final BigInt unlocked; |
| 11 | |
| 12 | Balance( |
| 13 | {required this.assetInfo, |
| 14 | required this.awaitingIn, |
| 15 | required this.awaitingOut, |
| 16 | required this.total, |
| 17 | required this.unlocked}); |
| 18 | |
| 19 | String get assetId => assetInfo.assetId; |
| 20 | |
| 21 | @override |
| 22 | String toString() => '$assetInfo: $total/$unlocked'; |
| 23 | |
| 24 | factory Balance.fromJson(Map<String, dynamic> json) => Balance( |
| 25 | assetInfo: ZanoAsset.fromJson(json['asset_info'] as Map<String, dynamic>? ?? {}), |
| 26 | awaitingIn: ZanoFormatter.bigIntFromDynamic(json['awaiting_in']), |
| 27 | awaitingOut: ZanoFormatter.bigIntFromDynamic(json['awaiting_out']), |
| 28 | total: ZanoFormatter.bigIntFromDynamic(json['total']), |
| 29 | unlocked: ZanoFormatter.bigIntFromDynamic(json['unlocked']), |
| 30 | ); |
| 31 | } |