@polkadot/extension-chains 0.42.4-0 → 0.42.5-10

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 ADDED
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.addMetadata = addMetadata;
7
+ exports.findChain = findChain;
8
+ exports.knownMetadata = knownMetadata;
9
+ exports.metadataExpand = metadataExpand;
10
+ Object.defineProperty(exports, "packageInfo", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _packageInfo.packageInfo;
14
+ }
15
+ });
16
+
17
+ var _types = require("@polkadot/types");
18
+
19
+ var _utilCrypto = require("@polkadot/util-crypto");
20
+
21
+ var _packageInfo = require("./packageInfo.cjs");
22
+
23
+ // Copyright 2019-2022 @polkadot/extension-chains authors & contributors
24
+ // SPDX-License-Identifier: Apache-2.0
25
+ // imports chain details, generally metadata. For the generation of these,
26
+ // inside the api, run `yarn chain:info --ws <url>`
27
+ const definitions = new Map();
28
+ const expanded = new Map();
29
+
30
+ function metadataExpand(definition) {
31
+ let isPartial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
32
+ const cached = expanded.get(definition.genesisHash);
33
+
34
+ if (cached && cached.specVersion === definition.specVersion) {
35
+ return cached;
36
+ }
37
+
38
+ const {
39
+ chain,
40
+ genesisHash,
41
+ icon,
42
+ metaCalls,
43
+ specVersion,
44
+ ss58Format,
45
+ tokenDecimals,
46
+ tokenSymbol,
47
+ types,
48
+ userExtensions
49
+ } = definition;
50
+ const registry = new _types.TypeRegistry();
51
+
52
+ if (!isPartial) {
53
+ registry.register(types);
54
+ }
55
+
56
+ registry.setChainProperties(registry.createType('ChainProperties', {
57
+ ss58Format,
58
+ tokenDecimals,
59
+ tokenSymbol
60
+ }));
61
+ const hasMetadata = !!metaCalls && !isPartial;
62
+
63
+ if (hasMetadata) {
64
+ registry.setMetadata(new _types.Metadata(registry, (0, _utilCrypto.base64Decode)(metaCalls)), undefined, userExtensions);
65
+ }
66
+
67
+ const isUnknown = genesisHash === '0x';
68
+ const result = {
69
+ definition,
70
+ genesisHash: isUnknown ? undefined : genesisHash,
71
+ hasMetadata,
72
+ icon: icon || 'substrate',
73
+ isUnknown,
74
+ name: chain,
75
+ registry,
76
+ specVersion,
77
+ ss58Format,
78
+ tokenDecimals,
79
+ tokenSymbol
80
+ };
81
+
82
+ if (result.genesisHash && !isPartial) {
83
+ expanded.set(result.genesisHash, result);
84
+ }
85
+
86
+ return result;
87
+ }
88
+
89
+ function findChain(definitions, genesisHash) {
90
+ const def = definitions.find(def => def.genesisHash === genesisHash);
91
+ return def ? metadataExpand(def) : null;
92
+ }
93
+
94
+ function addMetadata(def) {
95
+ definitions.set(def.genesisHash, def);
96
+ }
97
+
98
+ function knownMetadata() {
99
+ return [...definitions.values()];
100
+ }
package/bundle.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { MetadataDef } from '@polkadot/extension-inject/types';
2
+ import type { Chain } from './types';
3
+ export { packageInfo } from './packageInfo';
4
+ export declare function metadataExpand(definition: MetadataDef, isPartial?: boolean): Chain;
5
+ export declare function findChain(definitions: MetadataDef[], genesisHash?: string | null): Chain | null;
6
+ export declare function addMetadata(def: MetadataDef): void;
7
+ export declare function knownMetadata(): MetadataDef[];
package/bundle.js ADDED
@@ -0,0 +1,76 @@
1
+ // Copyright 2019-2022 @polkadot/extension-chains authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { Metadata, TypeRegistry } from '@polkadot/types';
4
+ import { base64Decode } from '@polkadot/util-crypto';
5
+ export { packageInfo } from "./packageInfo.js"; // imports chain details, generally metadata. For the generation of these,
6
+ // inside the api, run `yarn chain:info --ws <url>`
7
+
8
+ const definitions = new Map();
9
+ const expanded = new Map();
10
+ export function metadataExpand(definition, isPartial = false) {
11
+ const cached = expanded.get(definition.genesisHash);
12
+
13
+ if (cached && cached.specVersion === definition.specVersion) {
14
+ return cached;
15
+ }
16
+
17
+ const {
18
+ chain,
19
+ genesisHash,
20
+ icon,
21
+ metaCalls,
22
+ specVersion,
23
+ ss58Format,
24
+ tokenDecimals,
25
+ tokenSymbol,
26
+ types,
27
+ userExtensions
28
+ } = definition;
29
+ const registry = new TypeRegistry();
30
+
31
+ if (!isPartial) {
32
+ registry.register(types);
33
+ }
34
+
35
+ registry.setChainProperties(registry.createType('ChainProperties', {
36
+ ss58Format,
37
+ tokenDecimals,
38
+ tokenSymbol
39
+ }));
40
+ const hasMetadata = !!metaCalls && !isPartial;
41
+
42
+ if (hasMetadata) {
43
+ registry.setMetadata(new Metadata(registry, base64Decode(metaCalls)), undefined, userExtensions);
44
+ }
45
+
46
+ const isUnknown = genesisHash === '0x';
47
+ const result = {
48
+ definition,
49
+ genesisHash: isUnknown ? undefined : genesisHash,
50
+ hasMetadata,
51
+ icon: icon || 'substrate',
52
+ isUnknown,
53
+ name: chain,
54
+ registry,
55
+ specVersion,
56
+ ss58Format,
57
+ tokenDecimals,
58
+ tokenSymbol
59
+ };
60
+
61
+ if (result.genesisHash && !isPartial) {
62
+ expanded.set(result.genesisHash, result);
63
+ }
64
+
65
+ return result;
66
+ }
67
+ export function findChain(definitions, genesisHash) {
68
+ const def = definitions.find(def => def.genesisHash === genesisHash);
69
+ return def ? metadataExpand(def) : null;
70
+ }
71
+ export function addMetadata(def) {
72
+ definitions.set(def.genesisHash, def);
73
+ }
74
+ export function knownMetadata() {
75
+ return [...definitions.values()];
76
+ }
@@ -0,0 +1,8 @@
1
+ // Copyright 2017-2022 @polkadot/extension-chains authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Do not edit, auto-generated by @polkadot/dev
5
+
6
+ declare const __dirname: string | undefined;
7
+
8
+ export default __dirname;
package/cjs/dirname.js ADDED
@@ -0,0 +1,8 @@
1
+ // Copyright 2017-2022 @polkadot/extension-chains authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Do not edit, auto-generated by @polkadot/dev
5
+
6
+ module.exports = typeof __dirname === 'string'
7
+ ? __dirname.replace('/cjs', '')
8
+ : undefined;
@@ -0,0 +1,3 @@
1
+ {
2
+ "type":"commonjs"
3
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _packageInfo = require("@polkadot/extension-inject/packageInfo");
9
+
10
+ // Copyright 2017-2022 @polkadot/extension-chains authors & contributors
11
+ // SPDX-License-Identifier: Apache-2.0
12
+ var _default = [_packageInfo.packageInfo];
13
+ exports.default = _default;
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ name: string;
3
+ version: string;
4
+ }[];
5
+ export default _default;
package/detectOther.js ADDED
@@ -0,0 +1,4 @@
1
+ // Copyright 2017-2022 @polkadot/extension-chains authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { packageInfo as injectInfo } from '@polkadot/extension-inject/packageInfo';
4
+ export default [injectInfo];
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _util = require("@polkadot/util");
6
+
7
+ var _dirname = _interopRequireDefault(require("./cjs/dirname"));
8
+
9
+ var _detectOther = _interopRequireDefault(require("./detectOther.cjs"));
10
+
11
+ var _packageInfo = require("./packageInfo.cjs");
12
+
13
+ // Copyright 2017-2022 @polkadot/extension-chains authors & contributors
14
+ // SPDX-License-Identifier: Apache-2.0
15
+ // Do not edit, auto-generated by @polkadot/dev
16
+ (0, _util.detectPackage)(_packageInfo.packageInfo, _dirname.default, _detectOther.default);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ // Copyright 2017-2022 @polkadot/extension-chains authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // Do not edit, auto-generated by @polkadot/dev
4
+ import { detectPackage } from '@polkadot/util';
5
+ import dirname from "./cjs/dirname.js";
6
+ import others from "./detectOther.js";
7
+ import { packageInfo } from "./packageInfo.js";
8
+ detectPackage(packageInfo, dirname, others);
package/index.cjs CHANGED
@@ -3,90 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.addMetadata = addMetadata;
7
- exports.findChain = findChain;
8
- exports.knownMetadata = knownMetadata;
9
- exports.metadataExpand = metadataExpand;
10
6
 
11
- var _types = require("@polkadot/types");
12
-
13
- var _utilCrypto = require("@polkadot/util-crypto");
14
-
15
- // Copyright 2019-2021 @polkadot/extension-chains authors & contributors
16
- // SPDX-License-Identifier: Apache-2.0
17
- // imports chain details, generally metadata. For the generation of these,
18
- // inside the api, run `yarn chain:info --ws <url>`
19
- const definitions = new Map();
20
- const expanded = new Map();
21
-
22
- function metadataExpand(definition) {
23
- let isPartial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
24
- const cached = expanded.get(definition.genesisHash);
25
-
26
- if (cached && cached.specVersion === definition.specVersion) {
27
- return cached;
28
- }
29
-
30
- const {
31
- chain,
32
- genesisHash,
33
- icon,
34
- metaCalls,
35
- specVersion,
36
- ss58Format,
37
- tokenDecimals,
38
- tokenSymbol,
39
- types,
40
- userExtensions
41
- } = definition;
42
- const registry = new _types.TypeRegistry();
43
-
44
- if (!isPartial) {
45
- registry.register(types);
46
- }
47
-
48
- registry.setChainProperties(registry.createType('ChainProperties', {
49
- ss58Format,
50
- tokenDecimals,
51
- tokenSymbol
52
- }));
53
- const hasMetadata = !!metaCalls && !isPartial;
54
-
55
- if (hasMetadata) {
56
- registry.setMetadata(new _types.Metadata(registry, (0, _utilCrypto.base64Decode)(metaCalls)), undefined, userExtensions);
57
- }
58
-
59
- const isUnknown = genesisHash === '0x';
60
- const result = {
61
- definition,
62
- genesisHash: isUnknown ? undefined : genesisHash,
63
- hasMetadata,
64
- icon: icon || 'substrate',
65
- isUnknown,
66
- name: chain,
67
- registry,
68
- specVersion,
69
- ss58Format,
70
- tokenDecimals,
71
- tokenSymbol
72
- };
73
-
74
- if (result.genesisHash && !isPartial) {
75
- expanded.set(result.genesisHash, result);
76
- }
77
-
78
- return result;
79
- }
80
-
81
- function findChain(definitions, genesisHash) {
82
- const def = definitions.find(def => def.genesisHash === genesisHash);
83
- return def ? metadataExpand(def) : null;
84
- }
85
-
86
- function addMetadata(def) {
87
- definitions.set(def.genesisHash, def);
88
- }
89
-
90
- function knownMetadata() {
91
- return [...definitions.values()];
92
- }
7
+ var _bundle = require("./bundle.cjs");
8
+
9
+ Object.keys(_bundle).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _bundle[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _bundle[key];
16
+ }
17
+ });
18
+ });
package/index.d.ts CHANGED
@@ -1,6 +1 @@
1
- import type { MetadataDef } from '@polkadot/extension-inject/types';
2
- import type { Chain } from './types';
3
- export declare function metadataExpand(definition: MetadataDef, isPartial?: boolean): Chain;
4
- export declare function findChain(definitions: MetadataDef[], genesisHash?: string | null): Chain | null;
5
- export declare function addMetadata(def: MetadataDef): void;
6
- export declare function knownMetadata(): MetadataDef[];
1
+ export * from './bundle';
package/index.js CHANGED
@@ -1,75 +1,5 @@
1
- // Copyright 2019-2021 @polkadot/extension-chains authors & contributors
1
+ // Copyright 2019-2022 @polkadot/extension-chains authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { Metadata, TypeRegistry } from '@polkadot/types';
4
- import { base64Decode } from '@polkadot/util-crypto'; // imports chain details, generally metadata. For the generation of these,
5
- // inside the api, run `yarn chain:info --ws <url>`
6
-
7
- const definitions = new Map();
8
- const expanded = new Map();
9
- export function metadataExpand(definition, isPartial = false) {
10
- const cached = expanded.get(definition.genesisHash);
11
-
12
- if (cached && cached.specVersion === definition.specVersion) {
13
- return cached;
14
- }
15
-
16
- const {
17
- chain,
18
- genesisHash,
19
- icon,
20
- metaCalls,
21
- specVersion,
22
- ss58Format,
23
- tokenDecimals,
24
- tokenSymbol,
25
- types,
26
- userExtensions
27
- } = definition;
28
- const registry = new TypeRegistry();
29
-
30
- if (!isPartial) {
31
- registry.register(types);
32
- }
33
-
34
- registry.setChainProperties(registry.createType('ChainProperties', {
35
- ss58Format,
36
- tokenDecimals,
37
- tokenSymbol
38
- }));
39
- const hasMetadata = !!metaCalls && !isPartial;
40
-
41
- if (hasMetadata) {
42
- registry.setMetadata(new Metadata(registry, base64Decode(metaCalls)), undefined, userExtensions);
43
- }
44
-
45
- const isUnknown = genesisHash === '0x';
46
- const result = {
47
- definition,
48
- genesisHash: isUnknown ? undefined : genesisHash,
49
- hasMetadata,
50
- icon: icon || 'substrate',
51
- isUnknown,
52
- name: chain,
53
- registry,
54
- specVersion,
55
- ss58Format,
56
- tokenDecimals,
57
- tokenSymbol
58
- };
59
-
60
- if (result.genesisHash && !isPartial) {
61
- expanded.set(result.genesisHash, result);
62
- }
63
-
64
- return result;
65
- }
66
- export function findChain(definitions, genesisHash) {
67
- const def = definitions.find(def => def.genesisHash === genesisHash);
68
- return def ? metadataExpand(def) : null;
69
- }
70
- export function addMetadata(def) {
71
- definitions.set(def.genesisHash, def);
72
- }
73
- export function knownMetadata() {
74
- return [...definitions.values()];
75
- }
3
+ // Since we inject into pages, we skip this
4
+ // import './detectPackage';
5
+ export * from "./bundle.js";
package/package.json CHANGED
@@ -12,14 +12,18 @@
12
12
  "type": "git",
13
13
  "url": "https://github.com/polkadot-js/extension.git"
14
14
  },
15
- "sideEffects": false,
15
+ "sideEffects": [
16
+ "./detectPackage.js",
17
+ "./detectPackage.cjs"
18
+ ],
16
19
  "type": "module",
17
- "version": "0.42.4-0",
20
+ "version": "0.42.5-10",
18
21
  "main": "index.js",
19
22
  "dependencies": {
20
- "@babel/runtime": "^7.16.5",
21
- "@polkadot/extension-inject": "^0.42.4-0",
23
+ "@babel/runtime": "^7.16.7",
24
+ "@polkadot/extension-inject": "^0.42.5-10",
22
25
  "@polkadot/networks": "^8.2.2",
26
+ "@polkadot/util": "^8.2.2",
23
27
  "@polkadot/util-crypto": "^8.2.2"
24
28
  },
25
29
  "peerDependencies": {
@@ -32,6 +36,26 @@
32
36
  "require": "./index.cjs",
33
37
  "default": "./index.js"
34
38
  },
39
+ "./bundle": {
40
+ "types": "./bundle.d.ts",
41
+ "require": "./bundle.cjs",
42
+ "default": "./bundle.js"
43
+ },
44
+ "./cjs/dirname": {
45
+ "types": "./cjs/dirname.d.ts",
46
+ "default": "./cjs/dirname.js"
47
+ },
48
+ "./cjs/package.json": "./cjs/package.json",
49
+ "./detectOther": {
50
+ "types": "./detectOther.d.ts",
51
+ "require": "./detectOther.cjs",
52
+ "default": "./detectOther.js"
53
+ },
54
+ "./detectPackage": {
55
+ "types": "./detectPackage.d.ts",
56
+ "require": "./detectPackage.cjs",
57
+ "default": "./detectPackage.js"
58
+ },
35
59
  "./package.json": "./package.json",
36
60
  "./packageInfo": {
37
61
  "types": "./packageInfo.d.ts",
package/packageInfo.cjs CHANGED
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.packageInfo = void 0;
7
- // Copyright 2017-2021 @polkadot/extension-chains authors & contributors
7
+ // Copyright 2017-2022 @polkadot/extension-chains authors & contributors
8
8
  // SPDX-License-Identifier: Apache-2.0
9
- // Auto-generated by @polkadot/dev, do not edit
9
+ // Do not edit, auto-generated by @polkadot/dev
10
10
  const packageInfo = {
11
11
  name: '@polkadot/extension-chains',
12
- version: '0.42.4-0'
12
+ version: '0.42.5-10'
13
13
  };
14
14
  exports.packageInfo = packageInfo;
package/packageInfo.js CHANGED
@@ -1,7 +1,7 @@
1
- // Copyright 2017-2021 @polkadot/extension-chains authors & contributors
1
+ // Copyright 2017-2022 @polkadot/extension-chains authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- // Auto-generated by @polkadot/dev, do not edit
3
+ // Do not edit, auto-generated by @polkadot/dev
4
4
  export const packageInfo = {
5
5
  name: '@polkadot/extension-chains',
6
- version: '0.42.4-0'
6
+ version: '0.42.5-10'
7
7
  };