scale.rb 0.2.18 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,63 @@
1
+ module Scale
2
+ class Bytes
3
+ attr_reader :data, :bytes
4
+ attr_reader :offset
5
+
6
+ def initialize(data)
7
+ if (data.class == Array) && data.is_byte_array?
8
+ @bytes = data
9
+ elsif (data.class == String) && data.start_with?("0x") && (data.length % 2 == 0)
10
+ arr = data[2..].scan(/../).map(&:hex)
11
+ @bytes = arr
12
+ else
13
+ raise "Provided data is not valid"
14
+ end
15
+
16
+ @data = data
17
+ @offset = 0
18
+ end
19
+
20
+ def reset_offset
21
+ @offset = 0
22
+ end
23
+
24
+ def get_next_bytes(length)
25
+ result = @bytes[@offset...@offset + length]
26
+ if result.length < length
27
+ str = @data[(2 + @offset * 2)..]
28
+ str = str.length > 40 ? (str[0...40]).to_s + "..." : str
29
+ raise "No enough data: #{str}, expect length: #{length}, but #{result.length}"
30
+ end
31
+ @offset += length
32
+ result
33
+ rescue RangeError => ex
34
+ puts "length: #{length}"
35
+ puts ex.message
36
+ puts ex.backtrace
37
+ end
38
+
39
+ def get_remaining_bytes
40
+ @bytes[offset..]
41
+ end
42
+
43
+ def to_hex_string
44
+ @bytes.bytes_to_hex
45
+ end
46
+
47
+ def to_bin_string
48
+ @bytes.bytes_to_bin
49
+ end
50
+
51
+ def to_ascii
52
+ @bytes[0...offset].pack("C*") + "<================================>" + @bytes[offset..].pack("C*")
53
+ end
54
+
55
+ def ==(other)
56
+ bytes == other.bytes && offset == other.offset
57
+ end
58
+
59
+ def to_s
60
+ green(@bytes[0...offset].bytes_to_hex) + yellow(@bytes[offset..].bytes_to_hex[2..])
61
+ end
62
+ end
63
+ end
@@ -39,6 +39,7 @@ class SubstrateClient
39
39
  @url = url
40
40
  @request_id = 1
41
41
  @metadata_cache = {}
42
+ init_types_and_metadata
42
43
  end
43
44
 
44
45
  def request(method, params)
@@ -121,8 +122,8 @@ class SubstrateClient
121
122
  block = self.chain_getBlock(block_hash)
122
123
  SubstrateClient::Helper.decode_block(block)
123
124
  rescue => ex
124
- puts ex.message
125
- puts ex.backtrace.join("\n\t")
125
+ Scale::Types.logger.error ex
126
+ Scale::Types.logger.error ex.backtrace.join("\n\t")
126
127
  end
127
128
 
128
129
  def get_block_events(block_hash=nil)
@@ -136,16 +137,18 @@ class SubstrateClient
136
137
  [events_data, decoded]
137
138
  end
138
139
 
139
- # Plain: client.get_storage("Sudo", "Key")
140
- # Plain: client.get_storage("Balances", "TotalIssuance")
141
- # Map: client.get_storage("System", "Account", ["0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"])
142
- # DoubleMap: client.get_storage("ImOnline", "AuthoredBlocks", [2818, "0x749ddc93a65dfec3af27cc7478212cb7d4b0c0357fef35a0163966ab5333b757"])
143
140
  def get_storage(module_name, storage_name, params = nil, block_hash = nil)
144
141
  self.init_types_and_metadata(block_hash)
145
142
 
146
- storage_key, return_type = SubstrateClient::Helper.generate_storage_key_from_metadata(@metadata, module_name, storage_name, params)
143
+ storage_key, return_type, storage_item = SubstrateClient::Helper.generate_storage_key_from_metadata(@metadata, module_name, storage_name, params)
144
+
147
145
  data = self.state_getStorage(storage_key, block_hash)
148
- return unless data
146
+
147
+ if data.nil?
148
+ return if storage_item[:modifier] == "Optional"
149
+
150
+ data = storage_item[:fallback]
151
+ end
149
152
 
150
153
  bytes = Scale::Bytes.new(data)
151
154
  type = Scale::Types.get(return_type)
@@ -0,0 +1,280 @@
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
+ type_info.transform_keys!(&:to_sym)
45
+ if type_info[:type] == "struct"
46
+ build_struct(type_info)
47
+ elsif type_info[:type] == "enum"
48
+ build_enum(type_info)
49
+ elsif type_info[:type] == "set"
50
+ build_set(type_info)
51
+ else
52
+ raise Scale::TypeBuildError.new("Failed to build a type from #{type_info}")
53
+ end
54
+
55
+ end
56
+ end
57
+
58
+ def get_final_type_from_registry(type_info)
59
+ type_registry = TypeRegistry.instance
60
+ if type_registry.types.nil?
61
+ raise TypeRegistryNotLoadYet
62
+ end
63
+ TypeRegistry.instance.get(type_info)
64
+ end
65
+
66
+ def get_hard_coded_type(type_name)
67
+ # type_name = rename(type_name)
68
+ type_name = (type_name.start_with?("Scale::Types::") ? type_name : "Scale::Types::#{type_name}")
69
+ type_name.constantize2
70
+ rescue => e
71
+ raise Scale::TypeBuildError.new("Failed to get the hard coded type named `#{type_name}`")
72
+ end
73
+
74
+ def build_vec(type_string)
75
+ inner_type_str = type_string.scan(/\AVec<(.+)>\z/).first.first
76
+ inner_type = get(inner_type_str)
77
+
78
+ type_name = "Vec_#{inner_type.name.gsub('Scale::Types::', '')}_"
79
+
80
+ if !Scale::Types.const_defined?(type_name)
81
+ klass = Class.new do
82
+ include Scale::Types::Vec
83
+ inner_type inner_type
84
+ end
85
+ Scale::Types.const_set type_name, klass
86
+ else
87
+ Scale::Types.const_get type_name
88
+ end
89
+ end
90
+
91
+ def build_option(type_string)
92
+ inner_type_str = type_string.scan(/\AOption<(.+)>\z/).first.first
93
+
94
+ # an exception
95
+ # https://substrate.dev/docs/en/knowledgebase/advanced/codec#options
96
+ return get("Scale::Types::OptionBool") if inner_type_str.camelize2 == "Bool"
97
+
98
+ inner_type = get(inner_type_str)
99
+
100
+ type_name = "Option_#{inner_type.name.gsub('Scale::Types::', '')}_"
101
+
102
+ if !Scale::Types.const_defined?(type_name)
103
+ klass = Class.new do
104
+ include Scale::Types::Option
105
+ inner_type inner_type
106
+ end
107
+ Scale::Types.const_set type_name, klass
108
+ else
109
+ Scale::Types.const_get type_name
110
+ end
111
+ end
112
+
113
+ def build_array(type_string)
114
+ scan_result = type_string.scan /\[(.+);\s*(\d+)\]/
115
+
116
+ #
117
+ inner_type_str = scan_result[0][0]
118
+ inner_type = get(inner_type_str)
119
+
120
+ #
121
+ len = scan_result[0][1].to_i
122
+
123
+ type_name = "Array_#{inner_type.name.gsub('Scale::Types::', '')}_#{len}_"
124
+
125
+ if !Scale::Types.const_defined?(type_name)
126
+ klass = Class.new do
127
+ include Scale::Types::Array
128
+ inner_type inner_type
129
+ length len
130
+ end
131
+ Scale::Types.const_set type_name, klass
132
+ else
133
+ Scale::Types.const_get type_name
134
+ end
135
+ end
136
+
137
+ def build_tuple(type_string)
138
+ scan_result = type_string.scan /\A\((.+)\)\z/
139
+ inner_types_str = scan_result[0][0]
140
+ inner_type_strs = inner_types_str.split(",").map do |inner_type_str|
141
+ inner_type_str.strip
142
+ end
143
+
144
+ inner_types = inner_type_strs.map do |inner_type_str|
145
+ get(inner_type_str)
146
+ end
147
+
148
+ type_name = "Tuple_#{inner_types.map {|inner_type| inner_type.name.gsub('Scale::Types::', '')}.join("_")}_"
149
+ if !Scale::Types.const_defined?(type_name)
150
+ klass = Class.new do
151
+ include Scale::Types::Tuple
152
+ inner_types(*inner_types)
153
+ end
154
+ Scale::Types.const_set type_name, klass
155
+ else
156
+ Scale::Types.const_get type_name
157
+ end
158
+ end
159
+
160
+ def build_struct(type_info)
161
+ # items: {"a" => Type}
162
+ items = type_info[:type_mapping].map do |item|
163
+ item_name = item[0]
164
+ item_type = get(item[1])
165
+ [item_name, item_type]
166
+ end.to_h
167
+
168
+ partials = []
169
+ items.each_pair do |item_name, item_type|
170
+ partials << item_name.camelize2 + 'In' + item_type.name.gsub('Scale::Types::', '')
171
+ end
172
+ type_name = "Struct_#{partials.join('_')}_"
173
+
174
+ if !Scale::Types.const_defined?(type_name)
175
+ klass = Class.new do
176
+ include Scale::Types::Struct
177
+ items(**items)
178
+ end
179
+ Scale::Types.const_set type_name, klass
180
+ else
181
+ Scale::Types.const_get type_name
182
+ end
183
+ end
184
+
185
+ # not implemented: ["Compact", "Hex"]
186
+ def build_enum(type_info)
187
+ # type_mapping: [["Item1", "Compact"], [["Item2", "Hex"]]
188
+ if type_info.has_key?(:type_mapping)
189
+ # items: {a: Type}
190
+ items = type_info[:type_mapping].map do |item|
191
+ item_name = item[0]
192
+ item_type = get(item[1])
193
+ [item_name.to_sym, item_type]
194
+ end.to_h
195
+
196
+ partials = []
197
+ items.each_pair do |item_name, item_type|
198
+ partials << item_name.to_s.camelize2 + 'In' + item_type.name.gsub('Scale::Types::', '')
199
+ end
200
+ type_name = "Enum_#{partials.join('_')}_"
201
+
202
+ if !Scale::Types.const_defined?(type_name)
203
+ klass = Class.new do
204
+ include Scale::Types::Enum
205
+ items(**items)
206
+ end
207
+
208
+ return Scale::Types.const_set type_name, klass
209
+ else
210
+ return Scale::Types.const_get type_name
211
+ end
212
+ end
213
+
214
+ # value_list: [1, "hello"]
215
+ if type_info.has_key?(:value_list)
216
+ type_name = "Enum#{type_info[:value_list].map {|value| value.to_s.camelize2}.join}"
217
+
218
+ if !Scale::Types.const_defined?(type_name)
219
+ klass = Class.new do
220
+ include Scale::Types::Enum
221
+ values *type_info[:value_list]
222
+ end
223
+ return Scale::Types.const_set type_name, klass
224
+ else
225
+ return Scale::Types.const_get type_name
226
+ end
227
+ end
228
+ end
229
+
230
+
231
+ # {
232
+ # value_type: u32,
233
+ # value_list: {
234
+ # "TransactionPayment" => 0b00000001,
235
+ # "Transfer" => 0b00000010,
236
+ # "Reserve" => 0b00000100,
237
+ # ...
238
+ # }
239
+ # }
240
+ def build_set(type_info)
241
+ type_name = "Set#{type_info[:value_list].keys.map(&:camelize2).join("")}"
242
+ if !Scale::Types.const_defined?(type_name)
243
+ bytes_length = type_info[:value_type][1..].to_i / 8
244
+ klass = Class.new do
245
+ include Scale::Types::Set
246
+ items type_info[:value_list], bytes_length
247
+ end
248
+ return Scale::Types.const_set type_name, klass
249
+ else
250
+ return Scale::Types.const_get type_name
251
+ end
252
+ Scale::Types.const_set fix(name), klass
253
+ end
254
+
255
+ def fix_name(type)
256
+ type = type.gsub("T::", "")
257
+ .gsub("<T>", "")
258
+ .gsub("<T as Trait>::", "")
259
+ .delete("\n")
260
+ .gsub(/(u)(\d+)/, 'U\2')
261
+ return "Bool" if type == "bool"
262
+ return "Null" if type == "()"
263
+ return "String" if type == "Vec<u8>"
264
+ return "Compact" if type == "Compact<u32>" || type == "Compact<U32>"
265
+ return "Address" if type == "<Lookup as StaticLookup>::Source"
266
+ return "Compact" if type == "<Balance as HasCompact>::Type"
267
+ return "Compact" if type == "<BlockNumber as HasCompact>::Type"
268
+ return "Compact" if type =~ /\ACompact<[a-zA-Z0-9\s]*>\z/
269
+ return "CompactMoment" if type == "<Moment as HasCompact>::Type"
270
+ return "CompactMoment" if type == "Compact<Moment>"
271
+ return "InherentOfflineReport" if type == "<InherentOfflineReport as InherentOfflineReport>::Inherent"
272
+ return "AccountData" if type == "AccountData<Balance>"
273
+ return "EventRecord" if type == "EventRecord<Event, Hash>"
274
+
275
+ type
276
+ end
277
+
278
+ end
279
+ end
280
+ 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
  }