@metamask-previews/core-backend 6.2.1-preview-2fdaa18 → 6.2.1-preview-181ae75e1
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.
- package/CHANGELOG.md +8 -0
- package/dist/index.cjs +10 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +6 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -2
- package/dist/index.mjs.map +1 -1
- package/dist/ws/AccountActivityService-method-action-types.cjs.map +1 -0
- package/dist/ws/AccountActivityService-method-action-types.d.cts.map +1 -0
- package/dist/ws/AccountActivityService-method-action-types.d.mts.map +1 -0
- package/dist/ws/AccountActivityService-method-action-types.mjs.map +1 -0
- package/dist/{AccountActivityService.cjs → ws/AccountActivityService.cjs} +1 -1
- package/dist/ws/AccountActivityService.cjs.map +1 -0
- package/dist/{AccountActivityService.d.cts → ws/AccountActivityService.d.cts} +1 -1
- package/dist/ws/AccountActivityService.d.cts.map +1 -0
- package/dist/{AccountActivityService.d.mts → ws/AccountActivityService.d.mts} +1 -1
- package/dist/ws/AccountActivityService.d.mts.map +1 -0
- package/dist/{AccountActivityService.mjs → ws/AccountActivityService.mjs} +1 -1
- package/dist/ws/AccountActivityService.mjs.map +1 -0
- package/dist/ws/BackendWebSocketService-method-action-types.cjs.map +1 -0
- package/dist/ws/BackendWebSocketService-method-action-types.d.cts.map +1 -0
- package/dist/ws/BackendWebSocketService-method-action-types.d.mts.map +1 -0
- package/dist/ws/BackendWebSocketService-method-action-types.mjs.map +1 -0
- package/dist/{BackendWebSocketService.cjs → ws/BackendWebSocketService.cjs} +1 -1
- package/dist/ws/BackendWebSocketService.cjs.map +1 -0
- package/dist/ws/BackendWebSocketService.d.cts.map +1 -0
- package/dist/ws/BackendWebSocketService.d.mts.map +1 -0
- package/dist/{BackendWebSocketService.mjs → ws/BackendWebSocketService.mjs} +1 -1
- package/dist/ws/BackendWebSocketService.mjs.map +1 -0
- package/dist/ws/ohlcv/OHLCVService-method-action-types.cjs +7 -0
- package/dist/ws/ohlcv/OHLCVService-method-action-types.cjs.map +1 -0
- package/dist/ws/ohlcv/OHLCVService-method-action-types.d.cts +33 -0
- package/dist/ws/ohlcv/OHLCVService-method-action-types.d.cts.map +1 -0
- package/dist/ws/ohlcv/OHLCVService-method-action-types.d.mts +33 -0
- package/dist/ws/ohlcv/OHLCVService-method-action-types.d.mts.map +1 -0
- package/dist/ws/ohlcv/OHLCVService-method-action-types.mjs +6 -0
- package/dist/ws/ohlcv/OHLCVService-method-action-types.mjs.map +1 -0
- package/dist/ws/ohlcv/OHLCVService.cjs +294 -0
- package/dist/ws/ohlcv/OHLCVService.cjs.map +1 -0
- package/dist/ws/ohlcv/OHLCVService.d.cts +107 -0
- package/dist/ws/ohlcv/OHLCVService.d.cts.map +1 -0
- package/dist/ws/ohlcv/OHLCVService.d.mts +107 -0
- package/dist/ws/ohlcv/OHLCVService.d.mts.map +1 -0
- package/dist/ws/ohlcv/OHLCVService.mjs +290 -0
- package/dist/ws/ohlcv/OHLCVService.mjs.map +1 -0
- package/dist/ws/ohlcv/index.cjs +9 -0
- package/dist/ws/ohlcv/index.cjs.map +1 -0
- package/dist/ws/ohlcv/index.d.cts +5 -0
- package/dist/ws/ohlcv/index.d.cts.map +1 -0
- package/dist/ws/ohlcv/index.d.mts +5 -0
- package/dist/ws/ohlcv/index.d.mts.map +1 -0
- package/dist/ws/ohlcv/index.mjs +3 -0
- package/dist/ws/ohlcv/index.mjs.map +1 -0
- package/dist/ws/ohlcv/types.cjs +6 -0
- package/dist/ws/ohlcv/types.cjs.map +1 -0
- package/dist/ws/ohlcv/types.d.cts +32 -0
- package/dist/ws/ohlcv/types.d.cts.map +1 -0
- package/dist/ws/ohlcv/types.d.mts +32 -0
- package/dist/ws/ohlcv/types.d.mts.map +1 -0
- package/dist/ws/ohlcv/types.mjs +5 -0
- package/dist/ws/ohlcv/types.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/AccountActivityService-method-action-types.cjs.map +0 -1
- package/dist/AccountActivityService-method-action-types.d.cts.map +0 -1
- package/dist/AccountActivityService-method-action-types.d.mts.map +0 -1
- package/dist/AccountActivityService-method-action-types.mjs.map +0 -1
- package/dist/AccountActivityService.cjs.map +0 -1
- package/dist/AccountActivityService.d.cts.map +0 -1
- package/dist/AccountActivityService.d.mts.map +0 -1
- package/dist/AccountActivityService.mjs.map +0 -1
- package/dist/BackendWebSocketService-method-action-types.cjs.map +0 -1
- package/dist/BackendWebSocketService-method-action-types.d.cts.map +0 -1
- package/dist/BackendWebSocketService-method-action-types.d.mts.map +0 -1
- package/dist/BackendWebSocketService-method-action-types.mjs.map +0 -1
- package/dist/BackendWebSocketService.cjs.map +0 -1
- package/dist/BackendWebSocketService.d.cts.map +0 -1
- package/dist/BackendWebSocketService.d.mts.map +0 -1
- package/dist/BackendWebSocketService.mjs.map +0 -1
- /package/dist/{AccountActivityService-method-action-types.cjs → ws/AccountActivityService-method-action-types.cjs} +0 -0
- /package/dist/{AccountActivityService-method-action-types.d.cts → ws/AccountActivityService-method-action-types.d.cts} +0 -0
- /package/dist/{AccountActivityService-method-action-types.d.mts → ws/AccountActivityService-method-action-types.d.mts} +0 -0
- /package/dist/{AccountActivityService-method-action-types.mjs → ws/AccountActivityService-method-action-types.mjs} +0 -0
- /package/dist/{BackendWebSocketService-method-action-types.cjs → ws/BackendWebSocketService-method-action-types.cjs} +0 -0
- /package/dist/{BackendWebSocketService-method-action-types.d.cts → ws/BackendWebSocketService-method-action-types.d.cts} +0 -0
- /package/dist/{BackendWebSocketService-method-action-types.d.mts → ws/BackendWebSocketService-method-action-types.d.mts} +0 -0
- /package/dist/{BackendWebSocketService-method-action-types.mjs → ws/BackendWebSocketService-method-action-types.mjs} +0 -0
- /package/dist/{BackendWebSocketService.d.cts → ws/BackendWebSocketService.d.cts} +0 -0
- /package/dist/{BackendWebSocketService.d.mts → ws/BackendWebSocketService.d.mts} +0 -0
|
@@ -0,0 +1,290 @@
|
|
|
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
|
+
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:addChannelCallback', {
|
|
87
|
+
channelName: SYSTEM_NOTIFICATIONS_CHANNEL,
|
|
88
|
+
callback: (notification) => __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_handleSystemNotification).call(this, notification),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
// =============================================================================
|
|
92
|
+
// Public — Subscribe / Unsubscribe
|
|
93
|
+
// =============================================================================
|
|
94
|
+
/**
|
|
95
|
+
* Subscribe to an OHLCV channel. If this is the first subscriber for the
|
|
96
|
+
* given asset/interval/currency combination a WebSocket subscription is
|
|
97
|
+
* created. Additional calls for the same combination only bump the reference
|
|
98
|
+
* count.
|
|
99
|
+
*
|
|
100
|
+
* @param options - The subscription parameters.
|
|
101
|
+
*/
|
|
102
|
+
async subscribe(options) {
|
|
103
|
+
const channel = __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_buildChannel).call(this, options);
|
|
104
|
+
const entry = __classPrivateFieldGet(this, _OHLCVService_channels, "f").get(channel);
|
|
105
|
+
if (entry?.gracePeriodTimer) {
|
|
106
|
+
clearTimeout(entry.gracePeriodTimer);
|
|
107
|
+
entry.gracePeriodTimer = undefined;
|
|
108
|
+
entry.refCount += 1;
|
|
109
|
+
log('Cancelled grace-period unsubscribe, bumped refCount', {
|
|
110
|
+
channel,
|
|
111
|
+
refCount: entry.refCount,
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (entry && entry.refCount > 0) {
|
|
116
|
+
entry.refCount += 1;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
await __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:connect');
|
|
121
|
+
if (__classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:channelHasSubscription', channel)) {
|
|
122
|
+
__classPrivateFieldGet(this, _OHLCVService_channels, "f").set(channel, { refCount: 1 });
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
await __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:subscribe', {
|
|
126
|
+
channels: [channel],
|
|
127
|
+
channelType: SUBSCRIPTION_NAMESPACE,
|
|
128
|
+
callback: (notification) => {
|
|
129
|
+
__classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_handleBarUpdate).call(this, channel, notification);
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
__classPrivateFieldGet(this, _OHLCVService_channels, "f").set(channel, { refCount: 1 });
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
log('Subscription failed, forcing reconnection', { channel, error });
|
|
136
|
+
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:subscriptionError', {
|
|
137
|
+
channel,
|
|
138
|
+
error: String(error),
|
|
139
|
+
operation: 'subscribe',
|
|
140
|
+
});
|
|
141
|
+
await __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_forceReconnection).call(this);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Unsubscribe from an OHLCV channel. Decrements the reference count and,
|
|
146
|
+
* when it reaches zero, starts a grace-period timer before actually
|
|
147
|
+
* unsubscribing from the WebSocket to absorb rapid navigation patterns.
|
|
148
|
+
*
|
|
149
|
+
* @param options - The subscription parameters to unsubscribe from.
|
|
150
|
+
*/
|
|
151
|
+
async unsubscribe(options) {
|
|
152
|
+
const channel = __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_buildChannel).call(this, options);
|
|
153
|
+
const entry = __classPrivateFieldGet(this, _OHLCVService_channels, "f").get(channel);
|
|
154
|
+
if (!entry || entry.refCount <= 0) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
entry.refCount -= 1;
|
|
158
|
+
if (entry.refCount > 0) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
entry.gracePeriodTimer = setTimeout(() => {
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
163
|
+
__classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_performUnsubscribe).call(this, channel);
|
|
164
|
+
}, GRACE_PERIOD_MS);
|
|
165
|
+
}
|
|
166
|
+
// =============================================================================
|
|
167
|
+
// Public — Cleanup
|
|
168
|
+
// =============================================================================
|
|
169
|
+
/**
|
|
170
|
+
* Destroy the service and clean up all resources.
|
|
171
|
+
*/
|
|
172
|
+
destroy() {
|
|
173
|
+
for (const entry of __classPrivateFieldGet(this, _OHLCVService_channels, "f").values()) {
|
|
174
|
+
if (entry.gracePeriodTimer) {
|
|
175
|
+
clearTimeout(entry.gracePeriodTimer);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
__classPrivateFieldGet(this, _OHLCVService_channels, "f").clear();
|
|
179
|
+
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:removeChannelCallback', SYSTEM_NOTIFICATIONS_CHANNEL);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
_OHLCVService_messenger = new WeakMap(), _OHLCVService_trace = new WeakMap(), _OHLCVService_channels = new WeakMap(), _OHLCVService_chainsUp = new WeakMap(), _OHLCVService_instances = new WeakSet(), _OHLCVService_performUnsubscribe =
|
|
183
|
+
// =============================================================================
|
|
184
|
+
// Private — WebSocket Subscription Helpers
|
|
185
|
+
// =============================================================================
|
|
186
|
+
async function _OHLCVService_performUnsubscribe(channel) {
|
|
187
|
+
__classPrivateFieldGet(this, _OHLCVService_channels, "f").delete(channel);
|
|
188
|
+
try {
|
|
189
|
+
const subscriptions = __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:getSubscriptionsByChannel', channel);
|
|
190
|
+
for (const sub of subscriptions) {
|
|
191
|
+
await sub.unsubscribe();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
log('Unsubscription failed, forcing reconnection', { channel, error });
|
|
196
|
+
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:subscriptionError', {
|
|
197
|
+
channel,
|
|
198
|
+
error: String(error),
|
|
199
|
+
operation: 'unsubscribe',
|
|
200
|
+
});
|
|
201
|
+
await __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_forceReconnection).call(this);
|
|
202
|
+
}
|
|
203
|
+
}, _OHLCVService_resubscribeActiveChannels =
|
|
204
|
+
/**
|
|
205
|
+
* Resubscribe all channels that were active before a disconnect.
|
|
206
|
+
* Called when WebSocket transitions to CONNECTED.
|
|
207
|
+
*/
|
|
208
|
+
async function _OHLCVService_resubscribeActiveChannels() {
|
|
209
|
+
for (const [channel, entry] of __classPrivateFieldGet(this, _OHLCVService_channels, "f").entries()) {
|
|
210
|
+
if (entry.refCount <= 0 && !entry.gracePeriodTimer) {
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
if (__classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:channelHasSubscription', channel)) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
await __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:subscribe', {
|
|
218
|
+
channels: [channel],
|
|
219
|
+
channelType: SUBSCRIPTION_NAMESPACE,
|
|
220
|
+
callback: (notification) => {
|
|
221
|
+
__classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_handleBarUpdate).call(this, channel, notification);
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
log('Resubscription failed for channel', { channel, error });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}, _OHLCVService_handleBarUpdate = function _OHLCVService_handleBarUpdate(channel, notification) {
|
|
230
|
+
const bar = notification.data;
|
|
231
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
232
|
+
__classPrivateFieldGet(this, _OHLCVService_trace, "f").call(this, {
|
|
233
|
+
name: `${SERVICE_NAME} Bar Update`,
|
|
234
|
+
data: { channel, timestamp: bar.timestamp },
|
|
235
|
+
tags: { service: SERVICE_NAME },
|
|
236
|
+
}, () => {
|
|
237
|
+
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:barUpdated', { channel, bar });
|
|
238
|
+
});
|
|
239
|
+
}, _OHLCVService_handleSystemNotification = function _OHLCVService_handleSystemNotification(notification) {
|
|
240
|
+
const data = notification.data;
|
|
241
|
+
const { timestamp } = notification;
|
|
242
|
+
if (!data.chainIds || !Array.isArray(data.chainIds) || !data.status) {
|
|
243
|
+
throw new Error('Invalid system notification data: missing chainIds or status');
|
|
244
|
+
}
|
|
245
|
+
if (data.status === 'up') {
|
|
246
|
+
for (const chainId of data.chainIds) {
|
|
247
|
+
__classPrivateFieldGet(this, _OHLCVService_chainsUp, "f").add(chainId);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
for (const chainId of data.chainIds) {
|
|
252
|
+
__classPrivateFieldGet(this, _OHLCVService_chainsUp, "f").delete(chainId);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:chainStatusChanged', {
|
|
256
|
+
chainIds: data.chainIds,
|
|
257
|
+
status: data.status,
|
|
258
|
+
timestamp,
|
|
259
|
+
});
|
|
260
|
+
log(`Chain status change: ${data.status}`, {
|
|
261
|
+
chains: data.chainIds,
|
|
262
|
+
status: data.status,
|
|
263
|
+
});
|
|
264
|
+
}, _OHLCVService_handleWebSocketStateChange = async function _OHLCVService_handleWebSocketStateChange(connectionInfo) {
|
|
265
|
+
const { state } = connectionInfo;
|
|
266
|
+
if (state === WebSocketState.CONNECTED) {
|
|
267
|
+
await __classPrivateFieldGet(this, _OHLCVService_instances, "m", _OHLCVService_resubscribeActiveChannels).call(this);
|
|
268
|
+
}
|
|
269
|
+
else if (state === WebSocketState.DISCONNECTED) {
|
|
270
|
+
const chainsToMarkDown = Array.from(__classPrivateFieldGet(this, _OHLCVService_chainsUp, "f"));
|
|
271
|
+
if (chainsToMarkDown.length > 0) {
|
|
272
|
+
__classPrivateFieldGet(this, _OHLCVService_messenger, "f").publish('OHLCVService:chainStatusChanged', {
|
|
273
|
+
chainIds: chainsToMarkDown,
|
|
274
|
+
status: 'down',
|
|
275
|
+
timestamp: Date.now(),
|
|
276
|
+
});
|
|
277
|
+
log('WebSocket disconnection - marked tracked chains as down', {
|
|
278
|
+
count: chainsToMarkDown.length,
|
|
279
|
+
chains: chainsToMarkDown,
|
|
280
|
+
});
|
|
281
|
+
__classPrivateFieldGet(this, _OHLCVService_chainsUp, "f").clear();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}, _OHLCVService_buildChannel = function _OHLCVService_buildChannel(options) {
|
|
285
|
+
return `${SUBSCRIPTION_NAMESPACE}.${options.assetId}.${options.interval}.${options.currency}`;
|
|
286
|
+
}, _OHLCVService_forceReconnection = async function _OHLCVService_forceReconnection() {
|
|
287
|
+
log('Forcing WebSocket reconnection');
|
|
288
|
+
await __classPrivateFieldGet(this, _OHLCVService_messenger, "f").call('BackendWebSocketService:forceReconnection');
|
|
289
|
+
};
|
|
290
|
+
//# sourceMappingURL=OHLCVService.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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,2BAA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C,CAAC;QAEpD,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,uBAAA,IAAI,+BAAW,CAAC,OAAO,CAAC,iCAAiC,EAAE;gBACzD,QAAQ,EAAE,gBAAgB;gBAC1B,MAAM,EAAE,MAAM;gBACd,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC,CAAC;YAEH,GAAG,CAAC,yDAAyD,EAAE;gBAC7D,KAAK,EAAE,gBAAgB,CAAC,MAAM;gBAC9B,MAAM,EAAE,gBAAgB;aACzB,CAAC,CAAC;YAEH,uBAAA,IAAI,8BAAU,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;IACH,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,gCAAgC,CAAC,CAAC;IACtC,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 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('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 try {\n await this.#messenger.call('BackendWebSocketService:connect');\n\n if (\n this.#messenger.call(\n 'BackendWebSocketService:channelHasSubscription',\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 } catch (error) {\n log('Subscription failed, forcing reconnection', { channel, error });\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 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 } catch (error) {\n log('Unsubscription failed, forcing reconnection', { channel, error });\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 for (const [channel, entry] of this.#channels.entries()) {\n if (entry.refCount <= 0 && !entry.gracePeriodTimer) {\n continue;\n }\n\n try {\n if (\n this.#messenger.call(\n 'BackendWebSocketService:channelHasSubscription',\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 } catch (error) {\n log('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(`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('WebSocket disconnection - marked tracked chains as down', {\n count: chainsToMarkDown.length,\n chains: chainsToMarkDown,\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('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"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AccountActivityService-method-action-types.cjs","sourceRoot":"","sources":["../src/AccountActivityService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AccountActivityService } from './AccountActivityService';\n\n/**\n * Subscribe to account activity (transactions and balance updates)\n * Address should be in CAIP-10 format (e.g., \"eip155:0:0x1234...\" or \"solana:0:ABC123...\")\n *\n * @param subscription - Account subscription configuration with address\n */\nexport type AccountActivityServiceSubscribeAction = {\n type: `AccountActivityService:subscribe`;\n handler: AccountActivityService['subscribe'];\n};\n\n/**\n * Unsubscribe from account activity for specified address\n * Address should be in CAIP-10 format (e.g., \"eip155:0:0x1234...\" or \"solana:0:ABC123...\")\n *\n * @param subscription - Account subscription configuration with address to unsubscribe\n */\nexport type AccountActivityServiceUnsubscribeAction = {\n type: `AccountActivityService:unsubscribe`;\n handler: AccountActivityService['unsubscribe'];\n};\n\n/**\n * Union of all AccountActivityService action types.\n */\nexport type AccountActivityServiceMethodActions =\n | AccountActivityServiceSubscribeAction\n | AccountActivityServiceUnsubscribeAction;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AccountActivityService-method-action-types.d.cts","sourceRoot":"","sources":["../src/AccountActivityService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,qCAAiC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,sBAAsB,CAAC,WAAW,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAC3C,qCAAqC,GACrC,uCAAuC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AccountActivityService-method-action-types.d.mts","sourceRoot":"","sources":["../src/AccountActivityService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,qCAAiC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,sBAAsB,CAAC,WAAW,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAC3C,qCAAqC,GACrC,uCAAuC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AccountActivityService-method-action-types.mjs","sourceRoot":"","sources":["../src/AccountActivityService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AccountActivityService } from './AccountActivityService';\n\n/**\n * Subscribe to account activity (transactions and balance updates)\n * Address should be in CAIP-10 format (e.g., \"eip155:0:0x1234...\" or \"solana:0:ABC123...\")\n *\n * @param subscription - Account subscription configuration with address\n */\nexport type AccountActivityServiceSubscribeAction = {\n type: `AccountActivityService:subscribe`;\n handler: AccountActivityService['subscribe'];\n};\n\n/**\n * Unsubscribe from account activity for specified address\n * Address should be in CAIP-10 format (e.g., \"eip155:0:0x1234...\" or \"solana:0:ABC123...\")\n *\n * @param subscription - Account subscription configuration with address to unsubscribe\n */\nexport type AccountActivityServiceUnsubscribeAction = {\n type: `AccountActivityService:unsubscribe`;\n handler: AccountActivityService['unsubscribe'];\n};\n\n/**\n * Union of all AccountActivityService action types.\n */\nexport type AccountActivityServiceMethodActions =\n | AccountActivityServiceSubscribeAction\n | AccountActivityServiceUnsubscribeAction;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AccountActivityService.cjs","sourceRoot":"","sources":["../src/AccountActivityService.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;AAgBH,2EAA2D;AAE3D,yCAA6D;AAuB7D,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAE9C,MAAM,GAAG,GAAG,IAAA,2BAAkB,EAAC,sBAAa,EAAE,YAAY,CAAC,CAAC;AAE5D,MAAM,yBAAyB,GAAG,CAAC,WAAW,EAAE,aAAa,CAAU,CAAC;AAExE,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AA0BrD,4EAA4E;AAC/D,QAAA,wCAAwC,GAAG;IACtD,uCAAuC;IACvC,iCAAiC;IACjC,2CAA2C;IAC3C,mCAAmC;IACnC,2CAA2C;IAC3C,gDAAgD;IAChD,mDAAmD;IACnD,0DAA0D;IAC1D,4CAA4C;IAC5C,+CAA+C;CACvC,CAAC;AAEX,2DAA2D;AAC9C,QAAA,uCAAuC,GAAG;IACrD,0CAA0C;IAC1C,gDAAgD;CACxC,CAAC;AAkDX,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAa,sBAAsB;IAejC,gFAAgF;IAChF,iCAAiC;IACjC,gFAAgF;IAEhF;;;;OAIG;IACH,YACE,OAEC;;QA1BH;;WAEG;QACM,SAAI,GAAG,YAAY,CAAC;QAEpB,oDAA4C;QAE5C,kDAAmE;QAEnE,gDAAsB;QAE/B,qEAAqE;QAC5D,2CAAyB,IAAI,GAAG,EAAE,EAAC;QAgB1C,uBAAA,IAAI,qCAAc,OAAO,CAAC,SAAS,MAAA,CAAC;QAEpC,kCAAkC;QAClC,uBAAA,IAAI,mCAAY;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CAAC,CAAC,EAAE,CAAC;QAChE,oEAAoE;QACpE,OAAO,YAAY,OAAO,CAAC,OAAO,EAAE,CAAC;IACvC,CAAC;IAED,yDAAyD;IACzD,OAAO,OAAO,CAAC,OAAO,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,KAAK;IACH,GAAG,CAAC,+DAA+D,CAAC,CAAC;IAErE,yEAAyE;IACzE,kEAAkE;IAClE,MAAM,uBAAA,IAAI,yCAAW,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/**\n * Account Activity Service for monitoring account transactions and balance changes\n *\n * This service subscribes to account activity and receives all transactions\n * and balance updates for those accounts via the comprehensive AccountActivityMessage format.\n */\n\nimport type {\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerSelectedAccountChangeEvent,\n} from '@metamask/accounts-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { AccountActivityServiceMethodActions } from './AccountActivityService-method-action-types';\nimport type {\n WebSocketConnectionInfo,\n BackendWebSocketServiceConnectionStateChangedEvent,\n ServerNotificationMessage,\n} from './BackendWebSocketService';\nimport { WebSocketState } from './BackendWebSocketService';\nimport type { BackendWebSocketServiceMethodActions } from './BackendWebSocketService-method-action-types';\nimport { projectLogger, createModuleLogger } from './logger';\nimport type {\n Transaction,\n AccountActivityMessage,\n BalanceUpdate,\n} from './types';\n\n// =============================================================================\n// Types and Constants\n// =============================================================================\n\n/**\n * System notification data for chain status updates\n */\nexport type SystemNotificationData = {\n /** Array of chain IDs affected (e.g., ['eip155:137', 'eip155:1']) */\n chainIds: string[];\n /** Status of the chains: 'down' or 'up' */\n status: 'down' | 'up';\n /** Timestamp of the notification */\n timestamp?: number;\n};\n\nconst SERVICE_NAME = 'AccountActivityService';\n\nconst log = createModuleLogger(projectLogger, SERVICE_NAME);\n\nconst MESSENGER_EXPOSED_METHODS = ['subscribe', 'unsubscribe'] as const;\n\nconst SUBSCRIPTION_NAMESPACE = 'account-activity.v1';\n\n/**\n * Account subscription options\n */\nexport type SubscriptionOptions = {\n address: string; // Should be in CAIP-10 format, e.g., \"eip155:0:0x1234...\" or \"solana:0:ABC123...\"\n};\n\n/**\n * Configuration options for the account activity service\n */\nexport type AccountActivityServiceOptions = {\n /** Custom subscription namespace (default: 'account-activity.v1') */\n subscriptionNamespace?: string;\n /** Optional callback to trace performance of account activity operations (default: no-op) */\n traceFn?: TraceCallback;\n};\n\n// =============================================================================\n// Action and Event Types\n// =============================================================================\n\n// Action types for the messaging system - using generated method actions\nexport type AccountActivityServiceActions = AccountActivityServiceMethodActions;\n\n// Allowed actions that AccountActivityService can call on other controllers\nexport const ACCOUNT_ACTIVITY_SERVICE_ALLOWED_ACTIONS = [\n 'AccountsController:getSelectedAccount',\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\n// Allowed events that AccountActivityService can listen to\nexport const ACCOUNT_ACTIVITY_SERVICE_ALLOWED_EVENTS = [\n 'AccountsController:selectedAccountChange',\n 'BackendWebSocketService:connectionStateChanged',\n] as const;\n\nexport type AllowedActions =\n | AccountsControllerGetSelectedAccountAction\n | BackendWebSocketServiceMethodActions;\n\n// Event types for the messaging system\n\nexport type AccountActivityServiceTransactionUpdatedEvent = {\n type: `AccountActivityService:transactionUpdated`;\n payload: [Transaction];\n};\n\nexport type AccountActivityServiceBalanceUpdatedEvent = {\n type: `AccountActivityService:balanceUpdated`;\n payload: [{ address: string; chain: string; updates: BalanceUpdate[] }];\n};\n\nexport type AccountActivityServiceSubscriptionErrorEvent = {\n type: `AccountActivityService:subscriptionError`;\n payload: [{ addresses: string[]; error: string; operation: string }];\n};\n\nexport type AccountActivityServiceStatusChangedEvent = {\n type: `AccountActivityService:statusChanged`;\n payload: [\n {\n chainIds: string[];\n status: 'up' | 'down';\n timestamp?: number;\n },\n ];\n};\n\nexport type AccountActivityServiceEvents =\n | AccountActivityServiceTransactionUpdatedEvent\n | AccountActivityServiceBalanceUpdatedEvent\n | AccountActivityServiceSubscriptionErrorEvent\n | AccountActivityServiceStatusChangedEvent;\n\nexport type AllowedEvents =\n | AccountsControllerSelectedAccountChangeEvent\n | BackendWebSocketServiceConnectionStateChangedEvent;\n\nexport type AccountActivityServiceMessenger = Messenger<\n typeof SERVICE_NAME,\n AccountActivityServiceActions | AllowedActions,\n AccountActivityServiceEvents | AllowedEvents\n>;\n\n// =============================================================================\n// Main Service Class\n// =============================================================================\n\n/**\n * High-performance service for real-time account activity monitoring using optimized\n * WebSocket subscriptions with direct callback routing. Automatically subscribes to\n * the currently selected account and switches subscriptions when the selected account changes.\n * Receives transactions and balance updates using the comprehensive AccountActivityMessage format.\n *\n * Performance Features:\n * - Direct callback routing (no EventEmitter overhead)\n * - Minimal subscription tracking (no duplication with BackendWebSocketService)\n * - Optimized cleanup for mobile environments\n * - Single-account subscription (only selected account)\n * - Comprehensive balance updates with transfer tracking\n *\n * Architecture:\n * - Uses messenger pattern to communicate with BackendWebSocketService\n * - AccountActivityService tracks channel-to-subscriptionId mappings via messenger calls\n * - Automatically subscribes to selected account on initialization\n * - Switches subscriptions when selected account changes\n * - No direct dependency on BackendWebSocketService (uses messenger instead)\n *\n * @example\n * ```typescript\n * const service = new AccountActivityService({\n * messenger: activityMessenger,\n * });\n *\n * // Service automatically subscribes to the currently selected account\n * // When user switches accounts, service automatically resubscribes\n *\n * // All transactions and balance updates are received via optimized\n * // WebSocket callbacks and processed with zero-allocation routing\n * // Balance updates include comprehensive transfer details and post-transaction balances\n * ```\n */\nexport class AccountActivityService {\n /**\n * The name of the service.\n */\n readonly name = SERVICE_NAME;\n\n readonly #messenger: AccountActivityServiceMessenger;\n\n readonly #options: Required<Omit<AccountActivityServiceOptions, 'traceFn'>>;\n\n readonly #trace: TraceCallback;\n\n // Track chains that are currently up (based on system notifications)\n readonly #chainsUp: Set<string> = new Set();\n\n // =============================================================================\n // Constructor and Initialization\n // =============================================================================\n\n /**\n * Creates a new Account Activity service instance\n *\n * @param options - Configuration options including messenger\n */\n constructor(\n options: AccountActivityServiceOptions & {\n messenger: AccountActivityServiceMessenger;\n },\n ) {\n this.#messenger = options.messenger;\n\n // Set configuration with defaults\n this.#options = {\n subscriptionNamespace:\n options.subscriptionNamespace ?? SUBSCRIPTION_NAMESPACE,\n };\n\n // Default to no-op trace function to keep core platform-agnostic\n this.#trace =\n options.traceFn ??\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (((_request: any, fn?: any) => fn?.()) as TraceCallback);\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n this.#messenger.subscribe(\n 'AccountsController:selectedAccountChange',\n // Promise result intentionally not awaited\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (account: InternalAccount) =>\n await this.#handleSelectedAccountChange(account),\n );\n this.#messenger.subscribe(\n 'BackendWebSocketService:connectionStateChanged',\n // Promise result intentionally not awaited\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n (connectionInfo: WebSocketConnectionInfo) =>\n this.#handleWebSocketStateChange(connectionInfo),\n );\n this.#messenger.call('BackendWebSocketService:addChannelCallback', {\n channelName: `system-notifications.v1.${this.#options.subscriptionNamespace}`,\n callback: (notification: ServerNotificationMessage) =>\n this.#handleSystemNotification(notification),\n });\n }\n\n // =============================================================================\n // Account Subscription Methods\n // =============================================================================\n\n /**\n * Subscribe to account activity (transactions and balance updates)\n * Address should be in CAIP-10 format (e.g., \"eip155:0:0x1234...\" or \"solana:0:ABC123...\")\n *\n * @param subscription - Account subscription configuration with address\n */\n async subscribe(subscription: SubscriptionOptions): Promise<void> {\n try {\n await this.#messenger.call('BackendWebSocketService:connect');\n\n // Create channel name from address\n const channel = `${this.#options.subscriptionNamespace}.${subscription.address}`;\n\n // Check if already subscribed\n if (\n this.#messenger.call(\n 'BackendWebSocketService:channelHasSubscription',\n channel,\n )\n ) {\n return;\n }\n\n // Create subscription using the proper subscribe method (this will be stored in WebSocketService's internal tracking)\n await this.#messenger.call('BackendWebSocketService:subscribe', {\n channels: [channel],\n channelType: this.#options.subscriptionNamespace, // e.g., 'account-activity.v1'\n callback: (notification: ServerNotificationMessage) => {\n this.#handleAccountActivityUpdate(\n notification.data as AccountActivityMessage,\n );\n },\n });\n } catch (error) {\n log('Subscription failed, forcing reconnection', { error });\n await this.#forceReconnection();\n }\n }\n\n /**\n * Unsubscribe from account activity for specified address\n * Address should be in CAIP-10 format (e.g., \"eip155:0:0x1234...\" or \"solana:0:ABC123...\")\n *\n * @param subscription - Account subscription configuration with address to unsubscribe\n */\n async unsubscribe(subscription: SubscriptionOptions): Promise<void> {\n const { address } = subscription;\n try {\n // Find channel for the specified address\n const channel = `${this.#options.subscriptionNamespace}.${address}`;\n const subscriptions = this.#messenger.call(\n 'BackendWebSocketService:getSubscriptionsByChannel',\n channel,\n );\n\n if (subscriptions.length === 0) {\n return;\n }\n\n // Fast path: Direct unsubscribe using stored unsubscribe function\n // Unsubscribe from all matching subscriptions\n for (const subscriptionInfo of subscriptions) {\n await subscriptionInfo.unsubscribe();\n }\n } catch (error) {\n log('Unsubscription failed, forcing reconnection', { error });\n await this.#forceReconnection();\n }\n }\n\n // =============================================================================\n // Private Methods - Event Handlers\n // =============================================================================\n\n /**\n * Handle account activity updates (transactions + balance changes)\n * Processes the comprehensive AccountActivityMessage format with detailed balance updates and transfers\n *\n * @param payload - The account activity message containing transaction and balance updates\n * @example AccountActivityMessage format handling:\n * Input: {\n * address: \"0xd14b52362b5b777ffa754c666ddec6722aaeee08\",\n * tx: { id: \"0x1cde...\", chain: \"eip155:8453\", status: \"confirmed\", timestamp: 1760099871, ... },\n * updates: [{\n * asset: { fungible: true, type: \"eip155:8453/erc20:0x833...\", unit: \"USDC\", decimals: 6 },\n * postBalance: { amount: \"0xc350\" },\n * transfers: [{ from: \"0x7b07...\", to: \"0xd14b...\", amount: \"0x2710\" }]\n * }]\n * }\n * Output: Transaction and balance updates published separately\n */\n #handleAccountActivityUpdate(payload: AccountActivityMessage): void {\n const { address, tx, updates } = payload;\n\n // Calculate time elapsed between transaction time and message receipt\n const txTimestampMs = tx.timestamp * 1000; // Convert Unix timestamp (seconds) to milliseconds\n const elapsedMs = Date.now() - txTimestampMs;\n\n log('Handling account activity update', {\n address,\n updateCount: updates.length,\n elapsedMs,\n });\n\n // Trace message receipt with latency from transaction time to now\n // Promise result intentionally not awaited\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#trace(\n {\n name: `${SERVICE_NAME} Transaction Message`,\n data: {\n chain: tx.chain,\n status: tx.status,\n elapsed_ms: elapsedMs,\n },\n tags: {\n service: SERVICE_NAME,\n notification_type: this.#options.subscriptionNamespace,\n },\n },\n () => {\n // Process transaction update\n this.#messenger.publish(\n `AccountActivityService:transactionUpdated`,\n tx,\n );\n\n // Publish comprehensive balance updates with transfer details\n this.#messenger.publish(`AccountActivityService:balanceUpdated`, {\n address,\n chain: tx.chain,\n updates,\n });\n },\n );\n }\n\n /**\n * Handle selected account change event\n *\n * @param newAccount - The newly selected account\n */\n async #handleSelectedAccountChange(\n newAccount: InternalAccount | null,\n ): Promise<void> {\n if (!newAccount?.address) {\n return;\n }\n\n try {\n // Convert new account to CAIP-10 format\n const newAddress = this.#convertToCaip10Address(newAccount);\n\n // First, unsubscribe from all current account activity subscriptions to avoid multiple subscriptions\n await this.#unsubscribeFromAllAccountActivity();\n\n // Then, subscribe to the new selected account\n await this.subscribe({ address: newAddress });\n } catch (error) {\n log('Account change failed', { error });\n }\n }\n\n /**\n * Handle system notification for chain status changes\n * Publishes only the status change (delta) for affected chains\n *\n * @param notification - Server notification message containing chain status updates and timestamp\n */\n #handleSystemNotification(notification: ServerNotificationMessage): void {\n const data = notification.data as SystemNotificationData;\n const { timestamp } = notification;\n\n // Validate required fields\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 // Track chain status\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 // Publish status change directly (delta update)\n this.#messenger.publish(`AccountActivityService:statusChanged`, {\n chainIds: data.chainIds,\n status: data.status,\n timestamp,\n });\n\n log(\n `WebSocket status change - Published tracked chains as ${data.status}`,\n {\n count: data.chainIds.length,\n chains: data.chainIds,\n status: data.status,\n },\n );\n }\n\n /**\n * Handle WebSocket connection state changes for fallback polling and resubscription\n *\n * @param connectionInfo - WebSocket connection state information\n */\n async #handleWebSocketStateChange(\n connectionInfo: WebSocketConnectionInfo,\n ): Promise<void> {\n const { state } = connectionInfo;\n\n if (state === WebSocketState.CONNECTED) {\n // WebSocket connected - resubscribe to selected account\n // The system notification will automatically provide the list of chains that are up\n await this.#subscribeToSelectedAccount();\n } else if (state === WebSocketState.DISCONNECTED) {\n // On disconnect, flush all tracked chains as down\n const chainsToMarkDown = Array.from(this.#chainsUp);\n\n if (chainsToMarkDown.length > 0) {\n this.#messenger.publish(`AccountActivityService:statusChanged`, {\n chainIds: chainsToMarkDown,\n status: 'down',\n timestamp: Date.now(),\n });\n\n log('WebSocket disconnection - Published tracked chains as down', {\n count: chainsToMarkDown.length,\n chains: chainsToMarkDown,\n });\n\n // Clear the tracking set since all chains are now down\n this.#chainsUp.clear();\n }\n }\n }\n\n // =============================================================================\n // Private Methods - Subscription Management\n // =============================================================================\n\n /**\n * Subscribe to the currently selected account only\n */\n async #subscribeToSelectedAccount(): Promise<void> {\n const selectedAccount = this.#messenger.call(\n 'AccountsController:getSelectedAccount',\n );\n\n if (!selectedAccount?.address) {\n return;\n }\n\n // Convert to CAIP-10 format and subscribe\n const address = this.#convertToCaip10Address(selectedAccount);\n await this.subscribe({ address });\n }\n\n /**\n * Unsubscribe from all account activity subscriptions for this service\n * Finds all channels matching the service's namespace and unsubscribes from them\n */\n async #unsubscribeFromAllAccountActivity(): Promise<void> {\n const accountActivitySubscriptions = this.#messenger.call(\n 'BackendWebSocketService:findSubscriptionsByChannelPrefix',\n this.#options.subscriptionNamespace,\n );\n\n // Unsubscribe from all matching subscriptions\n for (const subscription of accountActivitySubscriptions) {\n await subscription.unsubscribe();\n }\n }\n\n // =============================================================================\n // Private Methods - Utility Functions\n // =============================================================================\n\n /**\n * Convert an InternalAccount address to CAIP-10 format or raw address\n *\n * @param account - The internal account to convert\n * @returns The CAIP-10 formatted address or raw address\n */\n #convertToCaip10Address(account: InternalAccount): string {\n // Check if account has EVM scopes\n if (account.scopes.some((scope) => scope.startsWith('eip155:'))) {\n // CAIP-10 format: eip155:0:address (subscribe to all EVM chains)\n return `eip155:0:${account.address}`;\n }\n\n // Check if account has Solana scopes\n if (account.scopes.some((scope) => scope.startsWith('solana:'))) {\n // CAIP-10 format: solana:0:address (subscribe to all Solana chains)\n return `solana:0:${account.address}`;\n }\n\n // For other chains or unknown scopes, return raw address\n return account.address;\n }\n\n /**\n * Force WebSocket reconnection to clean up subscription state\n */\n async #forceReconnection(): Promise<void> {\n log('Forcing WebSocket reconnection to clean up subscription state');\n\n // Use the dedicated forceReconnection method which performs a controlled\n // disconnect-then-connect sequence to clean up subscription state\n await this.#messenger.call('BackendWebSocketService:forceReconnection');\n }\n\n // =============================================================================\n // Public Methods - Cleanup\n // =============================================================================\n\n /**\n * Destroy the service and clean up all resources\n * Optimized for fast cleanup during service destruction or mobile app termination\n */\n destroy(): void {\n // Clean up system notification callback\n this.#messenger.call(\n 'BackendWebSocketService:removeChannelCallback',\n `system-notifications.v1.${this.#options.subscriptionNamespace}`,\n );\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-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