Skip to content

feat: define swap QuoteResponse V2 schema validators - #9724

Merged
micaelae merged 9 commits into
mainfrom
swaps4546-v2-schema
Aug 3, 2026
Merged

feat: define swap QuoteResponse V2 schema validators#9724
micaelae merged 9 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

Implements https://consensyssoftware.atlassian.net/browse/SWAPS-4546

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
Touches core bridge quote/trade validation shapes that downstream clients will adopt; changes are mostly additive but incorrect v2 parsing could affect migration consumers.

Overview
Adds QuoteResponse v2 validation (validateQuoteResponse, QuoteSchemaV2) aligned with the swap/bridge quote metadata migration: quotes use src/dest amount + asset blocks (AmountsAndAsset + BridgeAssetV2), array-based feeData (including network / relayer), richer priceData, and StepSchemaV2. Trade/approval shapes are validated per CAIP namespace (EVM, Solana, Tron, Bitcoin, Stellar) derived from the source asset’s assetId.

Introduces BridgeAssetV2 / MinimalAsset (CAIP assetId, optional security metadata) and validateBridgeAssetV2, while keeping v1 BridgeAsset in bridge-asset.ts (deprecated) and re-exporting validators/types from the package entry. NumberStringSchema is renamed to PositiveNumberStringSchema where used (e.g. batch-sell fees, tx fee gas limits).

Runtime quote fetching in this package still uses v1 (validateQuoteResponseV1); v2 is exported for consumers/migration. Test fixtures/snapshots normalize EVM addresses to lowercase.

Reviewed by Cursor Bugbot for commit e8b7fa7. 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
Comment thread packages/bridge-controller/src/utils/caip-formatters.ts
Comment thread packages/bridge-controller/src/validators/bridge-asset.ts
Comment thread packages/bridge-controller/src/validators/quote.ts Outdated
@micaelae
micaelae added this pull request to the merge queue Aug 3, 2026
Merged via the queue into main with commit 11c420a Aug 3, 2026
50 checks passed
@micaelae
micaelae deleted the swaps4546-v2-schema branch August 3, 2026 22:44
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.

2 participants