chore: add OHLCVService for real-time candlestick WebSocket streaming#8695
chore: add OHLCVService for real-time candlestick WebSocket streaming#8695sahar-fehri wants to merge 18 commits into
Conversation
2d69c0f to
bd0d4d2
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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 094d56f. Configure here.

Explanation
What
OHLCVServicefor real-time OHLCV (candlestick) data streaming via the backend WebSocket gatewayBackendWebSocketService,AccountActivityService) into a newsrc/ws/directory per code review feedbackWhy
ws/folder for better discoverabilityNew files
src/ws/ohlcv/OHLCVService.ts— main service with subscribe/unsubscribe semantics, reference counting, grace-period unsubscribe, idempotency checks, chain-status forwarding, and automatic resubscription on reconnectsrc/ws/ohlcv/OHLCVService.test.ts— 22 unit tests covering all paths (100% branch coverage)src/ws/ohlcv/OHLCVService-method-action-types.ts— auto-generated messenger action typessrc/ws/ohlcv/types.ts—OHLCVBarandOHLCVSubscriptionOptionstypessrc/ws/ohlcv/index.ts— barrel exportsModified files
src/index.ts— added exports forOHLCVService, its types, and allowed actions/events; updated import paths to./ws/eslint-suppressions.json— updated paths for moved files, added suppressions for new test fileCHANGELOG.md— documented new service and exportsMoved files (no logic changes)
src/BackendWebSocketService.ts→src/ws/BackendWebSocketService.tssrc/BackendWebSocketService.test.ts→src/ws/BackendWebSocketService.test.tssrc/BackendWebSocketService-method-action-types.ts→src/ws/BackendWebSocketService-method-action-types.tssrc/AccountActivityService.ts→src/ws/AccountActivityService.tssrc/AccountActivityService.test.ts→src/ws/AccountActivityService.test.tssrc/AccountActivityService-method-action-types.ts→src/ws/AccountActivityService-method-action-types.ts./logger→../logger,./types→../types, test helper paths)Key design decisions
AccountActivityService(auto-subscribes on account change),OHLCVServiceexposessubscribe()/unsubscribe()called by the UI when the chart mounts/unmountschannelHasSubscriptionbefore subscribing; duplicate calls are no-ops (React Strict Mode safe)system-notifications.v1.market-data.v1(auto-subscribed by server) and publishesOHLCVService:chainStatusChangedchainStatusChanged { status: 'down' }for all tracked chains, triggering UI polling fallbacksessionIdneeded for OHLCV; UI polling fallback covers the gap)init()method — system notification callback registered ininit()(not constructor) to comply with messenger-in-constructor lint ruleEvents published
OHLCVService:barUpdated—{ channel, bar: OHLCVBar }— new candle data from WebSocketOHLCVService:chainStatusChanged—{ chainIds, status, timestamp? }— chain up/down (server notification or WS disconnect)OHLCVService:subscriptionError—{ channel, error, operation }— subscribe or unsubscribe failureReferences
Checklist
Note
Medium Risk
Adds a new WebSocket-facing service with subscription lifecycle/ref-counting logic and reconnect handling, which could impact real-time data delivery if edge cases exist. Also moves existing WebSocket services into
src/ws/, so any missed import/path updates would be a build/runtime risk.Overview
Adds
OHLCVServiceto stream real-time OHLCV (candlestick) market data over the existing backend WebSocket messenger API, includingsubscribe/unsubscribe, ref-counted shared subscriptions, grace-period unsubscription, reconnect resubscription, and forwarding of chain up/down system notifications via new service events.Reorganizes WebSocket code by moving
BackendWebSocketServiceandAccountActivityService(and tests) undersrc/ws/and updating exports/import paths accordingly, plus updatingeslint-suppressions.jsonand thecore-backendchangelog to reflect the new service and exports.Reviewed by Cursor Bugbot for commit 9676545. Bugbot is set up for automated code reviews on this repo. Configure here.