Class: Eth::Contract::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/eth/contract/event.rb

Overview

Provide classes for contract event.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Event

Constructor of the Eth::Contract::Event class.

Parameters:

  • data (Hash)

    contract event data.



27
28
29
30
31
32
33
# File 'lib/eth/contract/event.rb', line 27

def initialize(data)
  @name = data["name"]
  @input_types = data["inputs"].collect { |x| x["type"] }
  @inputs = data["inputs"].collect { |x| x["name"] }
  @event_string = "#{@name}(#{@input_types.join(",")})"
  @signature = Digest::Keccak.hexdigest(@event_string, 256)
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



22
23
24
# File 'lib/eth/contract/event.rb', line 22

def address
  @address
end

#event_stringObject

Returns the value of attribute event_string.



22
23
24
# File 'lib/eth/contract/event.rb', line 22

def event_string
  @event_string
end

#input_typesObject

Returns the value of attribute input_types.



22
23
24
# File 'lib/eth/contract/event.rb', line 22

def input_types
  @input_types
end

#inputsObject

Returns the value of attribute inputs.



22
23
24
# File 'lib/eth/contract/event.rb', line 22

def inputs
  @inputs
end

#nameObject

Returns the value of attribute name.



22
23
24
# File 'lib/eth/contract/event.rb', line 22

def name
  @name
end

#signatureObject

Returns the value of attribute signature.



22
23
24
# File 'lib/eth/contract/event.rb', line 22

def signature
  @signature
end

Instance Method Details

#set_address(address) ⇒ Object

Set the address of the smart contract

Parameters:

  • address (String)

    contract address.



38
39
40
# File 'lib/eth/contract/event.rb', line 38

def set_address(address)
  @address = address.nil? ? nil : Eth::Address.new(address).address
end