Skip to content

CLI: lowercase --from/--to in swap now to match quote and pair#249

Open
eureka0928 wants to merge 1 commit intoentrius:testfrom
eureka0928:cli/swap-now-lowercase-chains
Open

CLI: lowercase --from/--to in swap now to match quote and pair#249
eureka0928 wants to merge 1 commit intoentrius:testfrom
eureka0928:cli/swap-now-lowercase-chains

Conversation

@eureka0928
Copy link
Copy Markdown
Contributor

Summary

alw swap now --from BTC --to TAO --amount 0.001 rejected with Unknown source chain: BTC even though BTC/TAO work fine in sister commands. SUPPORTED_CHAINS keys are lowercase (chains.py:40-43), and the membership check at swap.py:603-608 didn't lowercase first — swap now was the lone case-sensitive holdout:

Mirror that one-liner. Lowercasing also propagates into the downstream from_chain = from_chain_opt assignment at swap.py:650-651, so the rest of the function sees canonical lowercase IDs.

Side benefit

--from BTC --to btc previously slipped past the must be different guard because 'BTC' == 'btc' is False. Post-fix both sides lowercase first, so the equality check works correctly on mixed-case input too.

Before

$ alw swap now --from BTC --to TAO --amount 0.001
Unknown source chain: BTC

After

$ alw swap now --from BTC --to TAO --amount 0.001
# proceeds, identical to: alw swap now --from btc --to tao --amount 0.001

Test plan

  • pytest tests/test_swap_now_lowercase.py — 11 tests covering: uppercase/mixed-case BTC/TAO accepted; lowercase still works; one-sided invocations (--from BTC only); genuinely unsupported chains (ETH, XYZ) still rejected post-lowercase; --from BTC --to btc correctly hits the must-be-different guard; bare invocation no-ops on None
  • pytest tests/ — full suite green
  • ruff check + ruff format clean
  • Smoke: alw swap now --from BTC --to TAO reaches the interactive prompt path (was previously rejected)
  • Smoke: alw swap now --from ETH --to TAO still rejects with Unknown source chain: eth

Fixes #248.

`alw swap now --from BTC --to TAO` rejected with 'Unknown source
chain: BTC' because SUPPORTED_CHAINS keys are lowercase and swap_now
was the lone holdout that didn't lowercase before validating. Sister
commands (quote.py:40-41, pair.py:93,106) already lowercase. The fix
mirrors that one-liner and propagates lowercased values into the
downstream from_chain/to_chain assignment at swap.py:650-651.

Side benefit: --from BTC --to btc now correctly trips the
'must be different' guard (previously failed due to mixed-case ==).

Fixes entrius#248.
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.

CLI: alw swap now is case-sensitive on --from/--to chain IDs (inconsistent with quote and pair)

1 participant