32 lines
969 B
TypeScript
32 lines
969 B
TypeScript
import { Arguments } from 'yargs';
|
|
import assert from 'assert';
|
|
import { Registry } from '@cerc-io/laconic-sdk';
|
|
|
|
import { getConfig, getConnectionInfo } 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: { cns: cnsConfig } } = getConfig(argv.config as string)
|
|
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
|
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
|
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
|
assert(chainId, 'Invalid CNS Chain ID.');
|
|
|
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
|
const result = await registry.lookupNames([name], argv.history as boolean);
|
|
|
|
console.log(JSON.stringify(result, undefined, 2));
|
|
}
|