Part of https://www.notion.so/Rename-laconic2d-to-laconicd-9028d0c020d24d1288e92ebcb773d7a7 Co-authored-by: neeraj <neeraj.rtly@gmail.com> Reviewed-on: cerc-io/laconic-registry-cli#61 Co-authored-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to> Co-committed-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
32 lines
995 B
TypeScript
32 lines
995 B
TypeScript
import { Arguments } from 'yargs';
|
|
import assert from 'assert';
|
|
import { Registry } from '@cerc-io/registry-sdk';
|
|
|
|
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
|
|
|
export const command = 'lookup [name]';
|
|
|
|
export const desc = 'Lookup name information.';
|
|
|
|
export const builder = {
|
|
history: {
|
|
type: 'boolean'
|
|
}
|
|
};
|
|
|
|
export const handler = async (argv: Arguments) => {
|
|
const name = argv.name as string;
|
|
assert(name, 'Invalid Name.');
|
|
|
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
|
const { rpcEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
|
assert(rpcEndpoint, 'Invalid registry RPC endpoint.');
|
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
|
assert(chainId, 'Invalid registry Chain ID.');
|
|
|
|
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
|
const result = await registry.lookupNames([name], argv.history as boolean);
|
|
|
|
queryOutput(result, argv.output);
|
|
};
|