scale.rb 0.2.16 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Cargo.lock +8 -4
  4. data/Cargo.toml +2 -3
  5. data/Dockerfile +4 -1
  6. data/Gemfile.lock +43 -35
  7. data/README.md +44 -1
  8. data/Rakefile +6 -0
  9. data/exe/scale +39 -79
  10. data/lib/address.rb +3 -0
  11. data/lib/common.rb +163 -0
  12. data/lib/helper.rb +25 -8
  13. data/lib/metadata/metadata.rb +28 -18
  14. data/lib/metadata/metadata_v0.rb +24 -20
  15. data/lib/metadata/metadata_v1.rb +13 -9
  16. data/lib/metadata/metadata_v10.rb +2 -2
  17. data/lib/metadata/metadata_v11.rb +2 -2
  18. data/lib/metadata/metadata_v12.rb +9 -8
  19. data/lib/metadata/metadata_v13.rb +161 -0
  20. data/lib/metadata/metadata_v2.rb +2 -2
  21. data/lib/metadata/metadata_v3.rb +2 -2
  22. data/lib/metadata/metadata_v4.rb +21 -11
  23. data/lib/metadata/metadata_v5.rb +21 -11
  24. data/lib/metadata/metadata_v6.rb +9 -9
  25. data/lib/metadata/metadata_v7.rb +26 -15
  26. data/lib/metadata/metadata_v8.rb +9 -9
  27. data/lib/metadata/metadata_v9.rb +2 -2
  28. data/lib/scale.rb +41 -341
  29. data/lib/scale/base.rb +177 -95
  30. data/lib/scale/block.rb +17 -13
  31. data/lib/scale/trie.rb +1 -1
  32. data/lib/scale/types.rb +139 -40
  33. data/lib/scale/version.rb +1 -1
  34. data/lib/scale_bytes.rb +63 -0
  35. data/lib/substrate_client.rb +31 -17
  36. data/lib/type_builder.rb +279 -0
  37. data/lib/type_registry.rb +91 -0
  38. data/lib/type_registry/crab.json +676 -595
  39. data/lib/type_registry/darwinia.json +730 -554
  40. data/lib/type_registry/default.json +3 -2
  41. data/lib/type_registry/pangolin.json +771 -0
  42. data/scale.gemspec +7 -5
  43. data/scripts/mmr_root_to_sign.rb +10 -0
  44. data/src/lib.rs +80 -25
  45. metadata +59 -30
  46. data/lib/type_registry/edgeware.json +0 -124
  47. data/lib/type_registry/joystream.json +0 -49
  48. data/lib/type_registry/kulupu.json +0 -15
  49. data/lib/type_registry/plasm.json +0 -89
  50. data/lib/type_registry/robonomics.json +0 -39
  51. data/lib/type_registry/westend.json +0 -63
  52. data/src/storage_key.rs +0 -41
@@ -13,6 +13,7 @@
13
13
  "Fixed64": "u64",
14
14
  "Fixed128": "u128",
15
15
  "AccountIdOf": "AccountId",
16
+ "MultiAddress": "GenericMultiAddress",
16
17
  "AccountVoteSplit": {
17
18
  "type": "struct",
18
19
  "type_mapping": [
@@ -228,7 +229,7 @@
228
229
  ]
229
230
  ]
230
231
  },
231
- "RefCount": "u8",
232
+ "RefCount": "u32",
232
233
  "Moment": "u64",
233
234
  "AccountData": {
234
235
  "type": "struct",
@@ -259,7 +260,7 @@
259
260
  "Index"
260
261
  ],
261
262
  [
262
- "refcount",
263
+ "c",
263
264
  "RefCount"
264
265
  ],
265
266
  [
@@ -0,0 +1,771 @@
1
+ {
2
+ "types": {
3
+ "BalanceLock": {
4
+ "type": "struct",
5
+ "type_mapping": [
6
+ [
7
+ "id",
8
+ "LockIdentifier"
9
+ ],
10
+ [
11
+ "lock_for",
12
+ "LockFor"
13
+ ],
14
+ [
15
+ "lock_reasons",
16
+ "LockReasons"
17
+ ],
18
+ [
19
+ "amount",
20
+ "Balance"
21
+ ],
22
+ [
23
+ "reasons",
24
+ "Reasons"
25
+ ]
26
+ ]
27
+ },
28
+ "LockFor": {
29
+ "type": "enum",
30
+ "type_mapping": [
31
+ [
32
+ "Common",
33
+ "Common"
34
+ ],
35
+ [
36
+ "Staking",
37
+ "StakingLock"
38
+ ]
39
+ ]
40
+ },
41
+ "Common": {
42
+ "type": "struct",
43
+ "type_mapping": [
44
+ [
45
+ "amount",
46
+ "Balance"
47
+ ]
48
+ ]
49
+ },
50
+ "StakingLock": {
51
+ "type": "struct",
52
+ "type_mapping": [
53
+ [
54
+ "staking_amount",
55
+ "Balance"
56
+ ],
57
+ [
58
+ "unbondings",
59
+ "Vec<Unbonding>"
60
+ ]
61
+ ]
62
+ },
63
+ "LockReasons": {
64
+ "type": "enum",
65
+ "type_mapping": [
66
+ [
67
+ "Fee",
68
+ "Null"
69
+ ],
70
+ [
71
+ "Misc",
72
+ "Null"
73
+ ],
74
+ [
75
+ "All",
76
+ "Null"
77
+ ]
78
+ ]
79
+ },
80
+ "Unbonding": {
81
+ "type": "struct",
82
+ "type_mapping": [
83
+ [
84
+ "amount",
85
+ "Balance"
86
+ ],
87
+ [
88
+ "until",
89
+ "BlockNumber"
90
+ ]
91
+ ]
92
+ },
93
+ "AccountData": {
94
+ "type": "struct",
95
+ "type_mapping": [
96
+ [
97
+ "free",
98
+ "Balance"
99
+ ],
100
+ [
101
+ "reserved",
102
+ "Balance"
103
+ ],
104
+ [
105
+ "free_kton",
106
+ "Balance"
107
+ ],
108
+ [
109
+ "reserved_kton",
110
+ "Balance"
111
+ ],
112
+ [
113
+ "misc_frozen",
114
+ "Balance"
115
+ ],
116
+ [
117
+ "fee_frozen",
118
+ "Balance"
119
+ ]
120
+ ]
121
+ },
122
+ "RingBalance": "Balance",
123
+ "KtonBalance": "Balance",
124
+ "TsInMs": "u64",
125
+ "Power": "u32",
126
+ "DepositId": "U256",
127
+ "StakingBalanceT": {
128
+ "type": "enum",
129
+ "type_mapping": [
130
+ [
131
+ "RingBalance",
132
+ "Balance"
133
+ ],
134
+ [
135
+ "KtonBalance",
136
+ "Balance"
137
+ ]
138
+ ]
139
+ },
140
+ "StakingLedgerT": {
141
+ "type": "struct",
142
+ "type_mapping": [
143
+ [
144
+ "stash",
145
+ "AccountId"
146
+ ],
147
+ [
148
+ "active_ring",
149
+ "Compact<Balance>"
150
+ ],
151
+ [
152
+ "active_deposit_ring",
153
+ "Compact<Balance>"
154
+ ],
155
+ [
156
+ "active_kton",
157
+ "Compact<Balance>"
158
+ ],
159
+ [
160
+ "deposit_items",
161
+ "Vec<TimeDepositItem>"
162
+ ],
163
+ [
164
+ "ring_staking_lock",
165
+ "StakingLock"
166
+ ],
167
+ [
168
+ "kton_staking_lock",
169
+ "StakingLock"
170
+ ],
171
+ [
172
+ "claimed_rewards",
173
+ "Vec<EraIndex>"
174
+ ],
175
+ [
176
+ "total",
177
+ "Compact<Balance>"
178
+ ],
179
+ [
180
+ "active",
181
+ "Compact<Balance>"
182
+ ],
183
+ [
184
+ "unlocking",
185
+ "Vec<UnlockChunk>"
186
+ ]
187
+ ]
188
+ },
189
+ "TimeDepositItem": {
190
+ "type": "struct",
191
+ "type_mapping": [
192
+ [
193
+ "value",
194
+ "Compact<Balance>"
195
+ ],
196
+ [
197
+ "start_time",
198
+ "Compact<TsInMs>"
199
+ ],
200
+ [
201
+ "expire_time",
202
+ "Compact<TsInMs>"
203
+ ]
204
+ ]
205
+ },
206
+ "ExposureT": {
207
+ "type": "struct",
208
+ "type_mapping": [
209
+ [
210
+ "own_ring_balance",
211
+ "Compact<Balance>"
212
+ ],
213
+ [
214
+ "own_kton_balance",
215
+ "Compact<Balance>"
216
+ ],
217
+ [
218
+ "own_power",
219
+ "Power"
220
+ ],
221
+ [
222
+ "total_power",
223
+ "Power"
224
+ ],
225
+ [
226
+ "others",
227
+ "Vec<IndividualExposure>"
228
+ ]
229
+ ]
230
+ },
231
+ "IndividualExposure": {
232
+ "type": "struct",
233
+ "type_mapping": [
234
+ [
235
+ "who",
236
+ "AccountId"
237
+ ],
238
+ [
239
+ "ring_balance",
240
+ "Compact<Balance>"
241
+ ],
242
+ [
243
+ "kton_balance",
244
+ "Compact<Balance>"
245
+ ],
246
+ [
247
+ "power",
248
+ "Power"
249
+ ],
250
+ [
251
+ "value",
252
+ "Compact<Balance>"
253
+ ]
254
+ ]
255
+ },
256
+ "RKT": {
257
+ "type": "struct",
258
+ "type_mapping": [
259
+ [
260
+ "r",
261
+ "Balance"
262
+ ],
263
+ [
264
+ "k",
265
+ "Balance"
266
+ ]
267
+ ]
268
+ },
269
+ "SpanRecord": {
270
+ "type": "struct",
271
+ "type_mapping": [
272
+ [
273
+ "slashed",
274
+ "RKT"
275
+ ],
276
+ [
277
+ "paid_out",
278
+ "RKT"
279
+ ]
280
+ ]
281
+ },
282
+ "UnappliedSlash": {
283
+ "type": "struct",
284
+ "type_mapping": [
285
+ [
286
+ "validator",
287
+ "AccountId"
288
+ ],
289
+ [
290
+ "own",
291
+ "RKT"
292
+ ],
293
+ [
294
+ "others",
295
+ "Vec<(AccountId, RKT)>"
296
+ ],
297
+ [
298
+ "reporters",
299
+ "Vec<AccountId>"
300
+ ],
301
+ [
302
+ "payout",
303
+ "RKT"
304
+ ]
305
+ ]
306
+ },
307
+ "TreasuryProposal": {
308
+ "type": "struct",
309
+ "type_mapping": [
310
+ [
311
+ "proposer",
312
+ "AccountId"
313
+ ],
314
+ [
315
+ "beneficiary",
316
+ "AccountId"
317
+ ],
318
+ [
319
+ "ring_value",
320
+ "Balance"
321
+ ],
322
+ [
323
+ "kton_value",
324
+ "Balance"
325
+ ],
326
+ [
327
+ "ring_bond",
328
+ "Balance"
329
+ ],
330
+ [
331
+ "kton_bond",
332
+ "Balance"
333
+ ]
334
+ ]
335
+ },
336
+ "MappedRing": "u128",
337
+ "EthereumTransactionIndex": "(H256, u64)",
338
+ "EthereumBlockNumber": "u64",
339
+ "EthereumHeader": {
340
+ "type": "struct",
341
+ "type_mapping": [
342
+ [
343
+ "parent_hash",
344
+ "H256"
345
+ ],
346
+ [
347
+ "timestamp",
348
+ "u64"
349
+ ],
350
+ [
351
+ "number",
352
+ "EthereumBlockNumber"
353
+ ],
354
+ [
355
+ "author",
356
+ "EthereumAddress"
357
+ ],
358
+ [
359
+ "transactions_root",
360
+ "H256"
361
+ ],
362
+ [
363
+ "uncles_hash",
364
+ "H256"
365
+ ],
366
+ [
367
+ "extra_data",
368
+ "Bytes"
369
+ ],
370
+ [
371
+ "state_root",
372
+ "H256"
373
+ ],
374
+ [
375
+ "receipts_root",
376
+ "H256"
377
+ ],
378
+ [
379
+ "log_bloom",
380
+ "Bloom"
381
+ ],
382
+ [
383
+ "gas_used",
384
+ "U256"
385
+ ],
386
+ [
387
+ "gas_limit",
388
+ "U256"
389
+ ],
390
+ [
391
+ "difficulty",
392
+ "U256"
393
+ ],
394
+ [
395
+ "seal",
396
+ "Vec<Bytes>"
397
+ ],
398
+ [
399
+ "base_fee_per_gas",
400
+ "Option<U256>"
401
+ ],
402
+ [
403
+ "hash",
404
+ "Option<H256>"
405
+ ]
406
+ ]
407
+ },
408
+ "EthereumAddress": "H160",
409
+ "EcdsaMessage": "[u8; 32]",
410
+ "Bloom": "[u8; 256]",
411
+ "H128": "[u8; 16]",
412
+ "EthashProof": {
413
+ "type": "struct",
414
+ "type_mapping": [
415
+ [
416
+ "dag_nodes",
417
+ "(H512, H512)"
418
+ ],
419
+ [
420
+ "proof",
421
+ "Vec<H128>"
422
+ ]
423
+ ]
424
+ },
425
+ "EthereumReceipt": {
426
+ "type": "struct",
427
+ "type_mapping": [
428
+ [
429
+ "gas_used",
430
+ "U256"
431
+ ],
432
+ [
433
+ "log_bloom",
434
+ "Bloom"
435
+ ],
436
+ [
437
+ "logs",
438
+ "Vec<LogEntry>"
439
+ ],
440
+ [
441
+ "outcome",
442
+ "TransactionOutcome"
443
+ ]
444
+ ]
445
+ },
446
+ "EthereumNetwork": {
447
+ "type": "enum",
448
+ "type_mapping": [
449
+ [
450
+ "Mainnet",
451
+ "Null"
452
+ ],
453
+ [
454
+ "Ropsten",
455
+ "Null"
456
+ ]
457
+ ]
458
+ },
459
+ "RedeemFor": {
460
+ "type": "enum",
461
+ "type_mapping": [
462
+ [
463
+ "Token",
464
+ "Null"
465
+ ],
466
+ [
467
+ "Deposit",
468
+ "Null"
469
+ ]
470
+ ]
471
+ },
472
+ "EthereumReceiptProof": {
473
+ "type": "struct",
474
+ "type_mapping": [
475
+ [
476
+ "index",
477
+ "u64"
478
+ ],
479
+ [
480
+ "proof",
481
+ "Bytes"
482
+ ],
483
+ [
484
+ "header_hash",
485
+ "H256"
486
+ ]
487
+ ]
488
+ },
489
+ "EthereumReceiptProofThing": "(EthereumHeader, EthereumReceiptProof, MMRProof)",
490
+ "MMRProof": {
491
+ "type": "struct",
492
+ "type_mapping": [
493
+ [
494
+ "member_leaf_index",
495
+ "u64"
496
+ ],
497
+ [
498
+ "last_leaf_index",
499
+ "u64"
500
+ ],
501
+ [
502
+ "proof",
503
+ "Vec<H256>"
504
+ ]
505
+ ]
506
+ },
507
+ "EthereumRelayHeaderParcel": {
508
+ "type": "struct",
509
+ "type_mapping": [
510
+ [
511
+ "header",
512
+ "EthereumHeader"
513
+ ],
514
+ [
515
+ "parent_mmr_root",
516
+ "H256"
517
+ ]
518
+ ]
519
+ },
520
+ "EthereumRelayProofs": {
521
+ "type": "struct",
522
+ "type_mapping": [
523
+ [
524
+ "ethash_proof",
525
+ "Vec<EthashProof>"
526
+ ],
527
+ [
528
+ "mmr_proof",
529
+ "Vec<H256>"
530
+ ]
531
+ ]
532
+ },
533
+ "RelayAuthoritySigner": "EthereumAddress",
534
+ "RelayAuthorityMessage": "EcdsaMessage",
535
+ "RelayAuthoritySignature": "EcdsaSignature",
536
+ "OtherSignature": {
537
+ "type": "enum",
538
+ "type_mapping": [
539
+ [
540
+ "Eth",
541
+ "EcdsaSignature"
542
+ ],
543
+ [
544
+ "Tron",
545
+ "EcdsaSignature"
546
+ ]
547
+ ]
548
+ },
549
+ "EcdsaSignature": "[u8; 65]",
550
+ "OtherAddress": {
551
+ "type": "enum",
552
+ "type_mapping": [
553
+ [
554
+ "Eth",
555
+ "[u8; 20]"
556
+ ],
557
+ [
558
+ "Tron",
559
+ "[u8; 20]"
560
+ ]
561
+ ]
562
+ },
563
+ "AddressT": "[u8; 20]",
564
+ "NodeIndex": "u64",
565
+ "MerkleMountainRangeRootLog": {
566
+ "type": "struct",
567
+ "type_mapping": [
568
+ [
569
+ "prefix",
570
+ "[u8; 4]"
571
+ ],
572
+ [
573
+ "parent_mmr_root",
574
+ "Hash"
575
+ ]
576
+ ]
577
+ },
578
+ "OpCode": "[u8; 4]",
579
+ "Term": "u32",
580
+ "RelayHeaderId": "EthereumBlockNumber",
581
+ "RelayHeaderParcel": "EthereumRelayHeaderParcel",
582
+ "RelayProofs": "EthereumRelayProofs",
583
+ "RelayAffirmationId": {
584
+ "type": "struct",
585
+ "type_mapping": [
586
+ [
587
+ "game_id",
588
+ "EthereumBlockNumber"
589
+ ],
590
+ [
591
+ "round",
592
+ "u32"
593
+ ],
594
+ [
595
+ "index",
596
+ "u32"
597
+ ]
598
+ ]
599
+ },
600
+ "RelayAffirmationT": {
601
+ "type": "struct",
602
+ "type_mapping": [
603
+ [
604
+ "relayer",
605
+ "AccountId"
606
+ ],
607
+ [
608
+ "relay_header_parcels",
609
+ "EthereumRelayHeaderParcel"
610
+ ],
611
+ [
612
+ "bond",
613
+ "Balance"
614
+ ],
615
+ [
616
+ "maybe_extended_relay_affirmation_id",
617
+ "Option<RelayAffirmationId>"
618
+ ],
619
+ [
620
+ "verified",
621
+ "bool"
622
+ ]
623
+ ]
624
+ },
625
+ "RelayVotingState": {
626
+ "type": "struct",
627
+ "type_mapping": [
628
+ [
629
+ "ayes",
630
+ "Vec<AccountId>"
631
+ ],
632
+ [
633
+ "nays",
634
+ "Vec<AccountId>"
635
+ ]
636
+ ]
637
+ },
638
+ "RelayAuthorityT": {
639
+ "type": "struct",
640
+ "type_mapping": [
641
+ [
642
+ "account_id",
643
+ "AccountId"
644
+ ],
645
+ [
646
+ "signer",
647
+ "EthereumAddress"
648
+ ],
649
+ [
650
+ "stake",
651
+ "Balance"
652
+ ],
653
+ [
654
+ "term",
655
+ "BlockNumber"
656
+ ]
657
+ ]
658
+ },
659
+ "ScheduledAuthoritiesChangeT": {
660
+ "type": "struct",
661
+ "type_mapping": [
662
+ [
663
+ "next_authorities",
664
+ "Vec<RelayAuthorityT>"
665
+ ],
666
+ [
667
+ "deadline",
668
+ "BlockNumber"
669
+ ]
670
+ ]
671
+ },
672
+ "MmrRootToSign": {
673
+ "type": "struct",
674
+ "type_mapping": [
675
+ [
676
+ "mmr_root",
677
+ "Hash"
678
+ ],
679
+ [
680
+ "signatures",
681
+ "Vec<(EthereumAddress, EcdsaSignature)>"
682
+ ]
683
+ ]
684
+ },
685
+ "MMRRoot": "Hash",
686
+ "BSCHeader": {
687
+ "type": "struct",
688
+ "type_mapping": [
689
+ [
690
+ "parent_hash",
691
+ "H256"
692
+ ],
693
+ [
694
+ "uncle_hash",
695
+ "H256"
696
+ ],
697
+ [
698
+ "coinbase",
699
+ "EthereumAddress"
700
+ ],
701
+ [
702
+ "state_root",
703
+ "H256"
704
+ ],
705
+ [
706
+ "transactions_root",
707
+ "H256"
708
+ ],
709
+ [
710
+ "receipts_root",
711
+ "H256"
712
+ ],
713
+ [
714
+ "log_bloom",
715
+ "Bloom"
716
+ ],
717
+ [
718
+ "difficulty",
719
+ "U256"
720
+ ],
721
+ [
722
+ "number",
723
+ "u64"
724
+ ],
725
+ [
726
+ "gas_limit",
727
+ "U256"
728
+ ],
729
+ [
730
+ "gas_used",
731
+ "U256"
732
+ ],
733
+ [
734
+ "timestamp",
735
+ "u64"
736
+ ],
737
+ [
738
+ "extra_data",
739
+ "Bytes"
740
+ ],
741
+ [
742
+ "mix_digest",
743
+ "H256"
744
+ ],
745
+ [
746
+ "nonce",
747
+ "Bytes"
748
+ ]
749
+ ]
750
+ },
751
+ "BalancesRuntimeDispatchInfo": {
752
+ "type": "struct",
753
+ "type_mapping": [
754
+ [
755
+ "usable_balance",
756
+ "Balance"
757
+ ]
758
+ ]
759
+ },
760
+ "StakingRuntimeDispatchInfo": {
761
+ "type": "struct",
762
+ "type_mapping": [
763
+ [
764
+ "power",
765
+ "Power"
766
+ ]
767
+ ]
768
+ }
769
+ }
770
+
771
+ }