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

31 lines
1,007 B
Dart
Raw Normal View History

2024-03-15 12:42:27 +00:00
import 'package:cw_core/amount_converter.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:cw_zano/zano_asset.dart';
2023-12-02 09:42:00 +00:00
class Balance {
2024-03-15 12:42:27 +00:00
final ZanoAsset assetInfo;
2023-12-02 09:42:00 +00:00
final int awaitingIn;
final int awaitingOut;
final int total;
final int unlocked;
Balance(
{required this.assetInfo,
required this.awaitingIn,
required this.awaitingOut,
required this.total,
required this.unlocked});
2024-03-15 12:42:27 +00:00
@override
String toString() => '$assetInfo: ${AmountConverter.amountIntToString(CryptoCurrency.zano, total)}/${AmountConverter.amountIntToString(CryptoCurrency.zano, unlocked)}';
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>? ?? {}),
awaitingIn: json['awaiting_in'] as int? ?? 0,
awaitingOut: json['awaiting_out'] as int? ?? 0,
total: json['total'] as int? ?? 0,
unlocked: json['unlocked'] as int? ?? 0,
2023-12-02 09:42:00 +00:00
);
}