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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 241f9857282220d19480bed1cf2a1bcaeacd0948963a65455ee1c57b708ed4d6
4
- data.tar.gz: 8ab8fad9f853c7f3d1d57bf9f283b2fbe16a6d17bb2f1221b84ff3a78feff34c
3
+ metadata.gz: a4ecdacacab52152c1db21cd934b452fca391320112c7a8a1c5a8479b4df9946
4
+ data.tar.gz: 637a12f9313b048bcd7e5c77dd34862225db553b0e42f620736aea5c78505a49
5
5
  SHA512:
6
- metadata.gz: b712d5a8dc5a9c6c90580467f81939b843e876bc4bbf7f6b53bccbeb12a411e8104acffdfd3419ad70d760c4f375862c09de1b6964c5e4ecf8a92cdc4efdfdb2
7
- data.tar.gz: 2b9cb6bb007b0dbff88839e3e811628241290de7383e1f85cfc68ba7a7936ea85d0a479d54035854d18e3cf79685aba1bf8f7f0d7b519ab4089cd75048f0262a
6
+ metadata.gz: 18c6f40b6f41b3fa59a08c93a44b348e94642fe510f695576b164d5b0ad70362bfa0ade33823c422b85b9db55f2f23995598c9990c2a4b7c6e6113cb17b73ba0
7
+ data.tar.gz: bbb523afb3209dfd58827094cc4f1fce4d841fff5bba5b94538a736edac05803fb0dd3624dcedc5d2c068944614f7d43e053528574df402713f56b9ecb03c2ce
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scale_rb (0.1.8)
4
+ scale_rb (0.1.9)
5
5
  base58
6
6
  blake2b_rs (~> 0.1.4)
7
7
  xxhash
@@ -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 get_calls_type_id(pallet_name, metadata)
39
- pallet = get_module(pallet_name, metadata)
40
- raise "Pallet `#{pallet_name}` not found" if pallet.nil?
41
- pallet._get(:calls)._get(:type)
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
 
@@ -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?
@@ -1,3 +1,3 @@
1
1
  module ScaleRb
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
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.1.8
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-05 00:00:00.000000000 Z
11
+ date: 2023-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: blake2b_rs