chore: add OHLCVService for real-time candlestick WebSocket streaming#8695
Draft
sahar-fehri wants to merge 14 commits intomainfrom
Draft
chore: add OHLCVService for real-time candlestick WebSocket streaming#8695sahar-fehri wants to merge 14 commits intomainfrom
sahar-fehri wants to merge 14 commits intomainfrom
Conversation
2d69c0f to
bd0d4d2
Compare
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
10 tasks
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
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
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