Skip to content

Commit 78982eb

Browse files
authored
feat(lazer): improve time types (#2851)
* feat(lazer): improve time types (wip) * chore: remove cadd for now * feat(lazer): add a few more functions and costs * test(lazer): add time tests * chore: fix ci * fix(lazer): is_multiple_of * chore: bump version
1 parent fb52e84 commit 78982eb

File tree

18 files changed

+1002
-120
lines changed

18 files changed

+1002
-120
lines changed

.github/workflows/ci-lazer-rust.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ jobs:
4141
- name: Clippy check
4242
run: cargo clippy -p pyth-lazer-protocol -p pyth-lazer-client -p pyth-lazer-publisher-sdk --all-targets -- --deny warnings
4343
if: success() || failure()
44+
- name: Clippy check with mry
45+
run: cargo clippy -F mry -p pyth-lazer-protocol --all-targets -- --deny warnings
46+
if: success() || failure()
4447
- name: test
4548
run: cargo test -p pyth-lazer-protocol -p pyth-lazer-client -p pyth-lazer-publisher-sdk
4649
if: success() || failure()
50+
- name: test with mry
51+
run: cargo test -F mry -p pyth-lazer-protocol
52+
if: success() || failure()

Cargo.lock

Lines changed: 53 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lazer/contracts/solana/Cargo.lock

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lazer/contracts/solana/programs/pyth-lazer-solana-contract/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ no-log-ix-name = []
2222
idl-build = ["anchor-lang/idl-build"]
2323

2424
[dependencies]
25-
pyth-lazer-protocol = { path = "../../../../sdk/rust/protocol", version = "0.8.1" }
25+
pyth-lazer-protocol = { path = "../../../../sdk/rust/protocol", version = "0.9.0" }
2626

2727
anchor-lang = "0.30.1"
2828
bytemuck = "1.20.0"

lazer/publisher_sdk/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "Apache-2.0"
77
repository = "https://github.com/pyth-network/pyth-crosschain"
88

99
[dependencies]
10-
pyth-lazer-protocol = { version = "0.8.1", path = "../../sdk/rust/protocol" }
10+
pyth-lazer-protocol = { version = "0.9.0", path = "../../sdk/rust/protocol" }
1111
anyhow = "1.0.98"
1212
protobuf = "3.7.2"
1313
serde-value = "0.7.0"

lazer/publisher_sdk/rust/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use anyhow::{bail, ensure, Context};
77
use humantime::format_duration;
88
use protobuf::dynamic_value::{dynamic_value, DynamicValue};
99
use pyth_lazer_protocol::jrpc::{FeedUpdateParams, UpdateParams};
10-
use pyth_lazer_protocol::router::TimestampUs;
10+
use pyth_lazer_protocol::time::TimestampUs;
1111

1212
pub mod transaction_envelope {
1313
pub use crate::protobuf::transaction_envelope::*;
@@ -141,7 +141,7 @@ impl TryFrom<DynamicValue> for serde_value::Value {
141141
}
142142
dynamic_value::Value::TimestampValue(ts) => {
143143
let ts = TimestampUs::try_from(&ts)?;
144-
Ok(serde_value::Value::U64(ts.0))
144+
Ok(serde_value::Value::U64(ts.as_micros()))
145145
}
146146
dynamic_value::Value::List(list) => {
147147
let mut output = Vec::new();

lazer/sdk/rust/client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description = "A Rust client for Pyth Lazer"
66
license = "Apache-2.0"
77

88
[dependencies]
9-
pyth-lazer-protocol = { path = "../protocol", version = "0.8.1" }
9+
pyth-lazer-protocol = { path = "../protocol", version = "0.9.0" }
1010
tokio = { version = "1", features = ["full"] }
1111
tokio-tungstenite = { version = "0.20", features = ["native-tls"] }
1212
futures-util = "0.3"

lazer/sdk/rust/client/examples/subscribe_price_feeds.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ async fn main() -> anyhow::Result<()> {
4444
delivery_format: DeliveryFormat::Json,
4545
json_binary_encoding: JsonBinaryEncoding::Base64,
4646
parsed: true,
47-
channel: Channel::FixedRate(
48-
FixedRate::from_ms(200).expect("unsupported update rate"),
49-
),
47+
channel: Channel::FixedRate(FixedRate::RATE_200_MS),
5048
ignore_invalid_feed_ids: false,
5149
})
5250
.expect("invalid subscription params"),
@@ -66,9 +64,7 @@ async fn main() -> anyhow::Result<()> {
6664
delivery_format: DeliveryFormat::Binary,
6765
json_binary_encoding: JsonBinaryEncoding::Base64,
6866
parsed: false,
69-
channel: Channel::FixedRate(
70-
FixedRate::from_ms(50).expect("unsupported update rate"),
71-
),
67+
channel: Channel::FixedRate(FixedRate::RATE_50_MS),
7268
ignore_invalid_feed_ids: false,
7369
})
7470
.expect("invalid subscription params"),

lazer/sdk/rust/protocol/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-lazer-protocol"
3-
version = "0.8.1"
3+
version = "0.9.0"
44
edition = "2021"
55
description = "Pyth Lazer SDK - protocol types."
66
license = "Apache-2.0"
@@ -16,6 +16,8 @@ itertools = "0.13.0"
1616
rust_decimal = "1.36.0"
1717
protobuf = "3.7.2"
1818
humantime-serde = "1.1.1"
19+
mry = { version = "0.13.0", features = ["serde"], optional = true }
20+
chrono = "0.4.41"
1921

2022
[dev-dependencies]
2123
bincode = "1.3.3"

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use serde::{Deserialize, Serialize};
22

3-
use crate::router::{
4-
Channel, Format, JsonBinaryEncoding, JsonUpdate, PriceFeedId, PriceFeedProperty, TimestampUs,
3+
use crate::{
4+
router::{Channel, Format, JsonBinaryEncoding, JsonUpdate, PriceFeedId, PriceFeedProperty},
5+
time::TimestampUs,
56
};
67

78
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]

0 commit comments

Comments
 (0)