LCOV - code coverage report
Current view: top level - lib/src/messages - ethereum_log.dart (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 53 53 100.0 %
Date: 2018-01-19 11:13:13 Functions: 0 0 -

          Line data    Source code
       1             : /*
       2             :  * Package : Ethereum
       3             :  * Author : S. Hamblett <steve.hamblett@linux.com>
       4             :  * Date   : 08/01/2017
       5             :  * Copyright :  S.Hamblett
       6             :  *
       7             :  * A JSON RPC 2.0 client for Ethereum
       8             :  */
       9             : 
      10             : part of ethereum;
      11             : 
      12             : /// Ethereum log message
      13             : class EthereumLog {
      14           1 :   EthereumLog();
      15             : 
      16           1 :   EthereumLog.fromMap(Map result) {
      17           1 :     construct(result);
      18             :   }
      19             : 
      20             :   /// Removed. True when the log was removed, due to a chain reorganization. false if its a valid log.
      21             :   bool _removed;
      22             : 
      23           1 :   bool get removed => _removed;
      24             : 
      25             :   /// Log index. The log index position in the block. Null when the log is pending.
      26             :   int _logIndex;
      27             : 
      28           1 :   int get logIndex => _logIndex;
      29             : 
      30             :   /// Transaction index. The transactions index position the log was created from. Null when the log is pending.
      31             :   int _transactionIndex;
      32             : 
      33           1 :   int get transactionIndex => _transactionIndex;
      34             : 
      35             :   /// Transaction hash. Hash of the transactions this log was created from. Null when the log is pending.
      36             :   BigInteger _transactionHash;
      37             : 
      38           1 :   BigInteger get transactionHash => _transactionHash;
      39             : 
      40             :   /// Block hash. Hash of the block where this log was in. Null when the log is pending.
      41             :   BigInteger _blockHash;
      42             : 
      43           1 :   BigInteger get blockHash => _blockHash;
      44             : 
      45             :   /// Block number. The block number of this log. Null when the log is pending.
      46             :   int _blockNumber;
      47             : 
      48           1 :   int get blockNumber => _blockNumber;
      49             : 
      50             :   /// Address. Address from which this log originated.
      51             :   BigInteger _address;
      52             : 
      53           1 :   BigInteger get address => _address;
      54             : 
      55             :   /// Data. Contains one or more 32 Bytes non-indexed arguments of the log.
      56             :   BigInteger _data;
      57             : 
      58           1 :   BigInteger get data => _data;
      59             : 
      60             :   /// Topics. List of 0 to 4 32 of indexed log arguments. (In solidity:
      61             :   /// The first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256)),
      62             :   /// except you declared the event with the anonymous specifier.)
      63             :   List<BigInteger> _topics;
      64             : 
      65           1 :   List<BigInteger> get topics => _topics;
      66             : 
      67             :   /// Construct from the supplied Map, only check for the keys we need.
      68             :   void construct(Map data) {
      69           1 :     if (data[ethResultKey] == null) {
      70             :       return;
      71             :     }
      72           2 :     if (data[ethResultKey].containsKey('removed')) {
      73           3 :       _removed = data[ethResultKey]['removed'];
      74             :     }
      75           2 :     if (data[ethResultKey].containsKey('logIndex')) {
      76           4 :       _logIndex = EthereumUtilities.hexToInt(data[ethResultKey]['logIndex']);
      77             :     }
      78           2 :     if (data[ethResultKey].containsKey('transactionIndex')) {
      79           1 :       _transactionIndex =
      80           3 :           EthereumUtilities.hexToInt(data[ethResultKey]['transactionIndex']);
      81             :     }
      82           2 :     if (data[ethResultKey].containsKey('transactionHash')) {
      83           4 :       _transactionHash = new BigInteger(data[ethResultKey]['transactionHash']);
      84             :     }
      85           2 :     if (data[ethResultKey].containsKey('blockHash')) {
      86           4 :       _blockHash = new BigInteger(data[ethResultKey]['blockHash']);
      87             :     }
      88           2 :     if (data[ethResultKey].containsKey('blockNumber')) {
      89           1 :       _blockNumber =
      90           3 :           EthereumUtilities.hexToInt(data[ethResultKey]['blockNumber']);
      91             :     }
      92           2 :     if (data[ethResultKey].containsKey('address')) {
      93           4 :       _address = new BigInteger(data[ethResultKey]['address']);
      94             :     }
      95           2 :     if (data[ethResultKey].containsKey('data')) {
      96           4 :       _data = new BigInteger(data[ethResultKey]['data']);
      97             :     }
      98           2 :     if (data[ethResultKey].containsKey('topics')) {
      99           2 :       if ((data[ethResultKey]['topics'] != null) &&
     100           3 :           (data[ethResultKey]['topics'].isNotEmpty)) {
     101           2 :         _topics = new List<BigInteger>();
     102           4 :         for (String topic in data[ethResultKey]['topics']) {
     103           1 :           final BigInteger entry = new BigInteger(topic);
     104           2 :           _topics.add(entry);
     105             :         }
     106             :       }
     107             :     }
     108             :   }
     109             : 
     110             :   // To string
     111             :   String toString() {
     112           1 :     final String ret = "Ethereum Log :" +
     113           1 :         "\n" +
     114           2 :         "  Removed : $removed" +
     115           1 :         "\n" +
     116           2 :         "  Log Index : $logIndex" +
     117           1 :         "\n" +
     118           2 :         "  Transaction Index : $transactionIndex" +
     119           1 :         "\n" +
     120           2 :         "  Transaction Hash: $transactionHash" +
     121           1 :         "\n" +
     122           2 :         "  Block Number: $blockNumber" +
     123           1 :         "\n" +
     124           2 :         "  Block Hash : $blockHash" +
     125           1 :         "\n" +
     126           2 :         "  Address : $address" +
     127             :         "\n";
     128             :     return ret;
     129             :   }
     130             : }

Generated by: LCOV version 1.12