Skip to content

Commit b2886a5

Browse files
committed
refactor!(lazer): update api protocol
our apis should be similar to each other as much as possible.
1 parent 080feba commit b2886a5

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

lazer/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lazer/sdk/rust/protocol/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-lazer-protocol"
3-
version = "0.2.6"
3+
version = "0.3.0"
44
edition = "2021"
55
description = "Pyth Lazer SDK - protocol types."
66
license = "Apache-2.0"

lazer/sdk/rust/protocol/src/api.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
use serde::{Deserialize, Serialize};
22

3-
use crate::{
4-
payload::AggregatedPriceFeedData,
5-
router::{JsonUpdate, PriceFeedId},
6-
};
3+
use crate::router::{Chain, Channel, JsonUpdate, PriceFeedId, PriceFeedProperty};
74

85
#[derive(Debug, Clone, Serialize, Deserialize)]
96
#[serde(rename_all = "camelCase")]
107
pub struct LatestPriceRequest {
118
pub price_feed_ids: Vec<PriceFeedId>,
9+
pub properties: Vec<PriceFeedProperty>,
10+
pub chains: Vec<Chain>,
11+
/// If `true`, the stream update will contain a JSON object containing
12+
/// all data of the update.
13+
#[serde(default = "default_parsed")]
14+
pub parsed: bool,
15+
pub channel: Channel,
1216
}
1317

1418
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -18,22 +22,9 @@ pub struct ReducePriceRequest {
1822
pub price_feed_ids: Vec<PriceFeedId>,
1923
}
2024

21-
#[derive(Debug, Clone, Serialize, Deserialize)]
22-
#[serde(rename_all = "camelCase")]
23-
pub struct LatestPriceResponse {
24-
pub latest_prices: Vec<LatestPrice>,
25-
}
26-
27-
#[derive(Debug, Clone, Serialize, Deserialize)]
28-
#[serde(rename_all = "camelCase")]
29-
pub struct ReducePriceResponse {
30-
pub payload: JsonUpdate,
31-
}
25+
pub type LatestPriceResponse = JsonUpdate;
26+
pub type ReducePriceResponse = JsonUpdate;
3227

33-
#[derive(Debug, Clone, Serialize, Deserialize)]
34-
#[serde(rename_all = "camelCase")]
35-
pub struct LatestPrice {
36-
pub id: PriceFeedId,
37-
pub exponent: i16,
38-
pub prices: AggregatedPriceFeedData,
28+
pub fn default_parsed() -> bool {
29+
true
3930
}

0 commit comments

Comments
 (0)