scale_rb 0.5.0 → 0.5.1

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: cb19be98106d9f8331a9be9812f6252c23d6913cbd98cedcae34bf1a464e7b90
4
- data.tar.gz: cff1e034d85f130ed7d149628647f020adb9ffc532d9646bceda054007d6bf14
3
+ metadata.gz: 75a96df563f9cf0f827e034820d94316a898c4b3cab693524ee092b116c28146
4
+ data.tar.gz: 55201185ee42018db38f922fced2a30230f43f551274bbfd495dc386ac6b440d
5
5
  SHA512:
6
- metadata.gz: de658214901aa13071c6b8d0c1aa94c8db0b2cee3c6c1df3207eb0881399c12215ce6c05a7d89c7da115e279a60fbe4688710e5f3fba827d5bd729afb7275e59
7
- data.tar.gz: 999f5311c1a66933281798c40bbb3b7956e528b3164c264f2a7694fa48c142683e49ff47a185c1e174501b2e8c3b083d2bd513d1e6c37cffff9002d9186908e4
6
+ metadata.gz: 281c57184f73484c691b0be6076b0fb101428a0d980b3733550d0be25584cef103ff60650a671878ce03480724190308176a5c75b2c0f4faf906c3a7dae1e15b
7
+ data.tar.gz: 3be191954b301954da10e579ac326ab3cfe9c98d21d7205580ed1816b5ee1946bf08d8e4f13d4a9db17229aea6bfcac6265d80e11b23d613a33c744aa1890be4
@@ -18,8 +18,7 @@ module ScaleRb
18
18
  bytes = ScaleRb::Utils.hex_to_u8a(hex)
19
19
 
20
20
  registry = ScaleRb::Metadata::Registry.new TYPES
21
- ti = registry.use('MetadataPrefixed')
22
- metadata, = ScaleRb::Codec.decode(ti, bytes, registry)
21
+ metadata, = ScaleRb::Codec.decode('MetadataPrefixed', bytes, registry)
23
22
  metadata
24
23
  end
25
24
 
@@ -37,8 +37,14 @@ module ScaleRb
37
37
  end
38
38
  end
39
39
 
40
- def [](index)
41
- @types[index]
40
+ def [](identifier)
41
+ if identifier.is_a?(::Integer)
42
+ @types[identifier]
43
+ elsif identifier.is_a?(::String)
44
+ @types[use(identifier)]
45
+ else
46
+ raise "Unknown identifier type: #{identifier.class}"
47
+ end
42
48
  end
43
49
 
44
50
  def inspect
@@ -10,8 +10,9 @@ module ScaleRb
10
10
  Primitive = Types::Strict::Symbol.enum(
11
11
  :I8, :U8, :I16, :U16, :I32, :U32, :I64, :U64, :I128, :U128, :I256, :U256, :Bool, :Str, :Char
12
12
  )
13
- Ti = Types::Strict::Integer.constrained(gteq: 0)
14
- U8 = Types::Strict::Integer.constrained(gteq: 0, lt: 256)
13
+ Ti = Types::Strict::Integer | Types::Strict::String
14
+ # U8 = Types::Strict::Integer.constrained(gteq: 0, lt: 256)
15
+ U8 = Types::Strict::Integer
15
16
  U8Array = Types::Strict::Array.of(U8)
16
17
  Hex = Types::Strict::String.constrained(format: /\A0x[0-9a-fA-F]+\z/)
17
18
 
@@ -1,3 +1,3 @@
1
1
  module ScaleRb
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scale_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aki Wu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-13 00:00:00.000000000 Z
11
+ date: 2024-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base58