Class: Etherlite::Contract::EventBase

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

Defined Under Namespace

Classes: DecodeLogInputs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_block_hash, _block_number, _tx_hash, _address, _attributes) ⇒ EventBase

Returns a new instance of EventBase.



36
37
38
39
40
41
42
# File 'lib/etherlite/contract/event_base.rb', line 36

def initialize(_block_hash, _block_number, _tx_hash, _address, _attributes)
  @block_hash = _block_hash
  @block_number = _block_number
  @tx_hash = _tx_hash
  @address = _address
  @attributes = _attributes
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



34
35
36
# File 'lib/etherlite/contract/event_base.rb', line 34

def address
  @address
end

#attributesObject (readonly)

Returns the value of attribute attributes.



34
35
36
# File 'lib/etherlite/contract/event_base.rb', line 34

def attributes
  @attributes
end

#block_hashObject (readonly)

Returns the value of attribute block_hash.



34
35
36
# File 'lib/etherlite/contract/event_base.rb', line 34

def block_hash
  @block_hash
end

#block_numberObject (readonly)

Returns the value of attribute block_number.



34
35
36
# File 'lib/etherlite/contract/event_base.rb', line 34

def block_number
  @block_number
end

#tx_hashObject (readonly)

Returns the value of attribute tx_hash.



34
35
36
# File 'lib/etherlite/contract/event_base.rb', line 34

def tx_hash
  @tx_hash
end

Class Method Details

.decode(_connection, _json) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/etherlite/contract/event_base.rb', line 24

def self.decode(_connection, _json)
  new(
    _json['blockHash'],
    _json['blockNumber'].nil? ? nil : Etherlite::Utils.hex_to_uint(_json['blockNumber']),
    _json['transactionHash'],
    Etherlite::Address.new(_connection, Etherlite::Utils.normalize_address(_json['address'])),
    DecodeLogInputs.for(connection: _connection, inputs: inputs, json: _json)
  )
end

.inputsObject



5
6
7
# File 'lib/etherlite/contract/event_base.rb', line 5

def self.inputs
  nil # To be implemented by sub classes
end

.original_nameObject



9
10
11
# File 'lib/etherlite/contract/event_base.rb', line 9

def self.original_name
  nil # To be implemented by sub classes
end

.signatureObject



13
14
15
16
17
18
# File 'lib/etherlite/contract/event_base.rb', line 13

def self.signature
  @signature ||= begin
    input_sig = inputs.map { |i| i.type.signature }
    "#{original_name}(#{input_sig.join(',')})"
  end
end

.topicObject



20
21
22
# File 'lib/etherlite/contract/event_base.rb', line 20

def self.topic
  '0x' + Etherlite::Utils.sha3(signature)
end