@metaflux-dex/client 0.0.1
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/LICENSE +21 -0
- package/README.md +157 -0
- package/dist/client.d.ts +32 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +344 -0
- package/dist/client.js.map +1 -0
- package/dist/http.d.ts +17 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +106 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/info-types.d.ts +380 -0
- package/dist/info-types.d.ts.map +1 -0
- package/dist/info-types.js +16 -0
- package/dist/info-types.js.map +1 -0
- package/dist/info.d.ts +65 -0
- package/dist/info.d.ts.map +1 -0
- package/dist/info.js +252 -0
- package/dist/info.js.map +1 -0
- package/dist/native.d.ts +10 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +252 -0
- package/dist/native.js.map +1 -0
- package/dist/types.d.ts +143 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/wasm.d.ts +28 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +279 -0
- package/dist/wasm.js.map +1 -0
- package/dist/ws.d.ts +43 -0
- package/dist/ws.d.ts.map +1 -0
- package/dist/ws.js +221 -0
- package/dist/ws.js.map +1 -0
- package/package.json +65 -0
- package/src/client.ts +454 -0
- package/src/http.ts +153 -0
- package/src/index.ts +144 -0
- package/src/info-types.ts +783 -0
- package/src/info.ts +355 -0
- package/src/native.ts +307 -0
- package/src/types.ts +305 -0
- package/src/wasm.ts +384 -0
- package/src/ws.ts +279 -0
package/dist/ws.js
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// MTF-native WebSocket client — connect, subscribe/unsubscribe, typed frames.
|
|
2
|
+
//
|
|
3
|
+
// Mirrors the Rust SDK's `WsClient` behavior (reconnect with backoff, replay of
|
|
4
|
+
// active subscriptions, heartbeat ping) and the SERVER wire protocol
|
|
5
|
+
// (`metaflux/crates/api-node/src/ws/subscribe.rs` + `fanout.rs`):
|
|
6
|
+
//
|
|
7
|
+
// client → server:
|
|
8
|
+
// {"method":"subscribe","subscription":{"type":"l2Book","coin":"BTC"}}
|
|
9
|
+
// {"method":"unsubscribe","subscription":{"type":"trades"}}
|
|
10
|
+
// {"method":"ping"}
|
|
11
|
+
// server → client:
|
|
12
|
+
// {"channel":"subscriptionResponse","data":{"method":"subscribe","subscription":{...}}}
|
|
13
|
+
// {"channel":"l2Book","data":{...}} | {"channel":"error","data":{"error":"..."}}
|
|
14
|
+
//
|
|
15
|
+
// Channel names are the EXACT server `Channel::wire_name()` strings (camelCase:
|
|
16
|
+
// `l2Book`, `userEvents`). `coin` is the market symbol string and is optional
|
|
17
|
+
// (e.g. `userEvents` carries none).
|
|
18
|
+
//
|
|
19
|
+
// Transport: the standard `WebSocket` global (browser-native; Node ≥ 22 ships
|
|
20
|
+
// it globally, which is the SDK's floor). No `ws` npm dependency — keeping the
|
|
21
|
+
// SDK dependency-free for both runtimes.
|
|
22
|
+
/// All known channels — handy for callers that want to subscribe broadly.
|
|
23
|
+
export const WS_CHANNELS = [
|
|
24
|
+
'l2Book',
|
|
25
|
+
'trades',
|
|
26
|
+
'bbo',
|
|
27
|
+
'fills',
|
|
28
|
+
'candles',
|
|
29
|
+
'userEvents',
|
|
30
|
+
];
|
|
31
|
+
const DEFAULT_CONFIG = {
|
|
32
|
+
pingIntervalMs: 30_000,
|
|
33
|
+
initialBackoffMs: 250,
|
|
34
|
+
maxBackoffMs: 30_000,
|
|
35
|
+
autoReconnect: true,
|
|
36
|
+
};
|
|
37
|
+
/// Subscription set equality key — `(channel, coin)` is the server's routing
|
|
38
|
+
/// key, so two subscriptions are identical iff both match.
|
|
39
|
+
function subKey(s) {
|
|
40
|
+
return `${s.type}:${s.coin ?? ''}`;
|
|
41
|
+
}
|
|
42
|
+
/// MTF-native WebSocket client.
|
|
43
|
+
///
|
|
44
|
+
/// Usage:
|
|
45
|
+
/// ```ts
|
|
46
|
+
/// const ws = new WsClient('wss://api.mtf.exchange/ws');
|
|
47
|
+
/// ws.onMessage((f) => { if (f.channel === 'l2Book') handleBook(f.data); });
|
|
48
|
+
/// await ws.connect();
|
|
49
|
+
/// await ws.subscribe({ type: 'l2Book', coin: 'BTC' });
|
|
50
|
+
/// // ... later
|
|
51
|
+
/// ws.close();
|
|
52
|
+
/// ```
|
|
53
|
+
///
|
|
54
|
+
/// `connect()` resolves once the socket is OPEN. Active subscriptions are
|
|
55
|
+
/// re-issued automatically after a reconnect. Drop with `close()`.
|
|
56
|
+
export class WsClient {
|
|
57
|
+
url;
|
|
58
|
+
config;
|
|
59
|
+
socket;
|
|
60
|
+
/// Active subscriptions, replayed on (re)connect. Keyed for dedupe.
|
|
61
|
+
active = new Map();
|
|
62
|
+
handlers = [];
|
|
63
|
+
pingTimer;
|
|
64
|
+
reconnectTimer;
|
|
65
|
+
backoffMs;
|
|
66
|
+
/// True once `close()` is called — suppresses auto-reconnect.
|
|
67
|
+
closed = false;
|
|
68
|
+
constructor(url, config = {}) {
|
|
69
|
+
if (url.length === 0) {
|
|
70
|
+
throw new RangeError('WsClient url must be non-empty');
|
|
71
|
+
}
|
|
72
|
+
this.url = url;
|
|
73
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
74
|
+
this.backoffMs = this.config.initialBackoffMs;
|
|
75
|
+
}
|
|
76
|
+
/// Register an inbound-frame handler. Multiple handlers fan out; each
|
|
77
|
+
/// receives every frame. Returns an unsubscribe function.
|
|
78
|
+
onMessage(handler) {
|
|
79
|
+
this.handlers.push(handler);
|
|
80
|
+
return () => {
|
|
81
|
+
const i = this.handlers.indexOf(handler);
|
|
82
|
+
if (i >= 0)
|
|
83
|
+
this.handlers.splice(i, 1);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/// Open the connection. Resolves when the socket reaches OPEN; rejects if the
|
|
87
|
+
/// initial connect errors. Subsequent reconnects (if `autoReconnect`) happen
|
|
88
|
+
/// transparently in the background.
|
|
89
|
+
async connect() {
|
|
90
|
+
this.closed = false;
|
|
91
|
+
await this.openOnce();
|
|
92
|
+
}
|
|
93
|
+
/// Subscribe to a channel. The subscription is recorded and replayed on
|
|
94
|
+
/// reconnect. Idempotent — a duplicate `(channel, coin)` is a no-op (matching
|
|
95
|
+
/// the server, which silently ignores duplicate subscribes).
|
|
96
|
+
async subscribe(sub) {
|
|
97
|
+
const key = subKey(sub);
|
|
98
|
+
if (!this.active.has(key)) {
|
|
99
|
+
this.active.set(key, sub);
|
|
100
|
+
}
|
|
101
|
+
this.send({ method: 'subscribe', subscription: sub });
|
|
102
|
+
}
|
|
103
|
+
/// Unsubscribe from a channel.
|
|
104
|
+
async unsubscribe(sub) {
|
|
105
|
+
this.active.delete(subKey(sub));
|
|
106
|
+
this.send({ method: 'unsubscribe', subscription: sub });
|
|
107
|
+
}
|
|
108
|
+
/// Whether the socket is currently OPEN.
|
|
109
|
+
get isOpen() {
|
|
110
|
+
return this.socket?.readyState === 1; // WebSocket.OPEN
|
|
111
|
+
}
|
|
112
|
+
/// Close the connection and cancel auto-reconnect. After `close()` the client
|
|
113
|
+
/// is inert until `connect()` is called again.
|
|
114
|
+
close() {
|
|
115
|
+
this.closed = true;
|
|
116
|
+
this.clearTimers();
|
|
117
|
+
if (this.socket !== undefined) {
|
|
118
|
+
try {
|
|
119
|
+
this.socket.close();
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// Already closing / closed.
|
|
123
|
+
}
|
|
124
|
+
this.socket = undefined;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// -------------------------------------------------------------------------
|
|
128
|
+
openOnce() {
|
|
129
|
+
return new Promise((resolve, reject) => {
|
|
130
|
+
let settled = false;
|
|
131
|
+
const sock = new WebSocket(this.url);
|
|
132
|
+
this.socket = sock;
|
|
133
|
+
sock.onopen = () => {
|
|
134
|
+
this.backoffMs = this.config.initialBackoffMs;
|
|
135
|
+
// Replay active subscriptions on (re)connect.
|
|
136
|
+
for (const sub of this.active.values()) {
|
|
137
|
+
this.send({ method: 'subscribe', subscription: sub });
|
|
138
|
+
}
|
|
139
|
+
this.startPing();
|
|
140
|
+
settled = true;
|
|
141
|
+
resolve();
|
|
142
|
+
};
|
|
143
|
+
sock.onmessage = (ev) => {
|
|
144
|
+
this.dispatch(typeof ev.data === 'string' ? ev.data : String(ev.data));
|
|
145
|
+
};
|
|
146
|
+
sock.onerror = () => {
|
|
147
|
+
if (!settled) {
|
|
148
|
+
settled = true;
|
|
149
|
+
reject(new Error(`WsClient failed to connect to ${this.url}`));
|
|
150
|
+
}
|
|
151
|
+
// Post-open errors are handled by onclose → reconnect.
|
|
152
|
+
};
|
|
153
|
+
sock.onclose = () => {
|
|
154
|
+
this.clearTimers();
|
|
155
|
+
this.socket = undefined;
|
|
156
|
+
if (!this.closed && this.config.autoReconnect) {
|
|
157
|
+
this.scheduleReconnect();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
scheduleReconnect() {
|
|
163
|
+
if (this.reconnectTimer !== undefined)
|
|
164
|
+
return;
|
|
165
|
+
const delay = this.backoffMs;
|
|
166
|
+
this.backoffMs = Math.min(this.backoffMs * 2, this.config.maxBackoffMs);
|
|
167
|
+
this.reconnectTimer = setTimeout(() => {
|
|
168
|
+
this.reconnectTimer = undefined;
|
|
169
|
+
if (this.closed)
|
|
170
|
+
return;
|
|
171
|
+
// Best-effort reconnect; failures retry via the next onclose.
|
|
172
|
+
void this.openOnce().catch(() => {
|
|
173
|
+
if (!this.closed && this.config.autoReconnect) {
|
|
174
|
+
this.scheduleReconnect();
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}, delay);
|
|
178
|
+
}
|
|
179
|
+
startPing() {
|
|
180
|
+
this.clearPing();
|
|
181
|
+
this.pingTimer = setInterval(() => {
|
|
182
|
+
this.send({ method: 'ping' });
|
|
183
|
+
}, this.config.pingIntervalMs);
|
|
184
|
+
}
|
|
185
|
+
send(obj) {
|
|
186
|
+
if (this.socket?.readyState === 1) {
|
|
187
|
+
this.socket.send(JSON.stringify(obj));
|
|
188
|
+
}
|
|
189
|
+
// If not open, the frame is dropped; subscribe state is replayed on the
|
|
190
|
+
// next open, so a dropped subscribe self-heals. A dropped ping is benign.
|
|
191
|
+
}
|
|
192
|
+
dispatch(raw) {
|
|
193
|
+
let frame;
|
|
194
|
+
try {
|
|
195
|
+
const parsed = JSON.parse(raw);
|
|
196
|
+
if (typeof parsed.channel !== 'string')
|
|
197
|
+
return; // ignore malformed
|
|
198
|
+
frame = { channel: parsed.channel, data: parsed.data };
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return; // ignore non-JSON frames
|
|
202
|
+
}
|
|
203
|
+
for (const h of this.handlers) {
|
|
204
|
+
h(frame);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
clearTimers() {
|
|
208
|
+
this.clearPing();
|
|
209
|
+
if (this.reconnectTimer !== undefined) {
|
|
210
|
+
clearTimeout(this.reconnectTimer);
|
|
211
|
+
this.reconnectTimer = undefined;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
clearPing() {
|
|
215
|
+
if (this.pingTimer !== undefined) {
|
|
216
|
+
clearInterval(this.pingTimer);
|
|
217
|
+
this.pingTimer = undefined;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=ws.js.map
|
package/dist/ws.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws.js","sourceRoot":"","sources":["../src/ws.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,EAAE;AACF,gFAAgF;AAChF,qEAAqE;AACrE,kEAAkE;AAClE,EAAE;AACF,qBAAqB;AACrB,2EAA2E;AAC3E,gEAAgE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,CAAC,KAAK,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACtC,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QAClC,CAAC;IACH,CAAC;IAEO,SAAS;QACf,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACjC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC7B,CAAC;IACH,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@metaflux-dex/client",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "MetaFlux (MTF) TypeScript client SDK — WASM-backed crypto + ESM-only fetch wrappers.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": "MetaFlux",
|
|
7
|
+
"homepage": "https://github.com/mtf-exchange/metaflux-client-typescript#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/mtf-exchange/metaflux-client-typescript.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/mtf-exchange/metaflux-client-typescript/issues"
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./wasm": {
|
|
23
|
+
"import": "./pkg/metaflux_client_wasm.js",
|
|
24
|
+
"types": "./pkg/metaflux_client_wasm.d.ts"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"pkg",
|
|
30
|
+
"src",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^22.0.0",
|
|
36
|
+
"eslint": "^9.0.0",
|
|
37
|
+
"typescript": "^5.4.0",
|
|
38
|
+
"vitest": "^2.0.0"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20.0.0"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"metaflux",
|
|
45
|
+
"mtf",
|
|
46
|
+
"dex",
|
|
47
|
+
"perp",
|
|
48
|
+
"client",
|
|
49
|
+
"sdk",
|
|
50
|
+
"wasm"
|
|
51
|
+
],
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build:wasm": "wasm-pack build wasm/ --target web --out-dir ../pkg",
|
|
58
|
+
"build:ts": "tsc",
|
|
59
|
+
"build": "pnpm run build:wasm && pnpm run build:ts",
|
|
60
|
+
"test": "vitest run",
|
|
61
|
+
"test:watch": "vitest",
|
|
62
|
+
"lint": "eslint src/ __tests__/",
|
|
63
|
+
"typecheck": "tsc --noEmit"
|
|
64
|
+
}
|
|
65
|
+
}
|