Ver código fonte

feat(protocol): add update subscription message type

Co-Authored-By: Jayant Krishnamurthy <jayant@dourolabs.xyz>
Devin AI 11 meses atrás
pai
commit
0b5003c7a4

+ 1 - 1
lazer/Cargo.lock

@@ -3176,7 +3176,7 @@ dependencies = [
 
 [[package]]
 name = "pyth-lazer-protocol"
-version = "0.1.3"
+version = "0.1.4"
 dependencies = [
  "anyhow",
  "bincode",

+ 1 - 1
lazer/sdk/rust/protocol/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "pyth-lazer-protocol"
-version = "0.1.3"
+version = "0.1.4"
 edition = "2021"
 description = "Pyth Lazer SDK - protocol types."
 license = "Apache-2.0"

+ 15 - 0
lazer/sdk/rust/protocol/src/subscription.rs

@@ -14,6 +14,7 @@ use {
 pub enum Request {
     Subscribe(SubscribeRequest),
     Unsubscribe(UnsubscribeRequest),
+    UpdateSubscription(UpdateSubscriptionRequest),
 }
 
 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
@@ -33,6 +34,20 @@ pub struct UnsubscribeRequest {
     pub subscription_id: SubscriptionId,
 }
 
+/// A request to update an existing subscription with new parameters.
+/// This is idempotent - the new parameters completely replace the old ones.
+/// The subscription parameters include:
+/// - price_feed_ids: List of price feeds to subscribe to
+/// - properties: List of properties to include in updates (e.g., price, confidence, timestamp)
+///   These properties determine what data fields will be included in price feed updates
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct UpdateSubscriptionRequest {
+    pub subscription_id: SubscriptionId,
+    #[serde(flatten)]
+    pub params: SubscriptionParams,
+}
+
 /// A response sent from the server to the client.
 #[derive(Debug, Clone, Serialize, Deserialize, From)]
 #[serde(tag = "type")]