scale_rb 0.5.0 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,9 +4,9 @@ module ScaleRb
4
4
  module Metadata
5
5
  module MetadataV14
6
6
  class << self
7
- def build_registry(metadata)
8
- types = metadata._get(:lookup, :types)
9
- ScaleRb.build_types(types)
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: 'PortableRegistry',
58
- pallets: 'Vec<PalletMetadataV14>',
59
- extrinsic: 'ExtrinsicMetadataV14',
60
- type: 'SiLookupTypeId'
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: 'Vec<PortableTypeV14>'
66
- },
67
- PortableTypeV14: {
68
- id: 'Si1LookupTypeId',
69
- type: 'Si1Type'
70
- },
71
- Si1LookupTypeId: 'Compact',
72
- Si1Type: {
73
- path: 'Si1Path',
74
- params: 'Vec<Si1TypeParameter>',
75
- def: 'Si1TypeDef',
76
- docs: 'Vec<Text>'
77
- },
78
- Si1Path: 'Vec<Text>',
79
- Si1TypeParameter: {
80
- name: 'Text',
81
- type: 'Option<Si1LookupTypeId>'
82
- },
83
- Si1TypeDef: {
84
- _enum: {
85
- composite: 'Si1TypeDefComposite',
86
- variant: 'Si1TypeDefVariant',
87
- sequence: 'Si1TypeDefSequence',
88
- array: 'Si1TypeDefArray',
89
- tuple: 'Si1TypeDefTuple',
90
- primitive: 'Si1TypeDefPrimitive',
91
- compact: 'Si1TypeDefCompact',
92
- bitSequence: 'Si1TypeDefBitSequence',
93
- historicMetaCompat: 'Text' # TODO: sanitize?
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: 'Vec<Si1Field>'
102
+ 'Si1TypeDefComposite' => {
103
+ 'fields' => 'Vec<Si1Field>'
98
104
  },
99
- Si1Field: {
100
- name: 'Option<Text>',
101
- type: 'Si1LookupTypeId',
102
- typeName: 'Option<Text>',
103
- docs: 'Vec<Text>'
105
+ 'Si1Field' => {
106
+ 'name' => 'Option<Text>',
107
+ 'type' => 'Si1LookupTypeId',
108
+ 'typeName' => 'Option<Text>',
109
+ 'docs' => 'Vec<Text>'
104
110
  },
105
- Si1TypeDefVariant: {
106
- variants: 'Vec<Si1Variant>'
111
+ 'Si1TypeDefVariant' => {
112
+ 'variants' => 'Vec<Si1Variant>'
107
113
  },
108
- Si1Variant: {
109
- name: 'Text',
110
- fields: 'Vec<Si1Field>',
111
- index: 'u8',
112
- docs: 'Vec<Text>'
114
+ 'Si1Variant' => {
115
+ 'name' => 'Text',
116
+ 'fields' => 'Vec<Si1Field>',
117
+ 'index' => 'u8',
118
+ 'docs' => 'Vec<Text>'
113
119
  },
114
- Si1TypeDefSequence: {
115
- type: 'Si1LookupTypeId'
120
+ 'Si1TypeDefSequence' => {
121
+ 'type' => 'Si1LookupTypeId'
116
122
  },
117
- Si1TypeDefArray: {
118
- len: 'u32',
119
- type: 'Si1LookupTypeId'
123
+ 'Si1TypeDefArray' => {
124
+ 'len' => 'u32',
125
+ 'type' => 'Si1LookupTypeId'
120
126
  },
121
- Si1TypeDefTuple: 'Vec<Si1LookupTypeId>',
122
- Si1TypeDefPrimitive: {
123
- _enum: %w[
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: 'Si1LookupTypeId'
133
+ 'Si1TypeDefCompact' => {
134
+ 'type' => 'Si1LookupTypeId'
129
135
  },
130
- Si1TypeDefBitSequence: {
131
- bitStoreType: 'Si1LookupTypeId',
132
- bitOrderType: 'Si1LookupTypeId'
136
+ 'Si1TypeDefBitSequence' => {
137
+ 'bitStoreType' => 'Si1LookupTypeId',
138
+ 'bitOrderType' => 'Si1LookupTypeId'
133
139
  },
134
140
  # PortableRegistry end
135
141
 
136
142
  # PalletMetadataV14 begin
137
- PalletMetadataV14: {
138
- name: 'Text',
139
- storage: 'Option<PalletStorageMetadataV14>',
140
- calls: 'Option<PalletCallMetadataV14>',
141
- events: 'Option<PalletEventMetadataV14>',
142
- constants: 'Vec<PalletConstantMetadataV14>',
143
- errors: 'Option<PalletErrorMetadataV14>',
144
- index: 'U8'
145
- },
146
- PalletStorageMetadataV14: {
147
- prefix: 'Text',
148
- items: 'Vec<StorageEntryMetadataV14>'
149
- },
150
- StorageEntryMetadataV14: {
151
- name: 'Text',
152
- modifier: 'StorageEntryModifierV14',
153
- type: 'StorageEntryTypeV14',
154
- fallback: 'Bytes',
155
- docs: 'Vec<Text>'
156
- },
157
- StorageEntryModifierV14: {
158
- _enum: %w[Optional Default Required]
159
- },
160
- StorageEntryTypeV14: {
161
- _enum: {
162
- plain: 'SiLookupTypeId',
163
- map: {
164
- hashers: 'Vec<StorageHasherV14>',
165
- key: 'SiLookupTypeId',
166
- value: 'SiLookupTypeId'
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: %w[Blake2128 Blake2256 Blake2128Concat Twox128 Twox256 Twox64Concat Identity]
176
+ 'StorageHasherV14' => {
177
+ '_enum' => %w[Blake2128 Blake2256 Blake2128Concat Twox128 Twox256 Twox64Concat Identity]
172
178
  },
173
- PalletCallMetadataV14: {
174
- type: 'Si1LookupTypeId'
179
+ 'PalletCallMetadataV14' => {
180
+ 'type' => 'Si1LookupTypeId'
175
181
  },
176
- PalletEventMetadataV14: {
177
- type: 'SiLookupTypeId'
182
+ 'PalletEventMetadataV14' => {
183
+ 'type' => 'SiLookupTypeId'
178
184
  },
179
- PalletConstantMetadataV14: {
180
- name: 'Text',
181
- type: 'SiLookupTypeId',
182
- value: 'Bytes',
183
- docs: 'Vec<Text>'
185
+ 'PalletConstantMetadataV14' => {
186
+ 'name' => 'Text',
187
+ 'type' => 'SiLookupTypeId',
188
+ 'value' => 'Bytes',
189
+ 'docs' => 'Vec<Text>'
184
190
  },
185
- PalletErrorMetadataV14: {
186
- type: 'SiLookupTypeId'
191
+ 'PalletErrorMetadataV14' => {
192
+ 'type' => 'SiLookupTypeId'
187
193
  },
188
194
  # PalletMetadataV14 end
189
195
 
190
196
  # ExtrinsicMetadataV14 begin
191
- ExtrinsicMetadataV14: {
192
- type: 'SiLookupTypeId',
193
- version: 'u8',
194
- signedExtensions: 'Vec<SignedExtensionMetadataV14>'
197
+ 'ExtrinsicMetadataV14' => {
198
+ 'type' => 'SiLookupTypeId',
199
+ 'version' => 'u8',
200
+ 'signedExtensions' => 'Vec<SignedExtensionMetadataV14>'
195
201
  },
196
- SignedExtensionMetadataV14: {
197
- identifier: 'Text',
198
- type: 'SiLookupTypeId',
199
- additionalSigned: 'SiLookupTypeId'
202
+ 'SignedExtensionMetadataV14' => {
203
+ 'identifier' => 'Text',
204
+ 'type' => 'SiLookupTypeId',
205
+ 'additionalSigned' => 'SiLookupTypeId'
200
206
  },
201
207
  # ExtrinsicMetadataV14 end
202
208
 
203
- SiLookupTypeId: 'Compact'
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: 'Text',
9
- docs: 'Vec<Text>'
7
+ 'ErrorMetadataV9' => {
8
+ 'name' => 'Text',
9
+ 'docs' => 'Vec<Text>'
10
10
  },
11
- EventMetadataV9: {
12
- name: 'Text',
13
- args: 'Vec<Type>',
14
- docs: 'Vec<Text>'
11
+ 'EventMetadataV9' => {
12
+ 'name' => 'Text',
13
+ 'args' => 'Vec<Type>',
14
+ 'docs' => 'Vec<Text>'
15
15
  },
16
- FunctionArgumentMetadataV9: {
17
- name: 'Text',
18
- type: 'Type'
16
+ 'FunctionArgumentMetadataV9' => {
17
+ 'name' => 'Text',
18
+ 'type' => 'Type'
19
19
  },
20
- FunctionMetadataV9: {
21
- name: 'Text',
22
- args: 'Vec<FunctionArgumentMetadataV9>',
23
- docs: 'Vec<Text>'
20
+ 'FunctionMetadataV9' => {
21
+ 'name' => 'Text',
22
+ 'args' => 'Vec<FunctionArgumentMetadataV9>',
23
+ 'docs' => 'Vec<Text>'
24
24
  },
25
- MetadataV9: {
26
- modules: 'Vec<ModuleMetadataV9>'
25
+ 'MetadataV9' => {
26
+ 'modules' => 'Vec<ModuleMetadataV9>'
27
27
  },
28
- ModuleConstantMetadataV9: {
29
- name: 'Text',
30
- type: 'Type',
31
- value: 'Bytes',
32
- docs: 'Vec<Text>'
28
+ 'ModuleConstantMetadataV9' => {
29
+ 'name' => 'Text',
30
+ 'type' => 'Type',
31
+ 'value' => 'Bytes',
32
+ 'docs' => 'Vec<Text>'
33
33
  },
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>'
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: 'Text',
44
- modifier: 'StorageEntryModifierV9',
45
- type: 'StorageEntryTypeV9',
46
- fallback: 'Bytes',
47
- docs: 'Vec<Text>'
42
+ 'StorageEntryMetadataV9' => {
43
+ 'name' => 'Text',
44
+ 'modifier' => 'StorageEntryModifierV9',
45
+ 'type' => 'StorageEntryTypeV9',
46
+ 'fallback' => 'Bytes',
47
+ 'docs' => 'Vec<Text>'
48
48
  },
49
- StorageEntryModifierV9: {
50
- _enum: %w[Optional Default Required]
49
+ 'StorageEntryModifierV9' => {
50
+ '_enum' => %w[Optional Default Required]
51
51
  },
52
- StorageEntryTypeV9: {
53
- _enum: {
54
- Plain: 'Type',
55
- Map: {
56
- hasher: 'StorageHasherV9',
57
- key: 'Type',
58
- value: 'Type',
59
- linked: 'bool'
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: 'StorageHasherV9',
63
- key1: 'Type',
64
- key2: 'Type',
65
- value: 'Type',
66
- key2Hasher: 'StorageHasherV9'
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: %w[
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: 'Text',
81
- items: 'Vec<StorageEntryMetadataV9>'
79
+ 'StorageMetadataV9' => {
80
+ 'prefix' => 'Text',
81
+ 'items' => 'Vec<StorageEntryMetadataV9>'
82
82
  }
83
83
  }.freeze
84
84
  end