scale.rb 0.2.17 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) 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 +23 -21
  7. data/README.md +44 -1
  8. data/Rakefile +6 -0
  9. data/exe/scale +49 -0
  10. data/lib/helper.rb +19 -4
  11. data/lib/metadata/metadata.rb +27 -17
  12. data/lib/metadata/metadata_v0.rb +24 -20
  13. data/lib/metadata/metadata_v1.rb +13 -9
  14. data/lib/metadata/metadata_v10.rb +2 -2
  15. data/lib/metadata/metadata_v11.rb +2 -2
  16. data/lib/metadata/metadata_v12.rb +9 -8
  17. data/lib/metadata/metadata_v13.rb +161 -0
  18. data/lib/metadata/metadata_v2.rb +2 -2
  19. data/lib/metadata/metadata_v3.rb +2 -2
  20. data/lib/metadata/metadata_v4.rb +21 -11
  21. data/lib/metadata/metadata_v5.rb +21 -11
  22. data/lib/metadata/metadata_v6.rb +9 -9
  23. data/lib/metadata/metadata_v7.rb +26 -15
  24. data/lib/metadata/metadata_v8.rb +9 -9
  25. data/lib/metadata/metadata_v9.rb +2 -2
  26. data/lib/scale.rb +40 -339
  27. data/lib/scale/base.rb +175 -93
  28. data/lib/scale/block.rb +10 -10
  29. data/lib/scale/trie.rb +1 -1
  30. data/lib/scale/types.rb +139 -40
  31. data/lib/scale/version.rb +1 -1
  32. data/lib/scale_bytes.rb +63 -0
  33. data/lib/substrate_client.rb +11 -8
  34. data/lib/type_builder.rb +280 -0
  35. data/lib/type_registry.rb +91 -0
  36. data/lib/type_registry/crab.json +676 -595
  37. data/lib/type_registry/darwinia.json +730 -554
  38. data/lib/type_registry/default.json +3 -2
  39. data/lib/type_registry/pangolin.json +771 -0
  40. data/scale.gemspec +1 -0
  41. data/scripts/mmr_root_to_sign.rb +10 -0
  42. data/src/lib.rs +80 -25
  43. metadata +25 -10
  44. data/lib/type_registry/edgeware.json +0 -124
  45. data/lib/type_registry/joystream.json +0 -49
  46. data/lib/type_registry/kulupu.json +0 -15
  47. data/lib/type_registry/plasm.json +0 -89
  48. data/lib/type_registry/robonomics.json +0 -39
  49. data/lib/type_registry/westend.json +0 -63
  50. data/src/storage_key.rs +0 -41
@@ -1,39 +0,0 @@
1
- {
2
- "types": {
3
- "Keys": "SessionKeysSubstrate",
4
- "Index": "U64",
5
- "LiabilityIndex": "U64",
6
- "Order": {
7
- "type": "struct",
8
- "type_mapping": [
9
- ["models", "Vec<u8>"],
10
- ["objective", "Vec<u8>"],
11
- ["cost", "Balance"],
12
- ["custodian", "Option<AccountId>"]
13
- ]
14
- },
15
- "Offer": {
16
- "type": "struct",
17
- "type_mapping": [
18
- ["order", "Order"],
19
- ["sender", "AccountId"]
20
- ]
21
- },
22
- "Demand": {
23
- "type": "struct",
24
- "type_mapping": [
25
- ["order", "Order"],
26
- ["sender", "AccountId"]
27
- ]
28
- },
29
- "Liability": {
30
- "type": "struct",
31
- "type_mapping": [
32
- ["order", "Order"],
33
- ["promisee", "AccountId"],
34
- ["promisor", "AccountId"],
35
- ["result", "Option<Vec<u8>>"]
36
- ]
37
- }
38
- }
39
- }
@@ -1,63 +0,0 @@
1
- {
2
- "runtime_id": 23,
3
- "types": {
4
- "Address": "AccountIdAddress",
5
- "BlockNumber": "U32",
6
- "LeasePeriod": "BlockNumber",
7
- "SessionKeysPolkadot": {
8
- "type": "struct",
9
- "type_mapping": [
10
- ["grandpa", "AccountId"],
11
- ["babe", "AccountId"],
12
- ["im_online", "AccountId"],
13
- ["authority_discovery", "AccountId"],
14
- ["parachains", "AccountId"]
15
- ]
16
- },
17
- "Keys": "SessionKeysPolkadot",
18
- "ProxyType": {
19
- "type": "enum",
20
- "value_list": [
21
- "Any",
22
- "NonTransfer",
23
- "Staking",
24
- "SudoBalances",
25
- "IdentityJudgement"
26
- ]
27
- }
28
- },
29
- "versioning": [
30
- {
31
- "runtime_range": [3, 22],
32
- "types": {
33
- "OpenTip": {
34
- "type": "struct",
35
- "type_mapping": [
36
- ["reason", "Hash"],
37
- ["who", "AccountId"],
38
- ["finder", "Option<OpenTipFinder>"],
39
- ["closes", "Option<BlockNumber>"],
40
- ["tips", "Vec<OpenTipTip>"]
41
- ]
42
- }
43
- }
44
- },
45
- {
46
- "runtime_range": [23, null],
47
- "types": {
48
- "OpenTip": {
49
- "type": "struct",
50
- "type_mapping": [
51
- ["reason", "Hash"],
52
- ["who", "AccountId"],
53
- ["finder", "AccountId"],
54
- ["deposit", "Balance"],
55
- ["closes", "Option<BlockNumber>"],
56
- ["tips", "Vec<OpenTipTip>"],
57
- ["findersFee", "bool"]
58
- ]
59
- }
60
- }
61
- }
62
- ]
63
- }
data/src/storage_key.rs DELETED
@@ -1,41 +0,0 @@
1
- use frame_support::Twox128;
2
- use parity_scale_codec::Encode;
3
- use frame_support::{Identity, Blake2_128Concat, Twox64Concat};
4
- use frame_support::StorageHasher;
5
-
6
- pub fn to_hex_string(bytes: Vec<u8>) -> String {
7
- let strs: Vec<String> = bytes.iter()
8
- .map(|b| format!("{:02x}", b))
9
- .collect();
10
- strs.join("")
11
- }
12
-
13
- fn main() {
14
- // value
15
- let k = [Twox128::hash(b"Sudo"), Twox128::hash(b"Key")].concat();
16
- println!("{}", to_hex_string(k));
17
-
18
- // map
19
- let mut k = [Twox128::hash(b"ModuleAbc"), Twox128::hash(b"Map1")].concat();
20
- k.extend(vec![1u8, 0, 0, 0].using_encoded(Blake2_128Concat::hash));
21
- println!("{}", to_hex_string(k));
22
-
23
- let mut k = [Twox128::hash(b"ModuleAbc"), Twox128::hash(b"Map2")].concat();
24
- k.extend(1u32.using_encoded(Twox64Concat::hash));
25
- println!("{}", to_hex_string(k));
26
-
27
- let mut k = [Twox128::hash(b"ModuleAbc"), Twox128::hash(b"Map3")].concat();
28
- k.extend(1u32.using_encoded(Identity::hash));
29
- println!("{}", to_hex_string(k));
30
-
31
- // double map
32
- let mut k = [Twox128::hash(b"ModuleAbc"), Twox128::hash(b"DoubleMap1")].concat();
33
- k.extend(1u32.using_encoded(Blake2_128Concat::hash));
34
- k.extend(2u32.using_encoded(Blake2_128Concat::hash));
35
- println!("{}", to_hex_string(k));
36
-
37
- let mut k = [Twox128::hash(b"ModuleAbc"), Twox128::hash(b"DoubleMap2")].concat();
38
- k.extend(1u32.using_encoded(Blake2_128Concat::hash));
39
- k.extend(2u32.using_encoded(Twox64Concat::hash));
40
- println!("{}", to_hex_string(k));
41
- }