소스 검색

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

Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz>
Devin AI 11 달 전
부모
커밋
175631a300
2개의 변경된 파일16개의 추가작업 그리고 0개의 파일을 삭제
  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 = {