LCOV - code coverage report
Current view: top level - crypto/evm/entities/transactions - evm_transaction.dart (source / functions) Coverage Total Hit
Test: lcov.info Lines: 1.5 % 66 1
Test Date: 2025-01-30 01:10:00 Functions: - 0 0

            Line data    Source code
       1              : part of '../../../../domain/entities/generic_transaction.dart';
       2              : 
       3              : base class EVMTransaction extends GenericTransaction {
       4              :   final Uint8List input;
       5              :   final Amount? gasPrice;
       6              :   final int? gas;
       7              :   final int? gasUsed;
       8              :   final ContractFunctionWithValues? decodedInput;
       9              : 
      10            2 :   const EVMTransaction({
      11              :     required super.hash,
      12              :     required super.block,
      13              :     required super.confirmations,
      14              :     required super.timeMilli,
      15              :     required super.amount,
      16              :     required super.fee,
      17              :     required super.sender,
      18              :     required super.recipient,
      19              :     required super.transferMethod,
      20              :     required super.token,
      21              :     required super.status,
      22              :     required this.input,
      23              :     required this.decodedInput,
      24              :     required this.gasPrice,
      25              :     required this.gas,
      26              :     required this.gasUsed,
      27              :   });
      28              : 
      29            0 :   String? get uTF8Input {
      30              :     try {
      31            0 :       return utf8.decode(input);
      32              :     } catch (e) {
      33              :       return null;
      34              :     }
      35              :   }
      36              : 
      37            0 :   EVMTransaction copyWith({ContractFunctionWithValues? decodedInput}) {
      38            0 :     return EVMTransaction(
      39            0 :       hash: hash,
      40            0 :       block: block,
      41            0 :       confirmations: confirmations,
      42            0 :       timeMilli: timeMilli,
      43            0 :       amount: amount,
      44            0 :       fee: fee,
      45            0 :       gasPrice: gasPrice,
      46            0 :       gas: gas,
      47            0 :       gasUsed: gasUsed,
      48            0 :       sender: sender,
      49            0 :       recipient: recipient,
      50            0 :       transferMethod: transferMethod,
      51            0 :       status: status,
      52            0 :       input: input,
      53            0 :       token: token,
      54            0 :       decodedInput: decodedInput ?? this.decodedInput,
      55              :     );
      56              :   }
      57              : 
      58            0 :   @override
      59              :   Map<String, dynamic> toJson() {
      60            0 :     return {
      61            0 :       'hash': hash,
      62            0 :       'block': block,
      63            0 :       'confirmations': confirmations,
      64            0 :       'timeMilli': timeMilli,
      65            0 :       'amount': amount.toJson(),
      66            0 :       'fee': fee?.toJson(),
      67            0 :       'sender': sender,
      68            0 :       'gas': gas,
      69            0 :       'gasUsed': gasUsed,
      70            0 :       'gasPrice': gasPrice?.toJson(),
      71            0 :       'recipient': recipient,
      72            0 :       'transferMethod': transferMethod.index,
      73            0 :       'status': status.index,
      74            0 :       'input': input.toHex,
      75            0 :       'token': token.toJson(),
      76            0 :       'decodedInput': decodedInput?.toJson(),
      77              :     };
      78              :   }
      79              : 
      80            0 :   factory EVMTransaction.fromJson(Map<dynamic, dynamic> json) {
      81              :     if (json
      82              :         case {
      83            0 :           'hash': String hash,
      84            0 :           'block': int block,
      85            0 :           'confirmations': int confirmations,
      86            0 :           'timeMilli': int timeMilli,
      87            0 :           'amount': Map amount,
      88            0 :           'fee': Map? fee,
      89            0 :           'sender': String sender,
      90            0 :           'recipient': String recipient,
      91            0 :           'transferMethod': int transferMethod,
      92            0 :           'status': int status,
      93            0 :           'gas': int? gas,
      94            0 :           'gasPrice': Map? gasPrice,
      95            0 :           'gasUsed': int? gasUsed,
      96            0 :           'token': Map token,
      97            0 :           'input': String input,
      98            0 :           'decodedInput': Map? decodedInput,
      99              :         }) {
     100            0 :       return EVMTransaction(
     101              :         hash: hash,
     102              :         block: block,
     103              :         confirmations: confirmations,
     104              :         timeMilli: timeMilli,
     105            0 :         amount: Amount.fromJson(amount),
     106            0 :         fee: fee != null ? Amount.fromJson(fee) : null,
     107              :         sender: sender,
     108              :         gas: gas,
     109              :         recipient: recipient,
     110              :         gasUsed: gasUsed,
     111            0 :         gasPrice: gasPrice != null ? Amount.fromJson(gasPrice) : null,
     112            0 :         transferMethod: TransactionTransferMethod.fromJson(transferMethod),
     113            0 :         status: ConfirmationStatus.fromJson(status),
     114            0 :         input: input.hexToBytesOrNull ?? Uint8List(0),
     115            0 :         token: CoinEntity.fromJson(token),
     116              :         decodedInput: decodedInput != null
     117            0 :             ? ContractFunctionWithValues.fromJson(decodedInput)
     118              :             : null,
     119              :       );
     120              :     }
     121            0 :     throw Exception("Could not parse EVMTransaction from $json");
     122              :   }
     123              : }
        

Generated by: LCOV version 2.0-1