scale_rb 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c7019e91465191e14eb99ca5b57435245b9cb533cc0b5eb7e9ee944f8485a8c
4
- data.tar.gz: 8d9eb533ffb3046536f915c39271049d46b20a1417989e6844c6b3ba927bd1e3
3
+ metadata.gz: b9af24645257f5dc7c2028047ba01ef9a3d1fe4282581717cb62334a6f96f153
4
+ data.tar.gz: 8d79a47702d593158680d4fe2f5a887962fd87bc19e51e2d57b4ea6ca2ec0a9b
5
5
  SHA512:
6
- metadata.gz: ef65503ad4ccc4f26490c0ff9ed0715beb312ee50ca5ca6a1f4824a924a01cd833503bbd1f80e8c510eb26d12a6f400655a0fcc5bed12a505ef15cb1e686b69d
7
- data.tar.gz: cf36689a9d7bf12c104f51e39483f3db58d073423d314692f07cfba1ce49e324032c57b4fbe122b207f85ac08af60bbdb44dc8e21fde0c558bbbd05bb255d40f
6
+ metadata.gz: b573f530576618d07382f3b995cc5413a564e4bf95149882cc83b6cb0d885e2adee2f903b5db0c8a14fd5b6964683b6851f6105e0c53c6bcb98e625c2991a639
7
+ data.tar.gz: efa796fe20f73749749bfd06de0f08c1d836268ddb99963775003f282eff60e15accd4d62556eaa1d01b0821447bdcb4bd8956e5445401ca562da2df1fc547f8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scale_rb (0.1.10)
4
+ scale_rb (0.1.11)
5
5
  base58
6
6
  blake2b_rs (~> 0.1.4)
7
7
  xxhash
@@ -70,7 +70,23 @@ module PortableCodec
70
70
  def decode_array(array_type, bytes, registry)
71
71
  len = array_type._get(:len)
72
72
  inner_type_id = array_type._get(:type)
73
- _decode_types([inner_type_id] * len, bytes, registry)
73
+
74
+ # check if the type of inner_type_id is a u8
75
+ if _u8?(inner_type_id, registry)
76
+ [
77
+ bytes[0...len].to_hex,
78
+ bytes[len..]
79
+ ]
80
+ else
81
+ _decode_types([inner_type_id] * len, bytes, registry)
82
+ end
83
+ end
84
+
85
+ def _u8?(type_id, registry)
86
+ type = registry[type_id]
87
+ raise TypeNotFound, "id: #{type_id}" if type.nil?
88
+
89
+ type._get(:def)._get(:primitive)&.downcase == 'u8'
74
90
  end
75
91
 
76
92
  def decode_sequence(sequence_type, bytes, registry)
@@ -242,7 +258,10 @@ module PortableCodec
242
258
 
243
259
  # if the variant item has more than one field, the value must be a hash with the same length.
244
260
  # if the variant item has only one field, that means the field is a type id point to a composite. TODO: check the type's fields length
245
- raise VariantFieldsLengthNotMatch, "type: #{variant_type}, \nvalue: #{v}" if item._get(:fields).length > 1 && item._get(:fields).length != v.length
261
+ if item._get(:fields).length > 1 && item._get(:fields).length != v.length
262
+ raise VariantFieldsLengthNotMatch,
263
+ "type: #{variant_type}, \nvalue: #{v}"
264
+ end
246
265
 
247
266
  ScaleRb.encode_uint('u8', item._get(:index)) + encode_composite(item, v, registry)
248
267
  end
@@ -1,3 +1,3 @@
1
1
  module ScaleRb
2
- VERSION = '0.1.10'
2
+ VERSION = '0.1.11'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scale_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aki Wu