Kaynağa Gözat

feat(js-sdk): add update subscription message type

Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz>
Devin AI 11 ay önce
ebeveyn
işleme
175631a300
2 değiştirilmiş dosya ile 16 ekleme ve 0 silme
  1. 10 0
      lazer/sdk/js/examples/index.ts
  2. 6 0
      lazer/sdk/js/src/protocol.ts

+ 10 - 0
lazer/sdk/js/examples/index.ts

@@ -38,4 +38,14 @@ client.ws.addEventListener("open", () => {
     channel: "fixed_rate@200ms",
     jsonBinaryEncoding: "hex",
   });
+
+  // Example: Update an existing subscription
+  setTimeout(() => {
+    client.send({
+      type: "updateSubscription",
+      subscriptionId: 1,
+      priceFeedIds: [1, 2, 3],
+      properties: ["price", "bestBidPrice"],
+    });
+  }, 2000); // Wait 2 seconds before updating
 });

+ 6 - 0
lazer/sdk/js/src/protocol.ts

@@ -19,6 +19,12 @@ export type Request =
   | {
       type: "unsubscribe";
       subscriptionId: number;
+    }
+  | {
+      type: "updateSubscription";
+      subscriptionId: number;
+      priceFeedIds: number[];
+      properties: PriceFeedProperty[];
     };
 
 export type ParsedFeedPayload = {