Class: Ethereum::Tester::ABIContract

Inherits:
Object
  • Object
show all
Defined in:
lib/ethereum/tester/abi_contract.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state, abi, address, listen: true, log_listener: nil) ⇒ ABIContract

Returns a new instance of ABIContract.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ethereum/tester/abi_contract.rb', line 9

def initialize(state, abi, address, listen: true, log_listener: nil)
  @state = state
  @abi = abi
  @address = address

  @translator = ABI::ContractTranslator.new abi

  if listen
    if log_listener
      listener = lambda do |log|
        r = @translator.listen(log, noprint: true)
        log_listener.call r if r.true?
      end
    else
      listener = ->(log) { @translator.listen(log, noprint: false) }
    end
  end

  @translator.function_data.each do |f, _|
    generate_function f
  end
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



7
8
9
# File 'lib/ethereum/tester/abi_contract.rb', line 7

def address
  @address
end

Instance Method Details

#listen(x) ⇒ Object



32
33
34
# File 'lib/ethereum/tester/abi_contract.rb', line 32

def listen(x)
  @translator.listen x
end