fix: exclude target asset from Quick Buy pay-with list (TSA-660)#31455
fix: exclude target asset from Quick Buy pay-with list (TSA-660)#31455xavier-brochard wants to merge 1 commit into
Conversation
The Quick Buy bottom sheet (asset details page) listed the asset being bought among the "Pay with" options. Selecting it produced a source == destination pair for which no swap quote can ever be generated (TSA-660, #31414). - Extract the dest-matching predicate from selectDefaultSourceToken into an exported isSameAsset helper (chainId + case-insensitive address match, non-EVM symbol fallback for differing CAIP forms). - Filter the destination asset out of sourceTokenOptions in useQuickBuyController so it never appears in the pay-with picker. - Fall back to the best non-destination holding when the current selection resolves to the destination asset (e.g. after ERC-20 metadata normalises the dest address), instead of silently keeping an unquotable same-token pair. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
No E2E tests exist for this feature: Searching for No shared component impact: The changes don't touch TabBar, Navigation, Modals, confirmations, or any other shared infrastructure that could break existing E2E tests. No performance impact: These are hook/utility logic changes (filtering an array, adding a comparison function) with negligible performance implications. The changes are well-covered by the added unit tests. No E2E tags are needed as there are no E2E tests for this feature area, and the changes don't affect any shared components that other E2E tests depend on. Performance Test Selection: |
Description
The Quick Buy bottom sheet's "Pay with" picker listed every token the user holds — including the very asset being bought. Selecting it created a source == destination pair that can never produce quotes ("No quotes available",
1 ETH = 1 ETH). The destination-exclusion logic existed only in the default source-token preselection (selectDefaultSourceToken), not in the picker list itself.This PR:
isSameAsset(token, other)helper (app/components/Views/SocialLeaderboard/utils/tokenSelection.ts): chainId + case-insensitive address match, with a symbol fallback only for non-EVM (CAIP) chains to cover differing CAIP-19 forms. No symbol fallback on EVM to avoid fake-token symbol collisions.selectDefaultSourceTokennow delegates to it — behavior unchanged.useQuickBuyControlleragainst the destination asset, so the buy target never appears in the picker.Jira: TSA-660
Changelog
CHANGELOG entry: Fixed the Quick Buy "Pay with" list offering the same token being bought, which made quotes impossible
Related issues
Fixes: #31414
Manual testing steps
Screenshots/Recordings
Before
N/A
After
N/A
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist