|
|
@ -3,10 +3,10 @@ import { CommandModule } from 'yargs'; |
|
|
|
import { |
|
|
|
import { |
|
|
|
Chains, |
|
|
|
Chains, |
|
|
|
CoreChainName, |
|
|
|
CoreChainName, |
|
|
|
Mainnets, |
|
|
|
HyperlaneEnvironment, |
|
|
|
Testnets, |
|
|
|
|
|
|
|
chainMetadata, |
|
|
|
chainMetadata, |
|
|
|
hyperlaneContractAddresses, |
|
|
|
hyperlaneContractAddresses, |
|
|
|
|
|
|
|
hyperlaneEnvironments, |
|
|
|
} from '@hyperlane-xyz/sdk'; |
|
|
|
} from '@hyperlane-xyz/sdk'; |
|
|
|
|
|
|
|
|
|
|
|
import { log, logBlue, logGray, logTable } from '../logger.js'; |
|
|
|
import { log, logBlue, logGray, logTable } from '../logger.js'; |
|
|
@ -33,44 +33,36 @@ const listCommand: CommandModule = { |
|
|
|
command: 'list', |
|
|
|
command: 'list', |
|
|
|
describe: 'List all core chains included in the Hyperlane SDK', |
|
|
|
describe: 'List all core chains included in the Hyperlane SDK', |
|
|
|
builder: (yargs) => |
|
|
|
builder: (yargs) => |
|
|
|
yargs |
|
|
|
yargs.option('environment', { |
|
|
|
.option('mainnet', { |
|
|
|
alias: 'e', |
|
|
|
alias: 'm', |
|
|
|
describe: 'Specify the environment to list chains for', |
|
|
|
describe: 'Only list mainnet chains', |
|
|
|
choices: ['mainnet', 'testnet'], |
|
|
|
}) |
|
|
|
}), |
|
|
|
.option('testnet', { |
|
|
|
|
|
|
|
alias: 't', |
|
|
|
|
|
|
|
describe: 'Only list testnet chains', |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.conflicts('mainnet', 'testnet'), |
|
|
|
|
|
|
|
handler: (args) => { |
|
|
|
handler: (args) => { |
|
|
|
const mainnet = args.mainnet as string | undefined; |
|
|
|
const environment = args.environment as HyperlaneEnvironment | undefined; |
|
|
|
const testnet = args.testnet as string | undefined; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const serializer = (chains: string[]) => |
|
|
|
const serializer = (env: HyperlaneEnvironment) => |
|
|
|
chains.reduce<any>((result, chain) => { |
|
|
|
Object.keys(hyperlaneEnvironments[env]).reduce<any>((result, chain) => { |
|
|
|
|
|
|
|
const { chainId, displayName } = chainMetadata[chain]; |
|
|
|
result[chain] = { |
|
|
|
result[chain] = { |
|
|
|
'Display Name': chainMetadata[chain].displayName, |
|
|
|
'Display Name': displayName, |
|
|
|
'Chain Id': chainMetadata[chain].chainId, |
|
|
|
'Chain Id': chainId, |
|
|
|
}; |
|
|
|
}; |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
}, {}); |
|
|
|
}, {}); |
|
|
|
const logMainnet = () => { |
|
|
|
|
|
|
|
logBlue('\nHyperlane core mainnet chains:'); |
|
|
|
const logChainsForEnv = (env: HyperlaneEnvironment) => { |
|
|
|
logGray('------------------------------'); |
|
|
|
logBlue(`\nHyperlane core ${env} chains:`); |
|
|
|
logTable(serializer(Mainnets)); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
const logTestnet = () => { |
|
|
|
|
|
|
|
logBlue('\nHyperlane core testnet chains:'); |
|
|
|
|
|
|
|
logGray('------------------------------'); |
|
|
|
logGray('------------------------------'); |
|
|
|
logTable(serializer(Testnets)); |
|
|
|
logTable(serializer(env)); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (mainnet) return logMainnet(); |
|
|
|
if (environment) { |
|
|
|
else if (testnet) return logTestnet(); |
|
|
|
logChainsForEnv(environment); |
|
|
|
|
|
|
|
} else { |
|
|
|
logMainnet(); |
|
|
|
logChainsForEnv('mainnet'); |
|
|
|
logTestnet(); |
|
|
|
logChainsForEnv('testnet'); |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|