Class: EvmClient::Abi
- Inherits:
-
Object
- Object
- EvmClient::Abi
- Defined in:
- lib/evm_client/abi.rb
Class Method Summary collapse
Class Method Details
.parse_abi(abi) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/evm_client/abi.rb', line 4 def self.parse_abi(abi) constructor = abi.detect {|x| x["type"] == "constructor"} if constructor.present? constructor_inputs = constructor["inputs"].map { |input| EvmClient::FunctionInput.new(input) } else constructor_inputs = [] end functions = abi.select {|x| x["type"] == "function" }.map { |fun| EvmClient::Function.new(fun) } events = abi.select {|x| x["type"] == "event" }.map { |evt| EvmClient::ContractEvent.new(evt) } [constructor_inputs, functions, events] end |
.parse_array_type(type) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/evm_client/abi.rb', line 22 def self.parse_array_type(type) match = /(.+)\[(\d*)\]\z/.match(type) if match [true, match[2].present? ? match[2].to_i : nil, match[1]] else [false, nil, nil] end end |
.parse_type(type) ⇒ Object
16 17 18 19 20 |
# File 'lib/evm_client/abi.rb', line 16 def self.parse_type(type) raise NotImplementedError if type.ends_with?("]") match = /(\D+)(\d.*)?/.match(type) [match[1], match[2]] end |