Class: EvmClient::EventLog
- Inherits:
-
Object
- Object
- EvmClient::EventLog
- Defined in:
- lib/evm_client/event_log.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#block_hash ⇒ Object
readonly
Returns the value of attribute block_hash.
-
#block_number ⇒ Object
readonly
Returns the value of attribute block_number.
-
#contract ⇒ Object
readonly
Returns the value of attribute contract.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#log_index ⇒ Object
readonly
Returns the value of attribute log_index.
-
#removed ⇒ Object
readonly
Returns the value of attribute removed.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
-
#topics ⇒ Object
readonly
Returns the value of attribute topics.
-
#transaction_hash ⇒ Object
readonly
Returns the value of attribute transaction_hash.
-
#transaction_index ⇒ Object
readonly
Returns the value of attribute transaction_index.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(address:, block_hash:, block_number:, data:, log_index:, removed:, topics:, transaction_hash:, transaction_index:, signature:, contract:, event:) ⇒ EventLog
constructor
A new instance of EventLog.
- #name ⇒ Object
- #return_values ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(address:, block_hash:, block_number:, data:, log_index:, removed:, topics:, transaction_hash:, transaction_index:, signature:, contract:, event:) ⇒ EventLog
Returns a new instance of EventLog.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/evm_client/event_log.rb', line 26 def initialize( address:, block_hash:, block_number:, data:, log_index:, removed:, topics:, transaction_hash:, transaction_index:, signature:, contract:, event:) @address = address @block_hash = block_hash @block_number = block_number @data = data @log_index = log_index @removed = removed @topics = topics @transaction_hash = transaction_hash @transaction_index = transaction_index @signature = signature @contract = contract @event = event end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
3 4 5 |
# File 'lib/evm_client/event_log.rb', line 3 def address @address end |
#block_hash ⇒ Object (readonly)
Returns the value of attribute block_hash.
3 4 5 |
# File 'lib/evm_client/event_log.rb', line 3 def block_hash @block_hash end |
#block_number ⇒ Object (readonly)
Returns the value of attribute block_number.
3 4 5 |
# File 'lib/evm_client/event_log.rb', line 3 def block_number @block_number end |
#contract ⇒ Object (readonly)
Returns the value of attribute contract.
3 4 5 |
# File 'lib/evm_client/event_log.rb', line 3 def contract @contract end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/evm_client/event_log.rb', line 3 def data @data end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
3 4 5 |
# File 'lib/evm_client/event_log.rb', line 3 def event @event end |
#log_index ⇒ Object (readonly)
Returns the value of attribute log_index.
3 4 5 |
# File 'lib/evm_client/event_log.rb', line 3 def log_index @log_index end |
#removed ⇒ Object (readonly)
Returns the value of attribute removed.
3 4 5 |
# File 'lib/evm_client/event_log.rb', line 3 def removed @removed end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
3 4 5 |
# File 'lib/evm_client/event_log.rb', line 3 def signature @signature end |
#topics ⇒ Object (readonly)
Returns the value of attribute topics.
3 4 5 |
# File 'lib/evm_client/event_log.rb', line 3 def topics @topics end |
#transaction_hash ⇒ Object (readonly)
Returns the value of attribute transaction_hash.
3 4 5 |
# File 'lib/evm_client/event_log.rb', line 3 def transaction_hash @transaction_hash end |
#transaction_index ⇒ Object (readonly)
Returns the value of attribute transaction_index.
3 4 5 |
# File 'lib/evm_client/event_log.rb', line 3 def transaction_index @transaction_index end |
Class Method Details
.build(raw_response:, contract:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/evm_client/event_log.rb', line 6 def self.build(raw_response:, contract:) signature = raw_response['topics'][0] event = contract.events.find { |event| signature.match(event.signature) } new( address: raw_response['address'], block_hash: raw_response['blockHash'], block_number: raw_response['blockNumber'].to_i(16), data: raw_response['data'], log_index: raw_response['logIndex'], removed: raw_response['removed'], topics: raw_response['topics'], transaction_hash: raw_response['transactionHash'], transaction_index: raw_response['transactionIndex'], signature: signature, contract: contract, event: event ) end |
Instance Method Details
#name ⇒ Object
42 43 44 |
# File 'lib/evm_client/event_log.rb', line 42 def name event.name end |
#return_values ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/evm_client/event_log.rb', line 46 def return_values return_values = {} indexed_params.each_with_index do |param, index| return_values[param.name] = topics[index+1] end non_indexed_params.each_with_index do |param, index| return_values[param.name] = Decoder.new.decode_arguments(non_indexed_params, data)[index] end return_values end |
#to_h ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/evm_client/event_log.rb', line 60 def to_h { address: address, block_hash: block_hash, block_number: block_number, data: data, log_index: log_index, removed: removed, topics: topics, transaction_hash: transaction_hash, transaction_index: transaction_index, signature: signature, name: name, contract_name: contract.name, return_values: return_values } end |