Skip to content

feat: define swap QuoteResponse V2 schema validators - #9724

Open
micaelae wants to merge 4 commits into
mainfrom
swaps4546-v2-schema
Open

feat: define swap QuoteResponse V2 schema validators#9724
micaelae wants to merge 4 commits into
mainfrom
swaps4546-v2-schema

Conversation

@micaelae

@micaelae micaelae commented Jul 31, 2026

Copy link
Copy Markdown
Member

Explanation

Implements schema definitions and validators based on this ADR: https://github.com/MetaMask/decisions/blob/main/decisions/trading/0057-swap-bridge-quote-metadata-migration.md

References

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
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Introduces new quote/asset validation contracts for swap-bridge migration without switching the live fetch path yet; export relocation of BridgeAsset may affect consumers that imported it from types.

Overview
Adds superstruct schemas and validateQuoteResponse for the ADR-aligned QuoteResponse V2 shape, alongside existing V1 (validateQuoteResponseV1 / QuoteResponseV1 exports are unchanged for controller state and fetch).

V2 quotes use AmountsAndAsset for src/dest and fee line items, QuoteSchemaV2 (nested priceData, array-based feeData, required protocols), and StepSchemaV2. BridgeAssetV2 / MinimalAsset add CAIP-centric assets with optional security metadata; legacy BridgeAsset moves to validators/bridge-asset.js and is marked deprecated.

Package exports now include validateQuoteResponse, validateBridgeAssetV2, and related schemas/types. Internal imports were updated to pull BridgeAsset from the validator module. Test fixtures use lowercase EVM addresses; Stellar CAIP formatting no longer special-cases testnet in formatChainIdToCaip.

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

@micaelae micaelae changed the title Swaps4546 v2 schema feat: define swap QuoteResponse V2 schema validators Jul 31, 2026
@micaelae
micaelae marked this pull request as ready for review July 31, 2026 04:36
@micaelae
micaelae requested review from a team as code owners July 31, 2026 04:36
@micaelae
micaelae enabled auto-merge July 31, 2026 04:36
@micaelae
micaelae temporarily deployed to default-branch July 31, 2026 04:36 — with GitHub Actions Inactive

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 1 potential issue.

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 e9fc1d7. Configure here.

Comment thread packages/bridge-controller/src/validators/quote-response.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant