Skip to content

fix: exclude target asset from Quick Buy pay-with list (TSA-660)#31455

Draft
xavier-brochard wants to merge 1 commit into
mainfrom
fix/tsa-660-pay-with-excludes-target-asset
Draft

fix: exclude target asset from Quick Buy pay-with list (TSA-660)#31455
xavier-brochard wants to merge 1 commit into
mainfrom
fix/tsa-660-pay-with-excludes-target-asset

Conversation

@xavier-brochard

@xavier-brochard xavier-brochard commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

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:

  • Extracts the destination-matching predicate into an exported 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. selectDefaultSourceToken now delegates to it — behavior unchanged.
  • Filters the "Pay with" options in useQuickBuyController against the destination asset, so the buy target never appears in the picker.
  • Adds a fallback effect: if the currently-selected pay token resolves to the destination asset (e.g. selection made before ERC-20 metadata normalized the destination address), it re-selects the best non-destination holding, or clears the selection — never silently keeps an unquotable pair.

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

Feature: Quick Buy pay-with token list

  Scenario: user opens the pay-with picker for a token they hold
    Given the user holds USDC on Base
    And the user opens Quick Buy for USDC on Base from the token details page

    When the user opens the "Pay with" token picker
    Then USDC on Base is not listed as a payment option
    And other held tokens (e.g. ETH on Base) are listed

  Scenario: user holds only the asset being bought
    Given the user holds only USDC on Base
    And the user opens Quick Buy for USDC on Base

    When the "Pay with" selection resolves
    Then no payment token is auto-selected
    And the buy button stays disabled

Screenshots/Recordings

Before

N/A

After

N/A

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

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>
@xavier-brochard xavier-brochard self-assigned this Jun 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

@mm-token-exchange-service mm-token-exchange-service Bot added the team-social-ai Social & AI team label Jun 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are confined to the SocialLeaderboard/TraderPositionView/QuickBuy feature area:

  1. tokenSelection.ts: Adds a new isSameAsset() utility function and refactors selectDefaultSourceToken to use it. This utility is only imported within the SocialLeaderboard module (confirmed via grep - no other files import from this path).

  2. useQuickBuyController.ts: Bug fix (TSA-660) that filters the destination token from "Pay with" source options and adds a fallback effect when a selected source token resolves to be the same as the destination. This is a hook internal to the QuickBuy component.

  3. useQuickBuyController.test.ts: Unit tests for the new behavior.

No E2E tests exist for this feature: Searching for QuickBuy, SocialLeaderboard, TraderPosition, and useQuickBuyController in .spec.ts and .e2e.* files returned no results. The SocialLeaderboard feature doesn't have dedicated E2E test coverage.

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:
The changes are minor utility/hook logic changes (array filtering, token comparison function) within the SocialLeaderboard QuickBuy feature. There is no UI rendering change, no list rendering change, no state management change affecting performance-sensitive paths, and no impact on app startup, login, or critical user flows measured by performance tests.

View GitHub Actions results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-M team-social-ai Social & AI team

Projects

Status: Needs dev review

Development

Successfully merging this pull request may close these issues.

[Bug]: Quick Buy bottom sheet - "Pay with" list includes the same asset being bought, resulting in no quotes

1 participant