|
|
|
@ -20,6 +20,7 @@ export const registryCommand: CommandModule = { |
|
|
|
|
builder: (yargs) => |
|
|
|
|
yargs |
|
|
|
|
.command(addressesCommand) |
|
|
|
|
.command(rpcCommand) |
|
|
|
|
.command(createAgentConfigCommand) |
|
|
|
|
.command(initCommand) |
|
|
|
|
.command(listCommand) |
|
|
|
@ -71,8 +72,12 @@ const listCommand: CommandModuleWithContext<{ type: ChainType }> = { |
|
|
|
|
/** |
|
|
|
|
* Addresses command |
|
|
|
|
*/ |
|
|
|
|
const addressesCommand: CommandModuleWithContext<{ name: string }> = { |
|
|
|
|
const addressesCommand: CommandModuleWithContext<{ |
|
|
|
|
name: string; |
|
|
|
|
contract: string; |
|
|
|
|
}> = { |
|
|
|
|
command: 'addresses', |
|
|
|
|
aliases: ['address', 'addy'], |
|
|
|
|
describe: 'Display the addresses of core Hyperlane contracts', |
|
|
|
|
builder: { |
|
|
|
|
name: { |
|
|
|
@ -80,10 +85,21 @@ const addressesCommand: CommandModuleWithContext<{ name: string }> = { |
|
|
|
|
description: 'Chain to display addresses for', |
|
|
|
|
alias: 'chain', |
|
|
|
|
}, |
|
|
|
|
contract: { |
|
|
|
|
type: 'string', |
|
|
|
|
description: 'Specific contract name to print addresses for', |
|
|
|
|
implies: 'name', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
handler: async ({ name, context }) => { |
|
|
|
|
handler: async ({ name, context, contract }) => { |
|
|
|
|
if (name) { |
|
|
|
|
const result = await context.registry.getChainAddresses(name); |
|
|
|
|
if (contract && result?.[contract.toLowerCase()]) { |
|
|
|
|
// log only contract address for machine readability
|
|
|
|
|
log(result[contract]); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
logBlue('Hyperlane contract addresses for:', name); |
|
|
|
|
logGray('---------------------------------'); |
|
|
|
|
log(JSON.stringify(result, null, 2)); |
|
|
|
@ -96,6 +112,38 @@ const addressesCommand: CommandModuleWithContext<{ name: string }> = { |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const rpcCommand: CommandModuleWithContext<{ |
|
|
|
|
name: string; |
|
|
|
|
index: number; |
|
|
|
|
}> = { |
|
|
|
|
command: 'rpc', |
|
|
|
|
describe: 'Display the public rpc of a Hyperlane chain', |
|
|
|
|
builder: { |
|
|
|
|
name: { |
|
|
|
|
type: 'string', |
|
|
|
|
description: 'Chain to display addresses for', |
|
|
|
|
alias: 'chain', |
|
|
|
|
demandOption: true, |
|
|
|
|
}, |
|
|
|
|
index: { |
|
|
|
|
type: 'number', |
|
|
|
|
description: 'Index of the rpc to display', |
|
|
|
|
default: 0, |
|
|
|
|
demandOption: false, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
handler: async ({ name, context, index }) => { |
|
|
|
|
const result = await context.registry.getChainMetadata(name); |
|
|
|
|
const rpcUrl = result?.rpcUrls[index]?.http; |
|
|
|
|
if (!rpcUrl) { |
|
|
|
|
errorRed(`❌ No rpc found for chain ${name}`); |
|
|
|
|
process.exit(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log(rpcUrl); |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* agent-config command |
|
|
|
|
*/ |
|
|
|
|