scale_rb 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +0 -0
- data/examples/http_client_3.rb +84 -0
- data/exe/metadata +1 -1
- data/lib/scale_rb/call_helper.rb +5 -5
- data/lib/scale_rb/client/{client_ext.rb → client_share.rb} +12 -6
- data/lib/scale_rb/client/http_client.rb +2 -2
- data/lib/scale_rb/client/ws_client.rb +2 -2
- data/lib/scale_rb/decode.rb +17 -0
- data/lib/scale_rb/extrinsic_helper.rb +50 -0
- data/lib/scale_rb/metadata/metadata.rb +213 -64
- data/lib/scale_rb/metadata/metadata_v10.rb +40 -40
- data/lib/scale_rb/metadata/metadata_v11.rb +44 -44
- data/lib/scale_rb/metadata/metadata_v12.rb +22 -22
- data/lib/scale_rb/metadata/metadata_v13.rb +45 -45
- data/lib/scale_rb/metadata/metadata_v14.rb +123 -117
- data/lib/scale_rb/metadata/metadata_v9.rb +56 -56
- data/lib/scale_rb/old_registry.rb +552 -0
- data/lib/scale_rb/portable_registry.rb +30 -12
- data/lib/scale_rb/storage_helper.rb +9 -5
- data/lib/scale_rb/types.rb +6 -0
- data/lib/scale_rb/version.rb +1 -1
- data/lib/scale_rb.rb +3 -1
- metadata +7 -6
- data/lib/scale_rb/metadata/registry.rb +0 -269
- data/lib/scale_rb/metadata/type_exp.rb +0 -286
@@ -4,9 +4,9 @@ module ScaleRb
|
|
4
4
|
module Metadata
|
5
5
|
module MetadataV14
|
6
6
|
class << self
|
7
|
-
def build_registry(
|
8
|
-
types =
|
9
|
-
ScaleRb.
|
7
|
+
def build_registry(metadata_prefixed)
|
8
|
+
types = ScaleRb::Utils.get(metadata_prefixed, :metadata, :V14, :lookup, :types)
|
9
|
+
ScaleRb::PortableRegistry.new(types)
|
10
10
|
end
|
11
11
|
|
12
12
|
def get_module(pallet_name, metadata_prefixed)
|
@@ -50,157 +50,163 @@ module ScaleRb
|
|
50
50
|
variant._get(:name).downcase == call_name.downcase
|
51
51
|
end
|
52
52
|
end
|
53
|
+
|
54
|
+
def signature_type(metadata_prefixed); end
|
55
|
+
|
56
|
+
def signed_extensions(metadata_prefixed)
|
57
|
+
ScaleRb::Utils.get(metadata_prefixed, :metadata, :V14, :extrinsic, :signedExtensions)
|
58
|
+
end
|
53
59
|
end
|
54
60
|
|
55
61
|
TYPES = {
|
56
|
-
MetadataV14
|
57
|
-
lookup
|
58
|
-
pallets
|
59
|
-
extrinsic
|
60
|
-
type
|
62
|
+
'MetadataV14' => {
|
63
|
+
'lookup' => 'PortableRegistry',
|
64
|
+
'pallets' => 'Vec<PalletMetadataV14>',
|
65
|
+
'extrinsic' => 'ExtrinsicMetadataV14',
|
66
|
+
'type' => 'SiLookupTypeId'
|
61
67
|
},
|
62
68
|
|
63
69
|
# PortableRegistry begin
|
64
|
-
PortableRegistry
|
65
|
-
types
|
66
|
-
},
|
67
|
-
PortableTypeV14
|
68
|
-
id
|
69
|
-
type
|
70
|
-
},
|
71
|
-
Si1LookupTypeId
|
72
|
-
Si1Type
|
73
|
-
path
|
74
|
-
params
|
75
|
-
def
|
76
|
-
docs
|
77
|
-
},
|
78
|
-
Si1Path
|
79
|
-
Si1TypeParameter
|
80
|
-
name
|
81
|
-
type
|
82
|
-
},
|
83
|
-
Si1TypeDef
|
84
|
-
_enum
|
85
|
-
composite
|
86
|
-
variant
|
87
|
-
sequence
|
88
|
-
array
|
89
|
-
tuple
|
90
|
-
primitive
|
91
|
-
compact
|
92
|
-
bitSequence
|
93
|
-
historicMetaCompat
|
70
|
+
'PortableRegistry' => {
|
71
|
+
'types' => 'Vec<PortableTypeV14>'
|
72
|
+
},
|
73
|
+
'PortableTypeV14' => {
|
74
|
+
'id' => 'Si1LookupTypeId',
|
75
|
+
'type' => 'Si1Type'
|
76
|
+
},
|
77
|
+
'Si1LookupTypeId' => 'Compact',
|
78
|
+
'Si1Type' => {
|
79
|
+
'path' => 'Si1Path',
|
80
|
+
'params' => 'Vec<Si1TypeParameter>',
|
81
|
+
'def' => 'Si1TypeDef',
|
82
|
+
'docs' => 'Vec<Text>'
|
83
|
+
},
|
84
|
+
'Si1Path' => 'Vec<Text>',
|
85
|
+
'Si1TypeParameter' => {
|
86
|
+
'name' => 'Text',
|
87
|
+
'type' => 'Option<Si1LookupTypeId>'
|
88
|
+
},
|
89
|
+
'Si1TypeDef' => {
|
90
|
+
'_enum' => {
|
91
|
+
'composite' => 'Si1TypeDefComposite',
|
92
|
+
'variant' => 'Si1TypeDefVariant',
|
93
|
+
'sequence' => 'Si1TypeDefSequence',
|
94
|
+
'array' => 'Si1TypeDefArray',
|
95
|
+
'tuple' => 'Si1TypeDefTuple',
|
96
|
+
'primitive' => 'Si1TypeDefPrimitive',
|
97
|
+
'compact' => 'Si1TypeDefCompact',
|
98
|
+
'bitSequence' => 'Si1TypeDefBitSequence',
|
99
|
+
'historicMetaCompat' => 'Text'
|
94
100
|
}
|
95
101
|
},
|
96
|
-
Si1TypeDefComposite
|
97
|
-
fields
|
102
|
+
'Si1TypeDefComposite' => {
|
103
|
+
'fields' => 'Vec<Si1Field>'
|
98
104
|
},
|
99
|
-
Si1Field
|
100
|
-
name
|
101
|
-
type
|
102
|
-
typeName
|
103
|
-
docs
|
105
|
+
'Si1Field' => {
|
106
|
+
'name' => 'Option<Text>',
|
107
|
+
'type' => 'Si1LookupTypeId',
|
108
|
+
'typeName' => 'Option<Text>',
|
109
|
+
'docs' => 'Vec<Text>'
|
104
110
|
},
|
105
|
-
Si1TypeDefVariant
|
106
|
-
variants
|
111
|
+
'Si1TypeDefVariant' => {
|
112
|
+
'variants' => 'Vec<Si1Variant>'
|
107
113
|
},
|
108
|
-
Si1Variant
|
109
|
-
name
|
110
|
-
fields
|
111
|
-
index
|
112
|
-
docs
|
114
|
+
'Si1Variant' => {
|
115
|
+
'name' => 'Text',
|
116
|
+
'fields' => 'Vec<Si1Field>',
|
117
|
+
'index' => 'u8',
|
118
|
+
'docs' => 'Vec<Text>'
|
113
119
|
},
|
114
|
-
Si1TypeDefSequence
|
115
|
-
type
|
120
|
+
'Si1TypeDefSequence' => {
|
121
|
+
'type' => 'Si1LookupTypeId'
|
116
122
|
},
|
117
|
-
Si1TypeDefArray
|
118
|
-
len
|
119
|
-
type
|
123
|
+
'Si1TypeDefArray' => {
|
124
|
+
'len' => 'u32',
|
125
|
+
'type' => 'Si1LookupTypeId'
|
120
126
|
},
|
121
|
-
Si1TypeDefTuple
|
122
|
-
Si1TypeDefPrimitive
|
123
|
-
_enum
|
127
|
+
'Si1TypeDefTuple' => 'Vec<Si1LookupTypeId>',
|
128
|
+
'Si1TypeDefPrimitive' => {
|
129
|
+
'_enum' => %w[
|
124
130
|
Bool Char Str U8 U16 U32 U64 U128 U256 I8 I16 I32 I64 I128 I256
|
125
131
|
]
|
126
132
|
},
|
127
|
-
Si1TypeDefCompact
|
128
|
-
type
|
133
|
+
'Si1TypeDefCompact' => {
|
134
|
+
'type' => 'Si1LookupTypeId'
|
129
135
|
},
|
130
|
-
Si1TypeDefBitSequence
|
131
|
-
bitStoreType
|
132
|
-
bitOrderType
|
136
|
+
'Si1TypeDefBitSequence' => {
|
137
|
+
'bitStoreType' => 'Si1LookupTypeId',
|
138
|
+
'bitOrderType' => 'Si1LookupTypeId'
|
133
139
|
},
|
134
140
|
# PortableRegistry end
|
135
141
|
|
136
142
|
# PalletMetadataV14 begin
|
137
|
-
PalletMetadataV14
|
138
|
-
name
|
139
|
-
storage
|
140
|
-
calls
|
141
|
-
events
|
142
|
-
constants
|
143
|
-
errors
|
144
|
-
index
|
145
|
-
},
|
146
|
-
PalletStorageMetadataV14
|
147
|
-
prefix
|
148
|
-
items
|
149
|
-
},
|
150
|
-
StorageEntryMetadataV14
|
151
|
-
name
|
152
|
-
modifier
|
153
|
-
type
|
154
|
-
fallback
|
155
|
-
docs
|
156
|
-
},
|
157
|
-
StorageEntryModifierV14
|
158
|
-
_enum
|
159
|
-
},
|
160
|
-
StorageEntryTypeV14
|
161
|
-
_enum
|
162
|
-
plain
|
163
|
-
map
|
164
|
-
hashers
|
165
|
-
key
|
166
|
-
value
|
143
|
+
'PalletMetadataV14' => {
|
144
|
+
'name' => 'Text',
|
145
|
+
'storage' => 'Option<PalletStorageMetadataV14>',
|
146
|
+
'calls' => 'Option<PalletCallMetadataV14>',
|
147
|
+
'events' => 'Option<PalletEventMetadataV14>',
|
148
|
+
'constants' => 'Vec<PalletConstantMetadataV14>',
|
149
|
+
'errors' => 'Option<PalletErrorMetadataV14>',
|
150
|
+
'index' => 'U8'
|
151
|
+
},
|
152
|
+
'PalletStorageMetadataV14' => {
|
153
|
+
'prefix' => 'Text',
|
154
|
+
'items' => 'Vec<StorageEntryMetadataV14>'
|
155
|
+
},
|
156
|
+
'StorageEntryMetadataV14' => {
|
157
|
+
'name' => 'Text',
|
158
|
+
'modifier' => 'StorageEntryModifierV14',
|
159
|
+
'type' => 'StorageEntryTypeV14',
|
160
|
+
'fallback' => 'Bytes',
|
161
|
+
'docs' => 'Vec<Text>'
|
162
|
+
},
|
163
|
+
'StorageEntryModifierV14' => {
|
164
|
+
'_enum' => %w[Optional Default Required]
|
165
|
+
},
|
166
|
+
'StorageEntryTypeV14' => {
|
167
|
+
'_enum' => {
|
168
|
+
'plain' => 'SiLookupTypeId',
|
169
|
+
'map' => {
|
170
|
+
'hashers' => 'Vec<StorageHasherV14>',
|
171
|
+
'key' => 'SiLookupTypeId',
|
172
|
+
'value' => 'SiLookupTypeId'
|
167
173
|
}
|
168
174
|
}
|
169
175
|
},
|
170
|
-
StorageHasherV14
|
171
|
-
_enum
|
176
|
+
'StorageHasherV14' => {
|
177
|
+
'_enum' => %w[Blake2128 Blake2256 Blake2128Concat Twox128 Twox256 Twox64Concat Identity]
|
172
178
|
},
|
173
|
-
PalletCallMetadataV14
|
174
|
-
type
|
179
|
+
'PalletCallMetadataV14' => {
|
180
|
+
'type' => 'Si1LookupTypeId'
|
175
181
|
},
|
176
|
-
PalletEventMetadataV14
|
177
|
-
type
|
182
|
+
'PalletEventMetadataV14' => {
|
183
|
+
'type' => 'SiLookupTypeId'
|
178
184
|
},
|
179
|
-
PalletConstantMetadataV14
|
180
|
-
name
|
181
|
-
type
|
182
|
-
value
|
183
|
-
docs
|
185
|
+
'PalletConstantMetadataV14' => {
|
186
|
+
'name' => 'Text',
|
187
|
+
'type' => 'SiLookupTypeId',
|
188
|
+
'value' => 'Bytes',
|
189
|
+
'docs' => 'Vec<Text>'
|
184
190
|
},
|
185
|
-
PalletErrorMetadataV14
|
186
|
-
type
|
191
|
+
'PalletErrorMetadataV14' => {
|
192
|
+
'type' => 'SiLookupTypeId'
|
187
193
|
},
|
188
194
|
# PalletMetadataV14 end
|
189
195
|
|
190
196
|
# ExtrinsicMetadataV14 begin
|
191
|
-
ExtrinsicMetadataV14
|
192
|
-
type
|
193
|
-
version
|
194
|
-
signedExtensions
|
197
|
+
'ExtrinsicMetadataV14' => {
|
198
|
+
'type' => 'SiLookupTypeId',
|
199
|
+
'version' => 'u8',
|
200
|
+
'signedExtensions' => 'Vec<SignedExtensionMetadataV14>'
|
195
201
|
},
|
196
|
-
SignedExtensionMetadataV14
|
197
|
-
identifier
|
198
|
-
type
|
199
|
-
additionalSigned
|
202
|
+
'SignedExtensionMetadataV14' => {
|
203
|
+
'identifier' => 'Text',
|
204
|
+
'type' => 'SiLookupTypeId',
|
205
|
+
'additionalSigned' => 'SiLookupTypeId'
|
200
206
|
},
|
201
207
|
# ExtrinsicMetadataV14 end
|
202
208
|
|
203
|
-
SiLookupTypeId
|
209
|
+
'SiLookupTypeId' => 'Compact'
|
204
210
|
}.freeze
|
205
211
|
end
|
206
212
|
end
|
@@ -1,74 +1,74 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
# https://github.com/polkadot-js/api/blob/master/packages/types/src/metadata/v9/toV10.ts
|
3
3
|
module ScaleRb
|
4
4
|
module Metadata
|
5
5
|
module MetadataV9
|
6
6
|
TYPES = {
|
7
|
-
ErrorMetadataV9
|
8
|
-
name
|
9
|
-
docs
|
7
|
+
'ErrorMetadataV9' => {
|
8
|
+
'name' => 'Text',
|
9
|
+
'docs' => 'Vec<Text>'
|
10
10
|
},
|
11
|
-
EventMetadataV9
|
12
|
-
name
|
13
|
-
args
|
14
|
-
docs
|
11
|
+
'EventMetadataV9' => {
|
12
|
+
'name' => 'Text',
|
13
|
+
'args' => 'Vec<Type>',
|
14
|
+
'docs' => 'Vec<Text>'
|
15
15
|
},
|
16
|
-
FunctionArgumentMetadataV9
|
17
|
-
name
|
18
|
-
type
|
16
|
+
'FunctionArgumentMetadataV9' => {
|
17
|
+
'name' => 'Text',
|
18
|
+
'type' => 'Type'
|
19
19
|
},
|
20
|
-
FunctionMetadataV9
|
21
|
-
name
|
22
|
-
args
|
23
|
-
docs
|
20
|
+
'FunctionMetadataV9' => {
|
21
|
+
'name' => 'Text',
|
22
|
+
'args' => 'Vec<FunctionArgumentMetadataV9>',
|
23
|
+
'docs' => 'Vec<Text>'
|
24
24
|
},
|
25
|
-
MetadataV9
|
26
|
-
modules
|
25
|
+
'MetadataV9' => {
|
26
|
+
'modules' => 'Vec<ModuleMetadataV9>'
|
27
27
|
},
|
28
|
-
ModuleConstantMetadataV9
|
29
|
-
name
|
30
|
-
type
|
31
|
-
value
|
32
|
-
docs
|
28
|
+
'ModuleConstantMetadataV9' => {
|
29
|
+
'name' => 'Text',
|
30
|
+
'type' => 'Type',
|
31
|
+
'value' => 'Bytes',
|
32
|
+
'docs' => 'Vec<Text>'
|
33
33
|
},
|
34
|
-
ModuleMetadataV9
|
35
|
-
name
|
36
|
-
storage
|
37
|
-
calls
|
38
|
-
events
|
39
|
-
constants
|
40
|
-
errors
|
34
|
+
'ModuleMetadataV9' => {
|
35
|
+
'name' => 'Text',
|
36
|
+
'storage' => 'Option<StorageMetadataV9>',
|
37
|
+
'calls' => 'Option<Vec<FunctionMetadataV9>>',
|
38
|
+
'events' => 'Option<Vec<EventMetadataV9>>',
|
39
|
+
'constants' => 'Vec<ModuleConstantMetadataV9>',
|
40
|
+
'errors' => 'Vec<ErrorMetadataV9>'
|
41
41
|
},
|
42
|
-
StorageEntryMetadataV9
|
43
|
-
name
|
44
|
-
modifier
|
45
|
-
type
|
46
|
-
fallback
|
47
|
-
docs
|
42
|
+
'StorageEntryMetadataV9' => {
|
43
|
+
'name' => 'Text',
|
44
|
+
'modifier' => 'StorageEntryModifierV9',
|
45
|
+
'type' => 'StorageEntryTypeV9',
|
46
|
+
'fallback' => 'Bytes',
|
47
|
+
'docs' => 'Vec<Text>'
|
48
48
|
},
|
49
|
-
StorageEntryModifierV9
|
50
|
-
_enum
|
49
|
+
'StorageEntryModifierV9' => {
|
50
|
+
'_enum' => %w[Optional Default Required]
|
51
51
|
},
|
52
|
-
StorageEntryTypeV9
|
53
|
-
_enum
|
54
|
-
Plain
|
55
|
-
Map
|
56
|
-
hasher
|
57
|
-
key
|
58
|
-
value
|
59
|
-
linked
|
52
|
+
'StorageEntryTypeV9' => {
|
53
|
+
'_enum' => {
|
54
|
+
'Plain' => 'Type',
|
55
|
+
'Map' => {
|
56
|
+
'hasher' => 'StorageHasherV9',
|
57
|
+
'key' => 'Type',
|
58
|
+
'value' => 'Type',
|
59
|
+
'linked' => 'bool'
|
60
60
|
},
|
61
|
-
DoubleMap
|
62
|
-
hasher
|
63
|
-
key1
|
64
|
-
key2
|
65
|
-
value
|
66
|
-
key2Hasher
|
61
|
+
'DoubleMap' => {
|
62
|
+
'hasher' => 'StorageHasherV9',
|
63
|
+
'key1' => 'Type',
|
64
|
+
'key2' => 'Type',
|
65
|
+
'value' => 'Type',
|
66
|
+
'key2Hasher' => 'StorageHasherV9'
|
67
67
|
}
|
68
68
|
}
|
69
69
|
},
|
70
|
-
StorageHasherV9
|
71
|
-
_enum
|
70
|
+
'StorageHasherV9' => {
|
71
|
+
'_enum' => %w[
|
72
72
|
Blake2_128
|
73
73
|
Blake2_256
|
74
74
|
Twox128
|
@@ -76,9 +76,9 @@ module ScaleRb
|
|
76
76
|
Twox64Concat
|
77
77
|
]
|
78
78
|
},
|
79
|
-
StorageMetadataV9
|
80
|
-
prefix
|
81
|
-
items
|
79
|
+
'StorageMetadataV9' => {
|
80
|
+
'prefix' => 'Text',
|
81
|
+
'items' => 'Vec<StorageEntryMetadataV9>'
|
82
82
|
}
|
83
83
|
}.freeze
|
84
84
|
end
|