Class: EthereumContractABI::ContractInterface::Parsers::AbiTypeParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ethereum-contract-abi/contract/parsers/abi_type_parser.rb

Class Method Summary collapse

Class Method Details

.from_string(string_type) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ethereum-contract-abi/contract/parsers/abi_type_parser.rb', line 16

def self.from_string(string_type)
  uint = Uint.from_string(string_type)
  return uint unless uint.nil?

  bool = Bool.from_string(string_type)
  return bool unless bool.nil?

  decimal = Fixed.from_string(string_type)
  return decimal unless decimal.nil?

  str = EthereumContractABI::ContractInterface::AbiTypes::String.from_string(string_type)
  return str unless str.nil?

  bytes = Bytes.from_string(string_type)
  return bytes unless bytes.nil?

  address = Address.from_string(string_type)
  return address unless address.nil?

  raise ArgumentError.new('Unknown type')
end