CLI: lowercase --from/--to in swap now to match quote and pair#249
Open
eureka0928 wants to merge 1 commit intoentrius:testfrom
Open
CLI: lowercase --from/--to in swap now to match quote and pair#249eureka0928 wants to merge 1 commit intoentrius:testfrom
eureka0928 wants to merge 1 commit intoentrius:testfrom
Conversation
`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.
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
alw swap now --from BTC --to TAO --amount 0.001rejected withUnknown source chain: BTCeven thoughBTC/TAOwork fine in sister commands.SUPPORTED_CHAINSkeys are lowercase (chains.py:40-43), and the membership check at swap.py:603-608 didn't lowercase first —swap nowwas the lone case-sensitive holdout:from_chain = from_chain.lower()src_chain = src_chain.lower()Mirror that one-liner. Lowercasing also propagates into the downstream
from_chain = from_chain_optassignment at swap.py:650-651, so the rest of the function sees canonical lowercase IDs.Side benefit
--from BTC --to btcpreviously slipped past themust be differentguard because'BTC' == 'btc'is False. Post-fix both sides lowercase first, so the equality check works correctly on mixed-case input too.Before
After
Test plan
pytest tests/test_swap_now_lowercase.py— 11 tests covering: uppercase/mixed-caseBTC/TAOaccepted; lowercase still works; one-sided invocations (--from BTConly); genuinely unsupported chains (ETH,XYZ) still rejected post-lowercase;--from BTC --to btccorrectly hits the must-be-different guard; bare invocation no-ops onNonepytest tests/— full suite greenruff check+ruff formatcleanalw swap now --from BTC --to TAOreaches the interactive prompt path (was previously rejected)alw swap now --from ETH --to TAOstill rejects withUnknown source chain: ethFixes #248.