Skip to content

chore: set up batch sell quotes#29831

Merged
micaelae merged 20 commits into
mainfrom
swaps4443-batch-quotes
May 15, 2026
Merged

chore: set up batch sell quotes#29831
micaelae merged 20 commits into
mainfrom
swaps4443-batch-quotes

Conversation

@micaelae
Copy link
Copy Markdown
Member

@micaelae micaelae commented May 6, 2026

Description

Bumps the bridge-controller to 72.0.0, in which the state.quoteRequest's type has changed from QuoteRequest to an array of QuoteRequests. This PR doesn't use BatchSell quotes yet but updates existing tests and implements the selectBatchSellQuotes selector.

Changelog

CHANGELOG entry: chore: set up batch sell quotes

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-4443v

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

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.

Note

Medium Risk
Moderate risk because it updates the BridgeController state shape (quoteRequest now an array) and adjusts multiple selectors/hooks/tests and dependency versions; incorrect indexing could break quote fetching/enrichment paths.

Overview
Updates the app to @metamask/bridge-controller@^72.0.0 (and bridge-status-controller@^71.1.1), adapting to the controller state change where BridgeController.quoteRequest is now an array.

Migrates bridge-related code and fixtures to use quoteRequest[0] (e.g., selectQuoteRequest, QuickBuy quote metadata injection, initial background state, component-view fixtures, and mocks) and updates useBridgeQuoteRequest/tests to call updateBridgeQuoteRequestParams with explicit request index/range arguments.

Adjusts swap deeplink smoke tests to additionally mock popular token endpoints for more stable unified swap/bridge deep link coverage.

Reviewed by Cursor Bugbot for commit 9032cc9. Bugbot is set up for automated code reviews on this repo. Configure here.

@metamaskbotv2 metamaskbotv2 Bot added the team-swaps-and-bridge Swaps and Bridge team label May 6, 2026
@github-actions github-actions Bot added the size-S label May 6, 2026
pull Bot pushed a commit to dmrazzy/core that referenced this pull request May 7, 2026
## Explanation

This PR implements quote polling for batched swap requests

#### Changes
- `updateBridgeQuoteRequest` now takes 2 extra params: the quote
request’s index and the total quoteRequestCount within the batch. no
changes in how we are using this handler for regular swaps
- the new `selectBatchSellQuotes` selector returns the recommended quote
for each quoteRequest, and aggregated amounts for display purposes
- `isValidBatchSellQuoteRequest`


#### Usage
- the clients will need to maintain a list of requests, each one
identified by an index. the index identifies the quoteRequest and its
related side effects (quotes, metrics, submission etc) once it’s passed
to updateBridgeQuoteRequest
- to access quotes for a single quoteRequest, use the same index used
during quoteRequest update


#### Minimal client examples
- extension: MetaMask/metamask-extension#42434.
Checkout this branch and resolve the package locally to test
- mobile: MetaMask/metamask-mobile#29831

<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->

## References

<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?

For example:

* Fixes #12345
* Related to #67890
-->
Fixes https://consensyssoftware.atlassian.net/browse/SWAPS-4443

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> This is a breaking API/state-shape change (`quoteRequest` becomes an
array) that touches quote polling/streaming, analytics properties, and
exchange-rate lookup logic; regressions could affect quote fetching and
refresh behavior across swaps/bridges.
> 
> **Overview**
> **Adds BatchSell (batched swap) quote support** by changing
`quoteRequest` state and polling inputs from a single request to an
array, allowing callers to update a specific request via new
`updateBridgeQuoteRequestParams(…, quoteRequestIndex,
quoteRequestCount)` parameters.
> 
> Quote fetching/streaming is updated to accept multiple requests: SSE
uses a new `POST /getBatchQuoteStream` path when batching, tags incoming
quotes with `quoteRequestIndex`, traces via new Sentry trace name `Batch
Sell Quotes Fetched`, and adjusts polling stop/refresh logic to continue
as long as *any* request is sufficiently funded.
> 
> Selectors and rate lookup are extended for batching: adds
`selectBatchSellQuotes` (per-request recommended quotes plus aggregated
received/fee totals), switches exchange-rate selection to
`selectExchangeRateByAssetId`, and exports
`isValidBatchSellQuoteRequest`; tests/snapshots are updated and a new
SSE batch test is added.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
9e2a7fa. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@micaelae micaelae force-pushed the swaps4443-batch-quotes branch from 31fe499 to bf203f1 Compare May 7, 2026 17:58
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 7, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.82%. Comparing base (3751d9a) to head (faf968c).
⚠️ Report is 164 commits behind head on main.

Files with missing lines Patch % Lines
app/components/UI/Bridge/testUtils/index.ts 75.00% 0 Missing and 1 partial ⚠️
...omponents/QuickBuyBottomSheet/useQuickBuyQuotes.ts 0.00% 1 Missing ⚠️
app/selectors/bridgeController/index.ts 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (3751d9a) and HEAD (faf968c). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (3751d9a) HEAD (faf968c)
2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #29831       +/-   ##
===========================================
- Coverage   81.54%   61.82%   -19.73%     
===========================================
  Files        5343     5391       +48     
  Lines      142128   143699     +1571     
  Branches    32411    32820      +409     
===========================================
- Hits       115899    88837    -27062     
- Misses      18299    47805    +29506     
+ Partials     7930     7057      -873     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@micaelae micaelae changed the title chore: update quoteRequest usages feat: integrate batch-compatible bridge-controller state May 8, 2026
@micaelae micaelae changed the title feat: integrate batch-compatible bridge-controller state feat: integrate batch sell quotes May 8, 2026
@micaelae micaelae marked this pull request as ready for review May 8, 2026 18:24
@micaelae micaelae requested review from a team as code owners May 8, 2026 18:24
@github-actions github-actions Bot added size-M and removed size-S labels May 8, 2026
Comment thread app/core/redux/slices/bridge/index.ts Outdated
@micaelae micaelae changed the title feat: integrate batch sell quotes chore: set up batch sell quotes May 8, 2026
@micaelae micaelae enabled auto-merge May 8, 2026 18:39
Comment thread app/components/UI/Bridge/testUtils/index.ts Outdated
Comment thread app/components/UI/Bridge/testUtils/index.ts
@micaelae micaelae requested review from a team as code owners May 12, 2026 14:32
@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.

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d060170. Configure here.

Comment thread app/components/UI/Money/utils/moneyAccountTransactions.test.ts
Comment thread app/components/UI/Money/hooks/useMoneyAccount.ts
@micaelae
Copy link
Copy Markdown
Member Author

@metamaskbot update-mobile-fixture

@github-actions
Copy link
Copy Markdown
Contributor

🔄 Fixture update started. Running workflow from branch swaps4443-batch-quotes. View workflow runs

@github-actions
Copy link
Copy Markdown
Contributor

E2E fixture update failed.\n\nCommon causes:\n- CI workflow is still running — wait for 'Build iOS Apps' to complete\n- CI workflow was skipped — ensure your PR has iOS-impacting changes or use skip-smart-e2e-selection label\n- iOS build failed — check the CI workflow for errors\n\nView logs and retry

@micaelae
Copy link
Copy Markdown
Member Author

@metamaskbot update-mobile-fixture

@github-actions
Copy link
Copy Markdown
Contributor

🔄 Fixture update started. Running workflow from branch swaps4443-batch-quotes. View workflow runs

@github-actions
Copy link
Copy Markdown
Contributor

E2E fixture update failed.\n\nCommon causes:\n- CI workflow is still running — wait for 'Build iOS Apps' to complete\n- CI workflow was skipped — ensure your PR has iOS-impacting changes or use skip-smart-e2e-selection label\n- iOS build failed — check the CI workflow for errors\n\nView logs and retry

@micaelae micaelae added the skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run label May 14, 2026
@micaelae
Copy link
Copy Markdown
Member Author

@metamaskbot update-mobile-fixture

@micaelae
Copy link
Copy Markdown
Member Author

@metamaskbot update-mobile-fixture

@github-actions
Copy link
Copy Markdown
Contributor

🔄 Fixture update started. Running workflow from branch swaps4443-batch-quotes. View workflow runs

@github-actions
Copy link
Copy Markdown
Contributor

E2E fixture update failed.\n\nCommon causes:\n- CI workflow is still running — wait for 'Build iOS Apps' to complete\n- CI workflow was skipped — ensure your PR has iOS-impacting changes or use skip-smart-e2e-selection label\n- iOS build failed — check the CI workflow for errors\n\nView logs and retry

@micaelae
Copy link
Copy Markdown
Member Author

@metamaskbot update-mobile-fixture

@github-actions
Copy link
Copy Markdown
Contributor

🔄 Fixture update started. Running workflow from branch swaps4443-batch-quotes. View workflow runs

@github-actions
Copy link
Copy Markdown
Contributor

E2E fixture update failed.\n\nCommon causes:\n- CI workflow is still running — wait for 'Build iOS Apps' to complete\n- CI workflow was skipped — ensure your PR has iOS-impacting changes or use skip-smart-e2e-selection label\n- iOS build failed — check the CI workflow for errors\n\nView logs and retry

infiniteflower
infiniteflower previously approved these changes May 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - skip-smart-e2e-selection label found

All E2E tests pre-selected.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@micaelae micaelae added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit 5bfd071 May 15, 2026
207 of 209 checks passed
@micaelae micaelae deleted the swaps4443-batch-quotes branch May 15, 2026 20:20
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.79.0 Issue or pull request that will be included in release 7.79.0 size-M skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants