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