cake_wallet/cw_evm/lib/evm_chain_transaction_model.dart
Omar Hatem 698c222291
Generic fixes (#1348)
* Change order of currencies in currency picker

* Disable Background sync until implemented properly

* remove ability to use device pin in bio auth

* Fix condition

* Minor fix [skip ci]

* make notifications red dot go when opened

* Update Frozen coin text color

* Update Frozen coin text color

* Fetch internal transactions for eth and polygon

* Remove debug prints [skip ci]

* Fix Camera permission on iOS [skip ci]

---------

Co-authored-by: tuxsudo <tuxsudo@tux.pizza>
2024-03-29 20:54:59 +02:00

48 lines
1.5 KiB
Dart

class EVMChainTransactionModel {
final DateTime date;
final String hash;
final String from;
final String to;
final BigInt amount;
final int gasUsed;
final BigInt gasPrice;
final String contractAddress;
final int confirmations;
final int blockNumber;
final String? tokenSymbol;
final int? tokenDecimal;
final bool isError;
EVMChainTransactionModel({
required this.date,
required this.hash,
required this.from,
required this.to,
required this.amount,
required this.gasUsed,
required this.gasPrice,
required this.contractAddress,
required this.confirmations,
required this.blockNumber,
required this.tokenSymbol,
required this.tokenDecimal,
required this.isError,
});
factory EVMChainTransactionModel.fromJson(Map<String, dynamic> json, String defaultSymbol) =>
EVMChainTransactionModel(
date: DateTime.fromMillisecondsSinceEpoch(int.parse(json["timeStamp"]) * 1000),
hash: json["hash"] ?? "",
from: json["from"] ?? "",
to: json["to"] ?? "",
amount: BigInt.parse(json["value"] ?? "0"),
gasUsed: int.parse(json["gasUsed"] ?? "0"),
gasPrice: BigInt.parse(json["gasPrice"] ?? "0"),
contractAddress: json["contractAddress"] ?? "",
confirmations: int.parse(json["confirmations"] ?? "0"),
blockNumber: int.parse(json["blockNumber"] ?? "0"),
tokenSymbol: json["tokenSymbol"] ?? defaultSymbol,
tokenDecimal: int.tryParse(json["tokenDecimal"] ?? ""),
isError: json["isError"] == "1",
);
}