Sha256: 9ff8bacc7222977d29bac8dbbcbbd34800487d5940a37c4b5a3ce0b36e11f322
Contents?: true
Size: 804 Bytes
Versions: 1
Compression:
Stored size: 804 Bytes
Contents
module AbiCoderRb def encode_array(type, args, packed = false) raise EncodingError, "args must be an array" unless args.is_a?(::Array) _encode_array(type: type, args: args, packed: packed) end private def _encode_array(type:, args:, packed: false) head = "".b tail = "".b # 数组长度 head += encode_uint256(args.size) if type.is_a?(Array) && !packed args.each do |arg| if type.inner_type.dynamic? raise EncodingError, "#{type.class} with dynamic inner type is not supported in packed mode" if packed head += encode_uint256(32 * args.size + tail.size) # 当前数据的位置指针 tail += encode_type(type.inner_type, arg) else head += encode_type(type.inner_type, arg) end end head + tail end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
abi_coder_rb-0.2.9 | lib/abi_coder_rb/encode/encode_array.rb |