@polkadot/types-known 6.12.2-2 → 6.12.2-23

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.
@@ -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,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,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,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 {};
@@ -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,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.js ADDED
@@ -0,0 +1,102 @@
1
+ // Copyright 2017-2021 @polkadot/types-known authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { bnToBn, isNull, isUndefined, objectSpread } from '@polkadot/util';
4
+ import typesChain from "./chain/index.js";
5
+ import typesSpec from "./spec/index.js";
6
+ import upgrades from "./upgrades/index.js";
7
+
8
+ function withNames(chainName, specName, fn) {
9
+ return fn(chainName.toString(), specName.toString());
10
+ } // flatten a VersionedType[] into a Record<string, string>
11
+
12
+ /** @internal */
13
+
14
+
15
+ function filterVersions(versions = [], specVersion) {
16
+ return versions.filter(({
17
+ minmax: [min, max]
18
+ }) => (isUndefined(min) || isNull(min) || specVersion >= min) && (isUndefined(max) || isNull(max) || specVersion <= max)).reduce((result, {
19
+ types
20
+ }) => objectSpread(result, types), {});
21
+ }
22
+ /**
23
+ * @description Based on the chain and runtimeVersion, get the applicable signed extensions (ready for registration)
24
+ */
25
+
26
+
27
+ export function getSpecExtensions({
28
+ knownTypes
29
+ }, chainName, specName) {
30
+ return withNames(chainName, specName, (c, s) => {
31
+ 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);
34
+ });
35
+ }
36
+ /**
37
+ * @description Based on the chain and runtimeVersion, get the applicable types (ready for registration)
38
+ */
39
+
40
+ export function getSpecTypes({
41
+ knownTypes
42
+ }, chainName, specName, specVersion) {
43
+ const _specVersion = bnToBn(specVersion).toNumber();
44
+
45
+ return withNames(chainName, specName, (c, s) => {
46
+ 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 -
49
+ // - spec then chain
50
+ // - typesBundle takes higher precedence
51
+ // - 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)
53
+ );
54
+ });
55
+ }
56
+ export function getSpecHasher({
57
+ knownTypes
58
+ }, chainName, specName) {
59
+ return withNames(chainName, specName, (c, s) => {
60
+ 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;
63
+ });
64
+ }
65
+ /**
66
+ * @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
67
+ */
68
+
69
+ export function getSpecRpc({
70
+ knownTypes
71
+ }, chainName, specName) {
72
+ return withNames(chainName, specName, (c, s) => {
73
+ 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);
76
+ });
77
+ }
78
+ /**
79
+ * @description Based on the chain and runtimeVersion, get the applicable alias definitions (ready for registration)
80
+ */
81
+
82
+ export function getSpecAlias({
83
+ knownTypes
84
+ }, chainName, specName) {
85
+ return withNames(chainName, specName, (c, s) => {
86
+ var _knownTypes$typesBund25, _knownTypes$typesBund26, _knownTypes$typesBund27, _knownTypes$typesBund28, _knownTypes$typesBund29, _knownTypes$typesBund30;
87
+
88
+ return (// as per versions, first spec, then chain then finally non-versioned
89
+ 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)
90
+ );
91
+ });
92
+ }
93
+ /**
94
+ * @description Returns a version record for known chains where upgrades are being tracked
95
+ */
96
+
97
+ export function getUpgradeVersion(genesisHash, blockNumber) {
98
+ const known = upgrades.find(u => genesisHash.eq(u.genesisHash));
99
+ return known ? [known.versions.reduce((last, version) => {
100
+ return blockNumber.gt(version.blockNumber) ? version : last;
101
+ }, undefined), known.versions.find(version => blockNumber.lte(version.blockNumber))] : [undefined, undefined];
102
+ }
package/bundle.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from '@polkadot/types/known';
2
- export { packageInfo } from './packageInfo';
@@ -1 +0,0 @@
1
- export {};
package/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import './detectPackage';
2
- export * from './bundle';
package/packageInfo.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export declare const packageInfo: {
2
- name: string;
3
- version: string;
4
- };