cosmic-interchain-cli
Version:
A command-line utility for Cosmic Wire's interchain messaging protocol
65 lines • 1.77 kB
JavaScript
import { ethers } from 'ethers';
import { log } from '../logger.js';
import { sendTestMessage } from '../send/message.js';
/**
* Parent command
*/
export const sendCommand = {
command: 'send',
describe: 'Send a test message',
builder: (yargs) => yargs.command(messageCommand).version(false).demandCommand(),
handler: () => log('Command required'),
};
/**
* Message command
*/
export const messageOptions = {
origin: {
type: 'string',
description: 'Origin chain to send message from',
},
destination: {
type: 'string',
description: 'Destination chain to send message to',
},
timeout: {
type: 'number',
description: 'Timeout in seconds',
default: 5 * 60,
},
quick: {
type: 'boolean',
description: 'Skip wait for message to be delivered',
default: false,
},
relay: {
type: 'boolean',
description: 'Handle self-relay of message on destination chain',
default: false,
},
};
const messageCommand = {
command: 'message',
describe: 'Send a test message to a remote chain',
builder: {
...messageOptions,
body: {
type: 'string',
description: 'Optional Message body',
default: 'Hello!',
},
},
handler: async ({ context, origin, destination, timeout, quick, relay, body, }) => {
await sendTestMessage({
context,
origin,
destination,
messageBody: ethers.utils.hexlify(ethers.utils.toUtf8Bytes(body)),
timeoutSec: timeout,
skipWaitForDelivery: quick,
selfRelay: relay,
});
process.exit(0);
},
};
//# sourceMappingURL=send.js.map