scale.rb 0.2.19 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,279 @@
1
+ module Scale
2
+ module Types
3
+ class << self
4
+
5
+ # type_info: type_string or type_def
6
+ # type_string: hard coded type name, Compact, H128, Vec<Compact>, (U32, U128), ...
7
+ # type_def : struct, enum, set
8
+ #
9
+ # if type_string start_with Scale::Types::, it is treat as a hard coded type
10
+ def get(type_info)
11
+ if type_info.class == ::String
12
+ if type_info.start_with?('Scale::Types::')
13
+ return get_hard_coded_type(type_info)
14
+ end
15
+
16
+ # find the final type from registry
17
+ type_info = fix_name(type_info)
18
+ type_info = get_final_type_from_registry(type_info)
19
+ end
20
+
21
+ build_type(type_info)
22
+ end
23
+
24
+ private
25
+ def build_type(type_info)
26
+ # 1. hard coded types, 2. Vec<...>, 3. Option<...>, 4. [xx; x], 5. (x, y)
27
+ if type_info.class == ::String
28
+ type_string = fix_name(type_info)
29
+ if type_string =~ /\AVec<.+>\z/
30
+ build_vec(type_string)
31
+ elsif type_info =~ /\AOption<.+>\z/
32
+ build_option(type_string)
33
+ elsif type_info =~ /\A\[.+;\s*\d+\]\z/
34
+ build_array(type_string)
35
+ elsif type_info =~ /\A\(.+\)\z/
36
+ build_tuple(type_string)
37
+ else
38
+ get_hard_coded_type(type_string)
39
+ end
40
+
41
+ # 5. Struct, 6. Enum, 7. Set
42
+ else
43
+
44
+ if type_info["type"] == "struct"
45
+ build_struct(type_info)
46
+ elsif type_info["type"] == "enum"
47
+ build_enum(type_info)
48
+ elsif type_info["type"] == "set"
49
+ build_set(type_info)
50
+ else
51
+ raise Scale::TypeBuildError.new("Failed to build a type from #{type_info}")
52
+ end
53
+
54
+ end
55
+ end
56
+
57
+ def get_final_type_from_registry(type_info)
58
+ type_registry = TypeRegistry.instance
59
+ if type_registry.types.nil?
60
+ raise TypeRegistryNotLoadYet
61
+ end
62
+ TypeRegistry.instance.get(type_info)
63
+ end
64
+
65
+ def get_hard_coded_type(type_name)
66
+ # type_name = rename(type_name)
67
+ type_name = (type_name.start_with?("Scale::Types::") ? type_name : "Scale::Types::#{type_name}")
68
+ type_name.constantize2
69
+ rescue => e
70
+ raise Scale::TypeBuildError.new("Failed to get the hard coded type named `#{type_name}`")
71
+ end
72
+
73
+ def build_vec(type_string)
74
+ inner_type_str = type_string.scan(/\AVec<(.+)>\z/).first.first
75
+ inner_type = get(inner_type_str)
76
+
77
+ type_name = "Vec_#{inner_type.name.gsub('Scale::Types::', '')}_"
78
+
79
+ if !Scale::Types.const_defined?(type_name)
80
+ klass = Class.new do
81
+ include Scale::Types::Vec
82
+ inner_type inner_type
83
+ end
84
+ Scale::Types.const_set type_name, klass
85
+ else
86
+ Scale::Types.const_get type_name
87
+ end
88
+ end
89
+
90
+ def build_option(type_string)
91
+ inner_type_str = type_string.scan(/\AOption<(.+)>\z/).first.first
92
+
93
+ # an exception
94
+ # https://substrate.dev/docs/en/knowledgebase/advanced/codec#options
95
+ return get("Scale::Types::OptionBool") if inner_type_str.camelize2 == "Bool"
96
+
97
+ inner_type = get(inner_type_str)
98
+
99
+ type_name = "Option_#{inner_type.name.gsub('Scale::Types::', '')}_"
100
+
101
+ if !Scale::Types.const_defined?(type_name)
102
+ klass = Class.new do
103
+ include Scale::Types::Option
104
+ inner_type inner_type
105
+ end
106
+ Scale::Types.const_set type_name, klass
107
+ else
108
+ Scale::Types.const_get type_name
109
+ end
110
+ end
111
+
112
+ def build_array(type_string)
113
+ scan_result = type_string.scan /\[(.+);\s*(\d+)\]/
114
+
115
+ #
116
+ inner_type_str = scan_result[0][0]
117
+ inner_type = get(inner_type_str)
118
+
119
+ #
120
+ len = scan_result[0][1].to_i
121
+
122
+ type_name = "Array_#{inner_type.name.gsub('Scale::Types::', '')}_#{len}_"
123
+
124
+ if !Scale::Types.const_defined?(type_name)
125
+ klass = Class.new do
126
+ include Scale::Types::Array
127
+ inner_type inner_type
128
+ length len
129
+ end
130
+ Scale::Types.const_set type_name, klass
131
+ else
132
+ Scale::Types.const_get type_name
133
+ end
134
+ end
135
+
136
+ def build_tuple(type_string)
137
+ scan_result = type_string.scan /\A\((.+)\)\z/
138
+ inner_types_str = scan_result[0][0]
139
+ inner_type_strs = inner_types_str.split(",").map do |inner_type_str|
140
+ inner_type_str.strip
141
+ end
142
+
143
+ inner_types = inner_type_strs.map do |inner_type_str|
144
+ get(inner_type_str)
145
+ end
146
+
147
+ type_name = "Tuple_#{inner_types.map {|inner_type| inner_type.name.gsub('Scale::Types::', '')}.join("_")}_"
148
+ if !Scale::Types.const_defined?(type_name)
149
+ klass = Class.new do
150
+ include Scale::Types::Tuple
151
+ inner_types(*inner_types)
152
+ end
153
+ Scale::Types.const_set type_name, klass
154
+ else
155
+ Scale::Types.const_get type_name
156
+ end
157
+ end
158
+
159
+ def build_struct(type_info)
160
+ # items: {"a" => Type}
161
+ items = type_info["type_mapping"].map do |item|
162
+ item_name = item[0]
163
+ item_type = get(item[1])
164
+ [item_name, item_type]
165
+ end.to_h
166
+
167
+ partials = []
168
+ items.each_pair do |item_name, item_type|
169
+ partials << item_name.camelize2 + 'In' + item_type.name.gsub('Scale::Types::', '')
170
+ end
171
+ type_name = "Struct_#{partials.join('_')}_"
172
+
173
+ if !Scale::Types.const_defined?(type_name)
174
+ klass = Class.new do
175
+ include Scale::Types::Struct
176
+ items(**items)
177
+ end
178
+ Scale::Types.const_set type_name, klass
179
+ else
180
+ Scale::Types.const_get type_name
181
+ end
182
+ end
183
+
184
+ # not implemented: ["Compact", "Hex"]
185
+ def build_enum(type_info)
186
+ # type_info: [["Item1", "Compact"], [["Item2", "Hex"]]
187
+ if type_info.has_key?("type_mapping")
188
+ # items: {a: Type}
189
+ items = type_info["type_mapping"].map do |item|
190
+ item_name = item[0]
191
+ item_type = get(item[1])
192
+ [item_name.to_sym, item_type]
193
+ end.to_h
194
+
195
+ partials = []
196
+ items.each_pair do |item_name, item_type|
197
+ partials << item_name.to_s.camelize2 + 'In' + item_type.name.gsub('Scale::Types::', '')
198
+ end
199
+ type_name = "Enum_#{partials.join('_')}_"
200
+
201
+ if !Scale::Types.const_defined?(type_name)
202
+ klass = Class.new do
203
+ include Scale::Types::Enum
204
+ items(**items)
205
+ end
206
+
207
+ return Scale::Types.const_set type_name, klass
208
+ else
209
+ return Scale::Types.const_get type_name
210
+ end
211
+ end
212
+
213
+ # [1, "hello"]
214
+ if type_info.has_key?("value_list")
215
+ type_name = "Enum#{type_info["value_list"].map {|value| value.to_s.camelize2}.join}"
216
+
217
+ if !Scale::Types.const_defined?(type_name)
218
+ klass = Class.new do
219
+ include Scale::Types::Enum
220
+ values *type_info["value_list"]
221
+ end
222
+ return Scale::Types.const_set type_name, klass
223
+ else
224
+ return Scale::Types.const_get type_name
225
+ end
226
+ end
227
+ end
228
+
229
+
230
+ # {
231
+ # value_type: u32,
232
+ # value_list: {
233
+ # "TransactionPayment" => 0b00000001,
234
+ # "Transfer" => 0b00000010,
235
+ # "Reserve" => 0b00000100,
236
+ # ...
237
+ # }
238
+ # }
239
+ def build_set(type_info)
240
+ type_name = "Set#{type_info["value_list"].keys.map(&:camelize2).join("")}"
241
+ if !Scale::Types.const_defined?(type_name)
242
+ bytes_length = type_info["value_type"][1..].to_i / 8
243
+ klass = Class.new do
244
+ include Scale::Types::Set
245
+ items type_info["value_list"], bytes_length
246
+ end
247
+ return Scale::Types.const_set type_name, klass
248
+ else
249
+ return Scale::Types.const_get type_name
250
+ end
251
+ Scale::Types.const_set fix(name), klass
252
+ end
253
+
254
+ def fix_name(type)
255
+ type = type.gsub("T::", "")
256
+ .gsub("<T>", "")
257
+ .gsub("<T as Trait>::", "")
258
+ .delete("\n")
259
+ .gsub(/(u)(\d+)/, 'U\2')
260
+ return "Bool" if type == "bool"
261
+ return "Null" if type == "()"
262
+ return "String" if type == "Vec<u8>"
263
+ return "Compact" if type == "Compact<u32>" || type == "Compact<U32>"
264
+ return "Address" if type == "<Lookup as StaticLookup>::Source"
265
+ return "Compact" if type == "<Balance as HasCompact>::Type"
266
+ return "Compact" if type == "<BlockNumber as HasCompact>::Type"
267
+ return "Compact" if type =~ /\ACompact<[a-zA-Z0-9\s]*>\z/
268
+ return "CompactMoment" if type == "<Moment as HasCompact>::Type"
269
+ return "CompactMoment" if type == "Compact<Moment>"
270
+ return "InherentOfflineReport" if type == "<InherentOfflineReport as InherentOfflineReport>::Inherent"
271
+ return "AccountData" if type == "AccountData<Balance>"
272
+ return "EventRecord" if type == "EventRecord<Event, Hash>"
273
+
274
+ type
275
+ end
276
+
277
+ end
278
+ end
279
+ end
@@ -0,0 +1,91 @@
1
+ module Scale
2
+
3
+ class TypeRegistry
4
+ include Singleton
5
+
6
+ # init by load, and will not change
7
+ attr_reader :spec_name, :types
8
+ attr_reader :versioning, :custom_types # optional
9
+
10
+ # will change by different spec version
11
+ attr_accessor :spec_version # optional
12
+ attr_accessor :metadata
13
+
14
+ def load(spec_name: nil, custom_types: nil)
15
+ @spec_name = nil
16
+ @types = nil
17
+ @versioning = nil
18
+ @custom_types = nil
19
+
20
+ default_types, _, _ = load_chain_spec_types("default")
21
+
22
+ if spec_name
23
+ begin
24
+ @spec_name = spec_name
25
+ spec_types, @versioning, @spec_version = load_chain_spec_types(spec_name)
26
+ @types = default_types.merge(spec_types)
27
+ rescue => ex
28
+ # TODO: check different errors
29
+ puts "There is no types json file named #{spec_name}"
30
+ @types = default_types
31
+ end
32
+ else
33
+ @spec_name = "default"
34
+ @types = default_types
35
+ end
36
+
37
+ self.custom_types = custom_types
38
+ true
39
+ end
40
+
41
+ def get(type_name)
42
+ all_types = self.all_types
43
+ type_traverse(type_name, all_types)
44
+ end
45
+
46
+ def custom_types=(custom_types)
47
+ @custom_types = custom_types.stringify_keys if (not custom_types.nil?) && custom_types.class.name == "Hash"
48
+ end
49
+
50
+ def all_types
51
+ all_types = {}.merge(@types)
52
+
53
+ if @spec_version && @versioning
54
+ @versioning.each do |item|
55
+ if @spec_version >= item["runtime_range"][0] &&
56
+ ( item["runtime_range"][1].nil? || @spec_version <= item["runtime_range"][1] )
57
+ all_types.merge!(item["types"])
58
+ end
59
+ end
60
+ end
61
+
62
+ all_types.merge!(@custom_types) if @custom_types
63
+ all_types
64
+ end
65
+
66
+ private
67
+
68
+ def load_chain_spec_types(spec_name)
69
+ file = File.join File.expand_path("../..", __FILE__), "lib", "type_registry", "#{spec_name}.json"
70
+ json_string = File.open(file).read
71
+ json = JSON.parse(json_string)
72
+
73
+ runtime_id = json["runtime_id"]
74
+
75
+ [json["types"], json["versioning"], runtime_id]
76
+ end
77
+
78
+ def type_traverse(type, types)
79
+ if type.class == ::String
80
+ real_type = types[type]
81
+
82
+ return type if real_type.nil? || real_type == type
83
+
84
+ type_traverse(real_type, types)
85
+ else
86
+ type
87
+ end
88
+ end
89
+ end
90
+
91
+ end
@@ -1,143 +1,677 @@
1
1
  {
2
- "types": {
3
- "Address": "AccountId",
4
- "LookupSource": "AccountId",
5
- "BalanceLock": {
6
- "type": "struct",
7
- "type_mapping": [
8
- [
9
- "id",
10
- "LockIdentifier"
11
- ],
12
- [
13
- "lock_for",
14
- "LockFor"
15
- ],
16
- [
17
- "lock_reasons",
18
- "LockReasons"
19
- ]
20
- ]
21
- },
22
- "LockFor": {
23
- "type": "enum",
24
- "type_mapping": [
25
- [
26
- "Common",
27
- "Common"
28
- ],
29
- [
30
- "Staking",
31
- "StakingLock"
32
- ]
33
- ]
2
+ "versioning": [
3
+ {
4
+ "runtime_range": [
5
+ 1,
6
+ 23
7
+ ],
8
+ "types": {
9
+ "ElectionResultT": {
10
+ "type": "struct",
11
+ "type_mapping": [
12
+ [
13
+ "elected_stashes",
14
+ "Vec<AccountId>"
15
+ ],
16
+ [
17
+ "exposures",
18
+ "Vec<(AccountId, ExposureT)>"
19
+ ],
20
+ [
21
+ "compute",
22
+ "ElectionCompute"
23
+ ]
24
+ ]
25
+ }
26
+ }
34
27
  },
35
- "Common": {
36
- "type": "struct",
37
- "type_mapping": [
38
- [
39
- "amount",
40
- "Balance"
41
- ]
42
- ]
28
+ {
29
+ "runtime_range": [
30
+ 1,
31
+ 22
32
+ ],
33
+ "types": {
34
+ "Address": "AccountId",
35
+ "LookupSource": "AccountId"
36
+ }
43
37
  },
44
- "StakingLock": {
45
- "type": "struct",
46
- "type_mapping": [
47
- [
48
- "staking_amount",
49
- "Balance"
50
- ],
51
- [
52
- "unbondings",
53
- "Vec<Unbonding>"
54
- ]
55
- ]
38
+ {
39
+ "runtime_range": [
40
+ 16,
41
+ 24
42
+ ],
43
+ "types": {
44
+ "ScheduledAuthoritiesChangeT": {
45
+ "type": "struct",
46
+ "type_mapping": [
47
+ [
48
+ "next_authorities",
49
+ "Vec<RelayAuthorityT>"
50
+ ],
51
+ [
52
+ "deadline",
53
+ "BlockNumber"
54
+ ]
55
+ ]
56
+ }
57
+ }
56
58
  },
57
- "LockReasons": {
58
- "type": "enum",
59
- "type_mapping": [
60
- [
61
- "Fee",
62
- "Null"
63
- ],
64
- [
65
- "Misc",
66
- "Null"
67
- ],
68
- [
69
- "All",
70
- "Null"
71
- ]
72
- ]
59
+ {
60
+ "runtime_range": [
61
+ 15,
62
+ 24
63
+ ],
64
+ "types": {
65
+ "OpCode": "[u8; 4]"
66
+ }
73
67
  },
74
- "Unbonding": {
75
- "type": "struct",
76
- "type_mapping": [
77
- [
78
- "amount",
79
- "Balance"
80
- ],
81
- [
82
- "until",
83
- "BlockNumber"
84
- ]
85
- ]
68
+ {
69
+ "runtime_range": [
70
+ 15,
71
+ 15
72
+ ],
73
+ "types": {
74
+ "ScheduledAuthoritiesChange": {
75
+ "type": "struct",
76
+ "type_mapping": [
77
+ [
78
+ "next_authorities",
79
+ "Vec<RelayAuthorityT>"
80
+ ],
81
+ [
82
+ "deadline",
83
+ "BlockNumber"
84
+ ]
85
+ ]
86
+ }
87
+ }
86
88
  },
87
- "AccountData": {
88
- "type": "struct",
89
- "type_mapping": [
90
- [
91
- "free",
92
- "Balance"
93
- ],
94
- [
95
- "reserved",
96
- "Balance"
97
- ],
98
- [
99
- "free_kton",
100
- "Balance"
101
- ],
102
- [
103
- "reserved_kton",
104
- "Balance"
105
- ]
106
- ]
89
+ {
90
+ "runtime_range": [
91
+ 1,
92
+ 9
93
+ ],
94
+ "types": {
95
+ "OtherSignature": {
96
+ "type": "enum",
97
+ "type_mapping": [
98
+ [
99
+ "Eth",
100
+ "EcdsaSignature"
101
+ ],
102
+ [
103
+ "Tron",
104
+ "EcdsaSignature"
105
+ ]
106
+ ]
107
+ },
108
+ "EcdsaSignature": "[u8; 65]",
109
+ "OtherAddress": {
110
+ "type": "enum",
111
+ "type_mapping": [
112
+ [
113
+ "Eth",
114
+ "[u8; 20]"
115
+ ],
116
+ [
117
+ "Tron",
118
+ "[u8; 20]"
119
+ ]
120
+ ]
121
+ },
122
+ "AddressT": "[u8; 20]",
123
+ "MerkleMountainRangeRootLog": {
124
+ "type": "struct",
125
+ "type_mapping": [
126
+ [
127
+ "prefix",
128
+ "[u8; 4]"
129
+ ],
130
+ [
131
+ "mmr_root",
132
+ "Hash"
133
+ ]
134
+ ]
135
+ }
136
+ }
107
137
  },
108
- "RingBalance": "Balance",
109
- "KtonBalance": "Balance",
110
- "TsInMs": "u64",
111
- "Power": "u32",
112
- "DepositId": "U256",
113
- "StakingBalanceT": {
114
- "type": "enum",
115
- "type_mapping": [
116
- [
117
- "RingBalance",
118
- "Balance"
119
- ],
120
- [
121
- "KtonBalance",
122
- "Balance"
123
- ]
124
- ]
138
+ {
139
+ "runtime_range": [
140
+ 10,
141
+ 24
142
+ ],
143
+ "types": {
144
+ "EcdsaMessage": "[u8; 32]",
145
+ "RelayAuthoritySigner": "EthereumAddress",
146
+ "RelayAuthorityMessage": "EcdsaMessage",
147
+ "RelayAuthoritySignature": "EcdsaSignature",
148
+ "Term": "u32",
149
+ "RelayAuthorityT": {
150
+ "type": "struct",
151
+ "type_mapping": [
152
+ [
153
+ "account_id",
154
+ "AccountId"
155
+ ],
156
+ [
157
+ "signer",
158
+ "Signer"
159
+ ],
160
+ [
161
+ "stake",
162
+ "Balance"
163
+ ],
164
+ [
165
+ "term",
166
+ "BlockNumber"
167
+ ]
168
+ ]
169
+ },
170
+ "MMRRoot": "Hash",
171
+ "MerkleMountainRangeRootLog": {
172
+ "type": "struct",
173
+ "type_mapping": [
174
+ [
175
+ "prefix",
176
+ "[u8; 4]"
177
+ ],
178
+ [
179
+ "parent_mmr_root",
180
+ "Hash"
181
+ ]
182
+ ]
183
+ },
184
+ "EthereumRelayHeaderParcel": {
185
+ "type": "struct",
186
+ "type_mapping": [
187
+ [
188
+ "header",
189
+ "EthereumHeader"
190
+ ],
191
+ [
192
+ "parent_mmr_root",
193
+ "H256"
194
+ ]
195
+ ]
196
+ }
197
+ }
125
198
  },
126
- "StakingLedgerT": {
127
- "type": "struct",
128
- "type_mapping": [
129
- [
130
- "stash",
131
- "AccountId"
132
- ],
133
- [
134
- "active_ring",
135
- "Compact<Balance>"
136
- ],
137
- [
138
- "active_deposit_ring",
139
- "Compact<Balance>"
140
- ],
199
+ {
200
+ "runtime_range": [
201
+ 6,
202
+ 24
203
+ ],
204
+ "types": {
205
+ "ProxyType": {
206
+ "type": "enum",
207
+ "type_mapping": [
208
+ [
209
+ "Any",
210
+ "Null"
211
+ ],
212
+ [
213
+ "NonTransfer",
214
+ "Null"
215
+ ],
216
+ [
217
+ "Governance",
218
+ "Null"
219
+ ],
220
+ [
221
+ "Staking",
222
+ "Null"
223
+ ],
224
+ [
225
+ "IdentityJudgement",
226
+ "Null"
227
+ ],
228
+ [
229
+ "EthereumBridge",
230
+ "Null"
231
+ ]
232
+ ]
233
+ },
234
+ "RelayProofs": "EthereumRelayProofs"
235
+ }
236
+ },
237
+ {
238
+ "runtime_range": [
239
+ 5,
240
+ 24
241
+ ],
242
+ "types": {
243
+ "RelayVotingState": {
244
+ "type": "struct",
245
+ "type_mapping": [
246
+ [
247
+ "ayes",
248
+ "Vec<AccountId>"
249
+ ],
250
+ [
251
+ "nays",
252
+ "Vec<AccountId>"
253
+ ]
254
+ ]
255
+ },
256
+ "RelayHeaderId": "EthereumBlockNumber",
257
+ "RelayHeaderParcel": "EthereumRelayHeaderParcel",
258
+ "RelayAffirmationId": {
259
+ "type": "struct",
260
+ "type_mapping": [
261
+ [
262
+ "game_id",
263
+ "EthereumBlockNumber"
264
+ ],
265
+ [
266
+ "round",
267
+ "u32"
268
+ ],
269
+ [
270
+ "index",
271
+ "u32"
272
+ ]
273
+ ]
274
+ },
275
+ "RelayAffirmationT": {
276
+ "type": "struct",
277
+ "type_mapping": [
278
+ [
279
+ "relayer",
280
+ "AccountId"
281
+ ],
282
+ [
283
+ "relay_header_parcels",
284
+ "EthereumRelayHeaderParcel"
285
+ ],
286
+ [
287
+ "bond",
288
+ "Balance"
289
+ ],
290
+ [
291
+ "maybe_extended_relay_affirmation_id",
292
+ "Option<RelayAffirmationId>"
293
+ ],
294
+ [
295
+ "verified",
296
+ "bool"
297
+ ]
298
+ ]
299
+ }
300
+ }
301
+ },
302
+ {
303
+ "runtime_range": [
304
+ 5,
305
+ 5
306
+ ],
307
+ "types": {
308
+ "ProxyType": {
309
+ "type": "enum",
310
+ "type_mapping": [
311
+ [
312
+ "Any",
313
+ "Null"
314
+ ],
315
+ [
316
+ "NonTransfer",
317
+ "Null"
318
+ ],
319
+ [
320
+ "Staking",
321
+ "Null"
322
+ ],
323
+ [
324
+ "IdentityJudgement",
325
+ "Null"
326
+ ],
327
+ [
328
+ "EthereumBridge",
329
+ "Null"
330
+ ],
331
+ [
332
+ "Governance",
333
+ "Null"
334
+ ]
335
+ ]
336
+ },
337
+ "RelayProofs": "EthereumRelayProof"
338
+ }
339
+ },
340
+ {
341
+ "runtime_range": [
342
+ 1,
343
+ 3
344
+ ],
345
+ "types": {
346
+ "EthereumHeaderBrief": {
347
+ "type": "struct",
348
+ "type_mapping": [
349
+ [
350
+ "total_difficulty",
351
+ "U256"
352
+ ],
353
+ [
354
+ "parent_hash",
355
+ "H256"
356
+ ],
357
+ [
358
+ "number",
359
+ "EthereumBlockNumber"
360
+ ],
361
+ [
362
+ "relayer",
363
+ "AccountId"
364
+ ]
365
+ ]
366
+ },
367
+ "EthereumHeaderThingWithProof": {
368
+ "type": "struct",
369
+ "type_mapping": [
370
+ [
371
+ "header",
372
+ "EthereumHeader"
373
+ ],
374
+ [
375
+ "ethash_proof",
376
+ "Vec<EthashProof>"
377
+ ],
378
+ [
379
+ "mmr_root",
380
+ "H256"
381
+ ],
382
+ [
383
+ "mmr_proof",
384
+ "Vec<H256>"
385
+ ]
386
+ ]
387
+ },
388
+ "EthereumHeaderThing": {
389
+ "type": "struct",
390
+ "type_mapping": [
391
+ [
392
+ "header",
393
+ "EthereumHeader"
394
+ ],
395
+ [
396
+ "mmr_root",
397
+ "H256"
398
+ ]
399
+ ]
400
+ },
401
+ "Round": "u64",
402
+ "TcHeaderThingWithProof": "EthereumHeaderThingWithProof",
403
+ "TcHeaderThing": "EthereumHeaderThing",
404
+ "TcBlockNumber": "u64",
405
+ "TcHeaderHash": "H256",
406
+ "GameId": "TcBlockNumber",
407
+ "RelayProposalT": {
408
+ "type": "struct",
409
+ "type_mapping": [
410
+ [
411
+ "relayer",
412
+ "AccountId"
413
+ ],
414
+ [
415
+ "bonded_proposal",
416
+ "Vec<(Balance, TcHeaderThing)>"
417
+ ],
418
+ [
419
+ "extend_from_header_hash",
420
+ "Option<TcHeaderHash>"
421
+ ]
422
+ ]
423
+ }
424
+ }
425
+ },
426
+ {
427
+ "runtime_range": [
428
+ 4,
429
+ 24
430
+ ],
431
+ "types": {
432
+ "EthereumRelayProofs": {
433
+ "type": "struct",
434
+ "type_mapping": [
435
+ [
436
+ "ethash_proof",
437
+ "Vec<EthashProof>"
438
+ ],
439
+ [
440
+ "mmr_proof",
441
+ "Vec<H256>"
442
+ ]
443
+ ]
444
+ }
445
+ }
446
+ },
447
+ {
448
+ "runtime_range": [
449
+ 4,
450
+ 9
451
+ ],
452
+ "types": {
453
+ "EthereumRelayHeaderParcel": {
454
+ "type": "struct",
455
+ "type_mapping": [
456
+ [
457
+ "header",
458
+ "EthereumHeader"
459
+ ],
460
+ [
461
+ "mmr_root",
462
+ "H256"
463
+ ]
464
+ ]
465
+ }
466
+ }
467
+ },
468
+ {
469
+ "runtime_range": [
470
+ 4,
471
+ 4
472
+ ],
473
+ "types": {
474
+ "RelayHeaderId": "Vec<u8>",
475
+ "RelayHeaderParcel": "Vec<u8>",
476
+ "RelayAffirmationId": {
477
+ "type": "struct",
478
+ "type_mapping": [
479
+ [
480
+ "relay_header_id",
481
+ "Vec<u8>"
482
+ ],
483
+ [
484
+ "round",
485
+ "u32"
486
+ ],
487
+ [
488
+ "index",
489
+ "u32"
490
+ ]
491
+ ]
492
+ },
493
+ "RelayAffirmationT": {
494
+ "type": "struct",
495
+ "type_mapping": [
496
+ [
497
+ "relayer",
498
+ "AccountId"
499
+ ],
500
+ [
501
+ "relay_header_parcels",
502
+ "Vec<u8>"
503
+ ],
504
+ [
505
+ "bond",
506
+ "Balance"
507
+ ],
508
+ [
509
+ "maybe_extended_relay_affirmation_id",
510
+ "Option<Vec<u8>>"
511
+ ],
512
+ [
513
+ "verified",
514
+ "bool"
515
+ ]
516
+ ]
517
+ },
518
+ "RelayProofs": "Vec<u8>"
519
+ }
520
+ }
521
+ ],
522
+ "types": {
523
+ "BalanceLock": {
524
+ "type": "struct",
525
+ "type_mapping": [
526
+ [
527
+ "id",
528
+ "LockIdentifier"
529
+ ],
530
+ [
531
+ "lock_for",
532
+ "LockFor"
533
+ ],
534
+ [
535
+ "lock_reasons",
536
+ "LockReasons"
537
+ ],
538
+ [
539
+ "amount",
540
+ "Balance"
541
+ ],
542
+ [
543
+ "reasons",
544
+ "Reasons"
545
+ ]
546
+ ]
547
+ },
548
+ "LockFor": {
549
+ "type": "enum",
550
+ "type_mapping": [
551
+ [
552
+ "Common",
553
+ "Common"
554
+ ],
555
+ [
556
+ "Staking",
557
+ "StakingLock"
558
+ ]
559
+ ]
560
+ },
561
+ "Common": {
562
+ "type": "struct",
563
+ "type_mapping": [
564
+ [
565
+ "amount",
566
+ "Balance"
567
+ ]
568
+ ]
569
+ },
570
+ "StakingLock": {
571
+ "type": "struct",
572
+ "type_mapping": [
573
+ [
574
+ "staking_amount",
575
+ "Balance"
576
+ ],
577
+ [
578
+ "unbondings",
579
+ "Vec<Unbonding>"
580
+ ]
581
+ ]
582
+ },
583
+ "LockReasons": {
584
+ "type": "enum",
585
+ "type_mapping": [
586
+ [
587
+ "Fee",
588
+ "Null"
589
+ ],
590
+ [
591
+ "Misc",
592
+ "Null"
593
+ ],
594
+ [
595
+ "All",
596
+ "Null"
597
+ ]
598
+ ]
599
+ },
600
+ "Unbonding": {
601
+ "type": "struct",
602
+ "type_mapping": [
603
+ [
604
+ "amount",
605
+ "Balance"
606
+ ],
607
+ [
608
+ "until",
609
+ "BlockNumber"
610
+ ]
611
+ ]
612
+ },
613
+ "AccountData": {
614
+ "type": "struct",
615
+ "type_mapping": [
616
+ [
617
+ "free",
618
+ "Balance"
619
+ ],
620
+ [
621
+ "reserved",
622
+ "Balance"
623
+ ],
624
+ [
625
+ "free_kton",
626
+ "Balance"
627
+ ],
628
+ [
629
+ "reserved_kton",
630
+ "Balance"
631
+ ],
632
+ [
633
+ "misc_frozen",
634
+ "Balance"
635
+ ],
636
+ [
637
+ "fee_frozen",
638
+ "Balance"
639
+ ]
640
+ ]
641
+ },
642
+ "RingBalance": "Balance",
643
+ "KtonBalance": "Balance",
644
+ "TsInMs": "u64",
645
+ "Power": "u32",
646
+ "DepositId": "U256",
647
+ "StakingBalanceT": {
648
+ "type": "enum",
649
+ "type_mapping": [
650
+ [
651
+ "RingBalance",
652
+ "Balance"
653
+ ],
654
+ [
655
+ "KtonBalance",
656
+ "Balance"
657
+ ]
658
+ ]
659
+ },
660
+ "StakingLedgerT": {
661
+ "type": "struct",
662
+ "type_mapping": [
663
+ [
664
+ "stash",
665
+ "AccountId"
666
+ ],
667
+ [
668
+ "active_ring",
669
+ "Compact<Balance>"
670
+ ],
671
+ [
672
+ "active_deposit_ring",
673
+ "Compact<Balance>"
674
+ ],
141
675
  [
142
676
  "active_kton",
143
677
  "Compact<Balance>"
@@ -157,6 +691,18 @@
157
691
  [
158
692
  "claimed_rewards",
159
693
  "Vec<EraIndex>"
694
+ ],
695
+ [
696
+ "total",
697
+ "Compact<Balance>"
698
+ ],
699
+ [
700
+ "active",
701
+ "Compact<Balance>"
702
+ ],
703
+ [
704
+ "unlocking",
705
+ "Vec<UnlockChunk>"
160
706
  ]
161
707
  ]
162
708
  },
@@ -220,23 +766,10 @@
220
766
  [
221
767
  "power",
222
768
  "Power"
223
- ]
224
- ]
225
- },
226
- "ElectionResultT": {
227
- "type": "struct",
228
- "type_mapping": [
229
- [
230
- "elected_stashes",
231
- "Vec<AccountId>"
232
- ],
233
- [
234
- "exposures",
235
- "Vec<(AccountId, ExposureT)>"
236
769
  ],
237
770
  [
238
- "compute",
239
- "ElectionCompute"
771
+ "value",
772
+ "Compact<Balance>"
240
773
  ]
241
774
  ]
242
775
  },
@@ -451,415 +984,58 @@
451
984
  ]
452
985
  ]
453
986
  },
454
- "EthereumReceiptProof": {
455
- "type": "struct",
456
- "type_mapping": [
457
- [
458
- "index",
459
- "u64"
460
- ],
461
- [
462
- "proof",
463
- "Bytes"
464
- ],
465
- [
466
- "header_hash",
467
- "H256"
468
- ]
469
- ]
470
- },
471
- "EthereumReceiptProofThing": "(EthereumHeader, EthereumReceiptProof, MMRProof)",
472
- "MMRProof": {
473
- "type": "struct",
474
- "type_mapping": [
475
- [
476
- "member_leaf_index",
477
- "u64"
478
- ],
479
- [
480
- "last_leaf_index",
481
- "u64"
482
- ],
483
- [
484
- "proof",
485
- "Vec<H256>"
486
- ]
487
- ]
488
- },
489
- "OtherSignature": {
490
- "type": "enum",
491
- "type_mapping": [
492
- [
493
- "Eth",
494
- "EcdsaSignature"
495
- ],
496
- [
497
- "Tron",
498
- "EcdsaSignature"
499
- ]
500
- ]
501
- },
502
- "EcdsaSignature": "[u8; 65]",
503
- "OtherAddress": {
504
- "type": "enum",
505
- "type_mapping": [
506
- [
507
- "Eth",
508
- "[u8; 20]"
509
- ],
510
- [
511
- "Tron",
512
- "[u8; 20]"
513
- ]
514
- ]
515
- },
516
- "AddressT": "[u8; 20]",
517
- "MerkleMountainRangeRootLog": {
518
- "type": "struct",
519
- "type_mapping": [
520
- [
521
- "prefix",
522
- "[u8; 4]"
523
- ],
524
- [
525
- "mmr_root",
526
- "Hash"
527
- ]
528
- ]
529
- },
530
- "BalancesRuntimeDispatchInfo": {
531
- "type": "struct",
532
- "type_mapping": [
533
- [
534
- "usable_balance",
535
- "Balance"
536
- ]
537
- ]
538
- },
539
- "StakingRuntimeDispatchInfo": {
540
- "type": "struct",
541
- "type_mapping": [
542
- [
543
- "power",
544
- "Power"
545
- ]
546
- ]
547
- }
548
- },
549
- "versioning": [
550
- {
551
- "runtime_range": [
552
- 6,
553
- 9
554
- ],
555
- "types": {
556
- "ProxyType": {
557
- "type": "enum",
558
- "type_mapping": [
559
- [
560
- "Any",
561
- "Null"
562
- ],
563
- [
564
- "NonTransfer",
565
- "Null"
566
- ],
567
- [
568
- "Governance",
569
- "Null"
570
- ],
571
- [
572
- "Staking",
573
- "Null"
574
- ],
575
- [
576
- "IdentityJudgement",
577
- "Null"
578
- ],
579
- [
580
- "EthereumBridge",
581
- "Null"
582
- ]
583
- ]
584
- },
585
- "RelayProofs": "EthereumRelayProofs"
586
- }
587
- },
588
- {
589
- "runtime_range": [
590
- 5,
591
- 9
592
- ],
593
- "types": {
594
- "RelayVotingState": {
595
- "type": "struct",
596
- "type_mapping": [
597
- [
598
- "ayes",
599
- "Vec<AccountId>"
600
- ],
601
- [
602
- "nays",
603
- "Vec<AccountId>"
604
- ]
605
- ]
606
- },
607
- "RelayHeaderId": "EthereumBlockNumber",
608
- "RelayHeaderParcel": "EthereumRelayHeaderParcel",
609
- "RelayAffirmationId": {
610
- "type": "struct",
611
- "type_mapping": [
612
- [
613
- "game_id",
614
- "EthereumBlockNumber"
615
- ],
616
- [
617
- "round",
618
- "u32"
619
- ],
620
- [
621
- "index",
622
- "u32"
623
- ]
624
- ]
625
- },
626
- "RelayAffirmationT": {
627
- "type": "struct",
628
- "type_mapping": [
629
- [
630
- "relayer",
631
- "AccountId"
632
- ],
633
- [
634
- "relay_header_parcels",
635
- "EthereumRelayHeaderParcel"
636
- ],
637
- [
638
- "bond",
639
- "Balance"
640
- ],
641
- [
642
- "maybe_extended_relay_affirmation_id",
643
- "Option<RelayAffirmationId>"
644
- ],
645
- [
646
- "verified",
647
- "bool"
648
- ]
649
- ]
650
- }
651
- }
652
- },
653
- {
654
- "runtime_range": [
655
- 5,
656
- 5
657
- ],
658
- "types": {
659
- "ProxyType": {
660
- "type": "enum",
661
- "type_mapping": [
662
- [
663
- "Any",
664
- "Null"
665
- ],
666
- [
667
- "NonTransfer",
668
- "Null"
669
- ],
670
- [
671
- "Staking",
672
- "Null"
673
- ],
674
- [
675
- "IdentityJudgement",
676
- "Null"
677
- ],
678
- [
679
- "EthereumBridge",
680
- "Null"
681
- ],
682
- [
683
- "Governance",
684
- "Null"
685
- ]
686
- ]
687
- },
688
- "RelayProofs": "EthereumRelayProof"
689
- }
987
+ "EthereumReceiptProof": {
988
+ "type": "struct",
989
+ "type_mapping": [
990
+ [
991
+ "index",
992
+ "u64"
993
+ ],
994
+ [
995
+ "proof",
996
+ "Bytes"
997
+ ],
998
+ [
999
+ "header_hash",
1000
+ "H256"
1001
+ ]
1002
+ ]
690
1003
  },
691
- {
692
- "runtime_range": [
693
- 1,
694
- 3
695
- ],
696
- "types": {
697
- "EthereumHeaderBrief": {
698
- "type": "struct",
699
- "type_mapping": [
700
- [
701
- "total_difficulty",
702
- "U256"
703
- ],
704
- [
705
- "parent_hash",
706
- "H256"
707
- ],
708
- [
709
- "number",
710
- "EthereumBlockNumber"
711
- ],
712
- [
713
- "relayer",
714
- "AccountId"
715
- ]
716
- ]
717
- },
718
- "EthereumHeaderThingWithProof": {
719
- "type": "struct",
720
- "type_mapping": [
721
- [
722
- "header",
723
- "EthereumHeader"
724
- ],
725
- [
726
- "ethash_proof",
727
- "Vec<EthashProof>"
728
- ],
729
- [
730
- "mmr_root",
731
- "H256"
732
- ],
733
- [
734
- "mmr_proof",
735
- "Vec<H256>"
736
- ]
737
- ]
738
- },
739
- "EthereumHeaderThing": {
740
- "type": "struct",
741
- "type_mapping": [
742
- [
743
- "header",
744
- "EthereumHeader"
745
- ],
746
- [
747
- "mmr_root",
748
- "H256"
749
- ]
750
- ]
751
- },
752
- "Round": "u64",
753
- "TcHeaderThingWithProof": "EthereumHeaderThingWithProof",
754
- "TcHeaderThing": "EthereumHeaderThing",
755
- "TcBlockNumber": "u64",
756
- "TcHeaderHash": "H256",
757
- "GameId": "TcBlockNumber",
758
- "RelayProposalT": {
759
- "type": "struct",
760
- "type_mapping": [
761
- [
762
- "relayer",
763
- "AccountId"
764
- ],
765
- [
766
- "bonded_proposal",
767
- "Vec<(Balance, TcHeaderThing)>"
768
- ],
769
- [
770
- "extend_from_header_hash",
771
- "Option<TcHeaderHash>"
772
- ]
773
- ]
774
- }
775
- }
1004
+ "EthereumReceiptProofThing": "(EthereumHeader, EthereumReceiptProof, MMRProof)",
1005
+ "MMRProof": {
1006
+ "type": "struct",
1007
+ "type_mapping": [
1008
+ [
1009
+ "member_leaf_index",
1010
+ "u64"
1011
+ ],
1012
+ [
1013
+ "last_leaf_index",
1014
+ "u64"
1015
+ ],
1016
+ [
1017
+ "proof",
1018
+ "Vec<H256>"
1019
+ ]
1020
+ ]
776
1021
  },
777
- {
778
- "runtime_range": [
779
- 4,
780
- 9
781
- ],
782
- "types": {
783
- "EthereumRelayHeaderParcel": {
784
- "type": "struct",
785
- "type_mapping": [
786
- [
787
- "header",
788
- "EthereumHeader"
789
- ],
790
- [
791
- "mmr_root",
792
- "H256"
793
- ]
794
- ]
795
- },
796
- "EthereumRelayProofs": {
797
- "type": "struct",
798
- "type_mapping": [
799
- [
800
- "ethash_proof",
801
- "Vec<EthashProof>"
802
- ],
803
- [
804
- "mmr_proof",
805
- "Vec<H256>"
806
- ]
807
- ]
808
- }
809
- }
1022
+ "BalancesRuntimeDispatchInfo": {
1023
+ "type": "struct",
1024
+ "type_mapping": [
1025
+ [
1026
+ "usable_balance",
1027
+ "Balance"
1028
+ ]
1029
+ ]
810
1030
  },
811
- {
812
- "runtime_range": [
813
- 4,
814
- 4
815
- ],
816
- "types": {
817
- "RelayHeaderId": "Vec<u8>",
818
- "RelayHeaderParcel": "Vec<u8>",
819
- "RelayAffirmationId": {
820
- "type": "struct",
821
- "type_mapping": [
822
- [
823
- "relay_header_id",
824
- "Vec<u8>"
825
- ],
826
- [
827
- "round",
828
- "u32"
829
- ],
830
- [
831
- "index",
832
- "u32"
833
- ]
834
- ]
835
- },
836
- "RelayAffirmationT": {
837
- "type": "struct",
838
- "type_mapping": [
839
- [
840
- "relayer",
841
- "AccountId"
842
- ],
843
- [
844
- "relay_header_parcels",
845
- "Vec<u8>"
846
- ],
847
- [
848
- "bond",
849
- "Balance"
850
- ],
851
- [
852
- "maybe_extended_relay_affirmation_id",
853
- "Option<Vec<u8>>"
854
- ],
855
- [
856
- "verified",
857
- "bool"
858
- ]
859
- ]
860
- },
861
- "RelayProofs": "Vec<u8>"
862
- }
1031
+ "StakingRuntimeDispatchInfo": {
1032
+ "type": "struct",
1033
+ "type_mapping": [
1034
+ [
1035
+ "power",
1036
+ "Power"
1037
+ ]
1038
+ ]
863
1039
  }
864
- ]
1040
+ }
865
1041
  }