@polkadot/types-known 6.12.2-6 → 7.0.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 (57) hide show
  1. package/bundle.cjs +22 -34
  2. package/bundle.d.ts +2 -1
  3. package/bundle.js +3 -2
  4. package/chain/index.cjs +12 -0
  5. package/chain/index.d.ts +3 -0
  6. package/chain/index.js +5 -0
  7. package/package.json +92 -5
  8. package/packageInfo.cjs +1 -1
  9. package/packageInfo.js +1 -1
  10. package/spec/centrifuge-chain.cjs +98 -0
  11. package/spec/centrifuge-chain.d.ts +3 -0
  12. package/spec/centrifuge-chain.js +89 -0
  13. package/spec/index.cjs +45 -0
  14. package/spec/index.d.ts +3 -0
  15. package/spec/index.js +26 -0
  16. package/spec/kusama.cjs +177 -0
  17. package/spec/kusama.d.ts +3 -0
  18. package/spec/kusama.js +167 -0
  19. package/spec/node-template.cjs +17 -0
  20. package/spec/node-template.d.ts +3 -0
  21. package/spec/node-template.js +10 -0
  22. package/spec/node.cjs +17 -0
  23. package/spec/node.d.ts +3 -0
  24. package/spec/node.js +10 -0
  25. package/spec/polkadot.cjs +74 -0
  26. package/spec/polkadot.d.ts +3 -0
  27. package/spec/polkadot.js +65 -0
  28. package/spec/rococo.cjs +53 -0
  29. package/spec/rococo.d.ts +3 -0
  30. package/spec/rococo.js +43 -0
  31. package/spec/shell.cjs +17 -0
  32. package/spec/shell.d.ts +3 -0
  33. package/spec/shell.js +10 -0
  34. package/spec/statemint.cjs +35 -0
  35. package/spec/statemint.d.ts +3 -0
  36. package/spec/statemint.js +25 -0
  37. package/spec/westend.cjs +90 -0
  38. package/spec/westend.d.ts +3 -0
  39. package/spec/westend.js +80 -0
  40. package/upgrades/index.cjs +66 -0
  41. package/upgrades/index.d.ts +3 -0
  42. package/upgrades/index.js +47 -0
  43. package/upgrades/kusama.cjs +11 -0
  44. package/upgrades/kusama.d.ts +3 -0
  45. package/upgrades/kusama.js +4 -0
  46. package/upgrades/polkadot.cjs +11 -0
  47. package/upgrades/polkadot.d.ts +3 -0
  48. package/upgrades/polkadot.js +4 -0
  49. package/upgrades/types.cjs +1 -0
  50. package/upgrades/types.d.ts +1 -0
  51. package/upgrades/types.js +1 -0
  52. package/upgrades/westend.cjs +11 -0
  53. package/upgrades/westend.d.ts +3 -0
  54. package/upgrades/westend.js +4 -0
  55. package/util.cjs +139 -0
  56. package/util.d.ts +27 -0
  57. package/util.js +102 -0
package/spec/shell.js ADDED
@@ -0,0 +1,10 @@
1
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /* eslint-disable sort-keys */
5
+ const versioned = [{
6
+ minmax: [0, undefined],
7
+ types: {// nothing, limited runtime
8
+ }
9
+ }];
10
+ export default versioned;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _typesCreate = require("@polkadot/types-create");
9
+
10
+ var _util = require("@polkadot/util");
11
+
12
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
13
+ // SPDX-License-Identifier: Apache-2.0
14
+
15
+ /* eslint-disable sort-keys */
16
+ const sharedTypes = {
17
+ TAssetBalance: 'u128',
18
+ ProxyType: {
19
+ _enum: ['Any', 'NonTransfer', 'CancelProxy', 'Assets', 'AssetOwner', 'AssetManager', 'Staking']
20
+ }
21
+ }; // these are override types for Statemine, Statemint, Westmint
22
+
23
+ const versioned = [{
24
+ minmax: [0, 3],
25
+ types: (0, _util.objectSpread)({}, sharedTypes, (0, _typesCreate.mapXcmTypes)('V0'))
26
+ }, {
27
+ minmax: [4, 5],
28
+ types: (0, _util.objectSpread)({}, sharedTypes, (0, _typesCreate.mapXcmTypes)('V1'))
29
+ }, {
30
+ // metadata V14
31
+ minmax: [500, undefined],
32
+ types: {}
33
+ }];
34
+ var _default = versioned;
35
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import type { OverrideVersionedType } from '@polkadot/types/types';
2
+ declare const versioned: OverrideVersionedType[];
3
+ export default versioned;
@@ -0,0 +1,25 @@
1
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /* eslint-disable sort-keys */
5
+ import { mapXcmTypes } from '@polkadot/types-create';
6
+ import { objectSpread } from '@polkadot/util';
7
+ const sharedTypes = {
8
+ TAssetBalance: 'u128',
9
+ ProxyType: {
10
+ _enum: ['Any', 'NonTransfer', 'CancelProxy', 'Assets', 'AssetOwner', 'AssetManager', 'Staking']
11
+ }
12
+ }; // these are override types for Statemine, Statemint, Westmint
13
+
14
+ const versioned = [{
15
+ minmax: [0, 3],
16
+ types: objectSpread({}, sharedTypes, mapXcmTypes('V0'))
17
+ }, {
18
+ minmax: [4, 5],
19
+ types: objectSpread({}, sharedTypes, mapXcmTypes('V1'))
20
+ }, {
21
+ // metadata V14
22
+ minmax: [500, undefined],
23
+ types: {}
24
+ }];
25
+ export default versioned;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _typesCreate = require("@polkadot/types-create");
9
+
10
+ var _util = require("@polkadot/util");
11
+
12
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
13
+ // SPDX-License-Identifier: Apache-2.0
14
+
15
+ /* eslint-disable sort-keys */
16
+ const sharedTypes = {
17
+ // 16 validators
18
+ CompactAssignments: 'CompactAssignmentsWith16',
19
+ RawSolution: 'RawSolutionWith16',
20
+ // general
21
+ Keys: 'SessionKeys6',
22
+ ProxyType: {
23
+ _enum: ['Any', 'NonTransfer', 'Staking', 'SudoBalances', 'IdentityJudgement', 'CancelProxy']
24
+ }
25
+ };
26
+ const addrAccountIdTypes = {
27
+ AccountInfo: 'AccountInfoWithRefCount',
28
+ Address: 'AccountId',
29
+ CompactAssignments: 'CompactAssignmentsWith16',
30
+ LookupSource: 'AccountId',
31
+ Keys: 'SessionKeys5',
32
+ RawSolution: 'RawSolutionWith16',
33
+ ValidatorPrefs: 'ValidatorPrefsWithCommission'
34
+ };
35
+ const versioned = [{
36
+ minmax: [1, 2],
37
+ types: (0, _util.objectSpread)({}, sharedTypes, addrAccountIdTypes, {
38
+ CompactAssignments: 'CompactAssignmentsTo257',
39
+ DispatchInfo: 'DispatchInfoTo244',
40
+ Heartbeat: 'HeartbeatTo244',
41
+ Multiplier: 'Fixed64',
42
+ OpenTip: 'OpenTipTo225',
43
+ RefCount: 'RefCountTo259',
44
+ Weight: 'u32'
45
+ })
46
+ }, {
47
+ minmax: [3, 22],
48
+ types: (0, _util.objectSpread)({}, sharedTypes, addrAccountIdTypes, {
49
+ CompactAssignments: 'CompactAssignmentsTo257',
50
+ DispatchInfo: 'DispatchInfoTo244',
51
+ Heartbeat: 'HeartbeatTo244',
52
+ OpenTip: 'OpenTipTo225',
53
+ RefCount: 'RefCountTo259'
54
+ })
55
+ }, {
56
+ minmax: [23, 42],
57
+ types: (0, _util.objectSpread)({}, sharedTypes, addrAccountIdTypes, {
58
+ CompactAssignments: 'CompactAssignmentsTo257',
59
+ DispatchInfo: 'DispatchInfoTo244',
60
+ Heartbeat: 'HeartbeatTo244',
61
+ RefCount: 'RefCountTo259'
62
+ })
63
+ }, {
64
+ minmax: [43, 44],
65
+ types: (0, _util.objectSpread)({}, sharedTypes, addrAccountIdTypes, {
66
+ DispatchInfo: 'DispatchInfoTo244',
67
+ Heartbeat: 'HeartbeatTo244',
68
+ RefCount: 'RefCountTo259'
69
+ })
70
+ }, {
71
+ minmax: [45, 47],
72
+ types: (0, _util.objectSpread)({}, sharedTypes, addrAccountIdTypes)
73
+ }, {
74
+ minmax: [48, 49],
75
+ types: (0, _util.objectSpread)({}, sharedTypes, {
76
+ AccountInfo: 'AccountInfoWithDualRefCount'
77
+ })
78
+ }, {
79
+ minmax: [50, 9099],
80
+ types: (0, _util.objectSpread)({}, sharedTypes, (0, _typesCreate.mapXcmTypes)('V0'))
81
+ }, {
82
+ minmax: [9100, 9105],
83
+ types: (0, _util.objectSpread)({}, sharedTypes, (0, _typesCreate.mapXcmTypes)('V1'))
84
+ }, {
85
+ // metadata v14
86
+ minmax: [9106, undefined],
87
+ types: {}
88
+ }];
89
+ var _default = versioned;
90
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import type { OverrideVersionedType } from '@polkadot/types/types';
2
+ declare const versioned: OverrideVersionedType[];
3
+ export default versioned;
@@ -0,0 +1,80 @@
1
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /* eslint-disable sort-keys */
5
+ import { mapXcmTypes } from '@polkadot/types-create';
6
+ import { objectSpread } from '@polkadot/util';
7
+ const sharedTypes = {
8
+ // 16 validators
9
+ CompactAssignments: 'CompactAssignmentsWith16',
10
+ RawSolution: 'RawSolutionWith16',
11
+ // general
12
+ Keys: 'SessionKeys6',
13
+ ProxyType: {
14
+ _enum: ['Any', 'NonTransfer', 'Staking', 'SudoBalances', 'IdentityJudgement', 'CancelProxy']
15
+ }
16
+ };
17
+ const addrAccountIdTypes = {
18
+ AccountInfo: 'AccountInfoWithRefCount',
19
+ Address: 'AccountId',
20
+ CompactAssignments: 'CompactAssignmentsWith16',
21
+ LookupSource: 'AccountId',
22
+ Keys: 'SessionKeys5',
23
+ RawSolution: 'RawSolutionWith16',
24
+ ValidatorPrefs: 'ValidatorPrefsWithCommission'
25
+ };
26
+ const versioned = [{
27
+ minmax: [1, 2],
28
+ types: objectSpread({}, sharedTypes, addrAccountIdTypes, {
29
+ CompactAssignments: 'CompactAssignmentsTo257',
30
+ DispatchInfo: 'DispatchInfoTo244',
31
+ Heartbeat: 'HeartbeatTo244',
32
+ Multiplier: 'Fixed64',
33
+ OpenTip: 'OpenTipTo225',
34
+ RefCount: 'RefCountTo259',
35
+ Weight: 'u32'
36
+ })
37
+ }, {
38
+ minmax: [3, 22],
39
+ types: objectSpread({}, sharedTypes, addrAccountIdTypes, {
40
+ CompactAssignments: 'CompactAssignmentsTo257',
41
+ DispatchInfo: 'DispatchInfoTo244',
42
+ Heartbeat: 'HeartbeatTo244',
43
+ OpenTip: 'OpenTipTo225',
44
+ RefCount: 'RefCountTo259'
45
+ })
46
+ }, {
47
+ minmax: [23, 42],
48
+ types: objectSpread({}, sharedTypes, addrAccountIdTypes, {
49
+ CompactAssignments: 'CompactAssignmentsTo257',
50
+ DispatchInfo: 'DispatchInfoTo244',
51
+ Heartbeat: 'HeartbeatTo244',
52
+ RefCount: 'RefCountTo259'
53
+ })
54
+ }, {
55
+ minmax: [43, 44],
56
+ types: objectSpread({}, sharedTypes, addrAccountIdTypes, {
57
+ DispatchInfo: 'DispatchInfoTo244',
58
+ Heartbeat: 'HeartbeatTo244',
59
+ RefCount: 'RefCountTo259'
60
+ })
61
+ }, {
62
+ minmax: [45, 47],
63
+ types: objectSpread({}, sharedTypes, addrAccountIdTypes)
64
+ }, {
65
+ minmax: [48, 49],
66
+ types: objectSpread({}, sharedTypes, {
67
+ AccountInfo: 'AccountInfoWithDualRefCount'
68
+ })
69
+ }, {
70
+ minmax: [50, 9099],
71
+ types: objectSpread({}, sharedTypes, mapXcmTypes('V0'))
72
+ }, {
73
+ minmax: [9100, 9105],
74
+ types: objectSpread({}, sharedTypes, mapXcmTypes('V1'))
75
+ }, {
76
+ // metadata v14
77
+ minmax: [9106, undefined],
78
+ types: {}
79
+ }];
80
+ export default versioned;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _networks = require("@polkadot/networks");
11
+
12
+ var _util = require("@polkadot/util");
13
+
14
+ var _kusama = _interopRequireDefault(require("./kusama.cjs"));
15
+
16
+ var _polkadot = _interopRequireDefault(require("./polkadot.cjs"));
17
+
18
+ var _westend = _interopRequireDefault(require("./westend.cjs"));
19
+
20
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
21
+ // SPDX-License-Identifier: Apache-2.0
22
+ const allKnown = {
23
+ kusama: _kusama.default,
24
+ polkadot: _polkadot.default,
25
+ westend: _westend.default
26
+ }; // testnets are not available in the networks map
27
+
28
+ const NET_EXTRA = {
29
+ westend: {
30
+ genesisHash: ['0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e']
31
+ }
32
+ };
33
+ /** @internal */
34
+
35
+ function checkOrder(network, versions) {
36
+ const ooo = versions.filter((curr, index) => {
37
+ const prev = versions[index - 1];
38
+ return index === 0 ? false : curr[0] <= prev[0] || curr[1] <= prev[1];
39
+ });
40
+ (0, _util.assert)(!ooo.length, () => `${network}: Mismatched upgrade ordering: ${(0, _util.stringify)(ooo)}`);
41
+ return versions;
42
+ }
43
+ /** @internal */
44
+
45
+
46
+ function mapRaw(_ref) {
47
+ let [network, versions] = _ref;
48
+ const chain = _networks.selectableNetworks.find(n => n.network === network) || NET_EXTRA[network];
49
+ (0, _util.assert)(chain, () => `Unable to find info for chain ${network}`);
50
+ return {
51
+ genesisHash: (0, _util.hexToU8a)(chain.genesisHash[0]),
52
+ network,
53
+ versions: checkOrder(network, versions).map(_ref2 => {
54
+ let [blockNumber, specVersion] = _ref2;
55
+ return {
56
+ blockNumber: new _util.BN(blockNumber),
57
+ specVersion: new _util.BN(specVersion)
58
+ };
59
+ })
60
+ };
61
+ } // Type overrides for specific spec types & versions as given in runtimeVersion
62
+
63
+
64
+ const upgrades = Object.entries(allKnown).map(mapRaw);
65
+ var _default = upgrades;
66
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import type { ChainUpgrades } from '@polkadot/types/types';
2
+ declare const upgrades: ChainUpgrades[];
3
+ export default upgrades;
@@ -0,0 +1,47 @@
1
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { selectableNetworks } from '@polkadot/networks';
4
+ import { assert, BN, hexToU8a, stringify } from '@polkadot/util';
5
+ import kusama from "./kusama.js";
6
+ import polkadot from "./polkadot.js";
7
+ import westend from "./westend.js";
8
+ const allKnown = {
9
+ kusama,
10
+ polkadot,
11
+ westend
12
+ }; // testnets are not available in the networks map
13
+
14
+ const NET_EXTRA = {
15
+ westend: {
16
+ genesisHash: ['0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e']
17
+ }
18
+ };
19
+ /** @internal */
20
+
21
+ function checkOrder(network, versions) {
22
+ const ooo = versions.filter((curr, index) => {
23
+ const prev = versions[index - 1];
24
+ return index === 0 ? false : curr[0] <= prev[0] || curr[1] <= prev[1];
25
+ });
26
+ assert(!ooo.length, () => `${network}: Mismatched upgrade ordering: ${stringify(ooo)}`);
27
+ return versions;
28
+ }
29
+ /** @internal */
30
+
31
+
32
+ function mapRaw([network, versions]) {
33
+ const chain = selectableNetworks.find(n => n.network === network) || NET_EXTRA[network];
34
+ assert(chain, () => `Unable to find info for chain ${network}`);
35
+ return {
36
+ genesisHash: hexToU8a(chain.genesisHash[0]),
37
+ network,
38
+ versions: checkOrder(network, versions).map(([blockNumber, specVersion]) => ({
39
+ blockNumber: new BN(blockNumber),
40
+ specVersion: new BN(specVersion)
41
+ }))
42
+ };
43
+ } // Type overrides for specific spec types & versions as given in runtimeVersion
44
+
45
+
46
+ const upgrades = Object.entries(allKnown).map(mapRaw);
47
+ export default upgrades;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
8
+ // SPDX-License-Identifier: Apache-2.0
9
+ const upgrades = [[0, 1020], [26669, 1021], [38245, 1022], [54248, 1023], [59659, 1024], [67651, 1025], [82191, 1027], [83238, 1028], [101503, 1029], [203466, 1030], [295787, 1031], [461692, 1032], [504329, 1033], [569327, 1038], [587687, 1039], [653183, 1040], [693488, 1042], [901442, 1045], [1375086, 1050], [1445458, 1051], [1472960, 1052], [1475648, 1053], [1491596, 1054], [1574408, 1055], [2064961, 1058], [2201991, 1062], [2671528, 2005], [2704202, 2007], [2728002, 2008], [2832534, 2011], [2962294, 2012], [3240000, 2013], [3274408, 2015], [3323565, 2019], [3534175, 2022], [3860281, 2023], [4143129, 2024], [4401242, 2025], [4841367, 2026], [5961600, 2027], [6137912, 2028], [6561855, 2029], [7100891, 2030], [7468792, 9010], [7668600, 9030], [7812476, 9040], [8010981, 9050], [8073833, 9070], [8555825, 9080], [8945245, 9090], [9611377, 9100], [9625129, 9111], [9866422, 9122], [10403784, 9130]];
10
+ var _default = upgrades;
11
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import type { ChainUpgradesRaw } from './types';
2
+ declare const upgrades: ChainUpgradesRaw;
3
+ export default upgrades;
@@ -0,0 +1,4 @@
1
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ const upgrades = [[0, 1020], [26669, 1021], [38245, 1022], [54248, 1023], [59659, 1024], [67651, 1025], [82191, 1027], [83238, 1028], [101503, 1029], [203466, 1030], [295787, 1031], [461692, 1032], [504329, 1033], [569327, 1038], [587687, 1039], [653183, 1040], [693488, 1042], [901442, 1045], [1375086, 1050], [1445458, 1051], [1472960, 1052], [1475648, 1053], [1491596, 1054], [1574408, 1055], [2064961, 1058], [2201991, 1062], [2671528, 2005], [2704202, 2007], [2728002, 2008], [2832534, 2011], [2962294, 2012], [3240000, 2013], [3274408, 2015], [3323565, 2019], [3534175, 2022], [3860281, 2023], [4143129, 2024], [4401242, 2025], [4841367, 2026], [5961600, 2027], [6137912, 2028], [6561855, 2029], [7100891, 2030], [7468792, 9010], [7668600, 9030], [7812476, 9040], [8010981, 9050], [8073833, 9070], [8555825, 9080], [8945245, 9090], [9611377, 9100], [9625129, 9111], [9866422, 9122], [10403784, 9130]];
4
+ export default upgrades;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
8
+ // SPDX-License-Identifier: Apache-2.0
9
+ const upgrades = [[0, 0], [29231, 1], [188836, 5], [199405, 6], [214264, 7], [244358, 8], [303079, 9], [314201, 10], [342400, 11], [443963, 12], [528470, 13], [687751, 14], [746085, 15], [787923, 16], [799302, 17], [1205128, 18], [1603423, 23], [1733218, 24], [2005673, 25], [2436698, 26], [3613564, 27], [3899547, 28], [4345767, 29], [4876134, 30], [5661442, 9050], [6321619, 9080], [6713249, 9090], [7217907, 9100], [7229126, 9110], [7560558, 9122], [8115869, 9140]];
10
+ var _default = upgrades;
11
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import type { ChainUpgradesRaw } from './types';
2
+ declare const upgrades: ChainUpgradesRaw;
3
+ export default upgrades;
@@ -0,0 +1,4 @@
1
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ const upgrades = [[0, 0], [29231, 1], [188836, 5], [199405, 6], [214264, 7], [244358, 8], [303079, 9], [314201, 10], [342400, 11], [443963, 12], [528470, 13], [687751, 14], [746085, 15], [787923, 16], [799302, 17], [1205128, 18], [1603423, 23], [1733218, 24], [2005673, 25], [2436698, 26], [3613564, 27], [3899547, 28], [4345767, 29], [4876134, 30], [5661442, 9050], [6321619, 9080], [6713249, 9090], [7217907, 9100], [7229126, 9110], [7560558, 9122], [8115869, 9140]];
4
+ export default upgrades;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ export declare type ChainUpgradesRaw = [number, number][];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
8
+ // SPDX-License-Identifier: Apache-2.0
9
+ const upgrades = [[214356, 4], [392764, 7], [409740, 8], [809976, 20], [877581, 24], [879238, 25], [889472, 26], [902937, 27], [932751, 28], [991142, 29], [1030162, 31], [1119657, 32], [1199282, 33], [1342534, 34], [1392263, 35], [1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44], [2549864, 45], [3925782, 46], [3925843, 47], [4207800, 48], [4627944, 49], [5124076, 50], [5478664, 900], [5482450, 9000], [5584305, 9010], [5784566, 9030], [5879822, 9031], [5896856, 9032], [5897316, 9033], [6117927, 9050], [6210274, 9070], [6379314, 9080], [6979141, 9090], [7568453, 9100], [7766394, 9111], [7911691, 9120], [7968866, 9121], [7982889, 9122]];
10
+ var _default = upgrades;
11
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import type { ChainUpgradesRaw } from './types';
2
+ declare const upgrades: ChainUpgradesRaw;
3
+ export default upgrades;
@@ -0,0 +1,4 @@
1
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ const upgrades = [[214356, 4], [392764, 7], [409740, 8], [809976, 20], [877581, 24], [879238, 25], [889472, 26], [902937, 27], [932751, 28], [991142, 29], [1030162, 31], [1119657, 32], [1199282, 33], [1342534, 34], [1392263, 35], [1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44], [2549864, 45], [3925782, 46], [3925843, 47], [4207800, 48], [4627944, 49], [5124076, 50], [5478664, 900], [5482450, 9000], [5584305, 9010], [5784566, 9030], [5879822, 9031], [5896856, 9032], [5897316, 9033], [6117927, 9050], [6210274, 9070], [6379314, 9080], [6979141, 9090], [7568453, 9100], [7766394, 9111], [7911691, 9120], [7968866, 9121], [7982889, 9122]];
4
+ export default upgrades;
package/util.cjs ADDED
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.getSpecAlias = getSpecAlias;
9
+ exports.getSpecExtensions = getSpecExtensions;
10
+ exports.getSpecHasher = getSpecHasher;
11
+ exports.getSpecRpc = getSpecRpc;
12
+ exports.getSpecTypes = getSpecTypes;
13
+ exports.getUpgradeVersion = getUpgradeVersion;
14
+
15
+ var _util = require("@polkadot/util");
16
+
17
+ var _index = _interopRequireDefault(require("./chain/index.cjs"));
18
+
19
+ var _index2 = _interopRequireDefault(require("./spec/index.cjs"));
20
+
21
+ var _index3 = _interopRequireDefault(require("./upgrades/index.cjs"));
22
+
23
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
24
+ // SPDX-License-Identifier: Apache-2.0
25
+ function withNames(chainName, specName, fn) {
26
+ return fn(chainName.toString(), specName.toString());
27
+ } // flatten a VersionedType[] into a Record<string, string>
28
+
29
+ /** @internal */
30
+
31
+
32
+ function filterVersions() {
33
+ let versions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
34
+ let specVersion = arguments.length > 1 ? arguments[1] : undefined;
35
+ return versions.filter(_ref => {
36
+ let {
37
+ minmax: [min, max]
38
+ } = _ref;
39
+ return ((0, _util.isUndefined)(min) || (0, _util.isNull)(min) || specVersion >= min) && ((0, _util.isUndefined)(max) || (0, _util.isNull)(max) || specVersion <= max);
40
+ }).reduce((result, _ref2) => {
41
+ let {
42
+ types
43
+ } = _ref2;
44
+ return (0, _util.objectSpread)(result, types);
45
+ }, {});
46
+ }
47
+ /**
48
+ * @description Based on the chain and runtimeVersion, get the applicable signed extensions (ready for registration)
49
+ */
50
+
51
+
52
+ function getSpecExtensions(_ref3, chainName, specName) {
53
+ let {
54
+ knownTypes
55
+ } = _ref3;
56
+ return withNames(chainName, specName, (c, s) => {
57
+ var _knownTypes$typesBund, _knownTypes$typesBund2, _knownTypes$typesBund3, _knownTypes$typesBund4, _knownTypes$typesBund5, _knownTypes$typesBund6;
58
+
59
+ return (0, _util.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);
60
+ });
61
+ }
62
+ /**
63
+ * @description Based on the chain and runtimeVersion, get the applicable types (ready for registration)
64
+ */
65
+
66
+
67
+ function getSpecTypes(_ref4, chainName, specName, specVersion) {
68
+ let {
69
+ knownTypes
70
+ } = _ref4;
71
+
72
+ const _specVersion = (0, _util.bnToBn)(specVersion).toNumber();
73
+
74
+ return withNames(chainName, specName, (c, s) => {
75
+ var _knownTypes$typesBund7, _knownTypes$typesBund8, _knownTypes$typesBund9, _knownTypes$typesBund10, _knownTypes$typesBund11, _knownTypes$typesBund12, _knownTypes$typesSpec, _knownTypes$typesChai;
76
+
77
+ return (// The order here is always, based on -
78
+ // - spec then chain
79
+ // - typesBundle takes higher precedence
80
+ // - types is the final catch-all override
81
+ (0, _util.objectSpread)({}, filterVersions(_index2.default[s], _specVersion), filterVersions(_index.default[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)
82
+ );
83
+ });
84
+ }
85
+
86
+ function getSpecHasher(_ref5, chainName, specName) {
87
+ let {
88
+ knownTypes
89
+ } = _ref5;
90
+ return withNames(chainName, specName, (c, s) => {
91
+ var _knownTypes$typesBund13, _knownTypes$typesBund14, _knownTypes$typesBund15, _knownTypes$typesBund16, _knownTypes$typesBund17, _knownTypes$typesBund18;
92
+
93
+ 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;
94
+ });
95
+ }
96
+ /**
97
+ * @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
98
+ */
99
+
100
+
101
+ function getSpecRpc(_ref6, chainName, specName) {
102
+ let {
103
+ knownTypes
104
+ } = _ref6;
105
+ return withNames(chainName, specName, (c, s) => {
106
+ var _knownTypes$typesBund19, _knownTypes$typesBund20, _knownTypes$typesBund21, _knownTypes$typesBund22, _knownTypes$typesBund23, _knownTypes$typesBund24;
107
+
108
+ return (0, _util.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);
109
+ });
110
+ }
111
+ /**
112
+ * @description Based on the chain and runtimeVersion, get the applicable alias definitions (ready for registration)
113
+ */
114
+
115
+
116
+ function getSpecAlias(_ref7, chainName, specName) {
117
+ let {
118
+ knownTypes
119
+ } = _ref7;
120
+ return withNames(chainName, specName, (c, s) => {
121
+ var _knownTypes$typesBund25, _knownTypes$typesBund26, _knownTypes$typesBund27, _knownTypes$typesBund28, _knownTypes$typesBund29, _knownTypes$typesBund30;
122
+
123
+ return (// as per versions, first spec, then chain then finally non-versioned
124
+ (0, _util.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.alias, (_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.alias, knownTypes.typesAlias)
125
+ );
126
+ });
127
+ }
128
+ /**
129
+ * @description Returns a version record for known chains where upgrades are being tracked
130
+ */
131
+
132
+
133
+ function getUpgradeVersion(genesisHash, blockNumber) {
134
+ const known = _index3.default.find(u => genesisHash.eq(u.genesisHash));
135
+
136
+ return known ? [known.versions.reduce((last, version) => {
137
+ return blockNumber.gt(version.blockNumber) ? version : last;
138
+ }, undefined), known.versions.find(version => blockNumber.lte(version.blockNumber))] : [undefined, undefined];
139
+ }
package/util.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ /// <reference types="bn.js" />
2
+ import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
3
+ import type { Hash } from '@polkadot/types/interfaces';
4
+ import type { ChainUpgradeVersion, CodecHasher, DefinitionRpc, DefinitionRpcSub, OverrideModuleType, Registry, RegistryTypes } from '@polkadot/types/types';
5
+ import type { Text } from '@polkadot/types-codec';
6
+ import type { BN } from '@polkadot/util';
7
+ /**
8
+ * @description Based on the chain and runtimeVersion, get the applicable signed extensions (ready for registration)
9
+ */
10
+ export declare function getSpecExtensions({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): ExtDef;
11
+ /**
12
+ * @description Based on the chain and runtimeVersion, get the applicable types (ready for registration)
13
+ */
14
+ export declare function getSpecTypes({ knownTypes }: Registry, chainName: Text | string, specName: Text | string, specVersion: bigint | BN | number): RegistryTypes;
15
+ export declare function getSpecHasher({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): CodecHasher | null;
16
+ /**
17
+ * @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
18
+ */
19
+ export declare function getSpecRpc({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
20
+ /**
21
+ * @description Based on the chain and runtimeVersion, get the applicable alias definitions (ready for registration)
22
+ */
23
+ export declare function getSpecAlias({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): Record<string, OverrideModuleType>;
24
+ /**
25
+ * @description Returns a version record for known chains where upgrades are being tracked
26
+ */
27
+ export declare function getUpgradeVersion(genesisHash: Hash, blockNumber: BN): [ChainUpgradeVersion | undefined, ChainUpgradeVersion | undefined];