| 1 | class EVMChainTransactionModel { |
| 2 | final DateTime date; |
| 3 | final String hash; |
| 4 | final String from; |
| 5 | final String to; |
| 6 | final BigInt amount; |
| 7 | final int gasUsed; |
| 8 | final BigInt gasPrice; |
| 9 | final String contractAddress; |
| 10 | final int confirmations; |
| 11 | final int blockNumber; |
| 12 | final String? tokenSymbol; |
| 13 | final int? tokenDecimal; |
| 14 | final bool isError; |
| 15 | final String input; |
| 16 | final int chainId; |
| 17 | String? evmSignatureName; |
| 18 | |
| 19 | EVMChainTransactionModel({ |
| 20 | required this.date, |
| 21 | required this.hash, |
| 22 | required this.from, |
| 23 | required this.to, |
| 24 | required this.amount, |
| 25 | required this.gasUsed, |
| 26 | required this.gasPrice, |
| 27 | required this.contractAddress, |
| 28 | required this.confirmations, |
| 29 | required this.blockNumber, |
| 30 | required this.tokenSymbol, |
| 31 | required this.tokenDecimal, |
| 32 | required this.isError, |
| 33 | required this.input, |
| 34 | required this.chainId, |
| 35 | this.evmSignatureName, |
| 36 | }); |
| 37 | |
| 38 | factory EVMChainTransactionModel.fromJson( |
| 39 | Map<String, dynamic> json, String defaultSymbol, int chainId) => |
| 40 | EVMChainTransactionModel( |
| 41 | date: DateTime.fromMillisecondsSinceEpoch(int.parse(json["timeStamp"]) * 1000), |
| 42 | hash: json["hash"] ?? "", |
| 43 | from: json["from"] ?? "", |
| 44 | to: json["to"] ?? "", |
| 45 | amount: BigInt.parse(json["value"] ?? "0"), |
| 46 | gasUsed: int.parse(json["gasUsed"] ?? "0"), |
| 47 | gasPrice: BigInt.parse(json["gasPrice"] ?? "0"), |
| 48 | contractAddress: json["contractAddress"] ?? "", |
| 49 | confirmations: int.parse(json["confirmations"] ?? "0"), |
| 50 | blockNumber: int.parse(json["blockNumber"] ?? "0"), |
| 51 | tokenSymbol: json["tokenSymbol"] ?? defaultSymbol, |
| 52 | tokenDecimal: int.tryParse(json["tokenDecimal"] ?? ""), |
| 53 | isError: json["isError"] == "1", |
| 54 | input: json["input"] ?? "", |
| 55 | evmSignatureName: json["evmSignatureName"], |
| 56 | chainId: chainId, |
| 57 | ); |
| 58 | } |