Sha256: b94369667499fcede1da12e77418f99d6b694cae2ee1a95f71592fb26af0563d

Contents?: true

Size: 492 Bytes

Versions: 10

Compression:

Stored size: 492 Bytes

Contents

module AbiCoderRb
  def decode_fixed_array(type, data)
    l = type.dim
    subtype = type.subtype
    if subtype.dynamic?
      start_positions = (0...l).map { |i| decode_uint256(data[32 * i, 32]) }
      start_positions.push(data.size)

      outputs = (0...l).map { |i| data[start_positions[i]...start_positions[i + 1]] }

      outputs.map { |out| decode_type(subtype, out) }
    else
      (0...l).map { |i| decode_type(subtype, data[subtype.size * i, subtype.size]) }
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
abi_coder_rb-0.2.8 lib/abi_coder_rb/decode/decode_fixed_array.rb
abi_coder_rb-0.2.7 lib/abi_coder_rb/decode/decode_fixed_array.rb
abi_coder_rb-0.2.6 lib/abi_coder_rb/decode/decode_fixed_array.rb
abi_coder_rb-0.2.5 lib/abi_coder_rb/decode/decode_fixed_array.rb
abi_coder_rb-0.2.4 lib/abi_coder_rb/decode/decode_fixed_array.rb
abi_coder_rb-0.2.3 lib/abi_coder_rb/decode/decode_fixed_array.rb
abi_coder_rb-0.2.2 lib/abi_coder_rb/decode/decode_fixed_array.rb
abi_coder_rb-0.2.1 lib/abi_coder_rb/decode/decode_fixed_array.rb
abi_coder_rb-0.2.0 lib/abi_coder_rb/decode/decode_fixed_array.rb
abi_coder_rb-0.1.0 lib/abi_coder_rb/decode/decode_fixed_array.rb