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>
29 lines
981 B
TypeScript
29 lines
981 B
TypeScript
import { Arguments } from 'yargs';
|
|
import assert from 'assert';
|
|
import { Account, Registry } from '@cerc-io/registry-sdk';
|
|
|
|
import { getConfig, getConnectionInfo, queryOutput } from '../../../util';
|
|
|
|
export const command = 'get';
|
|
|
|
export const desc = 'Get account.';
|
|
|
|
export const handler = async (argv: Arguments) => {
|
|
let address = argv.address as string;
|
|
|
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
|
const { rpcEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
|
assert(rpcEndpoint, 'Invalid registry RPC endpoint.');
|
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
|
assert(chainId, 'Invalid registry Chain ID.');
|
|
|
|
if (!address && privateKey) {
|
|
address = new Account(Buffer.from(privateKey, 'hex')).address;
|
|
}
|
|
|
|
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
|
const result = await registry.getAccounts([address]);
|
|
|
|
queryOutput(result, argv.output);
|
|
};
|