@polkadot/types-known 9.5.2 → 9.6.1

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.
Files changed (53) hide show
  1. package/bundle.js +1 -0
  2. package/chain/index.js +1 -0
  3. package/cjs/bundle.js +0 -4
  4. package/cjs/chain/index.js +1 -0
  5. package/cjs/detectOther.js +0 -2
  6. package/cjs/detectPackage.js +2 -4
  7. package/cjs/index.js +0 -3
  8. package/cjs/packageInfo.js +3 -1
  9. package/cjs/spec/centrifuge-chain.js +1 -2
  10. package/cjs/spec/index.js +1 -11
  11. package/cjs/spec/kusama.js +3 -4
  12. package/cjs/spec/node-template.js +1 -0
  13. package/cjs/spec/node.js +1 -0
  14. package/cjs/spec/polkadot.js +5 -4
  15. package/cjs/spec/rococo.js +4 -5
  16. package/cjs/spec/shell.js +3 -1
  17. package/cjs/spec/statemint.js +5 -5
  18. package/cjs/spec/westend.js +3 -4
  19. package/cjs/upgrades/e2e/index.js +0 -4
  20. package/cjs/upgrades/e2e/kusama.js +2 -1
  21. package/cjs/upgrades/e2e/polkadot.js +3 -2
  22. package/cjs/upgrades/e2e/westend.js +3 -2
  23. package/cjs/upgrades/index.js +5 -15
  24. package/cjs/upgrades/manual/index.js +0 -4
  25. package/cjs/upgrades/manual/kusama.js +1 -0
  26. package/cjs/upgrades/manual/polkadot.js +2 -1
  27. package/cjs/upgrades/manual/westend.js +2 -1
  28. package/cjs/util.js +19 -39
  29. package/detectOther.js +1 -0
  30. package/detectPackage.js +2 -0
  31. package/index.js +1 -0
  32. package/package.json +4 -4
  33. package/packageInfo.js +3 -1
  34. package/spec/centrifuge-chain.js +1 -0
  35. package/spec/index.js +3 -1
  36. package/spec/kusama.js +4 -1
  37. package/spec/node-template.js +1 -0
  38. package/spec/node.js +1 -0
  39. package/spec/polkadot.js +6 -2
  40. package/spec/rococo.js +6 -2
  41. package/spec/shell.js +3 -1
  42. package/spec/statemint.js +6 -2
  43. package/spec/westend.js +4 -1
  44. package/upgrades/e2e/index.js +1 -0
  45. package/upgrades/e2e/kusama.js +2 -1
  46. package/upgrades/e2e/polkadot.js +3 -2
  47. package/upgrades/e2e/westend.js +3 -2
  48. package/upgrades/index.js +7 -10
  49. package/upgrades/manual/index.js +1 -0
  50. package/upgrades/manual/kusama.js +1 -0
  51. package/upgrades/manual/polkadot.js +2 -1
  52. package/upgrades/manual/westend.js +2 -1
  53. package/util.js +19 -26
package/util.js CHANGED
@@ -1,17 +1,16 @@
1
1
  // Copyright 2017-2022 @polkadot/types-known authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+
3
4
  import { bnToBn, objectSpread } from '@polkadot/util';
4
5
  import typesChain from "./chain/index.js";
5
6
  import typesSpec from "./spec/index.js";
6
7
  import upgrades from "./upgrades/index.js";
7
-
8
8
  function withNames(chainName, specName, fn) {
9
9
  return fn(chainName.toString(), specName.toString());
10
- } // flatten a VersionedType[] into a Record<string, string>
10
+ }
11
11
 
12
+ // flatten a VersionedType[] into a Record<string, string>
12
13
  /** @internal */
13
-
14
-
15
14
  function filterVersions(versions = [], specVersion) {
16
15
  return versions.filter(({
17
16
  minmax: [min, max]
@@ -19,37 +18,34 @@ function filterVersions(versions = [], specVersion) {
19
18
  types
20
19
  }) => objectSpread(result, types), {});
21
20
  }
21
+
22
22
  /**
23
23
  * @description Based on the chain and runtimeVersion, get the applicable signed extensions (ready for registration)
24
24
  */
25
-
26
-
27
25
  export function getSpecExtensions({
28
26
  knownTypes
29
27
  }, chainName, specName) {
30
28
  return withNames(chainName, specName, (c, s) => {
31
29
  var _knownTypes$typesBund, _knownTypes$typesBund2, _knownTypes$typesBund3, _knownTypes$typesBund4, _knownTypes$typesBund5, _knownTypes$typesBund6;
32
-
33
- return objectSpread({}, (_knownTypes$typesBund = knownTypes.typesBundle) === null || _knownTypes$typesBund === void 0 ? void 0 : (_knownTypes$typesBund2 = _knownTypes$typesBund.spec) === null || _knownTypes$typesBund2 === void 0 ? void 0 : (_knownTypes$typesBund3 = _knownTypes$typesBund2[s]) === null || _knownTypes$typesBund3 === void 0 ? void 0 : _knownTypes$typesBund3.signedExtensions, (_knownTypes$typesBund4 = knownTypes.typesBundle) === null || _knownTypes$typesBund4 === void 0 ? void 0 : (_knownTypes$typesBund5 = _knownTypes$typesBund4.chain) === null || _knownTypes$typesBund5 === void 0 ? void 0 : (_knownTypes$typesBund6 = _knownTypes$typesBund5[c]) === null || _knownTypes$typesBund6 === void 0 ? void 0 : _knownTypes$typesBund6.signedExtensions);
30
+ return objectSpread({}, (_knownTypes$typesBund = knownTypes.typesBundle) == null ? void 0 : (_knownTypes$typesBund2 = _knownTypes$typesBund.spec) == null ? void 0 : (_knownTypes$typesBund3 = _knownTypes$typesBund2[s]) == null ? void 0 : _knownTypes$typesBund3.signedExtensions, (_knownTypes$typesBund4 = knownTypes.typesBundle) == null ? void 0 : (_knownTypes$typesBund5 = _knownTypes$typesBund4.chain) == null ? void 0 : (_knownTypes$typesBund6 = _knownTypes$typesBund5[c]) == null ? void 0 : _knownTypes$typesBund6.signedExtensions);
34
31
  });
35
32
  }
33
+
36
34
  /**
37
35
  * @description Based on the chain and runtimeVersion, get the applicable types (ready for registration)
38
36
  */
39
-
40
37
  export function getSpecTypes({
41
38
  knownTypes
42
39
  }, chainName, specName, specVersion) {
43
40
  const _specVersion = bnToBn(specVersion).toNumber();
44
-
45
41
  return withNames(chainName, specName, (c, s) => {
46
42
  var _knownTypes$typesBund7, _knownTypes$typesBund8, _knownTypes$typesBund9, _knownTypes$typesBund10, _knownTypes$typesBund11, _knownTypes$typesBund12, _knownTypes$typesSpec, _knownTypes$typesChai;
47
-
48
- return (// The order here is always, based on -
43
+ return (
44
+ // The order here is always, based on -
49
45
  // - spec then chain
50
46
  // - typesBundle takes higher precedence
51
47
  // - types is the final catch-all override
52
- objectSpread({}, filterVersions(typesSpec[s], _specVersion), filterVersions(typesChain[c], _specVersion), filterVersions((_knownTypes$typesBund7 = knownTypes.typesBundle) === null || _knownTypes$typesBund7 === void 0 ? void 0 : (_knownTypes$typesBund8 = _knownTypes$typesBund7.spec) === null || _knownTypes$typesBund8 === void 0 ? void 0 : (_knownTypes$typesBund9 = _knownTypes$typesBund8[s]) === null || _knownTypes$typesBund9 === void 0 ? void 0 : _knownTypes$typesBund9.types, _specVersion), filterVersions((_knownTypes$typesBund10 = knownTypes.typesBundle) === null || _knownTypes$typesBund10 === void 0 ? void 0 : (_knownTypes$typesBund11 = _knownTypes$typesBund10.chain) === null || _knownTypes$typesBund11 === void 0 ? void 0 : (_knownTypes$typesBund12 = _knownTypes$typesBund11[c]) === null || _knownTypes$typesBund12 === void 0 ? void 0 : _knownTypes$typesBund12.types, _specVersion), (_knownTypes$typesSpec = knownTypes.typesSpec) === null || _knownTypes$typesSpec === void 0 ? void 0 : _knownTypes$typesSpec[s], (_knownTypes$typesChai = knownTypes.typesChain) === null || _knownTypes$typesChai === void 0 ? void 0 : _knownTypes$typesChai[c], knownTypes.types)
48
+ objectSpread({}, filterVersions(typesSpec[s], _specVersion), filterVersions(typesChain[c], _specVersion), filterVersions((_knownTypes$typesBund7 = knownTypes.typesBundle) == null ? void 0 : (_knownTypes$typesBund8 = _knownTypes$typesBund7.spec) == null ? void 0 : (_knownTypes$typesBund9 = _knownTypes$typesBund8[s]) == null ? void 0 : _knownTypes$typesBund9.types, _specVersion), filterVersions((_knownTypes$typesBund10 = knownTypes.typesBundle) == null ? void 0 : (_knownTypes$typesBund11 = _knownTypes$typesBund10.chain) == null ? void 0 : (_knownTypes$typesBund12 = _knownTypes$typesBund11[c]) == null ? void 0 : _knownTypes$typesBund12.types, _specVersion), (_knownTypes$typesSpec = knownTypes.typesSpec) == null ? void 0 : _knownTypes$typesSpec[s], (_knownTypes$typesChai = knownTypes.typesChain) == null ? void 0 : _knownTypes$typesChai[c], knownTypes.types)
53
49
  );
54
50
  });
55
51
  }
@@ -58,55 +54,52 @@ export function getSpecHasher({
58
54
  }, chainName, specName) {
59
55
  return withNames(chainName, specName, (c, s) => {
60
56
  var _knownTypes$typesBund13, _knownTypes$typesBund14, _knownTypes$typesBund15, _knownTypes$typesBund16, _knownTypes$typesBund17, _knownTypes$typesBund18;
61
-
62
- return knownTypes.hasher || ((_knownTypes$typesBund13 = knownTypes.typesBundle) === null || _knownTypes$typesBund13 === void 0 ? void 0 : (_knownTypes$typesBund14 = _knownTypes$typesBund13.chain) === null || _knownTypes$typesBund14 === void 0 ? void 0 : (_knownTypes$typesBund15 = _knownTypes$typesBund14[c]) === null || _knownTypes$typesBund15 === void 0 ? void 0 : _knownTypes$typesBund15.hasher) || ((_knownTypes$typesBund16 = knownTypes.typesBundle) === null || _knownTypes$typesBund16 === void 0 ? void 0 : (_knownTypes$typesBund17 = _knownTypes$typesBund16.spec) === null || _knownTypes$typesBund17 === void 0 ? void 0 : (_knownTypes$typesBund18 = _knownTypes$typesBund17[s]) === null || _knownTypes$typesBund18 === void 0 ? void 0 : _knownTypes$typesBund18.hasher) || null;
57
+ return knownTypes.hasher || ((_knownTypes$typesBund13 = knownTypes.typesBundle) == null ? void 0 : (_knownTypes$typesBund14 = _knownTypes$typesBund13.chain) == null ? void 0 : (_knownTypes$typesBund15 = _knownTypes$typesBund14[c]) == null ? void 0 : _knownTypes$typesBund15.hasher) || ((_knownTypes$typesBund16 = knownTypes.typesBundle) == null ? void 0 : (_knownTypes$typesBund17 = _knownTypes$typesBund16.spec) == null ? void 0 : (_knownTypes$typesBund18 = _knownTypes$typesBund17[s]) == null ? void 0 : _knownTypes$typesBund18.hasher) || null;
63
58
  });
64
59
  }
60
+
65
61
  /**
66
62
  * @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
67
63
  */
68
-
69
64
  export function getSpecRpc({
70
65
  knownTypes
71
66
  }, chainName, specName) {
72
67
  return withNames(chainName, specName, (c, s) => {
73
68
  var _knownTypes$typesBund19, _knownTypes$typesBund20, _knownTypes$typesBund21, _knownTypes$typesBund22, _knownTypes$typesBund23, _knownTypes$typesBund24;
74
-
75
- return objectSpread({}, (_knownTypes$typesBund19 = knownTypes.typesBundle) === null || _knownTypes$typesBund19 === void 0 ? void 0 : (_knownTypes$typesBund20 = _knownTypes$typesBund19.spec) === null || _knownTypes$typesBund20 === void 0 ? void 0 : (_knownTypes$typesBund21 = _knownTypes$typesBund20[s]) === null || _knownTypes$typesBund21 === void 0 ? void 0 : _knownTypes$typesBund21.rpc, (_knownTypes$typesBund22 = knownTypes.typesBundle) === null || _knownTypes$typesBund22 === void 0 ? void 0 : (_knownTypes$typesBund23 = _knownTypes$typesBund22.chain) === null || _knownTypes$typesBund23 === void 0 ? void 0 : (_knownTypes$typesBund24 = _knownTypes$typesBund23[c]) === null || _knownTypes$typesBund24 === void 0 ? void 0 : _knownTypes$typesBund24.rpc);
69
+ return objectSpread({}, (_knownTypes$typesBund19 = knownTypes.typesBundle) == null ? void 0 : (_knownTypes$typesBund20 = _knownTypes$typesBund19.spec) == null ? void 0 : (_knownTypes$typesBund21 = _knownTypes$typesBund20[s]) == null ? void 0 : _knownTypes$typesBund21.rpc, (_knownTypes$typesBund22 = knownTypes.typesBundle) == null ? void 0 : (_knownTypes$typesBund23 = _knownTypes$typesBund22.chain) == null ? void 0 : (_knownTypes$typesBund24 = _knownTypes$typesBund23[c]) == null ? void 0 : _knownTypes$typesBund24.rpc);
76
70
  });
77
71
  }
72
+
78
73
  /**
79
74
  * @description Based on the chain and runtimeVersion, get the applicable runtime definitions (ready for registration)
80
75
  */
81
-
82
76
  export function getSpecRuntime({
83
77
  knownTypes
84
78
  }, chainName, specName) {
85
79
  return withNames(chainName, specName, (c, s) => {
86
80
  var _knownTypes$typesBund25, _knownTypes$typesBund26, _knownTypes$typesBund27, _knownTypes$typesBund28, _knownTypes$typesBund29, _knownTypes$typesBund30;
87
-
88
- return objectSpread({}, (_knownTypes$typesBund25 = knownTypes.typesBundle) === null || _knownTypes$typesBund25 === void 0 ? void 0 : (_knownTypes$typesBund26 = _knownTypes$typesBund25.spec) === null || _knownTypes$typesBund26 === void 0 ? void 0 : (_knownTypes$typesBund27 = _knownTypes$typesBund26[s]) === null || _knownTypes$typesBund27 === void 0 ? void 0 : _knownTypes$typesBund27.runtime, (_knownTypes$typesBund28 = knownTypes.typesBundle) === null || _knownTypes$typesBund28 === void 0 ? void 0 : (_knownTypes$typesBund29 = _knownTypes$typesBund28.chain) === null || _knownTypes$typesBund29 === void 0 ? void 0 : (_knownTypes$typesBund30 = _knownTypes$typesBund29[c]) === null || _knownTypes$typesBund30 === void 0 ? void 0 : _knownTypes$typesBund30.runtime);
81
+ return objectSpread({}, (_knownTypes$typesBund25 = knownTypes.typesBundle) == null ? void 0 : (_knownTypes$typesBund26 = _knownTypes$typesBund25.spec) == null ? void 0 : (_knownTypes$typesBund27 = _knownTypes$typesBund26[s]) == null ? void 0 : _knownTypes$typesBund27.runtime, (_knownTypes$typesBund28 = knownTypes.typesBundle) == null ? void 0 : (_knownTypes$typesBund29 = _knownTypes$typesBund28.chain) == null ? void 0 : (_knownTypes$typesBund30 = _knownTypes$typesBund29[c]) == null ? void 0 : _knownTypes$typesBund30.runtime);
89
82
  });
90
83
  }
84
+
91
85
  /**
92
86
  * @description Based on the chain and runtimeVersion, get the applicable alias definitions (ready for registration)
93
87
  */
94
-
95
88
  export function getSpecAlias({
96
89
  knownTypes
97
90
  }, chainName, specName) {
98
91
  return withNames(chainName, specName, (c, s) => {
99
92
  var _knownTypes$typesBund31, _knownTypes$typesBund32, _knownTypes$typesBund33, _knownTypes$typesBund34, _knownTypes$typesBund35, _knownTypes$typesBund36;
100
-
101
- return (// as per versions, first spec, then chain then finally non-versioned
102
- objectSpread({}, (_knownTypes$typesBund31 = knownTypes.typesBundle) === null || _knownTypes$typesBund31 === void 0 ? void 0 : (_knownTypes$typesBund32 = _knownTypes$typesBund31.spec) === null || _knownTypes$typesBund32 === void 0 ? void 0 : (_knownTypes$typesBund33 = _knownTypes$typesBund32[s]) === null || _knownTypes$typesBund33 === void 0 ? void 0 : _knownTypes$typesBund33.alias, (_knownTypes$typesBund34 = knownTypes.typesBundle) === null || _knownTypes$typesBund34 === void 0 ? void 0 : (_knownTypes$typesBund35 = _knownTypes$typesBund34.chain) === null || _knownTypes$typesBund35 === void 0 ? void 0 : (_knownTypes$typesBund36 = _knownTypes$typesBund35[c]) === null || _knownTypes$typesBund36 === void 0 ? void 0 : _knownTypes$typesBund36.alias, knownTypes.typesAlias)
93
+ return (
94
+ // as per versions, first spec, then chain then finally non-versioned
95
+ objectSpread({}, (_knownTypes$typesBund31 = knownTypes.typesBundle) == null ? void 0 : (_knownTypes$typesBund32 = _knownTypes$typesBund31.spec) == null ? void 0 : (_knownTypes$typesBund33 = _knownTypes$typesBund32[s]) == null ? void 0 : _knownTypes$typesBund33.alias, (_knownTypes$typesBund34 = knownTypes.typesBundle) == null ? void 0 : (_knownTypes$typesBund35 = _knownTypes$typesBund34.chain) == null ? void 0 : (_knownTypes$typesBund36 = _knownTypes$typesBund35[c]) == null ? void 0 : _knownTypes$typesBund36.alias, knownTypes.typesAlias)
103
96
  );
104
97
  });
105
98
  }
99
+
106
100
  /**
107
101
  * @description Returns a version record for known chains where upgrades are being tracked
108
102
  */
109
-
110
103
  export function getUpgradeVersion(genesisHash, blockNumber) {
111
104
  const known = upgrades.find(u => genesisHash.eq(u.genesisHash));
112
105
  return known ? [known.versions.reduce((last, version) => {