Skip to content

feat(swap): add --chain flag for explicit chain selection (Vibe Kanban)#7

Merged
MinaraAgent merged 2 commits intomainfrom
vk/b17e-fix-add-chain-fl
Apr 3, 2026
Merged

feat(swap): add --chain flag for explicit chain selection (Vibe Kanban)#7
MinaraAgent merged 2 commits intomainfrom
vk/b17e-fix-add-chain-fl

Conversation

@MinaraAgent
Copy link
Copy Markdown
Member

@MinaraAgent MinaraAgent commented Apr 3, 2026

Summary

  • Adds -c, --chain <chain> option to the swap command, allowing users to explicitly specify the blockchain
  • Updates chain resolution logic to prefer the explicit --chain flag before falling back to token-derived chain
  • Validates the --chain flag and warns the user if an unsupported chain is provided (instead of silently falling back)
  • The transfer and withdraw commands already had this flag, so this brings swap to parity

Why

Previously, the swap command had no way to specify the chain explicitly. The chain was always derived from the resolved token, which could fail or be ambiguous when token lookup returned incomplete information. This made it impossible to disambiguate tokens that exist on multiple chains.

Implementation Details

  • Added -c, --chain <chain> option to the swap command options
  • Chain resolution now checks opts.chain first, normalizes it, and uses it if valid
  • If user provides an invalid --chain value, we warn and exit instead of silently falling back
  • Falls back to deriving chain from tokenInfo.chain if no explicit flag provided
  • Shows a helpful error message if chain cannot be determined by either method
  • Properly typed chain variable as Chain | undefined to match normalizeChain return type

Example Usage

minara swap -s buy -t ETH -a 20 --chain ethereum
minara swap -s sell -t BONK -a 1000 --chain solana

This PR was written using Vibe Kanban

…--chain` option. I only need to add it to `swap.ts` and update the chain resolution logic there.
@MinaraAgent MinaraAgent changed the title Add --chain flag to swap, transfer, and withdraw commands in minara-cli. (vibe-kanban) feat(swap): add --chain flag for explicit chain selection (Vibe Kanban) Apr 3, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a --chain flag to the swap command, allowing users to explicitly specify the blockchain. The logic was updated to prioritize this flag over the chain derived from token information. Feedback indicates that the implementation is currently incomplete as it misses the same flag for transfer and withdraw commands mentioned in the PR description. Additionally, the chain resolution logic should be improved to validate user input and prevent silent fallbacks when an invalid chain is provided.

Comment thread src/commands/swap.ts
Comment thread src/commands/swap.ts Outdated
…ibe Kanban)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MinaraAgent MinaraAgent merged commit 51edbe2 into main Apr 3, 2026
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.

2 participants