scale_rb 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/metadata/metadata.rb +7 -0
- data/lib/metadata/metadata_v14.rb +11 -4
- data/lib/portable_codec.rb +1 -1
- data/lib/scale_rb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4ecdacacab52152c1db21cd934b452fca391320112c7a8a1c5a8479b4df9946
|
4
|
+
data.tar.gz: 637a12f9313b048bcd7e5c77dd34862225db553b0e42f620736aea5c78505a49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18c6f40b6f41b3fa59a08c93a44b348e94642fe510f695576b164d5b0ad70362bfa0ade33823c422b85b9db55f2f23995598c9990c2a4b7c6e6113cb17b73ba0
|
7
|
+
data.tar.gz: bbb523afb3209dfd58827094cc4f1fce4d841fff5bba5b94538a736edac05803fb0dd3624dcedc5d2c068944614f7d43e053528574df402713f56b9ecb03c2ce
|
data/Gemfile.lock
CHANGED
data/lib/metadata/metadata.rb
CHANGED
@@ -49,6 +49,13 @@ module Metadata
|
|
49
49
|
Metadata.const_get("Metadata#{version.upcase}").get_calls_type_id(pallet_name, metadata)
|
50
50
|
end
|
51
51
|
|
52
|
+
def get_call_type(pallet_name, call_name, metadata)
|
53
|
+
version = metadata._get(:metadata).keys.first
|
54
|
+
raise ScaleRb::NotImplemented, metadata._get(:metadata).keys.first unless %w[v9 v10 v11 v12 v13 v14].include?(version.to_s)
|
55
|
+
|
56
|
+
Metadata.const_get("Metadata#{version.upcase}").get_call_type(pallet_name, call_name, metadata)
|
57
|
+
end
|
58
|
+
|
52
59
|
# call examples:
|
53
60
|
# {:pallet_name=>"Deposit", :call_name=>"Claim", :call=>["claim", []]}
|
54
61
|
# {:pallet_name=>"Balances", :call_name=>"Transfer", :call=>[{:transfer=>{:dest=>[10, 18, 135, 151, 117, 120, 248, 136, 189, 193, 199, 98, 119, 129, 175, 28, 192, 0, 230, 171], :value=>11000000000000000000}}, []]}
|
@@ -28,6 +28,12 @@ module Metadata
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def get_calls_type_id(pallet_name, metadata)
|
32
|
+
pallet = get_module(pallet_name, metadata)
|
33
|
+
raise "Pallet `#{pallet_name}` not found" if pallet.nil?
|
34
|
+
pallet._get(:calls)._get(:type)
|
35
|
+
end
|
36
|
+
|
31
37
|
def get_calls_type(pallet_name, metadata)
|
32
38
|
type_id = get_calls_type_id(pallet_name, metadata)
|
33
39
|
metadata._get(:metadata)._get(:v14)._get(:lookup)._get(:types).find do |type|
|
@@ -35,10 +41,11 @@ module Metadata
|
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
def get_call_type(pallet_name, call_name, metadata)
|
45
|
+
calls_type = get_calls_type(pallet_name, metadata)
|
46
|
+
calls_type._get(:type)._get(:def)._get(:variant)._get(:variants).find do |variant|
|
47
|
+
variant._get(:name).downcase == call_name.downcase
|
48
|
+
end
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
data/lib/portable_codec.rb
CHANGED
@@ -112,7 +112,7 @@ module PortableCodec
|
|
112
112
|
def decode_variant(variant_type, bytes, registry)
|
113
113
|
variants = variant_type._get(:variants)
|
114
114
|
|
115
|
-
index = bytes[0]
|
115
|
+
index = bytes[0].to_i # TODO: check
|
116
116
|
item = variants.find { |v| v._get(:index) == index } # item is an composite
|
117
117
|
|
118
118
|
raise VariantIndexOutOfRange, "type: #{variant_type}, index: #{index}, bytes: #{bytes}" if item.nil?
|
data/lib/scale_rb/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aki Wu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blake2b_rs
|