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
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { Arguments } from 'yargs';
|
|
import assert from 'assert';
|
|
import { Registry } from '@cerc-io/registry-sdk';
|
|
|
|
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
|
|
|
|
export const command = 'delete [name]';
|
|
|
|
export const desc = 'Delete name (remove name to record ID mapping).';
|
|
|
|
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, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
|
|
assert(rpcEndpoint, 'Invalid registry RPC endpoint.');
|
|
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
|
|
assert(privateKey, 'Invalid Transaction Key.');
|
|
assert(chainId, 'Invalid registry Chain ID.');
|
|
|
|
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
|
const fee = getGasAndFees(argv, registryConfig);
|
|
const result = await registry.deleteName({ lrn: name }, privateKey, fee);
|
|
|
|
const success = '{"success": true}';
|
|
txOutput(result, success, argv.output, argv.verbose);
|
|
};
|