cosmic-interchain-cli
Version:
A command-line utility for Cosmic Wire's interchain messaging protocol
86 lines • 2.87 kB
JavaScript
import { ProtocolType } from '@hyperlane-xyz/utils';
import { checkValidatorAvsSetup } from '../avs/check.js';
import { deregisterOperator, registerOperatorWithSignature, } from '../avs/stakeRegistry.js';
import { errorRed, log } from '../logger.js';
import { avsChainCommandOption, demandOption, operatorKeyPathCommandOption, } from './options.js';
/**
* Parent command
*/
export const avsCommand = {
command: 'bootstrap',
describe: 'Interact with the interchain bootstrapper',
builder: (yargs) => yargs
.command(registerCommand)
.command(deregisterCommand)
.command(checkCommand)
.version(false)
.demandCommand(),
handler: () => log('Command required'),
};
/**
* Registration command
*/
export const registrationOptions = {
chain: avsChainCommandOption,
operatorKeyPath: demandOption(operatorKeyPathCommandOption),
avsSigningKeyAddress: {
type: 'string',
description: 'Address of the signing key',
demandOption: true,
},
};
const registerCommand = {
command: 'register',
describe: 'Register operator with the protocol',
builder: registrationOptions,
handler: async ({ context, chain, operatorKeyPath, avsSigningKeyAddress, }) => {
await registerOperatorWithSignature({
context,
chain,
operatorKeyPath,
avsSigningKeyAddress,
});
process.exit(0);
},
};
const deregisterCommand = {
command: 'deregister',
describe: 'Deregister yourself with the protocol',
builder: registrationOptions,
handler: async ({ context, chain, operatorKeyPath }) => {
await deregisterOperator({
context,
chain,
operatorKeyPath,
});
process.exit(0);
},
};
const checkCommand = {
command: 'check',
describe: 'Check operator',
builder: {
chain: avsChainCommandOption,
operatorKeyPath: operatorKeyPathCommandOption,
operatorAddress: {
type: 'string',
description: 'Address of the operator to check',
},
},
handler: async ({ context, chain, operatorKeyPath, operatorAddress }) => {
const { multiProvider } = context;
// validate chain
if (!multiProvider.hasChain(chain)) {
errorRed(`❌ No metadata found for ${chain}. Ensure it is included in your configured registry.`);
process.exit(1);
}
const chainMetadata = multiProvider.getChainMetadata(chain);
if (chainMetadata.protocol !== ProtocolType.Ethereum) {
errorRed(`\n❌ Operator check only supports EVM chains. Exiting.`);
process.exit(1);
}
await checkValidatorAvsSetup(chain, context, operatorKeyPath, operatorAddress);
process.exit(0);
},
};
//# sourceMappingURL=avs.js.map