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

            Line data    Source code
       1              : class BlockNum {
       2              :   /// Use the state of the blockchain at the block specified.
       3            0 :   const BlockNum.exact(this.blockNum) : useAbsolute = true;
       4              : 
       5              :   /// Use the state of the blockchain with the first block
       6            0 :   const BlockNum.genesis()
       7              :       : useAbsolute = false,
       8              :         blockNum = 0;
       9              : 
      10              :   /// Use the state of the blockchain as of the latest mined block.
      11            0 :   const BlockNum.current()
      12              :       : useAbsolute = false,
      13              :         blockNum = 1;
      14              : 
      15              :   /// Use the current state of the blockchain, including pending transactions
      16              :   /// that have not yet been mined.
      17            0 :   const BlockNum.pending()
      18              :       : useAbsolute = false,
      19              :         blockNum = 2;
      20              : 
      21              :   final bool useAbsolute;
      22              :   final int blockNum;
      23              : 
      24            0 :   bool get isPending => !useAbsolute && blockNum == 2;
      25              : 
      26              :   /// Generates the block parameter as it is accepted by the Ethereum client.
      27            0 :   String toBlockParam() {
      28            0 :     if (useAbsolute) return '0x${blockNum.toRadixString(16)}';
      29              : 
      30            0 :     switch (blockNum) {
      31            0 :       case 0:
      32              :         return 'earliest';
      33            0 :       case 1:
      34              :         return 'latest';
      35            0 :       case 2:
      36              :         return 'pending';
      37              :       default:
      38              :         return 'latest'; //Can't happen, though
      39              :     }
      40              :   }
      41              : 
      42            0 :   @override
      43              :   String toString() {
      44            0 :     if (useAbsolute) return blockNum.toString();
      45              : 
      46            0 :     return toBlockParam();
      47              :   }
      48              : 
      49            0 :   @override
      50              :   bool operator ==(Object other) =>
      51              :       identical(this, other) ||
      52            0 :       other is BlockNum &&
      53            0 :           runtimeType == other.runtimeType &&
      54            0 :           useAbsolute == other.useAbsolute &&
      55            0 :           blockNum == other.blockNum;
      56              : 
      57            0 :   @override
      58            0 :   int get hashCode => useAbsolute.hashCode ^ blockNum.hashCode;
      59              : }
        

Generated by: LCOV version 2.0-1