Skip to content

feat: Bridge quotestream token warning events#8198

Merged
infiniteflower merged 19 commits intomainfrom
bridge-quotestream-token-warning-events
Mar 20, 2026
Merged

feat: Bridge quotestream token warning events#8198
infiniteflower merged 19 commits intomainfrom
bridge-quotestream-token-warning-events

Conversation

@infiniteflower
Copy link
Contributor

@infiniteflower infiniteflower commented Mar 12, 2026

Explanation

The bridge-api SSE quote stream (getQuoteStream) now emits token_warning events alongside quote events. These warnings come from Blockaid security scanning of the destination token and contain information like whether a token is a honeypot or has unstable pricing.

Previously, fetchBridgeQuoteStream ignored the SSE event: name and attempted to validate every message as a quote response. This meant token_warning events were silently dropped (or caused spurious validation failures).

This PR:

  • Adds event routing in fetchBridgeQuoteStream — only quote events go through quote validation, token_warning events are validated separately via a new superstruct schema and routed to a dedicated handler, and all other event types are skipped.
  • Adds a tokenWarnings: TokenFeature[] field to BridgeControllerState, populated from the SSE stream and cleared on reset / new quote fetch.
  • Renames onValidationFailure to onQuoteValidationFailure and #trackResponseValidationFailures to #trackQuoteValidationFailures for clarity now that there are multiple event types.
  • Exports TokenFeature type and TokenFeatureType enum for use by clients.
Screenshot 2026-03-18 at 5 03 24 PM

References

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

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
Medium risk: changes SSE stream message routing and BridgeController state shape, which could affect quote streaming behavior and downstream consumers expecting previous handler names/state fields.

Overview
Adds support for token_warning events in the bridge-api quote SSE stream by routing SSE messages by event type, validating warnings with a new TokenFeature schema, and exposing them via a new tokenWarnings field on BridgeControllerState (reset on new requests and resetState, and de-duplicated by feature_id).

Renames the stream callback onValidationFailure to onQuoteValidationFailure (and corresponding internal tracker) to clarify metrics for quote-validation failures, and exports TokenFeature/TokenFeatureType plus a new selectTokenWarnings selector. Tests/snapshots are updated and extended with SSE warning stream fixtures and dedup/reset coverage.

Written by Cursor Bugbot for commit 37d8983. This will update automatically on new commits. Configure here.

@infiniteflower infiniteflower changed the title Bridge quotestream token warning events feat: Bridge quotestream token warning events Mar 12, 2026
@infiniteflower infiniteflower force-pushed the bridge-quotestream-token-warning-events branch from 881e93d to 6d8a822 Compare March 18, 2026 21:06
@infiniteflower infiniteflower marked this pull request as ready for review March 18, 2026 21:07
@infiniteflower infiniteflower requested review from a team as code owners March 18, 2026 21:07
Copy link

@cursor cursor bot left a comment

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.

GeorgeGkas
GeorgeGkas previously approved these changes Mar 20, 2026
micaelae
micaelae previously approved these changes Mar 20, 2026
@infiniteflower infiniteflower added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit 7ce6ffb Mar 20, 2026
326 checks passed
@infiniteflower infiniteflower deleted the bridge-quotestream-token-warning-events branch March 20, 2026 19:35
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.

3 participants