Răsfoiți Sursa

refactor!(lazer): update api protocol (#2237)

* refactor!(lazer): update api protocol

our apis should be similar to each other as much as possible.

* fix: add json binary encoding
Ali Behjati 10 luni în urmă
părinte
comite
74e976ffdf
3 a modificat fișierele cu 17 adăugiri și 22 ștergeri
  1. 1 1
      lazer/Cargo.lock
  2. 1 1
      lazer/sdk/rust/protocol/Cargo.toml
  3. 15 20
      lazer/sdk/rust/protocol/src/api.rs

+ 1 - 1
lazer/Cargo.lock

@@ -3190,7 +3190,7 @@ dependencies = [
 
 [[package]]
 name = "pyth-lazer-protocol"
-version = "0.2.6"
+version = "0.3.0"
 dependencies = [
  "anyhow",
  "bincode",

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

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

+ 15 - 20
lazer/sdk/rust/protocol/src/api.rs

@@ -1,14 +1,22 @@
 use serde::{Deserialize, Serialize};
 
-use crate::{
-    payload::AggregatedPriceFeedData,
-    router::{JsonUpdate, PriceFeedId},
+use crate::router::{
+    Chain, Channel, JsonBinaryEncoding, JsonUpdate, PriceFeedId, PriceFeedProperty,
 };
 
 #[derive(Debug, Clone, Serialize, Deserialize)]
 #[serde(rename_all = "camelCase")]
 pub struct LatestPriceRequest {
     pub price_feed_ids: Vec<PriceFeedId>,
+    pub properties: Vec<PriceFeedProperty>,
+    pub chains: Vec<Chain>,
+    #[serde(default)]
+    pub json_binary_encoding: JsonBinaryEncoding,
+    /// If `true`, the stream update will contain a JSON object containing
+    /// all data of the update.
+    #[serde(default = "default_parsed")]
+    pub parsed: bool,
+    pub channel: Channel,
 }
 
 #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -18,22 +26,9 @@ pub struct ReducePriceRequest {
     pub price_feed_ids: Vec<PriceFeedId>,
 }
 
-#[derive(Debug, Clone, Serialize, Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct LatestPriceResponse {
-    pub latest_prices: Vec<LatestPrice>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct ReducePriceResponse {
-    pub payload: JsonUpdate,
-}
+pub type LatestPriceResponse = JsonUpdate;
+pub type ReducePriceResponse = JsonUpdate;
 
-#[derive(Debug, Clone, Serialize, Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct LatestPrice {
-    pub id: PriceFeedId,
-    pub exponent: i16,
-    pub prices: AggregatedPriceFeedData,
+pub fn default_parsed() -> bool {
+    true
 }