class Etherlite::Contract::EventBase::DecodeLogInputs

Public Instance Methods

perform() click to toggle source
# File lib/etherlite/commands/contract/event_base/decode_log_inputs.rb, line 3
def perform
  store_by_name non_indexed_inputs, non_indexed_values
  store_by_name indexed_inputs, indexed_values
  attributes
end

Private Instance Methods

attributes() click to toggle source
# File lib/etherlite/commands/contract/event_base/decode_log_inputs.rb, line 11
def attributes
  @attributes ||= {}
end
indexed_inputs() click to toggle source
# File lib/etherlite/commands/contract/event_base/decode_log_inputs.rb, line 25
def indexed_inputs
  @indexed_inputs ||= @inputs.select(&:indexed?)
end
indexed_values() click to toggle source
# File lib/etherlite/commands/contract/event_base/decode_log_inputs.rb, line 29
def indexed_values
  topics = @json['topics'][1..-1]
  indexed_inputs.each_with_index.map do |input, i|
    # dynamic indexed inputs cannot be retrieved (only the hash is stored)
    input.type.dynamic? ? topics[i] : input.type.decode(@connection, topics[i][2..-1])
  end
end
non_indexed_inputs() click to toggle source
# File lib/etherlite/commands/contract/event_base/decode_log_inputs.rb, line 15
def non_indexed_inputs
  @non_indexed_inputs ||= @inputs.select { |i| !i.indexed? }
end
non_indexed_values() click to toggle source
# File lib/etherlite/commands/contract/event_base/decode_log_inputs.rb, line 19
def non_indexed_values
  Etherlite::Support::Array.decode(
    @connection, non_indexed_inputs.map(&:type), @json['data'][2..-1]
  )
end
store_by_name(_inputs, _values) click to toggle source
# File lib/etherlite/commands/contract/event_base/decode_log_inputs.rb, line 37
def store_by_name(_inputs, _values)
  _inputs.each_with_index { |input, i| attributes[input.original_name] = _values[i] }
end