2023-07-27 17:02:10 +00:00
|
|
|
class NanoTransactionModel {
|
|
|
|
final DateTime? date;
|
|
|
|
final String hash;
|
|
|
|
final bool confirmed;
|
|
|
|
final String account;
|
|
|
|
final BigInt amount;
|
|
|
|
final int height;
|
|
|
|
final String type;
|
|
|
|
|
|
|
|
NanoTransactionModel({
|
|
|
|
this.date,
|
|
|
|
required this.hash,
|
|
|
|
required this.height,
|
|
|
|
required this.amount,
|
|
|
|
required this.confirmed,
|
|
|
|
required this.type,
|
|
|
|
required this.account,
|
|
|
|
});
|
|
|
|
|
2023-08-01 13:50:07 +00:00
|
|
|
factory NanoTransactionModel.fromJson(dynamic json) {
|
|
|
|
DateTime? localTimestamp;
|
2023-07-27 17:02:10 +00:00
|
|
|
try {
|
2023-08-01 13:50:07 +00:00
|
|
|
localTimestamp = DateTime.fromMillisecondsSinceEpoch(
|
|
|
|
int.parse(json["local_timestamp"] as String) * 1000);
|
2023-07-27 17:02:10 +00:00
|
|
|
} catch (e) {
|
2023-08-01 13:50:07 +00:00
|
|
|
localTimestamp = DateTime.now();
|
2023-07-27 17:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NanoTransactionModel(
|
2023-08-01 13:50:07 +00:00
|
|
|
date: localTimestamp,
|
2023-07-27 17:02:10 +00:00
|
|
|
hash: json["hash"] as String,
|
|
|
|
height: int.parse(json["height"] as String),
|
|
|
|
type: json["type"] as String,
|
|
|
|
amount: BigInt.parse(json["amount"] as String),
|
|
|
|
account: json["account"] as String,
|
|
|
|
confirmed: (json["confirmed"] as String) == "true",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|