@metamask-previews/core-backend 6.2.2-preview-094d56fb3 → 6.2.2-preview-7fbc8b83e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +0 -8
  2. package/dist/AccountActivityService-method-action-types.cjs.map +1 -0
  3. package/dist/AccountActivityService-method-action-types.d.cts.map +1 -0
  4. package/dist/AccountActivityService-method-action-types.d.mts.map +1 -0
  5. package/dist/AccountActivityService-method-action-types.mjs.map +1 -0
  6. package/dist/{ws/AccountActivityService.cjs → AccountActivityService.cjs} +1 -1
  7. package/dist/AccountActivityService.cjs.map +1 -0
  8. package/dist/{ws/AccountActivityService.d.cts → AccountActivityService.d.cts} +1 -1
  9. package/dist/AccountActivityService.d.cts.map +1 -0
  10. package/dist/{ws/AccountActivityService.d.mts → AccountActivityService.d.mts} +1 -1
  11. package/dist/AccountActivityService.d.mts.map +1 -0
  12. package/dist/{ws/AccountActivityService.mjs → AccountActivityService.mjs} +1 -1
  13. package/dist/AccountActivityService.mjs.map +1 -0
  14. package/dist/BackendWebSocketService-method-action-types.cjs.map +1 -0
  15. package/dist/BackendWebSocketService-method-action-types.d.cts.map +1 -0
  16. package/dist/BackendWebSocketService-method-action-types.d.mts.map +1 -0
  17. package/dist/BackendWebSocketService-method-action-types.mjs.map +1 -0
  18. package/dist/{ws/BackendWebSocketService.cjs → BackendWebSocketService.cjs} +1 -1
  19. package/dist/BackendWebSocketService.cjs.map +1 -0
  20. package/dist/BackendWebSocketService.d.cts.map +1 -0
  21. package/dist/BackendWebSocketService.d.mts.map +1 -0
  22. package/dist/{ws/BackendWebSocketService.mjs → BackendWebSocketService.mjs} +1 -1
  23. package/dist/BackendWebSocketService.mjs.map +1 -0
  24. package/dist/index.cjs +3 -10
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +4 -6
  27. package/dist/index.d.cts.map +1 -1
  28. package/dist/index.d.mts +4 -6
  29. package/dist/index.d.mts.map +1 -1
  30. package/dist/index.mjs +2 -6
  31. package/dist/index.mjs.map +1 -1
  32. package/package.json +1 -1
  33. package/dist/ws/AccountActivityService-method-action-types.cjs.map +0 -1
  34. package/dist/ws/AccountActivityService-method-action-types.d.cts.map +0 -1
  35. package/dist/ws/AccountActivityService-method-action-types.d.mts.map +0 -1
  36. package/dist/ws/AccountActivityService-method-action-types.mjs.map +0 -1
  37. package/dist/ws/AccountActivityService.cjs.map +0 -1
  38. package/dist/ws/AccountActivityService.d.cts.map +0 -1
  39. package/dist/ws/AccountActivityService.d.mts.map +0 -1
  40. package/dist/ws/AccountActivityService.mjs.map +0 -1
  41. package/dist/ws/BackendWebSocketService-method-action-types.cjs.map +0 -1
  42. package/dist/ws/BackendWebSocketService-method-action-types.d.cts.map +0 -1
  43. package/dist/ws/BackendWebSocketService-method-action-types.d.mts.map +0 -1
  44. package/dist/ws/BackendWebSocketService-method-action-types.mjs.map +0 -1
  45. package/dist/ws/BackendWebSocketService.cjs.map +0 -1
  46. package/dist/ws/BackendWebSocketService.d.cts.map +0 -1
  47. package/dist/ws/BackendWebSocketService.d.mts.map +0 -1
  48. package/dist/ws/BackendWebSocketService.mjs.map +0 -1
  49. package/dist/ws/ohlcv/OHLCVService-method-action-types.cjs +0 -7
  50. package/dist/ws/ohlcv/OHLCVService-method-action-types.cjs.map +0 -1
  51. package/dist/ws/ohlcv/OHLCVService-method-action-types.d.cts +0 -33
  52. package/dist/ws/ohlcv/OHLCVService-method-action-types.d.cts.map +0 -1
  53. package/dist/ws/ohlcv/OHLCVService-method-action-types.d.mts +0 -33
  54. package/dist/ws/ohlcv/OHLCVService-method-action-types.d.mts.map +0 -1
  55. package/dist/ws/ohlcv/OHLCVService-method-action-types.mjs +0 -6
  56. package/dist/ws/ohlcv/OHLCVService-method-action-types.mjs.map +0 -1
  57. package/dist/ws/ohlcv/OHLCVService.cjs +0 -329
  58. package/dist/ws/ohlcv/OHLCVService.cjs.map +0 -1
  59. package/dist/ws/ohlcv/OHLCVService.d.cts +0 -107
  60. package/dist/ws/ohlcv/OHLCVService.d.cts.map +0 -1
  61. package/dist/ws/ohlcv/OHLCVService.d.mts +0 -107
  62. package/dist/ws/ohlcv/OHLCVService.d.mts.map +0 -1
  63. package/dist/ws/ohlcv/OHLCVService.mjs +0 -325
  64. package/dist/ws/ohlcv/OHLCVService.mjs.map +0 -1
  65. package/dist/ws/ohlcv/index.cjs +0 -9
  66. package/dist/ws/ohlcv/index.cjs.map +0 -1
  67. package/dist/ws/ohlcv/index.d.cts +0 -5
  68. package/dist/ws/ohlcv/index.d.cts.map +0 -1
  69. package/dist/ws/ohlcv/index.d.mts +0 -5
  70. package/dist/ws/ohlcv/index.d.mts.map +0 -1
  71. package/dist/ws/ohlcv/index.mjs +0 -3
  72. package/dist/ws/ohlcv/index.mjs.map +0 -1
  73. package/dist/ws/ohlcv/types.cjs +0 -6
  74. package/dist/ws/ohlcv/types.cjs.map +0 -1
  75. package/dist/ws/ohlcv/types.d.cts +0 -32
  76. package/dist/ws/ohlcv/types.d.cts.map +0 -1
  77. package/dist/ws/ohlcv/types.d.mts +0 -32
  78. package/dist/ws/ohlcv/types.d.mts.map +0 -1
  79. package/dist/ws/ohlcv/types.mjs +0 -5
  80. package/dist/ws/ohlcv/types.mjs.map +0 -1
  81. /package/dist/{ws/AccountActivityService-method-action-types.cjs → AccountActivityService-method-action-types.cjs} +0 -0
  82. /package/dist/{ws/AccountActivityService-method-action-types.d.cts → AccountActivityService-method-action-types.d.cts} +0 -0
  83. /package/dist/{ws/AccountActivityService-method-action-types.d.mts → AccountActivityService-method-action-types.d.mts} +0 -0
  84. /package/dist/{ws/AccountActivityService-method-action-types.mjs → AccountActivityService-method-action-types.mjs} +0 -0
  85. /package/dist/{ws/BackendWebSocketService-method-action-types.cjs → BackendWebSocketService-method-action-types.cjs} +0 -0
  86. /package/dist/{ws/BackendWebSocketService-method-action-types.d.cts → BackendWebSocketService-method-action-types.d.cts} +0 -0
  87. /package/dist/{ws/BackendWebSocketService-method-action-types.d.mts → BackendWebSocketService-method-action-types.d.mts} +0 -0
  88. /package/dist/{ws/BackendWebSocketService-method-action-types.mjs → BackendWebSocketService-method-action-types.mjs} +0 -0
  89. /package/dist/{ws/BackendWebSocketService.d.cts → BackendWebSocketService.d.cts} +0 -0
  90. /package/dist/{ws/BackendWebSocketService.d.mts → BackendWebSocketService.d.mts} +0 -0
@@ -1,325 +0,0 @@
1
- /**
2
- * OHLCV Service for real-time candlestick data streaming via WebSocket.
3
- *
4
- * Wraps {@link BackendWebSocketService} through the messenger pattern to
5
- * provide subscribe/unsubscribe semantics for OHLCV market-data channels.
6
- * Includes reference counting, grace-period unsubscribe, idempotency checks,
7
- * chain-status forwarding, and automatic resubscription on reconnect.
8
- */
9
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10
- if (kind === "m") throw new TypeError("Private method is not writable");
11
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
12
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
13
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
14
- };
15
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
16
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
17
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
18
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
19
- };
20
- var _OHLCVService_instances, _OHLCVService_messenger, _OHLCVService_trace, _OHLCVService_channels, _OHLCVService_chainsUp, _OHLCVService_performUnsubscribe, _OHLCVService_resubscribeActiveChannels, _OHLCVService_handleBarUpdate, _OHLCVService_handleSystemNotification, _OHLCVService_handleWebSocketStateChange, _OHLCVService_buildChannel, _OHLCVService_forceReconnection;
21
- import { projectLogger, createModuleLogger } from "../../logger.mjs";
22
- import { WebSocketState } from "../BackendWebSocketService.mjs";
23
- // =============================================================================
24
- // Constants
25
- // =============================================================================
26
- const SERVICE_NAME = 'OHLCVService';
27
- const log = createModuleLogger(projectLogger, SERVICE_NAME);
28
- const MESSENGER_EXPOSED_METHODS = ['subscribe', 'unsubscribe'];
29
- const SUBSCRIPTION_NAMESPACE = 'market-data.v1';
30
- const SYSTEM_NOTIFICATIONS_CHANNEL = `system-notifications.v1.${SUBSCRIPTION_NAMESPACE}`;
31
- /** Delay before actually unsubscribing from a channel after refCount reaches 0. */
32
- const GRACE_PERIOD_MS = 3000;
33
- export const OHLCV_SERVICE_ALLOWED_ACTIONS = [
34
- 'BackendWebSocketService:connect',
35
- 'BackendWebSocketService:forceReconnection',
36
- 'BackendWebSocketService:subscribe',
37
- 'BackendWebSocketService:getConnectionInfo',
38
- 'BackendWebSocketService:channelHasSubscription',
39
- 'BackendWebSocketService:getSubscriptionsByChannel',
40
- 'BackendWebSocketService:findSubscriptionsByChannelPrefix',
41
- 'BackendWebSocketService:addChannelCallback',
42
- 'BackendWebSocketService:removeChannelCallback',
43
- ];
44
- export const OHLCV_SERVICE_ALLOWED_EVENTS = [
45
- 'BackendWebSocketService:connectionStateChanged',
46
- ];
47
- // =============================================================================
48
- // Main Service Class
49
- // =============================================================================
50
- /**
51
- * Service for real-time OHLCV candlestick streaming via the backend WebSocket
52
- * gateway. Communicates with {@link BackendWebSocketService} exclusively
53
- * through the messenger — no direct import of the class.
54
- *
55
- * Features:
56
- * - Reference counting: multiple UI consumers share one WebSocket subscription
57
- * - Grace-period unsubscribe: avoids rapid unsub/resub during navigation
58
- * - Idempotency: duplicate subscribe calls for the same channel are no-ops
59
- * - Reconnect resilience: resubscribes all active channels on reconnect
60
- * - Chain-status forwarding: listens to system-notifications for chain up/down
61
- *
62
- */
63
- export class OHLCVService {
64
- // =============================================================================
65
- // Constructor
66
- // =============================================================================
67
- constructor(options) {
68
- _OHLCVService_instances.add(this);
69
- this.name = SERVICE_NAME;
70
- _OHLCVService_messenger.set(this, void 0);
71
- _OHLCVService_trace.set(this, void 0);
72
- _OHLCVService_channels.set(this, new Map());
73
- _OHLCVService_chainsUp.set(this, new Set());
74
- __classPrivateFieldSet(this, _OHLCVService_messenger, options.messenger, "f");
75
- __classPrivateFieldSet(this, _OHLCVService_trace, options.traceFn ??
76
- ((_request, fn) => fn?.()), "f");
77
- __classPrivateFieldGet(this, _OHLCVService_messenger, "f").registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
78
- __classPrivateFieldGet(this, _OHLCVService_messenger, "f").subscribe('BackendWebSocketService:connectionStateChanged',
79
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
80
- (connectionInfo) => __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_handleWebSocketStateChange).call(this, connectionInfo));
81
- }
82
- /**
83
- * Register the system-notifications channel callback.
84
- */
85
- init() {
86
- log('OHLCV-WS: Initializing — registering system-notifications callback');
87
- __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:addChannelCallback', {
88
- channelName: SYSTEM_NOTIFICATIONS_CHANNEL,
89
- callback: (notification) => __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_handleSystemNotification).call(this, notification),
90
- });
91
- }
92
- // =============================================================================
93
- // Public — Subscribe / Unsubscribe
94
- // =============================================================================
95
- /**
96
- * Subscribe to an OHLCV channel. If this is the first subscriber for the
97
- * given asset/interval/currency combination a WebSocket subscription is
98
- * created. Additional calls for the same combination only bump the reference
99
- * count.
100
- *
101
- * @param options - The subscription parameters.
102
- */
103
- async subscribe(options) {
104
- const channel = __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_buildChannel).call(this, options);
105
- const entry = __classPrivateFieldGet(this, _OHLCVService_channels, "f").get(channel);
106
- if (entry?.gracePeriodTimer) {
107
- clearTimeout(entry.gracePeriodTimer);
108
- entry.gracePeriodTimer = undefined;
109
- entry.refCount += 1;
110
- log('OHLCV-WS: Cancelled grace-period unsubscribe, bumped refCount', {
111
- channel,
112
- refCount: entry.refCount,
113
- });
114
- return;
115
- }
116
- if (entry && entry.refCount > 0) {
117
- entry.refCount += 1;
118
- return;
119
- }
120
- // Flush other channels sitting in grace period to free server-side slots
121
- // and prevent accumulation when switching time ranges rapidly.
122
- for (const [otherChannel, otherEntry] of __classPrivateFieldGet(this, _OHLCVService_channels, "f").entries()) {
123
- if (otherChannel !== channel && otherEntry.gracePeriodTimer) {
124
- clearTimeout(otherEntry.gracePeriodTimer);
125
- otherEntry.gracePeriodTimer = undefined;
126
- log('OHLCV-WS: Flushing grace-period channel before new subscribe', {
127
- flushedChannel: otherChannel,
128
- newChannel: channel,
129
- });
130
- await __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_performUnsubscribe).call(this, otherChannel);
131
- }
132
- }
133
- try {
134
- await __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:connect');
135
- if (__classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:channelHasSubscription', channel)) {
136
- log('OHLCV-WS: Channel already has WS subscription (idempotency), skipping', {
137
- channel,
138
- });
139
- __classPrivateFieldGet(this, _OHLCVService_channels, "f").set(channel, { refCount: 1 });
140
- return;
141
- }
142
- await __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:subscribe', {
143
- channels: [channel],
144
- channelType: SUBSCRIPTION_NAMESPACE,
145
- callback: (notification) => {
146
- __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_handleBarUpdate).call(this, channel, notification);
147
- },
148
- });
149
- __classPrivateFieldGet(this, _OHLCVService_channels, "f").set(channel, { refCount: 1 });
150
- log('OHLCV-WS: Subscribe succeeded — new WS subscription created', {
151
- channel,
152
- });
153
- }
154
- catch (error) {
155
- log('OHLCV-WS: Subscription failed, forcing reconnection', {
156
- channel,
157
- error,
158
- });
159
- __classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:subscriptionError', {
160
- channel,
161
- error: String(error),
162
- operation: 'subscribe',
163
- });
164
- await __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_forceReconnection).call(this);
165
- }
166
- }
167
- /**
168
- * Unsubscribe from an OHLCV channel. Decrements the reference count and,
169
- * when it reaches zero, starts a grace-period timer before actually
170
- * unsubscribing from the WebSocket to absorb rapid navigation patterns.
171
- *
172
- * @param options - The subscription parameters to unsubscribe from.
173
- */
174
- async unsubscribe(options) {
175
- const channel = __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_buildChannel).call(this, options);
176
- const entry = __classPrivateFieldGet(this, _OHLCVService_channels, "f").get(channel);
177
- if (!entry || entry.refCount <= 0) {
178
- return;
179
- }
180
- entry.refCount -= 1;
181
- if (entry.refCount > 0) {
182
- return;
183
- }
184
- entry.gracePeriodTimer = setTimeout(() => {
185
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
186
- __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_performUnsubscribe).call(this, channel);
187
- }, GRACE_PERIOD_MS);
188
- }
189
- // =============================================================================
190
- // Public — Cleanup
191
- // =============================================================================
192
- /**
193
- * Destroy the service and clean up all resources.
194
- */
195
- destroy() {
196
- for (const entry of __classPrivateFieldGet(this, _OHLCVService_channels, "f").values()) {
197
- if (entry.gracePeriodTimer) {
198
- clearTimeout(entry.gracePeriodTimer);
199
- }
200
- }
201
- __classPrivateFieldGet(this, _OHLCVService_channels, "f").clear();
202
- __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:removeChannelCallback', SYSTEM_NOTIFICATIONS_CHANNEL);
203
- }
204
- }
205
- _OHLCVService_messenger = new WeakMap(), _OHLCVService_trace = new WeakMap(), _OHLCVService_channels = new WeakMap(), _OHLCVService_chainsUp = new WeakMap(), _OHLCVService_instances = new WeakSet(), _OHLCVService_performUnsubscribe =
206
- // =============================================================================
207
- // Private — WebSocket Subscription Helpers
208
- // =============================================================================
209
- async function _OHLCVService_performUnsubscribe(channel) {
210
- log('OHLCV-WS: Grace period expired — performing actual WS unsubscribe', {
211
- channel,
212
- });
213
- __classPrivateFieldGet(this, _OHLCVService_channels, "f").delete(channel);
214
- try {
215
- const subscriptions = __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:getSubscriptionsByChannel', channel);
216
- for (const sub of subscriptions) {
217
- await sub.unsubscribe();
218
- }
219
- log('OHLCV-WS: WS unsubscribe completed', { channel });
220
- }
221
- catch (error) {
222
- log('OHLCV-WS: Unsubscription failed, forcing reconnection', {
223
- channel,
224
- error,
225
- });
226
- __classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:subscriptionError', {
227
- channel,
228
- error: String(error),
229
- operation: 'unsubscribe',
230
- });
231
- await __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_forceReconnection).call(this);
232
- }
233
- }, _OHLCVService_resubscribeActiveChannels =
234
- /**
235
- * Resubscribe all channels that were active before a disconnect.
236
- * Called when WebSocket transitions to CONNECTED.
237
- */
238
- async function _OHLCVService_resubscribeActiveChannels() {
239
- const channelCount = __classPrivateFieldGet(this, _OHLCVService_channels, "f").size;
240
- log('OHLCV-WS: Resubscribing active channels after reconnect', {
241
- count: channelCount,
242
- });
243
- for (const [channel] of __classPrivateFieldGet(this, _OHLCVService_channels, "f").entries()) {
244
- try {
245
- if (__classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:channelHasSubscription', channel)) {
246
- log('OHLCV-WS: Channel already subscribed on server, skipping resubscribe', {
247
- channel,
248
- });
249
- continue;
250
- }
251
- await __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:subscribe', {
252
- channels: [channel],
253
- channelType: SUBSCRIPTION_NAMESPACE,
254
- callback: (notification) => {
255
- __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_handleBarUpdate).call(this, channel, notification);
256
- },
257
- });
258
- log('OHLCV-WS: Resubscription succeeded', { channel });
259
- }
260
- catch (error) {
261
- log('OHLCV-WS: Resubscription failed for channel', { channel, error });
262
- }
263
- }
264
- }, _OHLCVService_handleBarUpdate = function _OHLCVService_handleBarUpdate(channel, notification) {
265
- const bar = notification.data;
266
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
267
- __classPrivateFieldGet(this, _OHLCVService_trace, "f").call(this, {
268
- name: `${SERVICE_NAME} Bar Update`,
269
- data: { channel, timestamp: bar.timestamp },
270
- tags: { service: SERVICE_NAME },
271
- }, () => {
272
- __classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:barUpdated', { channel, bar });
273
- });
274
- }, _OHLCVService_handleSystemNotification = function _OHLCVService_handleSystemNotification(notification) {
275
- const data = notification.data;
276
- const { timestamp } = notification;
277
- if (!data.chainIds || !Array.isArray(data.chainIds) || !data.status) {
278
- throw new Error('Invalid system notification data: missing chainIds or status');
279
- }
280
- if (data.status === 'up') {
281
- for (const chainId of data.chainIds) {
282
- __classPrivateFieldGet(this, _OHLCVService_chainsUp, "f").add(chainId);
283
- }
284
- }
285
- else {
286
- for (const chainId of data.chainIds) {
287
- __classPrivateFieldGet(this, _OHLCVService_chainsUp, "f").delete(chainId);
288
- }
289
- }
290
- __classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:chainStatusChanged', {
291
- chainIds: data.chainIds,
292
- status: data.status,
293
- timestamp,
294
- });
295
- log(`OHLCV-WS: Chain status change: ${data.status}`, {
296
- chains: data.chainIds,
297
- status: data.status,
298
- });
299
- }, _OHLCVService_handleWebSocketStateChange = async function _OHLCVService_handleWebSocketStateChange(connectionInfo) {
300
- const { state } = connectionInfo;
301
- if (state === WebSocketState.CONNECTED) {
302
- await __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_resubscribeActiveChannels).call(this);
303
- }
304
- else if (state === WebSocketState.DISCONNECTED) {
305
- const chainsToMarkDown = Array.from(__classPrivateFieldGet(this, _OHLCVService_chainsUp, "f"));
306
- if (chainsToMarkDown.length > 0) {
307
- __classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:chainStatusChanged', {
308
- chainIds: chainsToMarkDown,
309
- status: 'down',
310
- timestamp: Date.now(),
311
- });
312
- log('OHLCV-WS: WebSocket disconnection — marked tracked chains as down', {
313
- count: chainsToMarkDown.length,
314
- chains: chainsToMarkDown,
315
- });
316
- __classPrivateFieldGet(this, _OHLCVService_chainsUp, "f").clear();
317
- }
318
- }
319
- }, _OHLCVService_buildChannel = function _OHLCVService_buildChannel(options) {
320
- return `${SUBSCRIPTION_NAMESPACE}.${options.assetId}.${options.interval}.${options.currency}`;
321
- }, _OHLCVService_forceReconnection = async function _OHLCVService_forceReconnection() {
322
- log('OHLCV-WS: Forcing WebSocket reconnection');
323
- await __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:forceReconnection');
324
- };
325
- //# sourceMappingURL=OHLCVService.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OHLCVService.mjs","sourceRoot":"","sources":["../../../src/ws/ohlcv/OHLCVService.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;;;;;;;;;;;;;AASH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,yBAAqB;AAMjE,OAAO,EAAE,cAAc,EAAE,uCAAmC;AAK5D,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AAE5D,MAAM,yBAAyB,GAAG,CAAC,WAAW,EAAE,aAAa,CAAU,CAAC;AAExE,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEhD,MAAM,4BAA4B,GAAG,2BAA2B,sBAAsB,EAAE,CAAC;AAEzF,mFAAmF;AACnF,MAAM,eAAe,GAAG,IAAK,CAAC;AA0C9B,MAAM,CAAC,MAAM,6BAA6B,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H,CAAC;AACH,CAAC,mEAMa,OAAiC;IAC7C,OAAO,GAAG,sBAAsB,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;AAChG,CAAC,oCAED,KAAK;IACH,GAAG,CAAC,0CAA0C,CAAC,CAAC;IAChD,MAAM,uBAAA,IAAI,+BAAW,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/**\n * OHLCV Service for real-time candlestick data streaming via WebSocket.\n *\n * Wraps {@link BackendWebSocketService} through the messenger pattern to\n * provide subscribe/unsubscribe semantics for OHLCV market-data channels.\n * Includes reference counting, grace-period unsubscribe, idempotency checks,\n * chain-status forwarding, and automatic resubscription on reconnect.\n */\n\nimport type {\n TraceCallback,\n TraceContext,\n TraceRequest,\n} from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { projectLogger, createModuleLogger } from '../../logger';\nimport type {\n WebSocketConnectionInfo,\n BackendWebSocketServiceConnectionStateChangedEvent,\n ServerNotificationMessage,\n} from '../BackendWebSocketService';\nimport { WebSocketState } from '../BackendWebSocketService';\nimport type { BackendWebSocketServiceMethodActions } from '../BackendWebSocketService-method-action-types';\nimport type { OHLCVServiceMethodActions } from './OHLCVService-method-action-types';\nimport type { OHLCVBar, OHLCVSubscriptionOptions } from './types';\n\n// =============================================================================\n// Constants\n// =============================================================================\n\nconst SERVICE_NAME = 'OHLCVService';\n\nconst log = createModuleLogger(projectLogger, SERVICE_NAME);\n\nconst MESSENGER_EXPOSED_METHODS = ['subscribe', 'unsubscribe'] as const;\n\nconst SUBSCRIPTION_NAMESPACE = 'market-data.v1';\n\nconst SYSTEM_NOTIFICATIONS_CHANNEL = `system-notifications.v1.${SUBSCRIPTION_NAMESPACE}`;\n\n/** Delay before actually unsubscribing from a channel after refCount reaches 0. */\nconst GRACE_PERIOD_MS = 3_000;\n\n// =============================================================================\n// Types — Channel Tracking\n// =============================================================================\n\ntype ChannelEntry = {\n refCount: number;\n gracePeriodTimer?: ReturnType<typeof setTimeout>;\n};\n\n// =============================================================================\n// Types — System Notifications\n// =============================================================================\n\n/**\n * System notification data for chain status updates on market-data channels.\n */\nexport type OHLCVSystemNotificationData = {\n chainIds: string[];\n status: 'down' | 'up';\n timestamp?: number;\n};\n\n// =============================================================================\n// Types — Service Options\n// =============================================================================\n\n/**\n * Configuration options for the OHLCV service.\n */\nexport type OHLCVServiceOptions = {\n /** Optional callback to trace performance of OHLCV operations (default: no-op) */\n traceFn?: TraceCallback;\n};\n\n// =============================================================================\n// Action and Event Types\n// =============================================================================\n\nexport type OHLCVServiceActions = OHLCVServiceMethodActions;\n\nexport const OHLCV_SERVICE_ALLOWED_ACTIONS = [\n 'BackendWebSocketService:connect',\n 'BackendWebSocketService:forceReconnection',\n 'BackendWebSocketService:subscribe',\n 'BackendWebSocketService:getConnectionInfo',\n 'BackendWebSocketService:channelHasSubscription',\n 'BackendWebSocketService:getSubscriptionsByChannel',\n 'BackendWebSocketService:findSubscriptionsByChannelPrefix',\n 'BackendWebSocketService:addChannelCallback',\n 'BackendWebSocketService:removeChannelCallback',\n] as const;\n\nexport const OHLCV_SERVICE_ALLOWED_EVENTS = [\n 'BackendWebSocketService:connectionStateChanged',\n] as const;\n\nexport type AllowedActions = BackendWebSocketServiceMethodActions;\n\n// Events published by OHLCVService\n\nexport type OHLCVServiceBarUpdatedEvent = {\n type: `OHLCVService:barUpdated`;\n payload: [{ channel: string; bar: OHLCVBar }];\n};\n\nexport type OHLCVServiceChainStatusChangedEvent = {\n type: `OHLCVService:chainStatusChanged`;\n payload: [{ chainIds: string[]; status: 'up' | 'down'; timestamp?: number }];\n};\n\nexport type OHLCVServiceSubscriptionErrorEvent = {\n type: `OHLCVService:subscriptionError`;\n payload: [{ channel: string; error: string; operation: string }];\n};\n\nexport type OHLCVServiceEvents =\n | OHLCVServiceBarUpdatedEvent\n | OHLCVServiceChainStatusChangedEvent\n | OHLCVServiceSubscriptionErrorEvent;\n\nexport type AllowedEvents = BackendWebSocketServiceConnectionStateChangedEvent;\n\nexport type OHLCVServiceMessenger = Messenger<\n typeof SERVICE_NAME,\n OHLCVServiceActions | AllowedActions,\n OHLCVServiceEvents | AllowedEvents\n>;\n\n// =============================================================================\n// Main Service Class\n// =============================================================================\n\n/**\n * Service for real-time OHLCV candlestick streaming via the backend WebSocket\n * gateway. Communicates with {@link BackendWebSocketService} exclusively\n * through the messenger — no direct import of the class.\n *\n * Features:\n * - Reference counting: multiple UI consumers share one WebSocket subscription\n * - Grace-period unsubscribe: avoids rapid unsub/resub during navigation\n * - Idempotency: duplicate subscribe calls for the same channel are no-ops\n * - Reconnect resilience: resubscribes all active channels on reconnect\n * - Chain-status forwarding: listens to system-notifications for chain up/down\n *\n */\nexport class OHLCVService {\n readonly name = SERVICE_NAME;\n\n readonly #messenger: OHLCVServiceMessenger;\n\n readonly #trace: TraceCallback;\n\n readonly #channels = new Map<string, ChannelEntry>();\n\n readonly #chainsUp = new Set<string>();\n\n // =============================================================================\n // Constructor\n // =============================================================================\n\n constructor(\n options: OHLCVServiceOptions & { messenger: OHLCVServiceMessenger },\n ) {\n this.#messenger = options.messenger;\n\n this.#trace =\n options.traceFn ??\n ((<Result>(\n _request: TraceRequest,\n fn?: (context?: TraceContext) => Result,\n ) => fn?.()) as TraceCallback);\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.#messenger.subscribe(\n 'BackendWebSocketService:connectionStateChanged',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n (connectionInfo: WebSocketConnectionInfo) =>\n this.#handleWebSocketStateChange(connectionInfo),\n );\n }\n\n /**\n * Register the system-notifications channel callback.\n */\n init(): void {\n log('OHLCV-WS: Initializing — registering system-notifications callback');\n this.#messenger.call('BackendWebSocketService:addChannelCallback', {\n channelName: SYSTEM_NOTIFICATIONS_CHANNEL,\n callback: (notification: ServerNotificationMessage) =>\n this.#handleSystemNotification(notification),\n });\n }\n\n // =============================================================================\n // Public — Subscribe / Unsubscribe\n // =============================================================================\n\n /**\n * Subscribe to an OHLCV channel. If this is the first subscriber for the\n * given asset/interval/currency combination a WebSocket subscription is\n * created. Additional calls for the same combination only bump the reference\n * count.\n *\n * @param options - The subscription parameters.\n */\n async subscribe(options: OHLCVSubscriptionOptions): Promise<void> {\n const channel = this.#buildChannel(options);\n const entry = this.#channels.get(channel);\n\n if (entry?.gracePeriodTimer) {\n clearTimeout(entry.gracePeriodTimer);\n entry.gracePeriodTimer = undefined;\n entry.refCount += 1;\n log('OHLCV-WS: Cancelled grace-period unsubscribe, bumped refCount', {\n channel,\n refCount: entry.refCount,\n });\n return;\n }\n\n if (entry && entry.refCount > 0) {\n entry.refCount += 1;\n return;\n }\n\n // Flush other channels sitting in grace period to free server-side slots\n // and prevent accumulation when switching time ranges rapidly.\n for (const [otherChannel, otherEntry] of this.#channels.entries()) {\n if (otherChannel !== channel && otherEntry.gracePeriodTimer) {\n clearTimeout(otherEntry.gracePeriodTimer);\n otherEntry.gracePeriodTimer = undefined;\n log('OHLCV-WS: Flushing grace-period channel before new subscribe', {\n flushedChannel: otherChannel,\n newChannel: channel,\n });\n await this.#performUnsubscribe(otherChannel);\n }\n }\n\n try {\n await this.#messenger.call('BackendWebSocketService:connect');\n\n if (\n this.#messenger.call(\n 'BackendWebSocketService:channelHasSubscription',\n channel,\n )\n ) {\n log(\n 'OHLCV-WS: Channel already has WS subscription (idempotency), skipping',\n {\n channel,\n },\n );\n this.#channels.set(channel, { refCount: 1 });\n return;\n }\n\n await this.#messenger.call('BackendWebSocketService:subscribe', {\n channels: [channel],\n channelType: SUBSCRIPTION_NAMESPACE,\n callback: (notification: ServerNotificationMessage) => {\n this.#handleBarUpdate(channel, notification);\n },\n });\n\n this.#channels.set(channel, { refCount: 1 });\n log('OHLCV-WS: Subscribe succeeded — new WS subscription created', {\n channel,\n });\n } catch (error) {\n log('OHLCV-WS: Subscription failed, forcing reconnection', {\n channel,\n error,\n });\n this.#messenger.publish('OHLCVService:subscriptionError', {\n channel,\n error: String(error),\n operation: 'subscribe',\n });\n await this.#forceReconnection();\n }\n }\n\n /**\n * Unsubscribe from an OHLCV channel. Decrements the reference count and,\n * when it reaches zero, starts a grace-period timer before actually\n * unsubscribing from the WebSocket to absorb rapid navigation patterns.\n *\n * @param options - The subscription parameters to unsubscribe from.\n */\n async unsubscribe(options: OHLCVSubscriptionOptions): Promise<void> {\n const channel = this.#buildChannel(options);\n const entry = this.#channels.get(channel);\n\n if (!entry || entry.refCount <= 0) {\n return;\n }\n\n entry.refCount -= 1;\n\n if (entry.refCount > 0) {\n return;\n }\n\n entry.gracePeriodTimer = setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#performUnsubscribe(channel);\n }, GRACE_PERIOD_MS);\n }\n\n // =============================================================================\n // Private — WebSocket Subscription Helpers\n // =============================================================================\n\n async #performUnsubscribe(channel: string): Promise<void> {\n log('OHLCV-WS: Grace period expired — performing actual WS unsubscribe', {\n channel,\n });\n this.#channels.delete(channel);\n\n try {\n const subscriptions = this.#messenger.call(\n 'BackendWebSocketService:getSubscriptionsByChannel',\n channel,\n );\n\n for (const sub of subscriptions) {\n await sub.unsubscribe();\n }\n log('OHLCV-WS: WS unsubscribe completed', { channel });\n } catch (error) {\n log('OHLCV-WS: Unsubscription failed, forcing reconnection', {\n channel,\n error,\n });\n this.#messenger.publish('OHLCVService:subscriptionError', {\n channel,\n error: String(error),\n operation: 'unsubscribe',\n });\n await this.#forceReconnection();\n }\n }\n\n /**\n * Resubscribe all channels that were active before a disconnect.\n * Called when WebSocket transitions to CONNECTED.\n */\n async #resubscribeActiveChannels(): Promise<void> {\n const channelCount = this.#channels.size;\n log('OHLCV-WS: Resubscribing active channels after reconnect', {\n count: channelCount,\n });\n\n for (const [channel] of this.#channels.entries()) {\n try {\n if (\n this.#messenger.call(\n 'BackendWebSocketService:channelHasSubscription',\n channel,\n )\n ) {\n log(\n 'OHLCV-WS: Channel already subscribed on server, skipping resubscribe',\n {\n channel,\n },\n );\n continue;\n }\n\n await this.#messenger.call('BackendWebSocketService:subscribe', {\n channels: [channel],\n channelType: SUBSCRIPTION_NAMESPACE,\n callback: (notification: ServerNotificationMessage) => {\n this.#handleBarUpdate(channel, notification);\n },\n });\n log('OHLCV-WS: Resubscription succeeded', { channel });\n } catch (error) {\n log('OHLCV-WS: Resubscription failed for channel', { channel, error });\n }\n }\n }\n\n // =============================================================================\n // Private — Message Handlers\n // =============================================================================\n\n #handleBarUpdate(\n channel: string,\n notification: ServerNotificationMessage,\n ): void {\n const bar = notification.data as OHLCVBar;\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#trace(\n {\n name: `${SERVICE_NAME} Bar Update`,\n data: { channel, timestamp: bar.timestamp },\n tags: { service: SERVICE_NAME },\n },\n () => {\n this.#messenger.publish('OHLCVService:barUpdated', { channel, bar });\n },\n );\n }\n\n #handleSystemNotification(notification: ServerNotificationMessage): void {\n const data = notification.data as OHLCVSystemNotificationData;\n const { timestamp } = notification;\n\n if (!data.chainIds || !Array.isArray(data.chainIds) || !data.status) {\n throw new Error(\n 'Invalid system notification data: missing chainIds or status',\n );\n }\n\n if (data.status === 'up') {\n for (const chainId of data.chainIds) {\n this.#chainsUp.add(chainId);\n }\n } else {\n for (const chainId of data.chainIds) {\n this.#chainsUp.delete(chainId);\n }\n }\n\n this.#messenger.publish('OHLCVService:chainStatusChanged', {\n chainIds: data.chainIds,\n status: data.status,\n timestamp,\n });\n\n log(`OHLCV-WS: Chain status change: ${data.status}`, {\n chains: data.chainIds,\n status: data.status,\n });\n }\n\n async #handleWebSocketStateChange(\n connectionInfo: WebSocketConnectionInfo,\n ): Promise<void> {\n const { state } = connectionInfo;\n\n if (state === WebSocketState.CONNECTED) {\n await this.#resubscribeActiveChannels();\n } else if (state === WebSocketState.DISCONNECTED) {\n const chainsToMarkDown = Array.from(this.#chainsUp);\n\n if (chainsToMarkDown.length > 0) {\n this.#messenger.publish('OHLCVService:chainStatusChanged', {\n chainIds: chainsToMarkDown,\n status: 'down',\n timestamp: Date.now(),\n });\n\n log(\n 'OHLCV-WS: WebSocket disconnection — marked tracked chains as down',\n {\n count: chainsToMarkDown.length,\n chains: chainsToMarkDown,\n },\n );\n\n this.#chainsUp.clear();\n }\n }\n }\n\n // =============================================================================\n // Private — Utility\n // =============================================================================\n\n #buildChannel(options: OHLCVSubscriptionOptions): string {\n return `${SUBSCRIPTION_NAMESPACE}.${options.assetId}.${options.interval}.${options.currency}`;\n }\n\n async #forceReconnection(): Promise<void> {\n log('OHLCV-WS: Forcing WebSocket reconnection');\n await this.#messenger.call('BackendWebSocketService:forceReconnection');\n }\n\n // =============================================================================\n // Public — Cleanup\n // =============================================================================\n\n /**\n * Destroy the service and clean up all resources.\n */\n destroy(): void {\n for (const entry of this.#channels.values()) {\n if (entry.gracePeriodTimer) {\n clearTimeout(entry.gracePeriodTimer);\n }\n }\n this.#channels.clear();\n\n this.#messenger.call(\n 'BackendWebSocketService:removeChannelCallback',\n SYSTEM_NOTIFICATIONS_CHANNEL,\n );\n }\n}\n"]}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OHLCV_SERVICE_ALLOWED_EVENTS = exports.OHLCV_SERVICE_ALLOWED_ACTIONS = exports.OHLCVService = void 0;
4
- var OHLCVService_1 = require("./OHLCVService.cjs");
5
- Object.defineProperty(exports, "OHLCVService", { enumerable: true, get: function () { return OHLCVService_1.OHLCVService; } });
6
- var OHLCVService_2 = require("./OHLCVService.cjs");
7
- Object.defineProperty(exports, "OHLCV_SERVICE_ALLOWED_ACTIONS", { enumerable: true, get: function () { return OHLCVService_2.OHLCV_SERVICE_ALLOWED_ACTIONS; } });
8
- Object.defineProperty(exports, "OHLCV_SERVICE_ALLOWED_EVENTS", { enumerable: true, get: function () { return OHLCVService_2.OHLCV_SERVICE_ALLOWED_EVENTS; } });
9
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/ws/ohlcv/index.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,mDAGwB;AAFtB,6HAAA,6BAA6B,OAAA;AAC7B,4HAAA,4BAA4B,OAAA","sourcesContent":["export { OHLCVService } from './OHLCVService';\nexport {\n OHLCV_SERVICE_ALLOWED_ACTIONS,\n OHLCV_SERVICE_ALLOWED_EVENTS,\n} from './OHLCVService';\nexport type {\n OHLCVSystemNotificationData,\n OHLCVServiceOptions,\n OHLCVServiceActions,\n AllowedActions as OHLCVServiceAllowedActions,\n OHLCVServiceBarUpdatedEvent,\n OHLCVServiceChainStatusChangedEvent,\n OHLCVServiceSubscriptionErrorEvent,\n OHLCVServiceEvents,\n AllowedEvents as OHLCVServiceAllowedEvents,\n OHLCVServiceMessenger,\n} from './OHLCVService';\nexport type { OHLCVBar, OHLCVSubscriptionOptions } from './types';\n"]}
@@ -1,5 +0,0 @@
1
- export { OHLCVService } from "./OHLCVService.cjs";
2
- export { OHLCV_SERVICE_ALLOWED_ACTIONS, OHLCV_SERVICE_ALLOWED_EVENTS, } from "./OHLCVService.cjs";
3
- export type { OHLCVSystemNotificationData, OHLCVServiceOptions, OHLCVServiceActions, AllowedActions as OHLCVServiceAllowedActions, OHLCVServiceBarUpdatedEvent, OHLCVServiceChainStatusChangedEvent, OHLCVServiceSubscriptionErrorEvent, OHLCVServiceEvents, AllowedEvents as OHLCVServiceAllowedEvents, OHLCVServiceMessenger, } from "./OHLCVService.cjs";
4
- export type { OHLCVBar, OHLCVSubscriptionOptions } from "./types.cjs";
5
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/ws/ohlcv/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,2BAAuB;AAC9C,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,GAC7B,2BAAuB;AACxB,YAAY,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,IAAI,0BAA0B,EAC5C,2BAA2B,EAC3B,mCAAmC,EACnC,kCAAkC,EAClC,kBAAkB,EAClB,aAAa,IAAI,yBAAyB,EAC1C,qBAAqB,GACtB,2BAAuB;AACxB,YAAY,EAAE,QAAQ,EAAE,wBAAwB,EAAE,oBAAgB"}
@@ -1,5 +0,0 @@
1
- export { OHLCVService } from "./OHLCVService.mjs";
2
- export { OHLCV_SERVICE_ALLOWED_ACTIONS, OHLCV_SERVICE_ALLOWED_EVENTS, } from "./OHLCVService.mjs";
3
- export type { OHLCVSystemNotificationData, OHLCVServiceOptions, OHLCVServiceActions, AllowedActions as OHLCVServiceAllowedActions, OHLCVServiceBarUpdatedEvent, OHLCVServiceChainStatusChangedEvent, OHLCVServiceSubscriptionErrorEvent, OHLCVServiceEvents, AllowedEvents as OHLCVServiceAllowedEvents, OHLCVServiceMessenger, } from "./OHLCVService.mjs";
4
- export type { OHLCVBar, OHLCVSubscriptionOptions } from "./types.mjs";
5
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/ws/ohlcv/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,2BAAuB;AAC9C,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,GAC7B,2BAAuB;AACxB,YAAY,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,IAAI,0BAA0B,EAC5C,2BAA2B,EAC3B,mCAAmC,EACnC,kCAAkC,EAClC,kBAAkB,EAClB,aAAa,IAAI,yBAAyB,EAC1C,qBAAqB,GACtB,2BAAuB;AACxB,YAAY,EAAE,QAAQ,EAAE,wBAAwB,EAAE,oBAAgB"}
@@ -1,3 +0,0 @@
1
- export { OHLCVService } from "./OHLCVService.mjs";
2
- export { OHLCV_SERVICE_ALLOWED_ACTIONS, OHLCV_SERVICE_ALLOWED_EVENTS } from "./OHLCVService.mjs";
3
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/ws/ohlcv/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,2BAAuB;AAC9C,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC7B,2BAAuB","sourcesContent":["export { OHLCVService } from './OHLCVService';\nexport {\n OHLCV_SERVICE_ALLOWED_ACTIONS,\n OHLCV_SERVICE_ALLOWED_EVENTS,\n} from './OHLCVService';\nexport type {\n OHLCVSystemNotificationData,\n OHLCVServiceOptions,\n OHLCVServiceActions,\n AllowedActions as OHLCVServiceAllowedActions,\n OHLCVServiceBarUpdatedEvent,\n OHLCVServiceChainStatusChangedEvent,\n OHLCVServiceSubscriptionErrorEvent,\n OHLCVServiceEvents,\n AllowedEvents as OHLCVServiceAllowedEvents,\n OHLCVServiceMessenger,\n} from './OHLCVService';\nexport type { OHLCVBar, OHLCVSubscriptionOptions } from './types';\n"]}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- /**
3
- * OHLCV WebSocket streaming types for real-time candlestick data.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- //# sourceMappingURL=types.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/ws/ohlcv/types.ts"],"names":[],"mappings":";AAAA;;GAEG","sourcesContent":["/**\n * OHLCV WebSocket streaming types for real-time candlestick data.\n */\n\n/**\n * A single OHLCV candlestick bar received from the market-data WebSocket stream.\n */\nexport type OHLCVBar = {\n /** Unix timestamp (seconds) of the candle open */\n timestamp: number;\n /** Opening price */\n open: number;\n /** Highest price during the candle period */\n high: number;\n /** Lowest price during the candle period */\n low: number;\n /** Closing price (latest) */\n close: number;\n /** Trading volume during the candle period */\n volume: number;\n};\n\n/**\n * Options for subscribing to an OHLCV channel.\n */\nexport type OHLCVSubscriptionOptions = {\n /** CAIP-19 asset identifier, e.g. \"eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\" */\n assetId: string;\n /** Candle interval, e.g. \"1m\", \"5m\", \"15m\", \"1h\", \"4h\", \"1d\" */\n interval: string;\n /** Fiat currency code, e.g. \"usd\", \"eur\" */\n currency: string;\n};\n"]}
@@ -1,32 +0,0 @@
1
- /**
2
- * OHLCV WebSocket streaming types for real-time candlestick data.
3
- */
4
- /**
5
- * A single OHLCV candlestick bar received from the market-data WebSocket stream.
6
- */
7
- export type OHLCVBar = {
8
- /** Unix timestamp (seconds) of the candle open */
9
- timestamp: number;
10
- /** Opening price */
11
- open: number;
12
- /** Highest price during the candle period */
13
- high: number;
14
- /** Lowest price during the candle period */
15
- low: number;
16
- /** Closing price (latest) */
17
- close: number;
18
- /** Trading volume during the candle period */
19
- volume: number;
20
- };
21
- /**
22
- * Options for subscribing to an OHLCV channel.
23
- */
24
- export type OHLCVSubscriptionOptions = {
25
- /** CAIP-19 asset identifier, e.g. "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" */
26
- assetId: string;
27
- /** Candle interval, e.g. "1m", "5m", "15m", "1h", "4h", "1d" */
28
- interval: string;
29
- /** Fiat currency code, e.g. "usd", "eur" */
30
- currency: string;
31
- };
32
- //# sourceMappingURL=types.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/ws/ohlcv/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,oGAAoG;IACpG,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
@@ -1,32 +0,0 @@
1
- /**
2
- * OHLCV WebSocket streaming types for real-time candlestick data.
3
- */
4
- /**
5
- * A single OHLCV candlestick bar received from the market-data WebSocket stream.
6
- */
7
- export type OHLCVBar = {
8
- /** Unix timestamp (seconds) of the candle open */
9
- timestamp: number;
10
- /** Opening price */
11
- open: number;
12
- /** Highest price during the candle period */
13
- high: number;
14
- /** Lowest price during the candle period */
15
- low: number;
16
- /** Closing price (latest) */
17
- close: number;
18
- /** Trading volume during the candle period */
19
- volume: number;
20
- };
21
- /**
22
- * Options for subscribing to an OHLCV channel.
23
- */
24
- export type OHLCVSubscriptionOptions = {
25
- /** CAIP-19 asset identifier, e.g. "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" */
26
- assetId: string;
27
- /** Candle interval, e.g. "1m", "5m", "15m", "1h", "4h", "1d" */
28
- interval: string;
29
- /** Fiat currency code, e.g. "usd", "eur" */
30
- currency: string;
31
- };
32
- //# sourceMappingURL=types.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/ws/ohlcv/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,oGAAoG;IACpG,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
@@ -1,5 +0,0 @@
1
- /**
2
- * OHLCV WebSocket streaming types for real-time candlestick data.
3
- */
4
- export {};
5
- //# sourceMappingURL=types.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/ws/ohlcv/types.ts"],"names":[],"mappings":"AAAA;;GAEG","sourcesContent":["/**\n * OHLCV WebSocket streaming types for real-time candlestick data.\n */\n\n/**\n * A single OHLCV candlestick bar received from the market-data WebSocket stream.\n */\nexport type OHLCVBar = {\n /** Unix timestamp (seconds) of the candle open */\n timestamp: number;\n /** Opening price */\n open: number;\n /** Highest price during the candle period */\n high: number;\n /** Lowest price during the candle period */\n low: number;\n /** Closing price (latest) */\n close: number;\n /** Trading volume during the candle period */\n volume: number;\n};\n\n/**\n * Options for subscribing to an OHLCV channel.\n */\nexport type OHLCVSubscriptionOptions = {\n /** CAIP-19 asset identifier, e.g. \"eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\" */\n assetId: string;\n /** Candle interval, e.g. \"1m\", \"5m\", \"15m\", \"1h\", \"4h\", \"1d\" */\n interval: string;\n /** Fiat currency code, e.g. \"usd\", \"eur\" */\n currency: string;\n};\n"]}