@alpha-arcade/sdk 0.4.0 → 0.4.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/README.md CHANGED
@@ -341,6 +341,27 @@ for (const m of rewardMarkets) {
341
341
 
342
342
  Real-time data streams via WebSocket. No API key or auth required. Replaces polling with push-based updates.
343
343
 
344
+ The SDK connects to the public platform websocket at `wss://wss.platform.alphaarcade.com`. The first
345
+ subscription is sent in the connection query string, and any later subscribe or unsubscribe calls use the
346
+ server's control-message envelope:
347
+
348
+ ```json
349
+ {
350
+ "id": "request-id",
351
+ "method": "SUBSCRIBE",
352
+ "params": [
353
+ { "stream": "get-orderbook", "slug": "will-btc-hit-100k" }
354
+ ]
355
+ }
356
+ ```
357
+
358
+ Supported public streams:
359
+
360
+ - `get-live-markets`
361
+ - `get-market` with `slug`
362
+ - `get-orderbook` with `slug`
363
+ - `get-wallet-orders` with `wallet`
364
+
344
365
  ```typescript
345
366
  import { AlphaWebSocket } from '@alpha-arcade/sdk';
346
367
 
@@ -429,7 +450,7 @@ unsub();
429
450
  // List active subscriptions on this connection
430
451
  const subs = await ws.listSubscriptions();
431
452
 
432
- // Query server properties
453
+ // Query server properties (`heartbeat` or `limits`)
433
454
  const props = await ws.getProperty('heartbeat');
434
455
  ```
435
456
 
package/dist/index.cjs CHANGED
@@ -3446,7 +3446,7 @@ var AlphaWebSocket = class {
3446
3446
  }
3447
3447
  /** Query a server property (e.g. "heartbeat", "limits") */
3448
3448
  getProperty(property) {
3449
- return this.sendRequest({ method: "GET_PROPERTY", property });
3449
+ return this.sendRequest({ method: "GET_PROPERTY", params: [property] });
3450
3450
  }
3451
3451
  // ============================================
3452
3452
  // Lifecycle
@@ -3546,9 +3546,10 @@ var AlphaWebSocket = class {
3546
3546
  this.send({ method: "PONG" });
3547
3547
  return;
3548
3548
  }
3549
- if (msg.requestId && this.pendingRequests.has(msg.requestId)) {
3550
- const req = this.pendingRequests.get(msg.requestId);
3551
- this.pendingRequests.delete(msg.requestId);
3549
+ const responseId = typeof msg.id === "string" ? msg.id : typeof msg.requestId === "string" ? msg.requestId : null;
3550
+ if (responseId && this.pendingRequests.has(responseId)) {
3551
+ const req = this.pendingRequests.get(responseId);
3552
+ this.pendingRequests.delete(responseId);
3552
3553
  clearTimeout(req.timer);
3553
3554
  req.resolve(msg);
3554
3555
  return;
@@ -3565,10 +3566,10 @@ var AlphaWebSocket = class {
3565
3566
  }
3566
3567
  }
3567
3568
  sendSubscribe(stream, params) {
3568
- this.send({ method: "SUBSCRIBE", stream, ...params });
3569
+ this.send({ method: "SUBSCRIBE", params: [{ stream, ...params }] });
3569
3570
  }
3570
3571
  sendUnsubscribe(stream, params) {
3571
- this.send({ method: "UNSUBSCRIBE", stream, ...params });
3572
+ this.send({ method: "UNSUBSCRIBE", params: [{ stream, ...params }] });
3572
3573
  }
3573
3574
  sendRequest(payload, timeoutMs = 1e4) {
3574
3575
  const requestId = crypto.randomUUID();
@@ -3580,10 +3581,10 @@ var AlphaWebSocket = class {
3580
3581
  this.pendingRequests.set(requestId, { resolve, reject, timer });
3581
3582
  if (!this.connected) {
3582
3583
  this.connect().then(() => {
3583
- this.send({ ...payload, requestId });
3584
+ this.send({ ...payload, id: requestId });
3584
3585
  }).catch(reject);
3585
3586
  } else {
3586
- this.send({ ...payload, requestId });
3587
+ this.send({ ...payload, id: requestId });
3587
3588
  }
3588
3589
  });
3589
3590
  }
@@ -3598,7 +3599,7 @@ var AlphaWebSocket = class {
3598
3599
  startHeartbeat() {
3599
3600
  this.stopHeartbeat();
3600
3601
  this.heartbeatTimer = setInterval(() => {
3601
- this.send({ type: "ping" });
3602
+ this.send({ method: "PING" });
3602
3603
  }, this.heartbeatIntervalMs);
3603
3604
  }
3604
3605
  stopHeartbeat() {