chore: set up batch sell quotes#29831
Conversation
## 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 -->
31fe499 to
bf203f1
Compare
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
|
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. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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.
|
@metamaskbot update-mobile-fixture |
|
🔄 Fixture update started. Running workflow from branch |
|
❌ 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 |
|
@metamaskbot update-mobile-fixture |
|
🔄 Fixture update started. Running workflow from branch |
|
❌ 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 |
|
@metamaskbot update-mobile-fixture |
|
@metamaskbot update-mobile-fixture |
|
🔄 Fixture update started. Running workflow from branch |
|
❌ 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 |
|
@metamaskbot update-mobile-fixture |
|
🔄 Fixture update started. Running workflow from branch |
|
❌ 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 |
🔍 Smart E2E Test Selection⏭️ Smart E2E selection skipped - skip-smart-e2e-selection label found All E2E tests pre-selected. |
|




Description
Bumps the bridge-controller to 72.0.0, in which the state.quoteRequest's type has changed from
QuoteRequestto an array of QuoteRequests. This PR doesn't use BatchSell quotes yet but updates existing tests and implements theselectBatchSellQuotesselector.Changelog
CHANGELOG entry: chore: set up batch sell quotes
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-4443v
Manual testing steps
Screenshots/Recordings
Before
After
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
Note
Medium Risk
Moderate risk because it updates the BridgeController state shape (
quoteRequestnow 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(andbridge-status-controller@^71.1.1), adapting to the controller state change whereBridgeController.quoteRequestis 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 updatesuseBridgeQuoteRequest/tests to callupdateBridgeQuoteRequestParamswith 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.