class EvmClient::Abi
Public Class Methods
parse_abi(abi)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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