diff --git a/apps/hermes/server/Cargo.lock b/apps/hermes/server/Cargo.lock index 1ac0e51262..ef9b6e46aa 100644 --- a/apps/hermes/server/Cargo.lock +++ b/apps/hermes/server/Cargo.lock @@ -1796,7 +1796,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermes" -version = "0.7.1" +version = "0.7.2" dependencies = [ "anyhow", "async-trait", @@ -3138,7 +3138,7 @@ dependencies = [ [[package]] name = "pythnet-sdk" -version = "2.3.0" +version = "2.3.1" dependencies = [ "bincode", "borsh 0.10.3", diff --git a/apps/hermes/server/Cargo.toml b/apps/hermes/server/Cargo.toml index a437da3c3d..6df64185ec 100644 --- a/apps/hermes/server/Cargo.toml +++ b/apps/hermes/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hermes" -version = "0.7.1" +version = "0.7.2" description = "Hermes is an agent that provides Verified Prices from the Pythnet Pyth Oracle." edition = "2021" diff --git a/apps/hermes/server/src/api/types.rs b/apps/hermes/server/src/api/types.rs index c9af0e631a..84816b9966 100644 --- a/apps/hermes/server/src/api/types.rs +++ b/apps/hermes/server/src/api/types.rs @@ -326,17 +326,70 @@ pub struct PriceFeedMetadata { } #[derive(Debug, Serialize, Deserialize, PartialEq, ToSchema)] -#[serde(rename_all = "lowercase")] +#[serde(rename_all = "snake_case")] pub enum AssetType { Crypto, FX, Equity, - Metals, + Metal, Rates, + CryptoRedemptionRate, } impl Display for AssetType { fn fmt(&self, f: &mut Formatter) -> FmtResult { - write!(f, "{:?}", self) + match self { + AssetType::Crypto => write!(f, "crypto"), + AssetType::FX => write!(f, "fx"), + AssetType::Equity => write!(f, "equity"), + AssetType::Metal => write!(f, "metal"), + AssetType::Rates => write!(f, "rates"), + AssetType::CryptoRedemptionRate => write!(f, "crypto_redemption_rate"), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_serialize_matches_display() { + assert_eq!( + AssetType::Crypto.to_string(), + serde_json::to_string(&AssetType::Crypto) + .unwrap() + .trim_matches('"') + ); + assert_eq!( + AssetType::FX.to_string(), + serde_json::to_string(&AssetType::FX) + .unwrap() + .trim_matches('"') + ); + assert_eq!( + AssetType::Equity.to_string(), + serde_json::to_string(&AssetType::Equity) + .unwrap() + .trim_matches('"') + ); + assert_eq!( + AssetType::Metal.to_string(), + serde_json::to_string(&AssetType::Metal) + .unwrap() + .trim_matches('"') + ); + assert_eq!( + AssetType::Rates.to_string(), + serde_json::to_string(&AssetType::Rates) + .unwrap() + .trim_matches('"') + ); + assert_eq!( + AssetType::CryptoRedemptionRate.to_string(), + serde_json::to_string(&AssetType::CryptoRedemptionRate) + .unwrap() + .trim_matches('"') + ); } } diff --git a/apps/hermes/server/src/state/price_feeds_metadata.rs b/apps/hermes/server/src/state/price_feeds_metadata.rs index d6cbe09a7e..030ea6b2dd 100644 --- a/apps/hermes/server/src/state/price_feeds_metadata.rs +++ b/apps/hermes/server/src/state/price_feeds_metadata.rs @@ -83,7 +83,8 @@ where if let Some(asset_type) = &asset_type { price_feeds_metadata.retain(|feed| { feed.attributes.get("asset_type").map_or(false, |type_str| { - type_str.to_lowercase() == asset_type.to_string().to_lowercase() + type_str.to_lowercase().trim().replace(" ", "_") + == asset_type.to_string().to_lowercase() }) }); }