Class: AbiCoderRb::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/abi_coder_rb/types.rb,
lib/abi_coder_rb/parser.rb

Overview

for now use (get inspired)

by the type names used by abi coder in rust
  see  https://github.com/rust-ethereum/ethabi/blob/master/ethabi/src/param_type/param_type.rs

Direct Known Subclasses

Address, Array, Bool, Bytes, FixedArray, FixedBytes, Int, String, Tuple, Uint

Defined Under Namespace

Classes: ParseError, Parser

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(type) ⇒ Object

convenience helper



8
9
10
# File 'lib/abi_coder_rb/types.rb', line 8

def self.parse(type) ## convenience helper
  Parser.parse(type)
end

Instance Method Details

#dynamic?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/abi_coder_rb/types.rb', line 22

def dynamic?
  size.nil?
end

#formatObject

Raises:

  • (ArgumentError)


26
27
28
29
# File 'lib/abi_coder_rb/types.rb', line 26

def format
  ## check/todo: what error to raise for not implemented / method not defined???
  raise ArgumentError, "no required format method defined for Type subclass #{self.class.name}; sorry"
end

#sizeInteger, NilClass

Get the static size of a type, or nil if dynamic.

Returns:

  • (Integer, NilClass)

    size of static type, or nil for dynamic type

Raises:

  • (ArgumentError)


17
18
19
20
# File 'lib/abi_coder_rb/types.rb', line 17

def size
  ## check/todo: what error to raise for not implemented / method not defined???
  raise ArgumentError, "no required size method defined for Type subclass #{self.class.name}; sorry"
end