Skip to content

feat: bridgeController consume complete event#8306

Draft
infiniteflower wants to merge 12 commits intomainfrom
swaps-4224-complete-event
Draft

feat: bridgeController consume complete event#8306
infiniteflower wants to merge 12 commits intomainfrom
swaps-4224-complete-event

Conversation

@infiniteflower
Copy link
Copy Markdown
Contributor

@infiniteflower infiniteflower commented Mar 25, 2026

Explanation

The bridge quote stream API emits a complete SSE event just before closing the stream. Previously this event was silently ignored by the client. This PR adds support for consuming it.

The complete event carries metadata about the stream result — how many quotes were sent, whether any quotes were available, an optional reason code (e.g. AMOUNT_TOO_LOW, TOKEN_NOT_SUPPORTED), and optional context. This information is useful for the UI to distinguish between "no quotes because the stream hasn't finished yet" vs "no quotes because the API determined there are none for this request".

Changes:

  • Added QuoteStreamCompleteReason enum and QuoteStreamCompleteSchema / validateQuoteStreamComplete to validators.ts, following the same pattern as TokenFeatureType / validateTokenFeature.
  • Added QuoteStreamCompleteData type (inferred from the schema) to types.ts.
  • Added quoteStreamComplete: QuoteStreamCompleteData | null to BridgeControllerState, defaulting to null.
  • quoteStreamComplete is cleared at the start of each fetch and in resetState, matching the behaviour of tokenWarnings.
  • Added onComplete to the serverEventHandlers object in fetchBridgeQuoteStream, dispatched via a new case 'complete': branch in onMessage.
  • The complete event does not set quotesLoadingStatus to FETCHED — that remains owned by onClose, which must first await any in-flight appendFeesToQuotes promises (L1 gas fee or snap fee calculations that may still be running when the stream closes).
  • Exported QuoteStreamCompleteData, QuoteStreamCompleteReason, and validateQuoteStreamComplete from the package's public index.ts.

References

https://consensyssoftware.atlassian.net/browse/SWAPS-4224

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

@infiniteflower infiniteflower changed the title Swaps 4224 complete event feat: bridgeController consume complete event Mar 25, 2026
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