@chain-registry/cli 1.27.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Dan Lynch <pyramation@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # @chain-registry/cli
2
+
3
+ <p align="center" width="100%">
4
+ <img height="90" src="https://user-images.githubusercontent.com/545047/190171475-b416f99e-2831-4786-9ba3-a7ff4d95b0d3.svg" />
5
+ </p>
6
+
7
+ <p align="center" width="100%">
8
+ <a href="https://github.com/cosmology-tech/chain-registry/actions/cli/run-tests.yml">
9
+ <img height="20" src="https://github.com/cosmology-tech/chain-registry/actions/cli/run-tests.yml/badge.svg" />
10
+ </a>
11
+ <a href="https://github.com/cosmology-tech/chain-registry/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
12
+ <a href="https://www.npmjs.com/package/@chain-registry/cli"><img height="20" src="https://img.shields.io/github/package-json/v/cosmology-tech/chain-registry?filename=packages%2Fcli%2Fpackage.json"></a>
13
+ </p>
14
+
15
+ TODO
16
+
17
+ ## Related
18
+
19
+ Checkout these related projects:
20
+
21
+ * [@cosmology/telescope](https://github.com/cosmology-tech/telescope) Your Frontend Companion for Building with TypeScript with Cosmos SDK Modules.
22
+ * [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) Convert your CosmWasm smart contracts into dev-friendly TypeScript classes.
23
+ * [chain-registry](https://github.com/cosmology-tech/chain-registry) Everything from token symbols, logos, and IBC denominations for all assets you want to support in your application.
24
+ * [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) Experience the convenience of connecting with a variety of web3 wallets through a single, streamlined interface.
25
+ * [create-cosmos-app](https://github.com/cosmology-tech/create-cosmos-app) Set up a modern Cosmos app by running one command.
26
+ * [interchain-ui](https://github.com/cosmology-tech/interchain-ui) The Interchain Design System, empowering developers with a flexible, easy-to-use UI kit.
27
+ * [starship](https://github.com/cosmology-tech/starship) Unified Testing and Development for the Interchain.
28
+
29
+ ## Credits
30
+
31
+ 🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.zone/validator)
32
+
33
+
34
+ ## Disclaimer
35
+
36
+ AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
37
+
38
+ No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
package/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { CLIOptions } from 'inquirerer';
3
+ export declare const options: Partial<CLIOptions>;
package/cli.js ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.options = void 0;
5
+ const inquirerer_1 = require("inquirerer");
6
+ const commands_1 = require("./commands");
7
+ exports.options = {
8
+ minimistOpts: {
9
+ alias: {
10
+ v: 'version'
11
+ }
12
+ }
13
+ };
14
+ const app = new inquirerer_1.CLI(commands_1.commands, exports.options);
15
+ app.run().then(() => {
16
+ // all done!
17
+ }).catch(error => {
18
+ console.error(error);
19
+ process.exit(1);
20
+ });
@@ -0,0 +1,3 @@
1
+ import { CLIOptions, Inquirerer } from 'inquirerer';
2
+ import { ParsedArgs } from 'minimist';
3
+ export declare const commands: (argv: Partial<ParsedArgs>, prompter: Inquirerer, _options: CLIOptions) => Promise<Partial<ParsedArgs>>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commands = void 0;
4
+ const workflows_1 = require("@chain-registry/workflows");
5
+ const fs_1 = require("fs");
6
+ const commands = async (argv, prompter, _options) => {
7
+ const { registryDir, outputDir, strictTypeSafety, useCamelCase } = await prompter.prompt(argv, [
8
+ {
9
+ type: 'text',
10
+ name: 'registryDir',
11
+ message: 'provide a registryDir:'
12
+ },
13
+ {
14
+ type: 'text',
15
+ name: 'outputDir',
16
+ message: 'provide a outputDir:'
17
+ },
18
+ {
19
+ type: 'confirm',
20
+ name: 'strictTypeSafety',
21
+ default: true,
22
+ useDefault: true
23
+ },
24
+ {
25
+ type: 'confirm',
26
+ name: 'useCamelCase',
27
+ default: true,
28
+ useDefault: false
29
+ }
30
+ ]);
31
+ if (!(0, fs_1.existsSync)(registryDir)) {
32
+ prompter.exit();
33
+ throw new Error('bad registry path!');
34
+ }
35
+ const registry = new workflows_1.Registry(registryDir);
36
+ const generator = new workflows_1.SchemaTypeGenerator({
37
+ outputDir,
38
+ registry,
39
+ schemaTSOptions: {
40
+ strictTypeSafety,
41
+ useCamelCase
42
+ }
43
+ });
44
+ generator.generateTypes();
45
+ return argv;
46
+ };
47
+ exports.commands = commands;
@@ -0,0 +1,3 @@
1
+ import { CLIOptions, Inquirerer } from 'inquirerer';
2
+ import { ParsedArgs } from 'minimist';
3
+ export declare const commands: (argv: Partial<ParsedArgs>, prompter: Inquirerer, _options: CLIOptions) => Promise<Partial<ParsedArgs>>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commands = void 0;
4
+ const codegen_1 = require("./codegen");
5
+ const info_1 = require("./info");
6
+ const validate_1 = require("./validate");
7
+ const commands = async (argv, prompter, _options) => {
8
+ let command;
9
+ if (argv._.length > 0) {
10
+ command = argv._.shift();
11
+ }
12
+ if (command) {
13
+ argv.command = command;
14
+ }
15
+ const questions = [
16
+ {
17
+ type: 'autocomplete',
18
+ name: 'command',
19
+ message: 'choose a command',
20
+ options: [
21
+ 'info',
22
+ 'validate',
23
+ 'codegen'
24
+ ]
25
+ }
26
+ ];
27
+ ({ command } = await prompter.prompt(argv, questions));
28
+ // recursive...
29
+ delete argv.command;
30
+ // @ts-ignore
31
+ prompter.exit = () => { };
32
+ switch (command) {
33
+ case 'info':
34
+ argv = await (0, info_1.commands)(argv, prompter, _options);
35
+ break;
36
+ case 'validate':
37
+ argv = await (0, validate_1.commands)(argv, prompter, _options);
38
+ break;
39
+ case 'codegen':
40
+ argv = await (0, codegen_1.commands)(argv, prompter, _options);
41
+ break;
42
+ default:
43
+ console.log(`No recognized command provided or no command given: ${command}`);
44
+ break;
45
+ }
46
+ return argv;
47
+ };
48
+ exports.commands = commands;
@@ -0,0 +1,2 @@
1
+ import { AssetList } from '@chain-registry/interfaces';
2
+ export declare function displayAssetList(assetList: AssetList): void;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.displayAssetList = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const asset_1 = require("./asset");
9
+ function displayAssetList(assetList) {
10
+ console.log(chalk_1.default.bold.blue(`Asset List for Chain: ${assetList.chain_name}`));
11
+ console.log(chalk_1.default.underline(`${assetList.assets.length} Assets Found:`));
12
+ assetList.assets.forEach(asset => {
13
+ (0, asset_1.displayAsset)(asset); // Call displayAsset for each asset in the list
14
+ });
15
+ }
16
+ exports.displayAssetList = displayAssetList;
@@ -0,0 +1,2 @@
1
+ import { Asset } from '@chain-registry/interfaces';
2
+ export declare function displayAsset(asset: Asset): void;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.displayAsset = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ function displayAsset(asset) {
9
+ console.log(chalk_1.default.bold.blue(`Asset Name: ${asset.name}`));
10
+ console.log(chalk_1.default.bold(`Symbol: ${asset.symbol}`));
11
+ console.log(chalk_1.default.bold(`Type: ${asset.type_asset || 'Not specified'}`));
12
+ console.log(`Base Unit: ${asset.base}`);
13
+ console.log(`Display Unit: ${asset.display}`);
14
+ if (asset.deprecated) {
15
+ console.log(chalk_1.default.red('Deprecated: Yes'));
16
+ }
17
+ if (asset.description) {
18
+ console.log(chalk_1.default.italic(`Description: ${asset.description}`));
19
+ }
20
+ if (asset.extended_description) {
21
+ console.log(chalk_1.default.italic(`Extended Description: ${asset.extended_description}`));
22
+ }
23
+ if (asset.denom_units) {
24
+ console.log(chalk_1.default.bold.green('Denomination Units:'));
25
+ asset.denom_units.forEach(unit => {
26
+ console.log(` - Denom: ${unit.denom}, Exponent: ${unit.exponent}${unit.aliases ? `, Aliases: ${unit.aliases.join(', ')}` : ''}`);
27
+ });
28
+ }
29
+ if (asset.ibc) {
30
+ console.log(chalk_1.default.bold.yellow('IBC Info:'));
31
+ console.log(` Source Channel: ${asset.ibc.source_channel}`);
32
+ console.log(` Destination Channel: ${asset.ibc.dst_channel}`);
33
+ console.log(` Source Denom: ${asset.ibc.source_denom}`);
34
+ }
35
+ if (asset.logo_URIs) {
36
+ console.log(chalk_1.default.bold.cyan('Logos:'));
37
+ asset.logo_URIs.png && console.log(` PNG: ${asset.logo_URIs.png}`);
38
+ asset.logo_URIs.svg && console.log(` SVG: ${asset.logo_URIs.svg}`);
39
+ }
40
+ if (asset.images && asset.images.length > 0) {
41
+ console.log(chalk_1.default.bold.magenta('Images:'));
42
+ asset.images.forEach((image, index) => {
43
+ console.log(` Image ${index + 1}:`);
44
+ image.png && console.log(` PNG: ${image.png}`);
45
+ image.svg && console.log(` SVG: ${image.svg}`);
46
+ if (image.theme) {
47
+ console.log(` Theme: ${image.theme.primary_color_hex} Circle: ${image.theme.circle ? 'Yes' : 'No'} Dark Mode: ${image.theme.dark_mode ? 'Yes' : 'No'}`);
48
+ }
49
+ });
50
+ }
51
+ if (asset.socials) {
52
+ console.log(chalk_1.default.bold('Socials:'));
53
+ asset.socials.website && console.log(` Website: ${asset.socials.website}`);
54
+ asset.socials.twitter && console.log(` Twitter: ${asset.socials.twitter}`);
55
+ }
56
+ console.log('\n');
57
+ }
58
+ exports.displayAsset = displayAsset;
@@ -0,0 +1,2 @@
1
+ import { Chain } from '@chain-registry/interfaces';
2
+ export declare function displayChain(chain: Chain): void;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.displayChain = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ function displayChain(chain) {
9
+ console.log(chalk_1.default.bold.green(`Chain Details: ${chain.chain_name}`));
10
+ console.log(chalk_1.default.bold(`Chain ID: ${chalk_1.default.cyan(chain.chain_id)}`));
11
+ if (chain.pretty_name) {
12
+ console.log(chalk_1.default.bold(`Pretty Name: ${chalk_1.default.cyan(chain.pretty_name)}`));
13
+ }
14
+ if (chain.website) {
15
+ console.log(chalk_1.default.bold(`Website: ${chalk_1.default.underline.blue(chain.website)}`));
16
+ }
17
+ if (chain.status) {
18
+ console.log(chalk_1.default.bold(`Status: ${chalk_1.default.yellow(chain.status)}`));
19
+ }
20
+ if (chain.network_type) {
21
+ console.log(chalk_1.default.bold(`Network Type: ${chalk_1.default.magenta(chain.network_type)}`));
22
+ }
23
+ console.log(chalk_1.default.bold(`Bech32 Prefix: ${chalk_1.default.cyan(chain.bech32_prefix)}`));
24
+ if (chain.daemon_name) {
25
+ console.log(chalk_1.default.bold(`Daemon Name: ${chain.daemon_name}`));
26
+ }
27
+ if (chain.codebase) {
28
+ console.log(chalk_1.default.bold(`Codebase:`));
29
+ console.log(` Git Repo: ${chain.codebase.git_repo}`);
30
+ console.log(` Recommended Version: ${chain.codebase.recommended_version}`);
31
+ console.log(` Go Version: ${chain.codebase.go_version}`);
32
+ }
33
+ if (chain.fees) {
34
+ console.log(chalk_1.default.bold(`Fee Tokens:`));
35
+ chain.fees.fee_tokens.forEach(fee => {
36
+ console.log(` Denom: ${fee.denom}, Fixed Min Gas Price: ${fee.fixed_min_gas_price}`);
37
+ });
38
+ }
39
+ if (chain.staking) {
40
+ console.log(chalk_1.default.bold(`Staking Tokens:`));
41
+ chain.staking.staking_tokens.forEach(token => {
42
+ console.log(` Denom: ${token.denom}`);
43
+ });
44
+ }
45
+ if (chain.apis) {
46
+ console.log(chalk_1.default.bold(`APIs:`));
47
+ if (chain.apis.rpc) {
48
+ console.log(` RPC:`);
49
+ chain.apis.rpc.forEach(endpoint => {
50
+ console.log(` Address: ${endpoint.address}`);
51
+ });
52
+ }
53
+ if (chain.apis.rest) {
54
+ console.log(` REST:`);
55
+ chain.apis.rest.forEach(endpoint => {
56
+ console.log(` Address: ${endpoint.address}`);
57
+ });
58
+ }
59
+ }
60
+ if (chain.explorers) {
61
+ console.log(chalk_1.default.bold(`Explorers:`));
62
+ chain.explorers.forEach(explorer => {
63
+ console.log(` URL: ${explorer.url}`);
64
+ if (explorer.tx_page) {
65
+ console.log(` TX Page: ${explorer.tx_page}`);
66
+ }
67
+ if (explorer.account_page) {
68
+ console.log(` Account Page: ${explorer.account_page}`);
69
+ }
70
+ });
71
+ }
72
+ console.log(chalk_1.default.bold(`Keywords: ${chain.keywords?.join(', ')}`));
73
+ }
74
+ exports.displayChain = displayChain;
@@ -0,0 +1,3 @@
1
+ import { CLIOptions, Inquirerer } from 'inquirerer';
2
+ import { ParsedArgs } from 'minimist';
3
+ export declare const commands: (argv: Partial<ParsedArgs>, prompter: Inquirerer, _options: CLIOptions) => Promise<Partial<ParsedArgs>>;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commands = void 0;
4
+ const workflows_1 = require("@chain-registry/workflows");
5
+ const fs_1 = require("fs");
6
+ const asset_1 = require("./asset");
7
+ const asset_list_1 = require("./asset-list");
8
+ const chain_1 = require("./chain");
9
+ const commands = async (argv, prompter, _options) => {
10
+ let command;
11
+ if (argv._.length > 0) {
12
+ command = argv._.shift();
13
+ }
14
+ if (command) {
15
+ argv.command = command;
16
+ }
17
+ const questions = [
18
+ {
19
+ type: 'autocomplete',
20
+ name: 'command',
21
+ message: 'choose a command',
22
+ options: [
23
+ 'chain',
24
+ 'asset-list',
25
+ 'asset'
26
+ ]
27
+ }
28
+ ];
29
+ ({ command } = await prompter.prompt(argv, questions));
30
+ argv = await prompter.prompt(argv, [
31
+ {
32
+ type: 'text',
33
+ name: 'registryDir',
34
+ message: 'provide a registryDir:'
35
+ }
36
+ ]);
37
+ if (!(0, fs_1.existsSync)(argv.registryDir)) {
38
+ prompter.exit();
39
+ throw new Error('bad registry path!');
40
+ }
41
+ const registry = new workflows_1.Registry(argv.registryDir);
42
+ switch (command) {
43
+ case 'chain':
44
+ argv = await prompter.prompt(argv, [
45
+ {
46
+ type: 'autocomplete',
47
+ name: 'chain',
48
+ message: 'Select a chain:',
49
+ options: registry.chains.map(chain => ({ name: chain.chain_name, value: chain })),
50
+ maxDisplayLines: 15
51
+ }
52
+ ]);
53
+ (0, chain_1.displayChain)(argv.chain);
54
+ break;
55
+ case 'asset-list':
56
+ argv = await prompter.prompt(argv, [
57
+ {
58
+ type: 'autocomplete',
59
+ name: 'chain',
60
+ message: 'Select a chain:',
61
+ options: registry.chains.map(chain => chain.chain_name),
62
+ maxDisplayLines: 15
63
+ }
64
+ ]);
65
+ const assetList = registry.assetLists.find(a => a.chain_name === argv.chain);
66
+ (0, asset_list_1.displayAssetList)(assetList);
67
+ break;
68
+ case 'asset':
69
+ argv = await prompter.prompt(argv, [
70
+ {
71
+ type: 'autocomplete',
72
+ name: 'chain',
73
+ message: 'Select a chain:',
74
+ options: registry.chains.map(chain => chain.chain_name),
75
+ maxDisplayLines: 15
76
+ }
77
+ ]);
78
+ argv = await prompter.prompt(argv, [
79
+ {
80
+ type: 'autocomplete',
81
+ name: 'asset',
82
+ message: 'Select an asset:',
83
+ options: registry.assetLists
84
+ .filter(list => list.chain_name === argv.chain)
85
+ .flatMap(list => list.assets)
86
+ .map(asset => ({
87
+ name: asset.base,
88
+ value: asset
89
+ })),
90
+ maxDisplayLines: 15
91
+ }
92
+ ]);
93
+ (0, asset_1.displayAsset)(argv.asset);
94
+ break;
95
+ default:
96
+ console.log(`No recognized command provided or no command given: ${command}`);
97
+ break;
98
+ }
99
+ return argv;
100
+ };
101
+ exports.commands = commands;
@@ -0,0 +1,3 @@
1
+ import { CLIOptions, Inquirerer } from 'inquirerer';
2
+ import { ParsedArgs } from 'minimist';
3
+ export declare const commands: (argv: Partial<ParsedArgs>, prompter: Inquirerer, _options: CLIOptions) => Promise<Partial<ParsedArgs>>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commands = void 0;
4
+ const workflows_1 = require("@chain-registry/workflows");
5
+ const fs_1 = require("fs");
6
+ const commands = async (argv, prompter, _options) => {
7
+ argv = await prompter.prompt(argv, [
8
+ {
9
+ type: 'text',
10
+ name: 'registryDir',
11
+ message: 'provide a registryDir:'
12
+ }
13
+ ]);
14
+ if (!(0, fs_1.existsSync)(argv.registryDir)) {
15
+ prompter.exit();
16
+ throw new Error('bad registry path!');
17
+ }
18
+ const registry = new workflows_1.Registry(argv.registryDir);
19
+ const validator = new workflows_1.SchemaValidator(registry);
20
+ validator.validateAllData(true);
21
+ return argv;
22
+ };
23
+ exports.commands = commands;
package/esm/cli.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import { CLI } from 'inquirerer';
3
+ import { commands } from './commands';
4
+ export const options = {
5
+ minimistOpts: {
6
+ alias: {
7
+ v: 'version'
8
+ }
9
+ }
10
+ };
11
+ const app = new CLI(commands, options);
12
+ app.run().then(() => {
13
+ // all done!
14
+ }).catch(error => {
15
+ console.error(error);
16
+ process.exit(1);
17
+ });
@@ -0,0 +1,43 @@
1
+ import { Registry, SchemaTypeGenerator } from '@chain-registry/workflows';
2
+ import { existsSync } from 'fs';
3
+ export const commands = async (argv, prompter, _options) => {
4
+ const { registryDir, outputDir, strictTypeSafety, useCamelCase } = await prompter.prompt(argv, [
5
+ {
6
+ type: 'text',
7
+ name: 'registryDir',
8
+ message: 'provide a registryDir:'
9
+ },
10
+ {
11
+ type: 'text',
12
+ name: 'outputDir',
13
+ message: 'provide a outputDir:'
14
+ },
15
+ {
16
+ type: 'confirm',
17
+ name: 'strictTypeSafety',
18
+ default: true,
19
+ useDefault: true
20
+ },
21
+ {
22
+ type: 'confirm',
23
+ name: 'useCamelCase',
24
+ default: true,
25
+ useDefault: false
26
+ }
27
+ ]);
28
+ if (!existsSync(registryDir)) {
29
+ prompter.exit();
30
+ throw new Error('bad registry path!');
31
+ }
32
+ const registry = new Registry(registryDir);
33
+ const generator = new SchemaTypeGenerator({
34
+ outputDir,
35
+ registry,
36
+ schemaTSOptions: {
37
+ strictTypeSafety,
38
+ useCamelCase
39
+ }
40
+ });
41
+ generator.generateTypes();
42
+ return argv;
43
+ };
@@ -0,0 +1,44 @@
1
+ import { commands as codegen } from './codegen';
2
+ import { commands as info } from './info';
3
+ import { commands as validate } from './validate';
4
+ export const commands = async (argv, prompter, _options) => {
5
+ let command;
6
+ if (argv._.length > 0) {
7
+ command = argv._.shift();
8
+ }
9
+ if (command) {
10
+ argv.command = command;
11
+ }
12
+ const questions = [
13
+ {
14
+ type: 'autocomplete',
15
+ name: 'command',
16
+ message: 'choose a command',
17
+ options: [
18
+ 'info',
19
+ 'validate',
20
+ 'codegen'
21
+ ]
22
+ }
23
+ ];
24
+ ({ command } = await prompter.prompt(argv, questions));
25
+ // recursive...
26
+ delete argv.command;
27
+ // @ts-ignore
28
+ prompter.exit = () => { };
29
+ switch (command) {
30
+ case 'info':
31
+ argv = await info(argv, prompter, _options);
32
+ break;
33
+ case 'validate':
34
+ argv = await validate(argv, prompter, _options);
35
+ break;
36
+ case 'codegen':
37
+ argv = await codegen(argv, prompter, _options);
38
+ break;
39
+ default:
40
+ console.log(`No recognized command provided or no command given: ${command}`);
41
+ break;
42
+ }
43
+ return argv;
44
+ };
@@ -0,0 +1,9 @@
1
+ import chalk from 'chalk';
2
+ import { displayAsset } from './asset';
3
+ export function displayAssetList(assetList) {
4
+ console.log(chalk.bold.blue(`Asset List for Chain: ${assetList.chain_name}`));
5
+ console.log(chalk.underline(`${assetList.assets.length} Assets Found:`));
6
+ assetList.assets.forEach(asset => {
7
+ displayAsset(asset); // Call displayAsset for each asset in the list
8
+ });
9
+ }
@@ -0,0 +1,51 @@
1
+ import chalk from 'chalk';
2
+ export function displayAsset(asset) {
3
+ console.log(chalk.bold.blue(`Asset Name: ${asset.name}`));
4
+ console.log(chalk.bold(`Symbol: ${asset.symbol}`));
5
+ console.log(chalk.bold(`Type: ${asset.type_asset || 'Not specified'}`));
6
+ console.log(`Base Unit: ${asset.base}`);
7
+ console.log(`Display Unit: ${asset.display}`);
8
+ if (asset.deprecated) {
9
+ console.log(chalk.red('Deprecated: Yes'));
10
+ }
11
+ if (asset.description) {
12
+ console.log(chalk.italic(`Description: ${asset.description}`));
13
+ }
14
+ if (asset.extended_description) {
15
+ console.log(chalk.italic(`Extended Description: ${asset.extended_description}`));
16
+ }
17
+ if (asset.denom_units) {
18
+ console.log(chalk.bold.green('Denomination Units:'));
19
+ asset.denom_units.forEach(unit => {
20
+ console.log(` - Denom: ${unit.denom}, Exponent: ${unit.exponent}${unit.aliases ? `, Aliases: ${unit.aliases.join(', ')}` : ''}`);
21
+ });
22
+ }
23
+ if (asset.ibc) {
24
+ console.log(chalk.bold.yellow('IBC Info:'));
25
+ console.log(` Source Channel: ${asset.ibc.source_channel}`);
26
+ console.log(` Destination Channel: ${asset.ibc.dst_channel}`);
27
+ console.log(` Source Denom: ${asset.ibc.source_denom}`);
28
+ }
29
+ if (asset.logo_URIs) {
30
+ console.log(chalk.bold.cyan('Logos:'));
31
+ asset.logo_URIs.png && console.log(` PNG: ${asset.logo_URIs.png}`);
32
+ asset.logo_URIs.svg && console.log(` SVG: ${asset.logo_URIs.svg}`);
33
+ }
34
+ if (asset.images && asset.images.length > 0) {
35
+ console.log(chalk.bold.magenta('Images:'));
36
+ asset.images.forEach((image, index) => {
37
+ console.log(` Image ${index + 1}:`);
38
+ image.png && console.log(` PNG: ${image.png}`);
39
+ image.svg && console.log(` SVG: ${image.svg}`);
40
+ if (image.theme) {
41
+ console.log(` Theme: ${image.theme.primary_color_hex} Circle: ${image.theme.circle ? 'Yes' : 'No'} Dark Mode: ${image.theme.dark_mode ? 'Yes' : 'No'}`);
42
+ }
43
+ });
44
+ }
45
+ if (asset.socials) {
46
+ console.log(chalk.bold('Socials:'));
47
+ asset.socials.website && console.log(` Website: ${asset.socials.website}`);
48
+ asset.socials.twitter && console.log(` Twitter: ${asset.socials.twitter}`);
49
+ }
50
+ console.log('\n');
51
+ }
@@ -0,0 +1,67 @@
1
+ import chalk from 'chalk';
2
+ export function displayChain(chain) {
3
+ console.log(chalk.bold.green(`Chain Details: ${chain.chain_name}`));
4
+ console.log(chalk.bold(`Chain ID: ${chalk.cyan(chain.chain_id)}`));
5
+ if (chain.pretty_name) {
6
+ console.log(chalk.bold(`Pretty Name: ${chalk.cyan(chain.pretty_name)}`));
7
+ }
8
+ if (chain.website) {
9
+ console.log(chalk.bold(`Website: ${chalk.underline.blue(chain.website)}`));
10
+ }
11
+ if (chain.status) {
12
+ console.log(chalk.bold(`Status: ${chalk.yellow(chain.status)}`));
13
+ }
14
+ if (chain.network_type) {
15
+ console.log(chalk.bold(`Network Type: ${chalk.magenta(chain.network_type)}`));
16
+ }
17
+ console.log(chalk.bold(`Bech32 Prefix: ${chalk.cyan(chain.bech32_prefix)}`));
18
+ if (chain.daemon_name) {
19
+ console.log(chalk.bold(`Daemon Name: ${chain.daemon_name}`));
20
+ }
21
+ if (chain.codebase) {
22
+ console.log(chalk.bold(`Codebase:`));
23
+ console.log(` Git Repo: ${chain.codebase.git_repo}`);
24
+ console.log(` Recommended Version: ${chain.codebase.recommended_version}`);
25
+ console.log(` Go Version: ${chain.codebase.go_version}`);
26
+ }
27
+ if (chain.fees) {
28
+ console.log(chalk.bold(`Fee Tokens:`));
29
+ chain.fees.fee_tokens.forEach(fee => {
30
+ console.log(` Denom: ${fee.denom}, Fixed Min Gas Price: ${fee.fixed_min_gas_price}`);
31
+ });
32
+ }
33
+ if (chain.staking) {
34
+ console.log(chalk.bold(`Staking Tokens:`));
35
+ chain.staking.staking_tokens.forEach(token => {
36
+ console.log(` Denom: ${token.denom}`);
37
+ });
38
+ }
39
+ if (chain.apis) {
40
+ console.log(chalk.bold(`APIs:`));
41
+ if (chain.apis.rpc) {
42
+ console.log(` RPC:`);
43
+ chain.apis.rpc.forEach(endpoint => {
44
+ console.log(` Address: ${endpoint.address}`);
45
+ });
46
+ }
47
+ if (chain.apis.rest) {
48
+ console.log(` REST:`);
49
+ chain.apis.rest.forEach(endpoint => {
50
+ console.log(` Address: ${endpoint.address}`);
51
+ });
52
+ }
53
+ }
54
+ if (chain.explorers) {
55
+ console.log(chalk.bold(`Explorers:`));
56
+ chain.explorers.forEach(explorer => {
57
+ console.log(` URL: ${explorer.url}`);
58
+ if (explorer.tx_page) {
59
+ console.log(` TX Page: ${explorer.tx_page}`);
60
+ }
61
+ if (explorer.account_page) {
62
+ console.log(` Account Page: ${explorer.account_page}`);
63
+ }
64
+ });
65
+ }
66
+ console.log(chalk.bold(`Keywords: ${chain.keywords?.join(', ')}`));
67
+ }
@@ -0,0 +1,97 @@
1
+ import { Registry } from '@chain-registry/workflows';
2
+ import { existsSync } from 'fs';
3
+ import { displayAsset } from './asset';
4
+ import { displayAssetList } from './asset-list';
5
+ import { displayChain } from './chain';
6
+ export const commands = async (argv, prompter, _options) => {
7
+ let command;
8
+ if (argv._.length > 0) {
9
+ command = argv._.shift();
10
+ }
11
+ if (command) {
12
+ argv.command = command;
13
+ }
14
+ const questions = [
15
+ {
16
+ type: 'autocomplete',
17
+ name: 'command',
18
+ message: 'choose a command',
19
+ options: [
20
+ 'chain',
21
+ 'asset-list',
22
+ 'asset'
23
+ ]
24
+ }
25
+ ];
26
+ ({ command } = await prompter.prompt(argv, questions));
27
+ argv = await prompter.prompt(argv, [
28
+ {
29
+ type: 'text',
30
+ name: 'registryDir',
31
+ message: 'provide a registryDir:'
32
+ }
33
+ ]);
34
+ if (!existsSync(argv.registryDir)) {
35
+ prompter.exit();
36
+ throw new Error('bad registry path!');
37
+ }
38
+ const registry = new Registry(argv.registryDir);
39
+ switch (command) {
40
+ case 'chain':
41
+ argv = await prompter.prompt(argv, [
42
+ {
43
+ type: 'autocomplete',
44
+ name: 'chain',
45
+ message: 'Select a chain:',
46
+ options: registry.chains.map(chain => ({ name: chain.chain_name, value: chain })),
47
+ maxDisplayLines: 15
48
+ }
49
+ ]);
50
+ displayChain(argv.chain);
51
+ break;
52
+ case 'asset-list':
53
+ argv = await prompter.prompt(argv, [
54
+ {
55
+ type: 'autocomplete',
56
+ name: 'chain',
57
+ message: 'Select a chain:',
58
+ options: registry.chains.map(chain => chain.chain_name),
59
+ maxDisplayLines: 15
60
+ }
61
+ ]);
62
+ const assetList = registry.assetLists.find(a => a.chain_name === argv.chain);
63
+ displayAssetList(assetList);
64
+ break;
65
+ case 'asset':
66
+ argv = await prompter.prompt(argv, [
67
+ {
68
+ type: 'autocomplete',
69
+ name: 'chain',
70
+ message: 'Select a chain:',
71
+ options: registry.chains.map(chain => chain.chain_name),
72
+ maxDisplayLines: 15
73
+ }
74
+ ]);
75
+ argv = await prompter.prompt(argv, [
76
+ {
77
+ type: 'autocomplete',
78
+ name: 'asset',
79
+ message: 'Select an asset:',
80
+ options: registry.assetLists
81
+ .filter(list => list.chain_name === argv.chain)
82
+ .flatMap(list => list.assets)
83
+ .map(asset => ({
84
+ name: asset.base,
85
+ value: asset
86
+ })),
87
+ maxDisplayLines: 15
88
+ }
89
+ ]);
90
+ displayAsset(argv.asset);
91
+ break;
92
+ default:
93
+ console.log(`No recognized command provided or no command given: ${command}`);
94
+ break;
95
+ }
96
+ return argv;
97
+ };
@@ -0,0 +1,19 @@
1
+ import { Registry, SchemaValidator } from '@chain-registry/workflows';
2
+ import { existsSync } from 'fs';
3
+ export const commands = async (argv, prompter, _options) => {
4
+ argv = await prompter.prompt(argv, [
5
+ {
6
+ type: 'text',
7
+ name: 'registryDir',
8
+ message: 'provide a registryDir:'
9
+ }
10
+ ]);
11
+ if (!existsSync(argv.registryDir)) {
12
+ prompter.exit();
13
+ throw new Error('bad registry path!');
14
+ }
15
+ const registry = new Registry(argv.registryDir);
16
+ const validator = new SchemaValidator(registry);
17
+ validator.validateAllData(true);
18
+ return argv;
19
+ };
package/esm/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './commands/info';
2
+ export * from './utils';
package/esm/package.js ADDED
@@ -0,0 +1,26 @@
1
+ import { existsSync, readFileSync } from "fs";
2
+ import { dirname, join } from "path";
3
+ // need to search due to the dist/ folder and src/, etc.
4
+ function findPackageJson(currentDir) {
5
+ const filePath = join(currentDir, 'package.json');
6
+ // Check if package.json exists in the current directory
7
+ if (existsSync(filePath)) {
8
+ return filePath;
9
+ }
10
+ // Get the parent directory
11
+ const parentDir = dirname(currentDir);
12
+ // If reached the root directory, package.json is not found
13
+ if (parentDir === currentDir) {
14
+ throw new Error('package.json not found in any parent directory');
15
+ }
16
+ // Recursively look in the parent directory
17
+ return findPackageJson(parentDir);
18
+ }
19
+ export function readAndParsePackageJson() {
20
+ // Start searching from the current directory
21
+ const pkgPath = findPackageJson(__dirname);
22
+ // Read and parse the package.json
23
+ const str = readFileSync(pkgPath, 'utf8');
24
+ const pkg = JSON.parse(str);
25
+ return pkg;
26
+ }
package/esm/utils.js ADDED
@@ -0,0 +1,12 @@
1
+ import chalk from 'chalk';
2
+ import { readAndParsePackageJson } from "./package";
3
+ // Function to display the version information
4
+ export function displayVersion() {
5
+ const pkg = readAndParsePackageJson();
6
+ console.log(chalk.green(`Name: ${pkg.name}`));
7
+ console.log(chalk.blue(`Version: ${pkg.version}`));
8
+ }
9
+ export function getVersion() {
10
+ const pkg = readAndParsePackageJson();
11
+ return pkg.version;
12
+ }
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './commands/info';
2
+ export * from './utils';
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./commands/info"), exports);
18
+ __exportStar(require("./utils"), exports);
package/package.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function readAndParsePackageJson(): any;
package/package.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readAndParsePackageJson = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ // need to search due to the dist/ folder and src/, etc.
7
+ function findPackageJson(currentDir) {
8
+ const filePath = (0, path_1.join)(currentDir, 'package.json');
9
+ // Check if package.json exists in the current directory
10
+ if ((0, fs_1.existsSync)(filePath)) {
11
+ return filePath;
12
+ }
13
+ // Get the parent directory
14
+ const parentDir = (0, path_1.dirname)(currentDir);
15
+ // If reached the root directory, package.json is not found
16
+ if (parentDir === currentDir) {
17
+ throw new Error('package.json not found in any parent directory');
18
+ }
19
+ // Recursively look in the parent directory
20
+ return findPackageJson(parentDir);
21
+ }
22
+ function readAndParsePackageJson() {
23
+ // Start searching from the current directory
24
+ const pkgPath = findPackageJson(__dirname);
25
+ // Read and parse the package.json
26
+ const str = (0, fs_1.readFileSync)(pkgPath, 'utf8');
27
+ const pkg = JSON.parse(str);
28
+ return pkg;
29
+ }
30
+ exports.readAndParsePackageJson = readAndParsePackageJson;
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@chain-registry/cli",
3
+ "version": "1.27.0",
4
+ "description": "Chain Registry CLI",
5
+ "author": "Dan Lynch <pyramation@gmail.com>",
6
+ "homepage": "https://github.com/cosmology-tech/chain-registry",
7
+ "license": "SEE LICENSE IN LICENSE",
8
+ "main": "index.js",
9
+ "module": "esm/index.js",
10
+ "types": "index.d.ts",
11
+ "bin": {
12
+ "registry": "cli.js"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "directory": "dist"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/cosmology-tech/chain-registry"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/cosmology-tech/chain-registry/issues"
24
+ },
25
+ "scripts": {
26
+ "copy": "copyfiles -f LICENSE README.md package.json dist",
27
+ "clean": "del dist/**",
28
+ "prepare": "npm run build",
29
+ "build": "npm run clean; tsc; tsc -p tsconfig.esm.json; npm run copy",
30
+ "dev": "ts-node src/cli",
31
+ "test": "jest",
32
+ "test:watch": "jest --watch"
33
+ },
34
+ "dependencies": {
35
+ "@chain-registry/interfaces": "^0.26.0",
36
+ "@chain-registry/workflows": "^1.27.0",
37
+ "chalk": "^4.1.0",
38
+ "deepmerge": "^4.3.1",
39
+ "inquirerer": "1.8.0",
40
+ "minimist": "^1.2.8"
41
+ },
42
+ "keywords": [
43
+ "cli",
44
+ "chain-registry",
45
+ "web3",
46
+ "cosmos",
47
+ "interchain"
48
+ ],
49
+ "gitHead": "bef55160d9bd8290980354c99963da3f3b12b94e"
50
+ }
package/utils.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function displayVersion(): void;
2
+ export declare function getVersion(): string;
package/utils.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getVersion = exports.displayVersion = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const package_1 = require("./package");
9
+ // Function to display the version information
10
+ function displayVersion() {
11
+ const pkg = (0, package_1.readAndParsePackageJson)();
12
+ console.log(chalk_1.default.green(`Name: ${pkg.name}`));
13
+ console.log(chalk_1.default.blue(`Version: ${pkg.version}`));
14
+ }
15
+ exports.displayVersion = displayVersion;
16
+ function getVersion() {
17
+ const pkg = (0, package_1.readAndParsePackageJson)();
18
+ return pkg.version;
19
+ }
20
+ exports.getVersion = getVersion;