scale_rb 0.1.14 → 0.2.0
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/address.rb +85 -89
- data/lib/client/abstract_ws_client.rb +85 -81
- data/lib/client/http_client.rb +2 -170
- data/lib/client/http_client_metadata.rb +10 -8
- data/lib/client/http_client_storage.rb +180 -0
- data/lib/client/rpc_request_builder.rb +44 -42
- data/lib/codec.rb +28 -29
- data/lib/hasher.rb +39 -37
- data/lib/metadata/metadata.rb +130 -122
- data/lib/metadata/metadata_v10.rb +72 -69
- data/lib/metadata/metadata_v11.rb +78 -75
- data/lib/metadata/metadata_v12.rb +42 -39
- data/lib/metadata/metadata_v13.rb +71 -68
- data/lib/metadata/metadata_v14.rb +185 -181
- data/lib/metadata/metadata_v9.rb +92 -89
- data/lib/monkey_patching.rb +22 -22
- data/lib/portable_codec.rb +236 -232
- data/lib/scale_rb/version.rb +1 -1
- data/lib/scale_rb.rb +0 -1
- data/lib/storage_helper.rb +52 -50
- metadata +3 -2
data/lib/metadata/metadata.rb
CHANGED
@@ -1,129 +1,137 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module ScaleRb
|
4
|
+
module Metadata
|
5
|
+
class << self
|
6
|
+
def decode_metadata(bytes)
|
7
|
+
metadata, = ScaleRb.decode('MetadataTop', bytes, TYPES)
|
8
|
+
metadata
|
9
|
+
end
|
10
|
+
|
11
|
+
def build_registry(metadata)
|
12
|
+
raise ScaleRb::NotImplemented, metadata._get(:metadata).keys.first unless metadata._get(:metadata)._key?(:v14)
|
13
|
+
|
14
|
+
metadata_v14 = metadata._get(:metadata)._get(:v14)
|
15
|
+
MetadataV14.build_registry(metadata_v14)
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_module(pallet_name, metadata)
|
19
|
+
version = metadata._get(:metadata).keys.first
|
20
|
+
raise ScaleRb::NotImplemented, metadata._get(:metadata).keys.first unless %w[v9 v10 v11 v12 v13
|
21
|
+
v14].include?(version.to_s)
|
22
|
+
|
23
|
+
Metadata.const_get("Metadata#{version.upcase}").get_module(pallet_name, metadata)
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_module_by_index(pallet_index, metadata)
|
27
|
+
version = metadata._get(:metadata).keys.first
|
28
|
+
raise ScaleRb::NotImplemented, metadata._get(:metadata).keys.first unless %w[v9 v10 v11 v12 v13
|
29
|
+
v14].include?(version.to_s)
|
30
|
+
|
31
|
+
Metadata.const_get("Metadata#{version.upcase}").get_module_by_index(pallet_index, metadata)
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_storage_item(pallet_name, item_name, metadata)
|
35
|
+
version = metadata._get(:metadata).keys.first
|
36
|
+
raise ScaleRb::NotImplemented, metadata._get(:metadata).keys.first unless %w[v9 v10 v11 v12 v13
|
37
|
+
v14].include?(version.to_s)
|
38
|
+
|
39
|
+
Metadata.const_get("Metadata#{version.upcase}").get_storage_item(pallet_name, item_name, metadata)
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_calls_type(pallet_name, metadata)
|
43
|
+
version = metadata._get(:metadata).keys.first
|
44
|
+
raise ScaleRb::NotImplemented, metadata._get(:metadata).keys.first unless %w[v9 v10 v11 v12 v13
|
45
|
+
v14].include?(version.to_s)
|
46
|
+
|
47
|
+
Metadata.const_get("Metadata#{version.upcase}").get_calls_type(pallet_name, metadata)
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_calls_type_id(pallet_name, metadata)
|
51
|
+
version = metadata._get(:metadata).keys.first
|
52
|
+
raise ScaleRb::NotImplemented, metadata._get(:metadata).keys.first unless %w[v9 v10 v11 v12 v13
|
53
|
+
v14].include?(version.to_s)
|
54
|
+
|
55
|
+
Metadata.const_get("Metadata#{version.upcase}").get_calls_type_id(pallet_name, metadata)
|
56
|
+
end
|
57
|
+
|
58
|
+
def get_call_type(pallet_name, call_name, metadata)
|
59
|
+
version = metadata._get(:metadata).keys.first
|
60
|
+
raise ScaleRb::NotImplemented, metadata._get(:metadata).keys.first unless %w[v9 v10 v11 v12 v13
|
61
|
+
v14].include?(version.to_s)
|
62
|
+
|
63
|
+
Metadata.const_get("Metadata#{version.upcase}").get_call_type(pallet_name, call_name, metadata)
|
64
|
+
end
|
65
|
+
|
66
|
+
# call examples:
|
67
|
+
# {:pallet_name=>"Deposit", :call_name=>"Claim", :call=>["claim", []]}
|
68
|
+
# {: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}}, []]}
|
69
|
+
def encode_call(call, metadata)
|
70
|
+
calls_type_id = get_calls_type_id(call[:pallet_name], metadata)
|
71
|
+
pallet_index = get_module(call[:pallet_name], metadata)._get(:index)
|
72
|
+
[pallet_index] + PortableCodec.encode(calls_type_id, call[:call].first, build_registry(metadata))
|
73
|
+
end
|
74
|
+
|
75
|
+
# callbytes's structure is: pallet_index + call_index + argsbytes
|
76
|
+
#
|
77
|
+
# callbytes examples:
|
78
|
+
# "0x0901"._to_bytes
|
79
|
+
# "0x05000a1287977578f888bdc1c7627781af1cc000e6ab1300004c31b8d9a798"._to_bytes
|
80
|
+
def decode_call(callbytes, metadata)
|
81
|
+
pallet_index = callbytes[0]
|
82
|
+
pallet = get_module_by_index(pallet_index, metadata)
|
83
|
+
|
84
|
+
pallet_name = pallet._get(:name)
|
85
|
+
|
86
|
+
# Remove the pallet_index
|
87
|
+
# The callbytes we used below should not contain the pallet index.
|
88
|
+
# This is because the pallet index is not part of the call type.
|
89
|
+
# Its structure is: call_index + call_args
|
90
|
+
callbytes_without_pallet_index = callbytes[1..]
|
91
|
+
calls_type_id = pallet._get(:calls)._get(:type)
|
92
|
+
decoded = PortableCodec.decode(
|
93
|
+
calls_type_id,
|
94
|
+
callbytes_without_pallet_index,
|
95
|
+
build_registry(metadata)
|
96
|
+
)
|
97
|
+
|
98
|
+
{
|
99
|
+
pallet_name: pallet_name,
|
100
|
+
call_name: decoded.first.is_a?(String) ? decoded.first._to_camel : decoded.first.keys.first.to_s._to_camel,
|
101
|
+
call: decoded
|
102
|
+
}
|
103
|
+
end
|
8
104
|
end
|
9
105
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
raise ScaleRb::NotImplemented, metadata._get(:metadata).keys.first unless %w[v9 v10 v11 v12 v13 v14].include?(version.to_s)
|
34
|
-
|
35
|
-
Metadata.const_get("Metadata#{version.upcase}").get_storage_item(pallet_name, item_name, metadata)
|
36
|
-
end
|
37
|
-
|
38
|
-
def get_calls_type(pallet_name, metadata)
|
39
|
-
version = metadata._get(:metadata).keys.first
|
40
|
-
raise ScaleRb::NotImplemented, metadata._get(:metadata).keys.first unless %w[v9 v10 v11 v12 v13 v14].include?(version.to_s)
|
41
|
-
|
42
|
-
Metadata.const_get("Metadata#{version.upcase}").get_calls_type(pallet_name, metadata)
|
43
|
-
end
|
44
|
-
|
45
|
-
def get_calls_type_id(pallet_name, metadata)
|
46
|
-
version = metadata._get(:metadata).keys.first
|
47
|
-
raise ScaleRb::NotImplemented, metadata._get(:metadata).keys.first unless %w[v9 v10 v11 v12 v13 v14].include?(version.to_s)
|
48
|
-
|
49
|
-
Metadata.const_get("Metadata#{version.upcase}").get_calls_type_id(pallet_name, metadata)
|
50
|
-
end
|
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
|
-
|
59
|
-
# call examples:
|
60
|
-
# {:pallet_name=>"Deposit", :call_name=>"Claim", :call=>["claim", []]}
|
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}}, []]}
|
62
|
-
def encode_call(call, metadata)
|
63
|
-
calls_type_id = get_calls_type_id(call[:pallet_name], metadata)
|
64
|
-
pallet_index = get_module(call[:pallet_name], metadata)._get(:index)
|
65
|
-
[pallet_index] + PortableCodec.encode(calls_type_id, call[:call].first, build_registry(metadata))
|
66
|
-
end
|
67
|
-
|
68
|
-
# callbytes's structure is: pallet_index + call_index + argsbytes
|
69
|
-
#
|
70
|
-
# callbytes examples:
|
71
|
-
# "0x0901".to_bytes
|
72
|
-
# "0x05000a1287977578f888bdc1c7627781af1cc000e6ab1300004c31b8d9a798".to_bytes
|
73
|
-
def decode_call(callbytes, metadata)
|
74
|
-
pallet_index = callbytes[0]
|
75
|
-
pallet = get_module_by_index(pallet_index, metadata)
|
76
|
-
|
77
|
-
pallet_name = pallet._get(:name)
|
78
|
-
|
79
|
-
# Remove the pallet_index
|
80
|
-
# The callbytes we used below should not contain the pallet index.
|
81
|
-
# This is because the pallet index is not part of the call type.
|
82
|
-
# Its structure is: call_index + call_args
|
83
|
-
callbytes_without_pallet_index = callbytes[1..]
|
84
|
-
calls_type_id = pallet._get(:calls)._get(:type)
|
85
|
-
decoded = PortableCodec.decode(
|
86
|
-
calls_type_id,
|
87
|
-
callbytes_without_pallet_index,
|
88
|
-
build_registry(metadata)
|
89
|
-
)
|
90
|
-
|
91
|
-
{
|
92
|
-
pallet_name: pallet_name,
|
93
|
-
call_name: decoded.first.is_a?(String) ? decoded.first.to_camel : decoded.first.keys.first.to_s.to_camel,
|
94
|
-
call: decoded
|
106
|
+
TYPES = {
|
107
|
+
'MetadataTop' => {
|
108
|
+
magicNumber: 'U32',
|
109
|
+
metadata: 'Metadata'
|
110
|
+
},
|
111
|
+
'Metadata' => {
|
112
|
+
_enum: {
|
113
|
+
v0: 'MetadataV0',
|
114
|
+
v1: 'MetadataV1',
|
115
|
+
v2: 'MetadataV2',
|
116
|
+
v3: 'MetadataV3',
|
117
|
+
v4: 'MetadataV4',
|
118
|
+
v5: 'MetadataV5',
|
119
|
+
v6: 'MetadataV6',
|
120
|
+
v7: 'MetadataV7',
|
121
|
+
v8: 'MetadataV8',
|
122
|
+
v9: 'MetadataV9',
|
123
|
+
v10: 'MetadataV10',
|
124
|
+
v11: 'MetadataV11',
|
125
|
+
v12: 'MetadataV12',
|
126
|
+
v13: 'MetadataV13',
|
127
|
+
v14: 'MetadataV14'
|
128
|
+
}
|
95
129
|
}
|
96
|
-
|
130
|
+
}.merge(MetadataV14::TYPES)
|
131
|
+
.merge(MetadataV13::TYPES)
|
132
|
+
.merge(MetadataV12::TYPES)
|
133
|
+
.merge(MetadataV11::TYPES)
|
134
|
+
.merge(MetadataV10::TYPES)
|
135
|
+
.merge(MetadataV9::TYPES)
|
97
136
|
end
|
98
|
-
|
99
|
-
TYPES = {
|
100
|
-
'MetadataTop' => {
|
101
|
-
magicNumber: 'U32',
|
102
|
-
metadata: 'Metadata'
|
103
|
-
},
|
104
|
-
'Metadata' => {
|
105
|
-
_enum: {
|
106
|
-
v0: 'MetadataV0',
|
107
|
-
v1: 'MetadataV1',
|
108
|
-
v2: 'MetadataV2',
|
109
|
-
v3: 'MetadataV3',
|
110
|
-
v4: 'MetadataV4',
|
111
|
-
v5: 'MetadataV5',
|
112
|
-
v6: 'MetadataV6',
|
113
|
-
v7: 'MetadataV7',
|
114
|
-
v8: 'MetadataV8',
|
115
|
-
v9: 'MetadataV9',
|
116
|
-
v10: 'MetadataV10',
|
117
|
-
v11: 'MetadataV11',
|
118
|
-
v12: 'MetadataV12',
|
119
|
-
v13: 'MetadataV13',
|
120
|
-
v14: 'MetadataV14'
|
121
|
-
}
|
122
|
-
}
|
123
|
-
}.merge(MetadataV14::TYPES)
|
124
|
-
.merge(MetadataV13::TYPES)
|
125
|
-
.merge(MetadataV12::TYPES)
|
126
|
-
.merge(MetadataV11::TYPES)
|
127
|
-
.merge(MetadataV10::TYPES)
|
128
|
-
.merge(MetadataV9::TYPES)
|
129
137
|
end
|
@@ -1,80 +1,83 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
module ScaleRb
|
4
|
+
module Metadata
|
5
|
+
module MetadataV10
|
6
|
+
class << self
|
7
|
+
def get_module(module_name, metadata)
|
8
|
+
metadata._get(:metadata)._get(:v10)._get(:modules).find do |m|
|
9
|
+
m._get(:name) == module_name
|
10
|
+
end
|
9
11
|
end
|
10
|
-
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def get_storage_item(module_name, item_name, metadata)
|
14
|
+
modula = get_module(module_name, metadata)
|
15
|
+
raise "Module `#{module_name}` not found" if modula.nil?
|
16
|
+
|
17
|
+
modula._get(:storage)._get(:items).find do |item|
|
18
|
+
item._get(:name) == item_name
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
19
|
-
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
23
|
+
TYPES = {
|
24
|
+
ErrorMetadataV10: 'ErrorMetadataV9',
|
25
|
+
EventMetadataV10: 'EventMetadataV9',
|
26
|
+
FunctionArgumentMetadataV10: 'FunctionArgumentMetadataV9',
|
27
|
+
FunctionMetadataV10: 'FunctionMetadataV9',
|
28
|
+
MetadataV10: {
|
29
|
+
modules: 'Vec<ModuleMetadataV10>'
|
30
|
+
},
|
31
|
+
ModuleConstantMetadataV10: 'ModuleConstantMetadataV9',
|
32
|
+
ModuleMetadataV10: {
|
33
|
+
name: 'Text',
|
34
|
+
storage: 'Option<StorageMetadataV10>',
|
35
|
+
calls: 'Option<Vec<FunctionMetadataV10>>',
|
36
|
+
events: 'Option<Vec<EventMetadataV10>>',
|
37
|
+
constants: 'Vec<ModuleConstantMetadataV10>',
|
38
|
+
errors: 'Vec<ErrorMetadataV10>'
|
39
|
+
},
|
40
|
+
StorageEntryModifierV10: 'StorageEntryModifierV9',
|
41
|
+
StorageEntryMetadataV10: {
|
42
|
+
name: 'Text',
|
43
|
+
modifier: 'StorageEntryModifierV10',
|
44
|
+
type: 'StorageEntryTypeV10',
|
45
|
+
fallback: 'Bytes',
|
46
|
+
docs: 'Vec<Text>'
|
47
|
+
},
|
48
|
+
StorageEntryTypeV10: {
|
49
|
+
_enum: {
|
50
|
+
Plain: 'Type',
|
51
|
+
Map: {
|
52
|
+
hasher: 'StorageHasherV10',
|
53
|
+
key: 'Type',
|
54
|
+
value: 'Type',
|
55
|
+
linked: 'bool'
|
56
|
+
},
|
57
|
+
DoubleMap: {
|
58
|
+
hasher: 'StorageHasherV10',
|
59
|
+
key1: 'Type',
|
60
|
+
key2: 'Type',
|
61
|
+
value: 'Type',
|
62
|
+
key2Hasher: 'StorageHasherV10'
|
63
|
+
}
|
61
64
|
}
|
65
|
+
},
|
66
|
+
StorageMetadataV10: {
|
67
|
+
prefix: 'Text',
|
68
|
+
items: 'Vec<StorageEntryMetadataV10>'
|
69
|
+
},
|
70
|
+
StorageHasherV10: {
|
71
|
+
_enum: %w[
|
72
|
+
Blake2_128
|
73
|
+
Blake2_256
|
74
|
+
Blake2_128Concat
|
75
|
+
Twox128
|
76
|
+
Twox256
|
77
|
+
Twox64Concat
|
78
|
+
]
|
62
79
|
}
|
63
|
-
}
|
64
|
-
|
65
|
-
prefix: 'Text',
|
66
|
-
items: 'Vec<StorageEntryMetadataV10>'
|
67
|
-
},
|
68
|
-
StorageHasherV10: {
|
69
|
-
_enum: %w[
|
70
|
-
Blake2_128
|
71
|
-
Blake2_256
|
72
|
-
Blake2_128Concat
|
73
|
-
Twox128
|
74
|
-
Twox256
|
75
|
-
Twox64Concat
|
76
|
-
]
|
77
|
-
}
|
78
|
-
}.freeze
|
80
|
+
}.freeze
|
81
|
+
end
|
79
82
|
end
|
80
83
|
end
|
@@ -1,86 +1,89 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
module ScaleRb
|
4
|
+
module Metadata
|
5
|
+
module MetadataV11
|
6
|
+
class << self
|
7
|
+
def get_module(module_name, metadata)
|
8
|
+
metadata._get(:metadata)._get(:v11)._get(:modules).find do |m|
|
9
|
+
m._get(:name) == module_name
|
10
|
+
end
|
9
11
|
end
|
10
|
-
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def get_storage_item(module_name, item_name, metadata)
|
14
|
+
modula = get_module(module_name, metadata)
|
15
|
+
raise "Module `#{module_name}` not found" if modula.nil?
|
16
|
+
|
17
|
+
modula._get(:storage)._get(:items).find do |item|
|
18
|
+
item._get(:name) == item_name
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
19
|
-
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
23
|
+
TYPES = {
|
24
|
+
ErrorMetadataV11: 'ErrorMetadataV10',
|
25
|
+
EventMetadataV11: 'EventMetadataV10',
|
26
|
+
ExtrinsicMetadataV11: {
|
27
|
+
version: 'u8',
|
28
|
+
signedExtensions: 'Vec<Text>'
|
29
|
+
},
|
30
|
+
FunctionArgumentMetadataV11: 'FunctionArgumentMetadataV10',
|
31
|
+
FunctionMetadataV11: 'FunctionMetadataV10',
|
32
|
+
MetadataV11: {
|
33
|
+
modules: 'Vec<ModuleMetadataV11>',
|
34
|
+
extrinsic: 'ExtrinsicMetadataV11'
|
35
|
+
},
|
36
|
+
ModuleConstantMetadataV11: 'ModuleConstantMetadataV10',
|
37
|
+
ModuleMetadataV11: {
|
38
|
+
name: 'Text',
|
39
|
+
storage: 'Option<StorageMetadataV11>',
|
40
|
+
calls: 'Option<Vec<FunctionMetadataV11>>',
|
41
|
+
events: 'Option<Vec<EventMetadataV11>>',
|
42
|
+
constants: 'Vec<ModuleConstantMetadataV11>',
|
43
|
+
errors: 'Vec<ErrorMetadataV11>'
|
44
|
+
},
|
45
|
+
StorageEntryModifierV11: 'StorageEntryModifierV10',
|
46
|
+
StorageEntryMetadataV11: {
|
47
|
+
name: 'Text',
|
48
|
+
modifier: 'StorageEntryModifierV11',
|
49
|
+
type: 'StorageEntryTypeV11',
|
50
|
+
fallback: 'Bytes',
|
51
|
+
docs: 'Vec<Text>'
|
52
|
+
},
|
53
|
+
StorageEntryTypeV11: {
|
54
|
+
_enum: {
|
55
|
+
Plain: 'Type',
|
56
|
+
Map: {
|
57
|
+
hasher: 'StorageHasherV11',
|
58
|
+
key: 'Type',
|
59
|
+
value: 'Type',
|
60
|
+
linked: 'bool'
|
61
|
+
},
|
62
|
+
DoubleMap: {
|
63
|
+
hasher: 'StorageHasherV11',
|
64
|
+
key1: 'Type',
|
65
|
+
key2: 'Type',
|
66
|
+
value: 'Type',
|
67
|
+
key2Hasher: 'StorageHasherV11'
|
68
|
+
}
|
66
69
|
}
|
70
|
+
},
|
71
|
+
StorageMetadataV11: {
|
72
|
+
prefix: 'Text',
|
73
|
+
items: 'Vec<StorageEntryMetadataV11>'
|
74
|
+
},
|
75
|
+
StorageHasherV11: {
|
76
|
+
_enum: %w[
|
77
|
+
Blake2_128
|
78
|
+
Blake2_256
|
79
|
+
Blake2_128Concat
|
80
|
+
Twox128
|
81
|
+
Twox256
|
82
|
+
Twox64Concat
|
83
|
+
Identity
|
84
|
+
]
|
67
85
|
}
|
68
|
-
}
|
69
|
-
|
70
|
-
prefix: 'Text',
|
71
|
-
items: 'Vec<StorageEntryMetadataV11>'
|
72
|
-
},
|
73
|
-
StorageHasherV11: {
|
74
|
-
_enum: %w[
|
75
|
-
Blake2_128
|
76
|
-
Blake2_256
|
77
|
-
Blake2_128Concat
|
78
|
-
Twox128
|
79
|
-
Twox256
|
80
|
-
Twox64Concat
|
81
|
-
Identity
|
82
|
-
]
|
83
|
-
}
|
84
|
-
}.freeze
|
86
|
+
}.freeze
|
87
|
+
end
|
85
88
|
end
|
86
89
|
end
|
@@ -1,48 +1,51 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
module ScaleRb
|
4
|
+
module Metadata
|
5
|
+
module MetadataV12
|
6
|
+
class << self
|
7
|
+
def get_module(module_name, metadata)
|
8
|
+
metadata._get(:metadata)._get(:v12)._get(:modules).find do |m|
|
9
|
+
m._get(:name) == module_name
|
10
|
+
end
|
9
11
|
end
|
10
|
-
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def get_storage_item(module_name, item_name, metadata)
|
14
|
+
modula = get_module(module_name, metadata)
|
15
|
+
raise "Module `#{module_name}` not found" if modula.nil?
|
16
|
+
|
17
|
+
modula._get(:storage)._get(:items).find do |item|
|
18
|
+
item._get(:name) == item_name
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
19
|
-
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
23
|
+
TYPES = {
|
24
|
+
ErrorMetadataV12: 'ErrorMetadataV11',
|
25
|
+
EventMetadataV12: 'EventMetadataV11',
|
26
|
+
ExtrinsicMetadataV12: 'ExtrinsicMetadataV11',
|
27
|
+
FunctionArgumentMetadataV12: 'FunctionArgumentMetadataV11',
|
28
|
+
FunctionMetadataV12: 'FunctionMetadataV11',
|
29
|
+
MetadataV12: {
|
30
|
+
modules: 'Vec<ModuleMetadataV12>',
|
31
|
+
extrinsic: 'ExtrinsicMetadataV12'
|
32
|
+
},
|
33
|
+
ModuleConstantMetadataV12: 'ModuleConstantMetadataV11',
|
34
|
+
ModuleMetadataV12: {
|
35
|
+
name: 'Text',
|
36
|
+
storage: 'Option<StorageMetadataV12>',
|
37
|
+
calls: 'Option<Vec<FunctionMetadataV12>>',
|
38
|
+
events: 'Option<Vec<EventMetadataV12>>',
|
39
|
+
constants: 'Vec<ModuleConstantMetadataV12>',
|
40
|
+
errors: 'Vec<ErrorMetadataV12>',
|
41
|
+
index: 'u8'
|
42
|
+
},
|
43
|
+
StorageEntryModifierV12: 'StorageEntryModifierV11',
|
44
|
+
StorageEntryMetadataV12: 'StorageEntryMetadataV11',
|
45
|
+
StorageEntryTypeV12: 'StorageEntryTypeV11',
|
46
|
+
StorageMetadataV12: 'StorageMetadataV11',
|
47
|
+
StorageHasherV12: 'StorageHasherV11'
|
48
|
+
}.freeze
|
49
|
+
end
|
47
50
|
end
|
48
51
|
end
|