Sha256: d58e721524d57129e927b65f0ee1dc8b142a8a2a398e78206aa347e0bed11920

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

module AbiCoderRb
  class AbiParser
    @tokenizer: AbiTokenizer
    @current_token: String

    def initialize: (AbiTokenizer) -> void
    def parse: -> abi_type

    private

    def parse_bytes: -> bytes
    def parse_numeric_type: -> numeric_type
    def parse_simple_type: -> simple_type
    def parse_tuple: -> tuple_type
    def parse_array: -> array_type
    def parse_array_length: -> Integer
    def expect: -> void
  end

  type abi_type = bytes | numeric_type | simple_type | array_type | tuple_type

  type bytes =
      { type: "bytes", length?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 }

  type numeric_type =
      { type: "uint", bits: 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | 208 | 216 | 224 | 232 | 240 | 248 | 256 } # uint will be parsed to uint256.
    | { type: "int", bits: 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | 208 | 216 | 224 | 232 | 240 | 248 | 256 } # int will be parsed to int256

  type simple_type =
      { type: "string" }
    | { type: "address" }
    | { type: "bool" }

  type array_type = { type: "array", inner_type: abi_type, length: Integer? } # length is nil for dynamic array.

  type tuple_type = { type: "tuple", inner_types: Array[abi_type] }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
abi_coder_rb-0.2.9 sig/abi_coder_rb/abi_parser.rbs