Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/cli-sdk/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Commands:
Options:
--browser Use browser UI instead of terminal QR code
--json Output as JSON (for whoami)
--chain <id> Specify chain (e.g. eip155:10, solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp) for connect
--chain <id> Specify chain (e.g. evm, solana, eip155:10) for connect
--version Show version number
--help Show this help message

Expand Down
33 changes: 31 additions & 2 deletions packages/cli-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,33 @@ const SOLANA_METHODS = ["solana_signTransaction", "solana_signMessage"];
const SOLANA_EVENTS: string[] = [];
const DEFAULT_STORAGE_PATH = join(homedir(), ".walletconnect-cli");

/** Shorthand chain names → CAIP-2 identifiers */
const CHAIN_ALIASES: Record<string, string | string[]> = {
solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
evm: [
"eip155:1", // Ethereum
"eip155:137", // Polygon
"eip155:10", // Optimism
"eip155:42161", // Arbitrum One
"eip155:8453", // Base
"eip155:56", // BNB Chain
"eip155:43114", // Avalanche C-Chain
"eip155:100", // Gnosis
"eip155:250", // Fantom
"eip155:324", // zkSync Era
"eip155:59144", // Linea
"eip155:534352", // Scroll
"eip155:5000", // Mantle
"eip155:81457", // Blast
"eip155:7777777", // Zora
"eip155:1101", // Polygon zkEVM
"eip155:42220", // Celo
"eip155:1284", // Moonbeam
"eip155:1285", // Moonriver
"eip155:25", // Cronos
],
};

export class WalletConnectCLI extends EventEmitter {
private readonly options: WalletConnectCLIOptions;
private signClient: InstanceType<typeof SignClient> | null = null;
Expand Down Expand Up @@ -286,8 +313,10 @@ export class WalletConnectCLI extends EventEmitter {
}

private buildNamespaces(chains: string[]): Record<string, { chains: string[]; methods: string[]; events: string[] }> {
const eipChains = chains.filter((c) => c.startsWith("eip155:"));
const solChains = chains.filter((c) => c.startsWith("solana:"));
const resolved = chains.flatMap((c) => CHAIN_ALIASES[c.toLowerCase()] ?? c);

const eipChains = resolved.filter((c) => c.startsWith("eip155:"));
const solChains = resolved.filter((c) => c.startsWith("solana:"));

const namespaces: Record<string, { chains: string[]; methods: string[]; events: string[] }> = {};

Expand Down
2 changes: 1 addition & 1 deletion packages/cli-sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface WalletConnectCLIOptions {
storagePath?: string;
/** Connection UI mode. Default: 'terminal' */
ui?: "terminal" | "browser";
/** CAIP-2 chain IDs to request. Default: ['eip155:1'] */
/** CAIP-2 chain IDs or shorthand names (e.g. 'ethereum', 'solana'). Default: ['eip155:1'] */
chains?: string[];
/** JSON-RPC methods to request. Default: common EVM signing methods */
methods?: string[];
Expand Down