From 421f349bdf443b45bf0f3c503c4a3cabdd0013b9 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Thu, 6 Jun 2024 21:06:18 +0900 Subject: [PATCH] fix(apps/hermes/server): use RpcPriceIdentifier instead of PriceIdentifier (#1662) * use RpcPriceIdentifier instead of PriceIdentifier * fix test * fix imports --- apps/hermes/Cargo.lock | 2 +- apps/hermes/Cargo.toml | 2 +- apps/hermes/src/api/types.rs | 2 +- apps/hermes/src/network/pythnet.rs | 8 +++++--- apps/hermes/src/state/aggregate.rs | 3 ++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/hermes/Cargo.lock b/apps/hermes/Cargo.lock index ae48fd4934..533f489349 100644 --- a/apps/hermes/Cargo.lock +++ b/apps/hermes/Cargo.lock @@ -1796,7 +1796,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermes" -version = "0.5.11" +version = "0.5.12" dependencies = [ "anyhow", "async-trait", diff --git a/apps/hermes/Cargo.toml b/apps/hermes/Cargo.toml index 1ce9053408..8ee7aedf2d 100644 --- a/apps/hermes/Cargo.toml +++ b/apps/hermes/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hermes" -version = "0.5.11" +version = "0.5.12" description = "Hermes is an agent that provides Verified Prices from the Pythnet Pyth Oracle." edition = "2021" diff --git a/apps/hermes/src/api/types.rs b/apps/hermes/src/api/types.rs index 795656d28e..5096c2a619 100644 --- a/apps/hermes/src/api/types.rs +++ b/apps/hermes/src/api/types.rs @@ -327,7 +327,7 @@ impl TryFrom for PriceFeedsWithUpdateData { #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] pub struct PriceFeedMetadata { - pub id: PriceIdentifier, + pub id: RpcPriceIdentifier, // BTreeMap is used to automatically sort the keys to ensure consistent ordering of attributes in the JSON response. // This enhances user experience by providing a predictable structure, avoiding confusion from varying orders in different responses. pub attributes: BTreeMap, diff --git a/apps/hermes/src/network/pythnet.rs b/apps/hermes/src/network/pythnet.rs index 401e90fc80..c4dd4f965b 100644 --- a/apps/hermes/src/network/pythnet.rs +++ b/apps/hermes/src/network/pythnet.rs @@ -4,7 +4,10 @@ use { crate::{ - api::types::PriceFeedMetadata, + api::types::{ + PriceFeedMetadata, + RpcPriceIdentifier, + }, config::RunOptions, network::wormhole::{ BridgeData, @@ -30,7 +33,6 @@ use { }, borsh::BorshDeserialize, futures::stream::StreamExt, - pyth_sdk::PriceIdentifier, pyth_sdk_solana::state::{ load_mapping_account, load_product_account, @@ -442,7 +444,7 @@ async fn fetch_price_feeds_metadata( .expect("Invalid length for PriceIdentifier"); let price_feed_metadata = PriceFeedMetadata { - id: PriceIdentifier::new(px_pkey_array), + id: RpcPriceIdentifier::new(px_pkey_array), attributes, }; diff --git a/apps/hermes/src/state/aggregate.rs b/apps/hermes/src/state/aggregate.rs index 55a2fb692a..ad012b24e4 100644 --- a/apps/hermes/src/state/aggregate.rs +++ b/apps/hermes/src/state/aggregate.rs @@ -19,6 +19,7 @@ use { WormholeMerkleState, }, crate::{ + api::types::RpcPriceIdentifier, network::wormhole::VaaBytes, state::{ benchmarks::Benchmarks, @@ -870,7 +871,7 @@ mod test { // Add a dummy price feeds metadata state .store_price_feeds_metadata(&[PriceFeedMetadata { - id: PriceIdentifier::new([100; 32]), + id: RpcPriceIdentifier::new([100; 32]), attributes: Default::default(), }]) .await