@polkadot/extension-chains 0.42.5-3 → 0.42.5-4

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-2021 @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-2021 @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
+ }
package/index.cjs CHANGED
@@ -3,100 +3,18 @@
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
6
 
17
7
  require("./detectPackage.cjs");
18
8
 
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
-
100
- function knownMetadata() {
101
- return [...definitions.values()];
102
- }
9
+ var _bundle = require("./bundle.cjs");
10
+
11
+ Object.keys(_bundle).forEach(function (key) {
12
+ if (key === "default" || key === "__esModule") return;
13
+ if (key in exports && exports[key] === _bundle[key]) return;
14
+ Object.defineProperty(exports, key, {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _bundle[key];
18
+ }
19
+ });
20
+ });
package/index.d.ts CHANGED
@@ -1,8 +1,2 @@
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[];
2
+ export * from './bundle';
package/index.js CHANGED
@@ -1,77 +1,4 @@
1
1
  // Copyright 2019-2021 @polkadot/extension-chains authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
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
- }
4
+ 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-3",
20
+ "version": "0.42.5-4",
21
21
  "main": "index.js",
22
22
  "dependencies": {
23
23
  "@babel/runtime": "^7.16.5",
24
- "@polkadot/extension-inject": "^0.42.5-3",
24
+ "@polkadot/extension-inject": "^0.42.5-4",
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,11 @@
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
+ },
39
44
  "./detectPackage": {
40
45
  "types": "./detectPackage.d.ts",
41
46
  "require": "./detectPackage.cjs",
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/extension-chains',
12
- version: '0.42.5-3'
12
+ version: '0.42.5-4'
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/extension-chains',
6
- version: '0.42.5-3'
6
+ version: '0.42.5-4'
7
7
  };