Skip to content

Add balance command and improve CLI consistency#262

Open
fan-zhang-sv wants to merge 1 commit intofelix/cli-interactive-session-pickerfrom
felix/cli-balance-command
Open

Add balance command and improve CLI consistency#262
fan-zhang-sv wants to merge 1 commit intofelix/cli-interactive-session-pickerfrom
felix/cli-balance-command

Conversation

@fan-zhang-sv
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a balance command that fetches native and ERC-20 token balances via viem, with contract address validation (isAddress), cached chain lookup, and both JSON and human-readable output
  • Displays chain names using KNOWN_CHAINS aliases (e.g. base, base-sepolia) instead of raw CAIP-2 identifiers (eip155:8453) across all commands via a new chainDisplayName helper
  • Breaks circular dependency between core/session and utils/prompt by moving resolveSessionInteractive to utils/prompt
  • Uses resolveSessionInteractive in the balance command so users with multiple sessions get the interactive picker instead of a hard error
  • Simplifies formatOutput by removing the dead json parameter (both branches were identical)

Test plan

  • All 135 existing tests pass (npx vitest run)
  • New core/balance/index.test.ts covers: ERC-20 balance, native balance, zero balances, unsupported chain error, and RPC error propagation (7 tests)
  • New chainDisplayName unit tests in caip.test.ts cover known aliases and fallback
  • Session integration tests updated to assert chain: "base" / chain: "base-sepolia" instead of chain_id: "eip155:..."
  • formatOutput unit tests updated for simplified signature

Made with Cursor

@fan-zhang-sv fan-zhang-sv force-pushed the felix/cli-interactive-session-picker branch from abcfdaf to 48dacea Compare March 24, 2026 23:42
@fan-zhang-sv fan-zhang-sv force-pushed the felix/cli-balance-command branch 3 times, most recently from c758036 to e856f12 Compare March 25, 2026 17:00
@fan-zhang-sv fan-zhang-sv force-pushed the felix/cli-interactive-session-picker branch from 8e8fb86 to b721a2d Compare March 25, 2026 21:10
- Add `balance` command to fetch native and ERC-20 token balances via
  viem, with contract address validation and human-readable output
- Display chain names using KNOWN_CHAINS aliases (e.g. "base") instead
  of raw CAIP-2 identifiers across all commands
- Break circular dependency between core/session and utils/prompt by
  moving resolveSessionInteractive to utils/prompt
- Use resolveSessionInteractive in balance command for interactive
  session picking when multiple sessions exist
- Simplify formatOutput by removing dead json parameter
- Add chainDisplayName helper with reverse KNOWN_CHAINS lookup

Made-with: Cursor
@fan-zhang-sv fan-zhang-sv force-pushed the felix/cli-balance-command branch from e856f12 to e15c27a Compare March 25, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant