Skip to content

Commit e14a82c

Browse files
authored
fix hermes v2 openapi schemas (#1298)
* fix docs * address comment * bump * fix from implementation of RpcPriceIdentifier
1 parent 5c1e83a commit e14a82c

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

hermes/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.

hermes/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hermes"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
description = "Hermes is an agent that provides Verified Prices from the Pythnet Pyth Oracle."
55
edition = "2021"
66

hermes/src/api.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ pub async fn run(opts: RunOptions, state: ApiState) -> Result<()> {
134134
types::RpcPriceFeed,
135135
types::RpcPriceFeedMetadata,
136136
types::RpcPriceIdentifier,
137+
types::EncodingType,
138+
types::PriceUpdate,
139+
types::BinaryPriceUpdate,
140+
types::ParsedPriceUpdate,
141+
types::RpcPriceFeedMetadataV2,
137142
)
138143
),
139144
tags(

hermes/src/api/rest/price_feed_ids.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub async fn price_feed_ids(
2626
) -> Result<Json<Vec<RpcPriceIdentifier>>, RestError> {
2727
let price_feed_ids = crate::aggregate::get_price_feed_ids(&*state.state)
2828
.await
29-
.iter()
29+
.into_iter()
3030
.map(RpcPriceIdentifier::from)
3131
.collect();
3232

hermes/src/api/types.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,21 @@ impl RpcPriceIdentifier {
190190
pub fn new(bytes: [u8; 32]) -> RpcPriceIdentifier {
191191
RpcPriceIdentifier(bytes)
192192
}
193+
}
193194

194-
pub fn from(id: &PriceIdentifier) -> RpcPriceIdentifier {
195+
impl From<RpcPriceIdentifier> for PriceIdentifier {
196+
fn from(id: RpcPriceIdentifier) -> Self {
197+
PriceIdentifier::new(id.0)
198+
}
199+
}
200+
201+
impl From<PriceIdentifier> for RpcPriceIdentifier {
202+
fn from(id: PriceIdentifier) -> Self {
195203
RpcPriceIdentifier(id.to_bytes())
196204
}
197205
}
198206

199-
#[derive(Clone, Copy, Debug, Default, serde::Deserialize, serde::Serialize)]
207+
#[derive(Clone, Copy, Debug, Default, serde::Deserialize, serde::Serialize, ToSchema)]
200208
pub enum EncodingType {
201209
#[default]
202210
#[serde(rename = "hex")]
@@ -222,7 +230,7 @@ pub struct BinaryPriceUpdate {
222230

223231
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
224232
pub struct ParsedPriceUpdate {
225-
pub id: PriceIdentifier,
233+
pub id: RpcPriceIdentifier,
226234
pub price: RpcPrice,
227235
pub ema_price: RpcPrice,
228236
pub metadata: RpcPriceFeedMetadataV2,
@@ -233,7 +241,7 @@ impl From<PriceFeedUpdate> for ParsedPriceUpdate {
233241
let price_feed = price_feed_update.price_feed;
234242

235243
Self {
236-
id: price_feed.id,
244+
id: RpcPriceIdentifier::from(price_feed.id),
237245
price: RpcPrice {
238246
price: price_feed.get_price_unchecked().price,
239247
conf: price_feed.get_price_unchecked().conf,
@@ -271,7 +279,7 @@ impl TryFrom<PriceUpdate> for PriceFeedsWithUpdateData {
271279
.map(|parsed_price_update| {
272280
Ok(PriceFeedUpdate {
273281
price_feed: PriceFeed::new(
274-
parsed_price_update.id,
282+
parsed_price_update.id.into(),
275283
Price {
276284
price: parsed_price_update.price.price,
277285
conf: parsed_price_update.price.conf,

0 commit comments

Comments
 (0)