feat: add quote metadata migration phases 1.5 and 2 - #9744
Conversation
363f891 to
8257447
Compare
cb46f5f to
3885f72
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 3885f72. Configure here.
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Pull request was converted to draft
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |

Explanation
This PR enables clients to consume bridge-api's nested usd and fiat fields by specifying one of these migration phases:
QuoteMetadataMigrationPhase.V1Data(1): strip API V2 fee currency metadata; serve legacycalcQuoteMetadatain the V2 nested shapeQuoteMetadataMigrationPhase.V2WithV1Fallback(1.5): prefer API V2 metadata, convertusdamounts to fiat, fall back to legacy when the API field is not available. Top-level V1 metadata stays on the quote for client testingQuoteMetadataMigrationPhase.V2Only(2): API V2 metadata only; no legacy calcsubmitTx,submitIntent, andsubmitBatchSellalso accept the migrationPhase parameter. It is passed totoQuoteMetadataV1when converting V2 quotesTo integrate this change in the clients:
Draft client PRs
References
Related to https://consensyssoftware.atlassian.net/browse/SWAPS-4547
Checklist
Note
High Risk
Breaking API for all clients of
selectBridgeQuotesand submit flows; wrong phase can change displayed fees, fiat amounts, and pre-confirmation metrics until extension/mobile adopt the flag.Overview
Breaking:
selectBridgeQuotes(and related client params) now requiremigrationPhase, exported asQuoteMetadataMigrationPhase(V1Data,V2WithV1Fallback,V2Only). That flag controls whether quotes use legacycalcQuoteMetadata, API V2 nested fields with legacy fallback, or V2-only output (no legacy calc/flattened fields).Quote assembly is split by phase: legacy metadata calculation is skipped in V2Only;
toCurrencyValuesfills fiat from backendusdwhen phase is not V1Data;mergeQuoteMetadatais V2-only, takesmigrationPhaseplus optional currency overlays, and drops the old V1 merge path.toQuoteMetadataV1can rebuild legacy-shaped metadata from nested V2 data for submission/metrics.bridge-status-controller threads
migrationPhasethroughsubmitTx/submitIntent/submitBatchSelland builds V1 submission payloads viatoQuoteMetadataV1instead ofmergeQuoteMetadata. Tests and changelogs document the breaking API.Reviewed by Cursor Bugbot for commit 24fd854. Bugbot is set up for automated code reviews on this repo. Configure here.