Add command to get authorities list

This commit is contained in:
IshaVenikar 2024-08-01 16:28:27 +05:30
parent 70e63c74f1
commit 1e2bd72185

View File

@ -0,0 +1,24 @@
import { Arguments } from 'yargs';
import assert from 'assert';
import { Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
export const command = 'get [owner]';
export const desc = 'List authorities (optionally by owner).';
export const handler = async (argv: Arguments) => {
const owner = argv.owner as string || '';
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.getAuthorities(owner);
queryOutput(result, argv.output);
};