-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hermes: Add prv publish time metadata #1061
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,10 +152,11 @@ pub enum Update { | |
|
||
#[derive(Debug, PartialEq)] | ||
pub struct PriceFeedUpdate { | ||
pub price_feed: PriceFeed, | ||
pub slot: Option<Slot>, | ||
pub received_at: Option<UnixTimestamp>, | ||
pub update_data: Option<Vec<u8>>, | ||
pub price_feed: PriceFeed, | ||
pub slot: Option<Slot>, | ||
pub received_at: Option<UnixTimestamp>, | ||
pub update_data: Option<Vec<u8>>, | ||
pub prev_publish_time: Option<UnixTimestamp>, | ||
} | ||
|
||
#[derive(Debug, PartialEq)] | ||
|
@@ -333,7 +334,7 @@ where | |
.iter() | ||
.map(|message_state| match message_state.message { | ||
Message::PriceFeedMessage(price_feed) => Ok(PriceFeedUpdate { | ||
price_feed: PriceFeed::new( | ||
price_feed: PriceFeed::new( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the extra spacing seems weird but seems like it passes pre-commit 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah it is the rust formatter config that we have :D |
||
PriceIdentifier::new(price_feed.feed_id), | ||
Price { | ||
price: price_feed.price, | ||
|
@@ -348,14 +349,15 @@ where | |
publish_time: price_feed.publish_time, | ||
}, | ||
), | ||
received_at: Some(message_state.received_at), | ||
slot: Some(message_state.slot), | ||
update_data: Some( | ||
received_at: Some(message_state.received_at), | ||
slot: Some(message_state.slot), | ||
update_data: Some( | ||
construct_update_data(vec![message_state.clone().into()])? | ||
.into_iter() | ||
.next() | ||
.ok_or(anyhow!("Missing update data for message"))?, | ||
), | ||
prev_publish_time: Some(price_feed.prev_publish_time), | ||
}), | ||
_ => Err(anyhow!("Invalid message state type")), | ||
}) | ||
|
@@ -574,7 +576,7 @@ mod test { | |
assert_eq!( | ||
price_feeds_with_update_data.price_feeds, | ||
vec![PriceFeedUpdate { | ||
price_feed: PriceFeed::new( | ||
price_feed: PriceFeed::new( | ||
PriceIdentifier::new(price_feed_message.feed_id), | ||
Price { | ||
price: price_feed_message.price, | ||
|
@@ -589,11 +591,12 @@ mod test { | |
publish_time: price_feed_message.publish_time, | ||
} | ||
), | ||
slot: Some(10), | ||
received_at: price_feeds_with_update_data.price_feeds[0].received_at, // Ignore checking this field. | ||
update_data: price_feeds_with_update_data.price_feeds[0] | ||
slot: Some(10), | ||
received_at: price_feeds_with_update_data.price_feeds[0].received_at, // Ignore checking this field. | ||
update_data: price_feeds_with_update_data.price_feeds[0] | ||
.update_data | ||
.clone(), // Ignore checking this field. | ||
prev_publish_time: Some(9), | ||
}] | ||
); | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@pythnetwork/price-service-client", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👌 on the respecting semver |
||
"description": "Pyth price service client", | ||
"author": { | ||
"name": "Pyth Data Association" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,8 @@ const argvPromise = yargs(hideBin(process.argv)) | |
type: "array", | ||
demandOption: true, | ||
}) | ||
.option("price-service", { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a minor change to move to hermes |
||
description: | ||
"Endpoint URL for the price service. e.g: https://xc-mainnet.pyth.network", | ||
.option("hermes", { | ||
description: "Endpoint URL for Hermes. e.g: https://hermes.pyth.network", | ||
type: "string", | ||
demandOption: true, | ||
}) | ||
|
@@ -52,7 +51,7 @@ async function run() { | |
const argv = await argvPromise; | ||
|
||
// Fetch the latest price feed update data from the Price Service | ||
const connection = new SuiPriceServiceConnection(argv["price-service"]); | ||
const connection = new SuiPriceServiceConnection(argv["hermes"]); | ||
const feeds = argv["feed-id"] as string[]; | ||
const priceFeedUpdateData = await connection.getPriceFeedsUpdateData(feeds); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realise we can't change it at this point but It's a shame this isn't
last_publish_time
like otherlast_
fields we have in our codebases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think here
prev
is more clear thanlast
.