Class: Ethereum::Tester::ABIContract
- Defined in:
- lib/ethereum/tester/abi_contract.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
Instance Method Summary collapse
-
#initialize(state, abi, address, listen: true, log_listener: nil, default_key: nil) ⇒ ABIContract
constructor
A new instance of ABIContract.
- #listen(x, noprint: true) ⇒ Object
Constructor Details
#initialize(state, abi, address, listen: true, log_listener: nil, default_key: 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 |
# File 'lib/ethereum/tester/abi_contract.rb', line 9 def initialize(state, abi, address, listen: true, log_listener: nil, default_key: nil) @state = state @address = address @default_key = default_key || Fixture.keys.first @translator = abi.instance_of?(ABI::ContractTranslator) ? abi : ABI::ContractTranslator.new(abi) if listen listener = ->(log) { result = @translator.listen log, noprint: false # result could be nil if the log cannot be parsed into an event # in that case we just pass raw log to listener log_listener.call(result || log) if log_listener } @state.block.log_listeners.push listener end @translator.function_data.each do |fn, _| generate_function fn end end |
Instance Attribute Details
#address ⇒ Object (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, noprint: true) ⇒ Object
31 32 33 |
# File 'lib/ethereum/tester/abi_contract.rb', line 31 def listen(x, noprint: true) @translator.listen x, noprint: end |