Part of https://www.notion.so/Create-laconic-registry-SDK-d3a636d4aba44f7cbba3bd99b7146811 - Use user key as transaction private key in record publish cmd Co-authored-by: neeraj <neeraj.rtly@gmail.com> Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Reviewed-on: cerc-io/laconic-registry-cli#56 Co-authored-by: Nabarun <nabarun@deepstacksoft.com> Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
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: { cns: cnsConfig } } = getConfig(argv.config as string);
|
|
const { restEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, cnsConfig);
|
|
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
|
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
|
assert(privateKey, 'Invalid Transaction Key.');
|
|
assert(chainId, 'Invalid CNS Chain ID.');
|
|
|
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
|
const fee = getGasAndFees(argv, cnsConfig);
|
|
const result = await registry.deleteName({ lrn: name }, privateKey, fee);
|
|
|
|
const success = '{"success": true}';
|
|
txOutput(result, success, argv.output, argv.verbose);
|
|
};
|