Skip to content

fix(predict): use correct payload for dynamic market subscriptions cp-8.3.0#33289

Merged
matallui merged 1 commit into
mainfrom
predict/PRED-1092-fix-web-socket-payload-for-dynamic-token-subscriptions
Jul 15, 2026
Merged

fix(predict): use correct payload for dynamic market subscriptions cp-8.3.0#33289
matallui merged 1 commit into
mainfrom
predict/PRED-1092-fix-web-socket-payload-for-dynamic-token-subscriptions

Conversation

@caieu

@caieu caieu commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes live price updates for market tokens added after the Polymarket WebSocket connection is already open.

Initial and reconnect subscriptions continue using the market connection payload, while dynamic token additions now use Polymarket's subscribe operation. Previously, dynamically added tokens were sent using the initial connection payload and were not subscribed, preventing components such as moneyline cards and charts from receiving updates.

Regression tests cover dynamic price and orderbook subscriptions while preserving initial and reconnect behavior.

Changelog

CHANGELOG entry: Fixed live prediction market prices not updating for dynamically subscribed markets

Related issues

Refs: https://consensyssoftware.atlassian.net/browse/PRED-1092

Manual testing steps

Feature: Live prediction market prices

  Scenario: Receive updates for tokens added to an open WebSocket connection
    Given a prediction game details page is open
    And the market WebSocket connection is already active

    When moneyline tokens are added to the connection
    Then the moneyline card displays live price updates
    And the moneyline chart displays live price updates

Automated verification:

npx jest app/components/UI/Predict/providers/polymarket/WebSocketManager.test.ts --coverage=false

Screenshots/Recordings

N/A — this change fixes the WebSocket subscription payload and has no visual changes.

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
Targeted WebSocket subscription payload fix in Predict Polymarket provider with tests; initial/reconnect behavior unchanged.

Overview
Fixes live prediction market prices when tokens are subscribed after the Polymarket market WebSocket is already open (e.g. moneyline cards/charts on game details).

WebSocketManager now sends { type: 'market', assets_ids } only for the first connection and reconnect resubscribe, and { operation: 'subscribe', assets_ids } when price or orderbook subscriptions are added on an open socket. Previously, dynamic adds reused the initial payload and Polymarket did not subscribe those assets.

Regression tests assert the subscribe payload for late-added market prices and orderbooks.

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

@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamask-ci metamask-ci Bot added the team-predict Predict team label Jul 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePredictions, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR modifies WebSocketManager.ts in the Polymarket Predictions provider. The change refactors the market subscription logic by:

  1. Renaming sendMarketSubscribesendInitialMarketSubscription (used when WebSocket first opens)
  2. Adding a new sendMarketSubscriptionUpdate method for dynamically subscribing to tokens on an already-open connection
  3. Updating ensureMarketConnection to use the new dynamic update method when the connection is already OPEN

This is a functional change to how Polymarket WebSocket subscriptions work — specifically fixing/improving the behavior when subscribing to additional tokens after a connection is already established. This directly impacts the Predictions feature's ability to receive real-time market data.

SmokePredictions is selected as the primary tag since this is core Polymarket functionality. Per the tag description, SmokePredictions requires also selecting SmokeWalletPlatform (Predictions is a section inside Trending tab) and SmokeConfirmations (opening/closing positions are on-chain transactions).

No other areas are affected — this is isolated to the Polymarket WebSocket provider.

Performance Test Selection:
The changes are limited to WebSocket subscription logic refactoring in the Polymarket provider. No performance-sensitive paths are affected — no rendering changes, no balance fetching, no app launch paths, no account list changes. The @PerformancePredict tag covers prediction market list loading and deposit flows, but this WebSocket subscription change is an internal implementation detail that doesn't affect the measured performance scenarios.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@caieu caieu marked this pull request as ready for review July 14, 2026 21:29
@caieu caieu requested a review from a team as a code owner July 14, 2026 21:29
@github-actions github-actions Bot added the risk:medium AI analysis: medium risk label Jul 14, 2026
@matallui matallui changed the title fix(predict): use correct payload for dynamic market subscriptions fix(predict): use correct payload for dynamic market subscriptions cp-8.3.0 Jul 15, 2026
@matallui matallui enabled auto-merge July 15, 2026 10:10
@matallui matallui added this pull request to the merge queue Jul 15, 2026
@matallui matallui self-requested a review July 15, 2026 10:28
Merged via the queue into main with commit 887370f Jul 15, 2026
323 of 326 checks passed
@matallui matallui deleted the predict/PRED-1092-fix-web-socket-payload-for-dynamic-token-subscriptions branch July 15, 2026 10:33
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 15, 2026
@metamask-ci metamask-ci Bot added the release-8.4.0 Issue or pull request that will be included in release 8.4.0 label Jul 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.4.0 Issue or pull request that will be included in release 8.4.0 risk:medium AI analysis: medium risk size-S team-predict Predict team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants