@polkadot/types-known 6.12.1 → 6.12.2-11

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.
package/bundle.cjs CHANGED
@@ -1,27 +1,16 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
- exports.getModuleTypes = getModuleTypes;
9
- exports.getSpecAlias = getSpecAlias;
10
- exports.getSpecExtensions = getSpecExtensions;
11
- exports.getSpecHasher = getSpecHasher;
12
- exports.getSpecRpc = getSpecRpc;
13
- exports.getSpecTypes = getSpecTypes;
14
- exports.getUpgradeVersion = getUpgradeVersion;
15
- Object.defineProperty(exports, "knownOrigins", {
16
- enumerable: true,
17
- get: function () {
18
- return _knownOrigins.knownOrigins;
19
- }
20
- });
6
+ var _exportNames = {
7
+ mapXcmTypes: true,
8
+ packageInfo: true
9
+ };
21
10
  Object.defineProperty(exports, "mapXcmTypes", {
22
11
  enumerable: true,
23
12
  get: function () {
24
- return _xcm.mapXcmTypes;
13
+ return _typesCreate.mapXcmTypes;
25
14
  }
26
15
  });
27
16
  Object.defineProperty(exports, "packageInfo", {
@@ -31,149 +20,20 @@ Object.defineProperty(exports, "packageInfo", {
31
20
  }
32
21
  });
33
22
 
34
- var _util = require("@polkadot/util");
35
-
36
- var _index = _interopRequireDefault(require("./chain/index.cjs"));
37
-
38
- var _modules = _interopRequireDefault(require("./modules.cjs"));
39
-
40
- var _index2 = _interopRequireDefault(require("./spec/index.cjs"));
41
-
42
- var _index3 = _interopRequireDefault(require("./upgrades/index.cjs"));
43
-
44
- var _knownOrigins = require("./knownOrigins.cjs");
23
+ var _typesCreate = require("@polkadot/types-create");
45
24
 
46
25
  var _packageInfo = require("./packageInfo.cjs");
47
26
 
48
- var _xcm = require("./xcm.cjs");
49
-
50
- // Copyright 2017-2021 @polkadot/types-known authors & contributors
51
- // SPDX-License-Identifier: Apache-2.0
52
- function withNames(chainName, specName, fn) {
53
- return fn(chainName.toString(), specName.toString());
54
- } // flatten a VersionedType[] into a Record<string, string>
55
-
56
- /** @internal */
57
-
58
-
59
- function filterVersions() {
60
- let versions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
61
- let specVersion = arguments.length > 1 ? arguments[1] : undefined;
62
- return versions.filter(_ref => {
63
- let {
64
- minmax: [min, max]
65
- } = _ref;
66
- return ((0, _util.isUndefined)(min) || (0, _util.isNull)(min) || specVersion >= min) && ((0, _util.isUndefined)(max) || (0, _util.isNull)(max) || specVersion <= max);
67
- }).reduce((result, _ref2) => {
68
- let {
69
- types
70
- } = _ref2;
71
- return (0, _util.objectSpread)(result, types);
72
- }, {});
73
- }
74
- /**
75
- * @description Get types for specific modules (metadata override)
76
- */
77
-
78
-
79
- function getModuleTypes(_ref3, section) {
80
- var _knownTypes$typesAlia;
81
-
82
- let {
83
- knownTypes
84
- } = _ref3;
85
- return (0, _util.objectSpread)({}, _modules.default[section], (_knownTypes$typesAlia = knownTypes.typesAlias) === null || _knownTypes$typesAlia === void 0 ? void 0 : _knownTypes$typesAlia[section]);
86
- }
87
- /**
88
- * @description Based on the chain and runtimeVersion, get the applicable signed extensions (ready for registration)
89
- */
90
-
91
-
92
- function getSpecExtensions(_ref4, chainName, specName) {
93
- let {
94
- knownTypes
95
- } = _ref4;
96
- return withNames(chainName, specName, (c, s) => {
97
- var _knownTypes$typesBund, _knownTypes$typesBund2, _knownTypes$typesBund3, _knownTypes$typesBund4, _knownTypes$typesBund5, _knownTypes$typesBund6;
98
-
99
- 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);
27
+ var _util = require("./util.cjs");
28
+
29
+ Object.keys(_util).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
32
+ if (key in exports && exports[key] === _util[key]) return;
33
+ Object.defineProperty(exports, key, {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _util[key];
37
+ }
100
38
  });
101
- }
102
- /**
103
- * @description Based on the chain and runtimeVersion, get the applicable types (ready for registration)
104
- */
105
-
106
-
107
- function getSpecTypes(_ref5, chainName, specName, specVersion) {
108
- let {
109
- knownTypes
110
- } = _ref5;
111
-
112
- const _specVersion = (0, _util.bnToBn)(specVersion).toNumber();
113
-
114
- return withNames(chainName, specName, (c, s) => {
115
- var _knownTypes$typesBund7, _knownTypes$typesBund8, _knownTypes$typesBund9, _knownTypes$typesBund10, _knownTypes$typesBund11, _knownTypes$typesBund12, _knownTypes$typesSpec, _knownTypes$typesChai;
116
-
117
- return (// The order here is always, based on -
118
- // - spec then chain
119
- // - typesBundle takes higher precedence
120
- // - types is the final catch-all override
121
- (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)
122
- );
123
- });
124
- }
125
-
126
- function getSpecHasher(_ref6, chainName, specName) {
127
- let {
128
- knownTypes
129
- } = _ref6;
130
- return withNames(chainName, specName, (c, s) => {
131
- var _knownTypes$typesBund13, _knownTypes$typesBund14, _knownTypes$typesBund15, _knownTypes$typesBund16, _knownTypes$typesBund17, _knownTypes$typesBund18;
132
-
133
- 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;
134
- });
135
- }
136
- /**
137
- * @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
138
- */
139
-
140
-
141
- function getSpecRpc(_ref7, chainName, specName) {
142
- let {
143
- knownTypes
144
- } = _ref7;
145
- return withNames(chainName, specName, (c, s) => {
146
- var _knownTypes$typesBund19, _knownTypes$typesBund20, _knownTypes$typesBund21, _knownTypes$typesBund22, _knownTypes$typesBund23, _knownTypes$typesBund24;
147
-
148
- 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);
149
- });
150
- }
151
- /**
152
- * @description Based on the chain and runtimeVersion, get the applicable alias definitions (ready for registration)
153
- */
154
-
155
-
156
- function getSpecAlias(_ref8, chainName, specName) {
157
- let {
158
- knownTypes
159
- } = _ref8;
160
- return withNames(chainName, specName, (c, s) => {
161
- var _knownTypes$typesBund25, _knownTypes$typesBund26, _knownTypes$typesBund27, _knownTypes$typesBund28, _knownTypes$typesBund29, _knownTypes$typesBund30;
162
-
163
- return (// as per versions, first spec, then chain then finally non-versioned
164
- (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)
165
- );
166
- });
167
- }
168
- /**
169
- * @description Returns a version record for known chains where upgrades are being tracked
170
- */
171
-
172
-
173
- function getUpgradeVersion(genesisHash, blockNumber) {
174
- const known = _index3.default.find(u => genesisHash.eq(u.genesisHash));
175
-
176
- return known ? [known.versions.reduce((last, version) => {
177
- return blockNumber.gt(version.blockNumber) ? version : last;
178
- }, undefined), known.versions.find(version => blockNumber.lte(version.blockNumber))] : [undefined, undefined];
179
- }
39
+ });
package/bundle.d.ts CHANGED
@@ -1,34 +1,3 @@
1
- /// <reference types="bn.js" />
2
- import type { Text } from '@polkadot/types';
3
- import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
4
- import type { Hash } from '@polkadot/types/interfaces';
5
- import type { ChainUpgradeVersion, CodecHasher, DefinitionRpc, DefinitionRpcSub, OverrideModuleType, Registry, RegistryTypes } from '@polkadot/types/types';
6
- import type { BN } from '@polkadot/util';
7
- export { knownOrigins } from './knownOrigins';
1
+ export { mapXcmTypes } from '@polkadot/types-create';
8
2
  export { packageInfo } from './packageInfo';
9
- export { mapXcmTypes } from './xcm';
10
- /**
11
- * @description Get types for specific modules (metadata override)
12
- */
13
- export declare function getModuleTypes({ knownTypes }: Registry, section: string): OverrideModuleType;
14
- /**
15
- * @description Based on the chain and runtimeVersion, get the applicable signed extensions (ready for registration)
16
- */
17
- export declare function getSpecExtensions({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): ExtDef;
18
- /**
19
- * @description Based on the chain and runtimeVersion, get the applicable types (ready for registration)
20
- */
21
- export declare function getSpecTypes({ knownTypes }: Registry, chainName: Text | string, specName: Text | string, specVersion: bigint | BN | number): RegistryTypes;
22
- export declare function getSpecHasher({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): CodecHasher | null;
23
- /**
24
- * @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
25
- */
26
- export declare function getSpecRpc({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
27
- /**
28
- * @description Based on the chain and runtimeVersion, get the applicable alias definitions (ready for registration)
29
- */
30
- export declare function getSpecAlias({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): Record<string, OverrideModuleType>;
31
- /**
32
- * @description Returns a version record for known chains where upgrades are being tracked
33
- */
34
- export declare function getUpgradeVersion(genesisHash: Hash, blockNumber: BN): [ChainUpgradeVersion | undefined, ChainUpgradeVersion | undefined];
3
+ export * from './util';
package/bundle.js CHANGED
@@ -1,117 +1,5 @@
1
1
  // Copyright 2017-2021 @polkadot/types-known authors & contributors
2
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 typesModules from "./modules.js";
6
- import typesSpec from "./spec/index.js";
7
- import upgrades from "./upgrades/index.js";
8
- export { knownOrigins } from "./knownOrigins.js";
3
+ export { mapXcmTypes } from '@polkadot/types-create';
9
4
  export { packageInfo } from "./packageInfo.js";
10
- export { mapXcmTypes } from "./xcm.js";
11
-
12
- function withNames(chainName, specName, fn) {
13
- return fn(chainName.toString(), specName.toString());
14
- } // flatten a VersionedType[] into a Record<string, string>
15
-
16
- /** @internal */
17
-
18
-
19
- function filterVersions(versions = [], specVersion) {
20
- return versions.filter(({
21
- minmax: [min, max]
22
- }) => (isUndefined(min) || isNull(min) || specVersion >= min) && (isUndefined(max) || isNull(max) || specVersion <= max)).reduce((result, {
23
- types
24
- }) => objectSpread(result, types), {});
25
- }
26
- /**
27
- * @description Get types for specific modules (metadata override)
28
- */
29
-
30
-
31
- export function getModuleTypes({
32
- knownTypes
33
- }, section) {
34
- var _knownTypes$typesAlia;
35
-
36
- return objectSpread({}, typesModules[section], (_knownTypes$typesAlia = knownTypes.typesAlias) === null || _knownTypes$typesAlia === void 0 ? void 0 : _knownTypes$typesAlia[section]);
37
- }
38
- /**
39
- * @description Based on the chain and runtimeVersion, get the applicable signed extensions (ready for registration)
40
- */
41
-
42
- export function getSpecExtensions({
43
- knownTypes
44
- }, chainName, specName) {
45
- return withNames(chainName, specName, (c, s) => {
46
- var _knownTypes$typesBund, _knownTypes$typesBund2, _knownTypes$typesBund3, _knownTypes$typesBund4, _knownTypes$typesBund5, _knownTypes$typesBund6;
47
-
48
- 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);
49
- });
50
- }
51
- /**
52
- * @description Based on the chain and runtimeVersion, get the applicable types (ready for registration)
53
- */
54
-
55
- export function getSpecTypes({
56
- knownTypes
57
- }, chainName, specName, specVersion) {
58
- const _specVersion = bnToBn(specVersion).toNumber();
59
-
60
- return withNames(chainName, specName, (c, s) => {
61
- var _knownTypes$typesBund7, _knownTypes$typesBund8, _knownTypes$typesBund9, _knownTypes$typesBund10, _knownTypes$typesBund11, _knownTypes$typesBund12, _knownTypes$typesSpec, _knownTypes$typesChai;
62
-
63
- return (// The order here is always, based on -
64
- // - spec then chain
65
- // - typesBundle takes higher precedence
66
- // - types is the final catch-all override
67
- 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)
68
- );
69
- });
70
- }
71
- export function getSpecHasher({
72
- knownTypes
73
- }, chainName, specName) {
74
- return withNames(chainName, specName, (c, s) => {
75
- var _knownTypes$typesBund13, _knownTypes$typesBund14, _knownTypes$typesBund15, _knownTypes$typesBund16, _knownTypes$typesBund17, _knownTypes$typesBund18;
76
-
77
- 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;
78
- });
79
- }
80
- /**
81
- * @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
82
- */
83
-
84
- export function getSpecRpc({
85
- knownTypes
86
- }, chainName, specName) {
87
- return withNames(chainName, specName, (c, s) => {
88
- var _knownTypes$typesBund19, _knownTypes$typesBund20, _knownTypes$typesBund21, _knownTypes$typesBund22, _knownTypes$typesBund23, _knownTypes$typesBund24;
89
-
90
- 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);
91
- });
92
- }
93
- /**
94
- * @description Based on the chain and runtimeVersion, get the applicable alias definitions (ready for registration)
95
- */
96
-
97
- export function getSpecAlias({
98
- knownTypes
99
- }, chainName, specName) {
100
- return withNames(chainName, specName, (c, s) => {
101
- var _knownTypes$typesBund25, _knownTypes$typesBund26, _knownTypes$typesBund27, _knownTypes$typesBund28, _knownTypes$typesBund29, _knownTypes$typesBund30;
102
-
103
- return (// as per versions, first spec, then chain then finally non-versioned
104
- 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)
105
- );
106
- });
107
- }
108
- /**
109
- * @description Returns a version record for known chains where upgrades are being tracked
110
- */
111
-
112
- export function getUpgradeVersion(genesisHash, blockNumber) {
113
- const known = upgrades.find(u => genesisHash.eq(u.genesisHash));
114
- return known ? [known.versions.reduce((last, version) => {
115
- return blockNumber.gt(version.blockNumber) ? version : last;
116
- }, undefined), known.versions.find(version => blockNumber.lte(version.blockNumber))] : [undefined, undefined];
117
- }
5
+ export * from "./util.js";
package/package.json CHANGED
@@ -20,12 +20,12 @@
20
20
  "./detectPackage.cjs"
21
21
  ],
22
22
  "type": "module",
23
- "version": "6.12.1",
23
+ "version": "6.12.2-11",
24
24
  "main": "index.js",
25
25
  "dependencies": {
26
- "@babel/runtime": "^7.16.3",
26
+ "@babel/runtime": "^7.16.5",
27
27
  "@polkadot/networks": "^8.1.2",
28
- "@polkadot/types": "6.12.1",
28
+ "@polkadot/types": "6.12.2-11",
29
29
  "@polkadot/util": "^8.1.2"
30
30
  },
31
31
  "exports": {
@@ -49,16 +49,6 @@
49
49
  },
50
50
  "./detectPackage.d.ts": "./detectPackage.d.ts",
51
51
  "./index.d.ts": "./index.d.ts",
52
- "./knownOrigins": {
53
- "require": "./knownOrigins.cjs",
54
- "default": "./knownOrigins.js"
55
- },
56
- "./knownOrigins.d.ts": "./knownOrigins.d.ts",
57
- "./modules": {
58
- "require": "./modules.cjs",
59
- "default": "./modules.js"
60
- },
61
- "./modules.d.ts": "./modules.d.ts",
62
52
  "./package.json": "./package.json",
63
53
  "./packageInfo": {
64
54
  "require": "./packageInfo.cjs",
@@ -141,10 +131,10 @@
141
131
  "default": "./upgrades/westend.js"
142
132
  },
143
133
  "./upgrades/westend.d.ts": "./upgrades/westend.d.ts",
144
- "./xcm": {
145
- "require": "./xcm.cjs",
146
- "default": "./xcm.js"
134
+ "./util": {
135
+ "require": "./util.cjs",
136
+ "default": "./util.js"
147
137
  },
148
- "./xcm.d.ts": "./xcm.d.ts"
138
+ "./util.d.ts": "./util.d.ts"
149
139
  }
150
140
  }
package/packageInfo.cjs CHANGED
@@ -9,6 +9,6 @@ exports.packageInfo = void 0;
9
9
  // Auto-generated by @polkadot/dev, do not edit
10
10
  const packageInfo = {
11
11
  name: '@polkadot/types-known',
12
- version: '6.12.1'
12
+ version: '6.12.2-11'
13
13
  };
14
14
  exports.packageInfo = packageInfo;
package/packageInfo.js CHANGED
@@ -3,5 +3,5 @@
3
3
  // Auto-generated by @polkadot/dev, do not edit
4
4
  export const packageInfo = {
5
5
  name: '@polkadot/types-known',
6
- version: '6.12.1'
6
+ version: '6.12.2-11'
7
7
  };
package/spec/kusama.cjs CHANGED
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _util = require("@polkadot/util");
8
+ var _typesCreate = require("@polkadot/types-create");
9
9
 
10
- var _xcm = require("../xcm.cjs");
10
+ var _util = require("@polkadot/util");
11
11
 
12
12
  // Copyright 2017-2021 @polkadot/types-known authors & contributors
13
13
  // SPDX-License-Identifier: Apache-2.0
@@ -163,11 +163,11 @@ const versioned = [{
163
163
  })
164
164
  }, {
165
165
  minmax: [9010, 9099],
166
- types: (0, _util.objectSpread)({}, sharedTypes, (0, _xcm.mapXcmTypes)('V0'))
166
+ types: (0, _util.objectSpread)({}, sharedTypes, (0, _typesCreate.mapXcmTypes)('V0'))
167
167
  }, {
168
168
  // jump from 9100 to 9110, however align with Rococo
169
169
  minmax: [9100, 9105],
170
- types: (0, _util.objectSpread)({}, sharedTypes, (0, _xcm.mapXcmTypes)('V1'))
170
+ types: (0, _util.objectSpread)({}, sharedTypes, (0, _typesCreate.mapXcmTypes)('V1'))
171
171
  }, {
172
172
  // metadata v14
173
173
  minmax: [9106, undefined],
package/spec/kusama.js CHANGED
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  /* eslint-disable sort-keys */
5
+ import { mapXcmTypes } from '@polkadot/types-create';
5
6
  import { objectSpread } from '@polkadot/util';
6
- import { mapXcmTypes } from "../xcm.js";
7
7
  const sharedTypes = {
8
8
  CompactAssignments: 'CompactAssignmentsWith24',
9
9
  RawSolution: 'RawSolutionWith24',
package/spec/rococo.cjs CHANGED
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _util = require("@polkadot/util");
8
+ var _typesCreate = require("@polkadot/types-create");
9
9
 
10
- var _xcm = require("../xcm.cjs");
10
+ var _util = require("@polkadot/util");
11
11
 
12
12
  // Copyright 2017-2021 @polkadot/types-known authors & contributors
13
13
  // SPDX-License-Identifier: Apache-2.0
@@ -40,10 +40,10 @@ const versioned = [{
40
40
  })
41
41
  }, {
42
42
  minmax: [229, 9099],
43
- types: (0, _util.objectSpread)({}, sharedTypes, (0, _xcm.mapXcmTypes)('V0'))
43
+ types: (0, _util.objectSpread)({}, sharedTypes, (0, _typesCreate.mapXcmTypes)('V0'))
44
44
  }, {
45
45
  minmax: [9100, 9105],
46
- types: (0, _util.objectSpread)({}, sharedTypes, (0, _xcm.mapXcmTypes)('V1'))
46
+ types: (0, _util.objectSpread)({}, sharedTypes, (0, _typesCreate.mapXcmTypes)('V1'))
47
47
  }, {
48
48
  // metadata v14
49
49
  minmax: [9106, undefined],
package/spec/rococo.js CHANGED
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  /* eslint-disable sort-keys */
5
- import { objectSpread } from '@polkadot/util';
6
- import { mapXcmTypes } from "../xcm.js"; // structs need to be in order
5
+ import { mapXcmTypes } from '@polkadot/types-create';
6
+ import { objectSpread } from '@polkadot/util'; // structs need to be in order
7
7
 
8
8
  /* eslint-disable sort-keys */
9
9
 
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _util = require("@polkadot/util");
8
+ var _typesCreate = require("@polkadot/types-create");
9
9
 
10
- var _xcm = require("../xcm.cjs");
10
+ var _util = require("@polkadot/util");
11
11
 
12
12
  // Copyright 2017-2021 @polkadot/types-known authors & contributors
13
13
  // SPDX-License-Identifier: Apache-2.0
@@ -22,10 +22,10 @@ const sharedTypes = {
22
22
 
23
23
  const versioned = [{
24
24
  minmax: [0, 3],
25
- types: (0, _util.objectSpread)({}, sharedTypes, (0, _xcm.mapXcmTypes)('V0'))
25
+ types: (0, _util.objectSpread)({}, sharedTypes, (0, _typesCreate.mapXcmTypes)('V0'))
26
26
  }, {
27
27
  minmax: [4, 5],
28
- types: (0, _util.objectSpread)({}, sharedTypes, (0, _xcm.mapXcmTypes)('V1'))
28
+ types: (0, _util.objectSpread)({}, sharedTypes, (0, _typesCreate.mapXcmTypes)('V1'))
29
29
  }, {
30
30
  // metadata V14
31
31
  minmax: [500, undefined],
package/spec/statemint.js CHANGED
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  /* eslint-disable sort-keys */
5
+ import { mapXcmTypes } from '@polkadot/types-create';
5
6
  import { objectSpread } from '@polkadot/util';
6
- import { mapXcmTypes } from "../xcm.js";
7
7
  const sharedTypes = {
8
8
  TAssetBalance: 'u128',
9
9
  ProxyType: {
package/spec/westend.cjs CHANGED
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _util = require("@polkadot/util");
8
+ var _typesCreate = require("@polkadot/types-create");
9
9
 
10
- var _xcm = require("../xcm.cjs");
10
+ var _util = require("@polkadot/util");
11
11
 
12
12
  // Copyright 2017-2021 @polkadot/types-known authors & contributors
13
13
  // SPDX-License-Identifier: Apache-2.0
@@ -77,10 +77,10 @@ const versioned = [{
77
77
  })
78
78
  }, {
79
79
  minmax: [50, 9099],
80
- types: (0, _util.objectSpread)({}, sharedTypes, (0, _xcm.mapXcmTypes)('V0'))
80
+ types: (0, _util.objectSpread)({}, sharedTypes, (0, _typesCreate.mapXcmTypes)('V0'))
81
81
  }, {
82
82
  minmax: [9100, 9105],
83
- types: (0, _util.objectSpread)({}, sharedTypes, (0, _xcm.mapXcmTypes)('V1'))
83
+ types: (0, _util.objectSpread)({}, sharedTypes, (0, _typesCreate.mapXcmTypes)('V1'))
84
84
  }, {
85
85
  // metadata v14
86
86
  minmax: [9106, undefined],
package/spec/westend.js CHANGED
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  /* eslint-disable sort-keys */
5
+ import { mapXcmTypes } from '@polkadot/types-create';
5
6
  import { objectSpread } from '@polkadot/util';
6
- import { mapXcmTypes } from "../xcm.js";
7
7
  const sharedTypes = {
8
8
  // 16 validators
9
9
  CompactAssignments: 'CompactAssignmentsWith16',
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];
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/knownOrigins.cjs DELETED
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.knownOrigins = void 0;
7
- // Copyright 2017-2021 @polkadot/types authors & contributors
8
- // SPDX-License-Identifier: Apache-2.0
9
- // We want predictive ordering (manually managed)
10
-
11
- /* eslint-disable sort-keys */
12
- // Since we don't have insight into the origin specification, we can only define what we know about
13
- // in a pure Substrate/Polkadot implementation, any other custom origins won't be handled at all
14
- const knownOrigins = {
15
- //
16
- // (1) Defaults from Substrate
17
- //
18
- Council: 'CollectiveOrigin',
19
- System: 'SystemOrigin',
20
- TechnicalCommittee: 'CollectiveOrigin',
21
- //
22
- // (2) Defaults from Polkadot
23
- //
24
- Xcm: 'XcmOrigin',
25
- XcmPallet: 'XcmOrigin',
26
- //
27
- // (3) Defaults from Acala
28
- //
29
- Authority: 'AuthorityOrigin',
30
- GeneralCouncil: 'CollectiveOrigin'
31
- };
32
- exports.knownOrigins = knownOrigins;
package/knownOrigins.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const knownOrigins: Record<string, string>;
package/knownOrigins.js DELETED
@@ -1,25 +0,0 @@
1
- // Copyright 2017-2021 @polkadot/types authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
- // We want predictive ordering (manually managed)
4
-
5
- /* eslint-disable sort-keys */
6
- // Since we don't have insight into the origin specification, we can only define what we know about
7
- // in a pure Substrate/Polkadot implementation, any other custom origins won't be handled at all
8
- export const knownOrigins = {
9
- //
10
- // (1) Defaults from Substrate
11
- //
12
- Council: 'CollectiveOrigin',
13
- System: 'SystemOrigin',
14
- TechnicalCommittee: 'CollectiveOrigin',
15
- //
16
- // (2) Defaults from Polkadot
17
- //
18
- Xcm: 'XcmOrigin',
19
- XcmPallet: 'XcmOrigin',
20
- //
21
- // (3) Defaults from Acala
22
- //
23
- Authority: 'AuthorityOrigin',
24
- GeneralCouncil: 'CollectiveOrigin'
25
- };
package/modules.cjs DELETED
@@ -1,111 +0,0 @@
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
- // type overrides for modules (where duplication between modules exist)
10
- const typesModules = {
11
- assets: {
12
- Approval: 'AssetApproval',
13
- ApprovalKey: 'AssetApprovalKey',
14
- Balance: 'TAssetBalance',
15
- DestroyWitness: 'AssetDestroyWitness'
16
- },
17
- babe: {
18
- EquivocationProof: 'BabeEquivocationProof'
19
- },
20
- balances: {
21
- Status: 'BalanceStatus'
22
- },
23
- beefy: {
24
- AuthorityId: 'BeefyId'
25
- },
26
- contracts: {
27
- StorageKey: 'ContractStorageKey'
28
- },
29
- electionProviderMultiPhase: {
30
- Phase: 'ElectionPhase'
31
- },
32
- ethereum: {
33
- Block: 'EthBlock',
34
- Header: 'EthHeader',
35
- Receipt: 'EthReceipt',
36
- Transaction: 'EthTransaction',
37
- TransactionStatus: 'EthTransactionStatus'
38
- },
39
- evm: {
40
- Account: 'EvmAccount',
41
- Log: 'EvmLog',
42
- Vicinity: 'EvmVicinity'
43
- },
44
- grandpa: {
45
- Equivocation: 'GrandpaEquivocation',
46
- EquivocationProof: 'GrandpaEquivocationProof'
47
- },
48
- identity: {
49
- Judgement: 'IdentityJudgement'
50
- },
51
- inclusion: {
52
- ValidatorIndex: 'ParaValidatorIndex'
53
- },
54
- paraDisputes: {
55
- ValidatorIndex: 'ParaValidatorIndex'
56
- },
57
- paraInclusion: {
58
- ValidatorIndex: 'ParaValidatorIndex'
59
- },
60
- paraScheduler: {
61
- ValidatorIndex: 'ParaValidatorIndex'
62
- },
63
- paraShared: {
64
- ValidatorIndex: 'ParaValidatorIndex'
65
- },
66
- parachains: {
67
- Id: 'ParaId'
68
- },
69
- parasDisputes: {
70
- ValidatorIndex: 'ParaValidatorIndex'
71
- },
72
- parasInclusion: {
73
- ValidatorIndex: 'ParaValidatorIndex'
74
- },
75
- parasScheduler: {
76
- ValidatorIndex: 'ParaValidatorIndex'
77
- },
78
- parasShared: {
79
- ValidatorIndex: 'ParaValidatorIndex'
80
- },
81
- proposeParachain: {
82
- Proposal: 'ParachainProposal'
83
- },
84
- proxy: {
85
- Announcement: 'ProxyAnnouncement'
86
- },
87
- scheduler: {
88
- ValidatorIndex: 'ParaValidatorIndex'
89
- },
90
- shared: {
91
- ValidatorIndex: 'ParaValidatorIndex'
92
- },
93
- society: {
94
- Judgement: 'SocietyJudgement',
95
- Vote: 'SocietyVote'
96
- },
97
- staking: {
98
- Compact: 'CompactAssignments'
99
- },
100
- treasury: {
101
- Proposal: 'TreasuryProposal'
102
- },
103
- xcm: {
104
- AssetId: 'XcmAssetId'
105
- },
106
- xcmPallet: {
107
- AssetId: 'XcmAssetId'
108
- }
109
- };
110
- var _default = typesModules;
111
- exports.default = _default;
package/modules.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { OverrideModuleType } from '@polkadot/types/types';
2
- declare const typesModules: Record<string, OverrideModuleType>;
3
- export default typesModules;
package/modules.js DELETED
@@ -1,104 +0,0 @@
1
- // Copyright 2017-2021 @polkadot/types-known authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
- // type overrides for modules (where duplication between modules exist)
4
- const typesModules = {
5
- assets: {
6
- Approval: 'AssetApproval',
7
- ApprovalKey: 'AssetApprovalKey',
8
- Balance: 'TAssetBalance',
9
- DestroyWitness: 'AssetDestroyWitness'
10
- },
11
- babe: {
12
- EquivocationProof: 'BabeEquivocationProof'
13
- },
14
- balances: {
15
- Status: 'BalanceStatus'
16
- },
17
- beefy: {
18
- AuthorityId: 'BeefyId'
19
- },
20
- contracts: {
21
- StorageKey: 'ContractStorageKey'
22
- },
23
- electionProviderMultiPhase: {
24
- Phase: 'ElectionPhase'
25
- },
26
- ethereum: {
27
- Block: 'EthBlock',
28
- Header: 'EthHeader',
29
- Receipt: 'EthReceipt',
30
- Transaction: 'EthTransaction',
31
- TransactionStatus: 'EthTransactionStatus'
32
- },
33
- evm: {
34
- Account: 'EvmAccount',
35
- Log: 'EvmLog',
36
- Vicinity: 'EvmVicinity'
37
- },
38
- grandpa: {
39
- Equivocation: 'GrandpaEquivocation',
40
- EquivocationProof: 'GrandpaEquivocationProof'
41
- },
42
- identity: {
43
- Judgement: 'IdentityJudgement'
44
- },
45
- inclusion: {
46
- ValidatorIndex: 'ParaValidatorIndex'
47
- },
48
- paraDisputes: {
49
- ValidatorIndex: 'ParaValidatorIndex'
50
- },
51
- paraInclusion: {
52
- ValidatorIndex: 'ParaValidatorIndex'
53
- },
54
- paraScheduler: {
55
- ValidatorIndex: 'ParaValidatorIndex'
56
- },
57
- paraShared: {
58
- ValidatorIndex: 'ParaValidatorIndex'
59
- },
60
- parachains: {
61
- Id: 'ParaId'
62
- },
63
- parasDisputes: {
64
- ValidatorIndex: 'ParaValidatorIndex'
65
- },
66
- parasInclusion: {
67
- ValidatorIndex: 'ParaValidatorIndex'
68
- },
69
- parasScheduler: {
70
- ValidatorIndex: 'ParaValidatorIndex'
71
- },
72
- parasShared: {
73
- ValidatorIndex: 'ParaValidatorIndex'
74
- },
75
- proposeParachain: {
76
- Proposal: 'ParachainProposal'
77
- },
78
- proxy: {
79
- Announcement: 'ProxyAnnouncement'
80
- },
81
- scheduler: {
82
- ValidatorIndex: 'ParaValidatorIndex'
83
- },
84
- shared: {
85
- ValidatorIndex: 'ParaValidatorIndex'
86
- },
87
- society: {
88
- Judgement: 'SocietyJudgement',
89
- Vote: 'SocietyVote'
90
- },
91
- staking: {
92
- Compact: 'CompactAssignments'
93
- },
94
- treasury: {
95
- Proposal: 'TreasuryProposal'
96
- },
97
- xcm: {
98
- AssetId: 'XcmAssetId'
99
- },
100
- xcmPallet: {
101
- AssetId: 'XcmAssetId'
102
- }
103
- };
104
- export default typesModules;
package/xcm.cjs DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.XCM_MAPPINGS = void 0;
7
- exports.mapXcmTypes = mapXcmTypes;
8
-
9
- var _util = require("@polkadot/util");
10
-
11
- // Copyright 2017-2021 @polkadot/types-known authors & contributors
12
- // SPDX-License-Identifier: Apache-2.0
13
- const XCM_MAPPINGS = ['AssetInstance', 'Fungibility', 'Junction', 'Junctions', 'MultiAsset', 'MultiAssetFilter', 'MultiLocation', 'Response', 'WildFungibility', 'WildMultiAsset', 'Xcm', 'XcmError', 'XcmOrder'];
14
- exports.XCM_MAPPINGS = XCM_MAPPINGS;
15
-
16
- function mapXcmTypes(version) {
17
- return XCM_MAPPINGS.reduce((all, key) => (0, _util.objectSpread)(all, {
18
- [key]: `${key}${version}`
19
- }), {});
20
- }
package/xcm.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const XCM_MAPPINGS: string[];
2
- export declare function mapXcmTypes(version: 'V0' | 'V1' | 'V2'): Record<string, string>;
package/xcm.js DELETED
@@ -1,9 +0,0 @@
1
- // Copyright 2017-2021 @polkadot/types-known authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { objectSpread } from '@polkadot/util';
4
- export const XCM_MAPPINGS = ['AssetInstance', 'Fungibility', 'Junction', 'Junctions', 'MultiAsset', 'MultiAssetFilter', 'MultiLocation', 'Response', 'WildFungibility', 'WildMultiAsset', 'Xcm', 'XcmError', 'XcmOrder'];
5
- export function mapXcmTypes(version) {
6
- return XCM_MAPPINGS.reduce((all, key) => objectSpread(all, {
7
- [key]: `${key}${version}`
8
- }), {});
9
- }