feat: bridgeController consume complete event#8306
Draft
infiniteflower wants to merge 12 commits intomainfrom
Draft
feat: bridgeController consume complete event#8306infiniteflower wants to merge 12 commits intomainfrom
infiniteflower wants to merge 12 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
The bridge quote stream API emits a
completeSSE event just before closing the stream. Previously this event was silently ignored by the client. This PR adds support for consuming it.The
completeevent 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:
QuoteStreamCompleteReasonenum andQuoteStreamCompleteSchema/validateQuoteStreamCompletetovalidators.ts, following the same pattern asTokenFeatureType/validateTokenFeature.QuoteStreamCompleteDatatype (inferred from the schema) totypes.ts.quoteStreamComplete: QuoteStreamCompleteData | nulltoBridgeControllerState, defaulting tonull.quoteStreamCompleteis cleared at the start of each fetch and inresetState, matching the behaviour oftokenWarnings.onCompleteto theserverEventHandlersobject infetchBridgeQuoteStream, dispatched via a newcase 'complete':branch inonMessage.completeevent does not setquotesLoadingStatustoFETCHED— that remains owned byonClose, which must first await any in-flightappendFeesToQuotespromises (L1 gas fee or snap fee calculations that may still be running when the stream closes).QuoteStreamCompleteData,QuoteStreamCompleteReason, andvalidateQuoteStreamCompletefrom the package's publicindex.ts.References
https://consensyssoftware.atlassian.net/browse/SWAPS-4224
Checklist