Skip to content

Commit 74e976f

Browse files
authored
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
1 parent 080feba commit 74e976f

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
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: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
use serde::{Deserialize, Serialize};
22

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

87
#[derive(Debug, Clone, Serialize, Deserialize)]
98
#[serde(rename_all = "camelCase")]
109
pub struct LatestPriceRequest {
1110
pub price_feed_ids: Vec<PriceFeedId>,
11+
pub properties: Vec<PriceFeedProperty>,
12+
pub chains: Vec<Chain>,
13+
#[serde(default)]
14+
pub json_binary_encoding: JsonBinaryEncoding,
15+
/// If `true`, the stream update will contain a JSON object containing
16+
/// all data of the update.
17+
#[serde(default = "default_parsed")]
18+
pub parsed: bool,
19+
pub channel: Channel,
1220
}
1321

1422
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -18,22 +26,9 @@ pub struct ReducePriceRequest {
1826
pub price_feed_ids: Vec<PriceFeedId>,
1927
}
2028

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-
}
29+
pub type LatestPriceResponse = JsonUpdate;
30+
pub type ReducePriceResponse = JsonUpdate;
3231

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,
32+
pub fn default_parsed() -> bool {
33+
true
3934
}

0 commit comments

Comments
 (0)