Add balance command and improve CLI consistency#262
Open
fan-zhang-sv wants to merge 1 commit intofelix/cli-interactive-session-pickerfrom
Open
Add balance command and improve CLI consistency#262fan-zhang-sv wants to merge 1 commit intofelix/cli-interactive-session-pickerfrom
fan-zhang-sv wants to merge 1 commit intofelix/cli-interactive-session-pickerfrom
Conversation
abcfdaf to
48dacea
Compare
c758036 to
e856f12
Compare
8e8fb86 to
b721a2d
Compare
- 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
e856f12 to
e15c27a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
balancecommand that fetches native and ERC-20 token balances via viem, with contract address validation (isAddress), cached chain lookup, and both JSON and human-readable outputKNOWN_CHAINSaliases (e.g.base,base-sepolia) instead of raw CAIP-2 identifiers (eip155:8453) across all commands via a newchainDisplayNamehelpercore/sessionandutils/promptby movingresolveSessionInteractivetoutils/promptresolveSessionInteractivein the balance command so users with multiple sessions get the interactive picker instead of a hard errorformatOutputby removing the deadjsonparameter (both branches were identical)Test plan
npx vitest run)core/balance/index.test.tscovers: ERC-20 balance, native balance, zero balances, unsupported chain error, and RPC error propagation (7 tests)chainDisplayNameunit tests incaip.test.tscover known aliases and fallbackchain: "base"/chain: "base-sepolia"instead ofchain_id: "eip155:..."formatOutputunit tests updated for simplified signatureMade with Cursor