Class: Etherlite::Contract::EventBase::DecodeLogInputs

Inherits:
Object
  • Object
show all
Defined in:
lib/etherlite/commands/contract/event_base/decode_log_inputs.rb

Instance Method Summary collapse

Instance Method Details

#performObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/etherlite/commands/contract/event_base/decode_log_inputs.rb', line 3

def perform
  indexed = []
  non_indexed = []
  attributes = {}

  @inputs.each { |i| (i.indexed? ? indexed : non_indexed) << i }

  @json['data'][2..-1].scan(/.{64}/).each_with_index do |data, i|
    attributes[non_indexed[i].original_name] = non_indexed[i].type.decode(@connection, data)
  end

  @json['topics'][1..-1].each_with_index do |topic, i|
    attributes[indexed[i].original_name] = indexed[i].type.decode(@connection, topic[2..-1])
  end

  attributes
end