diff --git a/src/cmds/registry-cmds/authority-cmds/get.ts b/src/cmds/registry-cmds/authority-cmds/get.ts new file mode 100644 index 0000000..cce4912 --- /dev/null +++ b/src/cmds/registry-cmds/authority-cmds/get.ts @@ -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); +};