Parcourir la source

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

Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz>
Devin AI il y a 11 mois
Parent
commit
175631a300
2 fichiers modifiés avec 16 ajouts et 0 suppressions
  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 = {