Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/commands/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { Command } from "commander";
import {
EVM_MAINNET_CHAINS,
EVM_TESTNET_CHAINS,
SOLANA_DEVNET_CHAIN_ID,
SOLANA_MAINNET_CHAIN_ID,
} from "@virtuals-protocol/acp-node-v2";
import { isJson, outputResult, outputError, isTTY } from "../lib/output";
import { c } from "../lib/color";
Expand All @@ -19,7 +21,24 @@ export function registerChainCommands(program: Command): void {
const chains = isTestnet ? EVM_TESTNET_CHAINS : EVM_MAINNET_CHAINS;
const env = isTestnet ? "testnet" : "mainnet";

const items = chains.map((ch) => ({ id: ch.id, name: ch.name }));
// Solana has no entry in EVM_*_CHAINS, so it has to be listed
// explicitly — jobs on it work, they just weren't discoverable here.
const solanaChains = isTestnet
? [{ id: SOLANA_DEVNET_CHAIN_ID, name: "Solana Devnet" }]
: [{ id: SOLANA_MAINNET_CHAIN_ID, name: "Solana" }];

const items = [
...chains.map((ch) => ({
id: ch.id,
name: ch.name,
family: "evm" as const,
})),
...solanaChains.map((ch) => ({
id: ch.id,
name: ch.name,
family: "solana" as const,
})),
];

if (json) {
outputResult(json, { environment: env, chains: items });
Expand All @@ -29,10 +48,13 @@ export function registerChainCommands(program: Command): void {
if (isTTY()) {
console.log(`\n${c.bold(`Supported Chains (${env})`)}\n`);
for (const ch of items) {
console.log(` ${c.cyan(String(ch.id).padEnd(10))}${ch.name}`);
console.log(
` ${c.cyan(String(ch.id).padEnd(10))}${ch.name.padEnd(26)}${c.dim(ch.family)}`,
);
}
console.log("");
} else {
// Keep the two-column contract stable for anything parsing this.
console.log("CHAIN_ID\tNAME");
for (const ch of items) {
console.log(`${ch.id}\t${ch.name}`);
Expand Down