scale.rb 0.2.7 → 0.2.8
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 +1 -1
- data/lib/metadata/metadata_v12.rb +87 -0
- data/lib/scale.rb +1 -0
- data/lib/scale/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1efdbfb5ae89e2d4ff5abf3ca77717b3c95df5fbcd0e196066d813a03b80c7b
|
4
|
+
data.tar.gz: d8ce883df1522681efa389822fadd93da861685dbe5bc9e16206d2a97bd4a0de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff7098aca9829ed818bcfe59a9a9cbeed492aead969619ab9acb62c47b6f6fce85d5519dc30a2e4d4816658528d0c9c1db2f4ff1c653b15646d2c1a4929d0435
|
7
|
+
data.tar.gz: 1034c3b87ffcbf8516cc23c4bcb5f524c096f78e6343901a10864ac4c94832f569c935807a70181fcb43b2ddbabc268b41902a649b5e45868377d5fe55b695a5
|
data/Gemfile.lock
CHANGED
data/lib/metadata/metadata.rb
CHANGED
@@ -6,7 +6,7 @@ module Scale
|
|
6
6
|
def self.decode(scale_bytes)
|
7
7
|
bytes = scale_bytes.get_next_bytes(4)
|
8
8
|
if bytes.bytes_to_utf8 == "meta"
|
9
|
-
metadata_version = Scale::Types.type_of("Enum", %w[MetadataV0 MetadataV1 MetadataV2 MetadataV3 MetadataV4 MetadataV5 MetadataV6 MetadataV7 MetadataV8 MetadataV9 MetadataV10 MetadataV11]).decode(scale_bytes).value
|
9
|
+
metadata_version = Scale::Types.type_of("Enum", %w[MetadataV0 MetadataV1 MetadataV2 MetadataV3 MetadataV4 MetadataV5 MetadataV6 MetadataV7 MetadataV8 MetadataV9 MetadataV10 MetadataV11 MetadataV12]).decode(scale_bytes).value
|
10
10
|
metadata = Metadata.new "Scale::Types::#{metadata_version}".constantize.decode(scale_bytes)
|
11
11
|
metadata.version = metadata_version[9..].to_i
|
12
12
|
else
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Scale
|
2
|
+
module Types
|
3
|
+
class MetadataV12
|
4
|
+
include SingleValue
|
5
|
+
attr_accessor :call_index, :event_index
|
6
|
+
|
7
|
+
def initialize(value)
|
8
|
+
@call_index = {}
|
9
|
+
@event_index = {}
|
10
|
+
super(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.decode(scale_bytes)
|
14
|
+
modules = Scale::Types.type_of("Vec<MetadataV12Module>").decode(scale_bytes).value
|
15
|
+
|
16
|
+
value = {
|
17
|
+
magicNumber: 1_635_018_093,
|
18
|
+
metadata: {
|
19
|
+
version: 12,
|
20
|
+
modules: modules.map(&:value)
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
result = MetadataV12.new(value)
|
25
|
+
|
26
|
+
call_module_index = 0
|
27
|
+
event_module_index = 0
|
28
|
+
|
29
|
+
modules.map(&:value).each do |m|
|
30
|
+
if m[:calls]
|
31
|
+
m[:calls].each_with_index do |call, index|
|
32
|
+
call[:lookup] = "%02x%02x" % [call_module_index, index]
|
33
|
+
result.call_index[call[:lookup]] = [m, call]
|
34
|
+
end
|
35
|
+
call_module_index += 1
|
36
|
+
end
|
37
|
+
|
38
|
+
if m[:events]
|
39
|
+
m[:events].each_with_index do |event, index|
|
40
|
+
event[:lookup] = "%02x%02x" % [event_module_index, index]
|
41
|
+
result.event_index[event[:lookup]] = [m, event]
|
42
|
+
end
|
43
|
+
event_module_index += 1
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
result
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class MetadataV12Module
|
52
|
+
include SingleValue
|
53
|
+
def self.decode(scale_bytes)
|
54
|
+
name = String.decode(scale_bytes).value
|
55
|
+
|
56
|
+
result = {
|
57
|
+
name: name
|
58
|
+
}
|
59
|
+
|
60
|
+
has_storage = Bool.decode(scale_bytes).value
|
61
|
+
if has_storage
|
62
|
+
storage = MetadataV7ModuleStorage.decode(scale_bytes).value
|
63
|
+
result[:storage] = storage
|
64
|
+
result[:prefix] = storage[:prefix]
|
65
|
+
end
|
66
|
+
|
67
|
+
has_calls = Bool.decode(scale_bytes).value
|
68
|
+
if has_calls
|
69
|
+
calls = Scale::Types.type_of("Vec<MetadataModuleCall>").decode(scale_bytes).value
|
70
|
+
result[:calls] = calls.map(&:value)
|
71
|
+
end
|
72
|
+
|
73
|
+
has_events = Bool.decode(scale_bytes).value
|
74
|
+
if has_events
|
75
|
+
events = Scale::Types.type_of("Vec<MetadataModuleEvent>").decode(scale_bytes).value
|
76
|
+
result[:events] = events.map(&:value)
|
77
|
+
end
|
78
|
+
|
79
|
+
result[:constants] = Scale::Types.type_of("Vec<MetadataV7ModuleConstants>").decode(scale_bytes).value.map(&:value)
|
80
|
+
result[:errors] = Scale::Types.type_of("Vec<MetadataModuleError>").decode(scale_bytes).value.map(&:value)
|
81
|
+
|
82
|
+
result[:index] = U8.decode(scale_bytes).value
|
83
|
+
MetadataV12Module.new(result)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/scale.rb
CHANGED
data/lib/scale/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.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wu Minzhe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: substrate_common.rb
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- lib/metadata/metadata_v1.rb
|
166
166
|
- lib/metadata/metadata_v10.rb
|
167
167
|
- lib/metadata/metadata_v11.rb
|
168
|
+
- lib/metadata/metadata_v12.rb
|
168
169
|
- lib/metadata/metadata_v2.rb
|
169
170
|
- lib/metadata/metadata_v3.rb
|
170
171
|
- lib/metadata/metadata_v4.rb
|