Skip to content

Commit

Permalink
feat(hermes): fix publisher cap schema (#1890)
Browse files Browse the repository at this point in the history
* feat(hermes): fix publisher cap schema

* update version

* go
  • Loading branch information
keyvankhademi authored Sep 11, 2024
1 parent 8e6c518 commit cac1a8e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion apps/hermes/server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/hermes/server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hermes"
version = "0.6.0"
version = "0.6.1"
description = "Hermes is an agent that provides Verified Prices from the Pythnet Pyth Oracle."
edition = "2021"

Expand Down
5 changes: 4 additions & 1 deletion apps/hermes/server/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ where
types::ParsedPriceUpdate,
types::RpcPriceFeedMetadataV2,
types::PriceFeedMetadata,
types::AssetType
types::LatestPublisherStakeCapsUpdateDataResponse,
types::ParsedPublisherStakeCapsUpdate,
types::ParsedPublisherStakeCap,
types::AssetType,
)
),
tags(
Expand Down
20 changes: 4 additions & 16 deletions apps/hermes/server/src/api/rest/v2/latest_publisher_stake_caps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use {
types::{
BinaryUpdate,
EncodingType,
LatestPublisherStakeCapsUpdateDataResponse,
ParsedPublisherStakeCapsUpdate,
},
ApiState,
Expand All @@ -20,15 +21,9 @@ use {
engine::general_purpose::STANDARD as base64_standard_engine,
Engine as _,
},
serde::{
Deserialize,
Serialize,
},
serde::Deserialize,
serde_qs::axum::QsQuery,
utoipa::{
IntoParams,
ToSchema,
},
utoipa::IntoParams,
};


Expand All @@ -50,19 +45,12 @@ fn default_true() -> bool {
true
}

#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct LatestPublisherStakeCapsUpdateDataResponse {
pub binary: BinaryUpdate,
#[serde(skip_serializing_if = "Option::is_none")]
pub parsed: Option<Vec<ParsedPublisherStakeCapsUpdate>>,
}

/// Get the most recent publisher stake caps update data.
#[utoipa::path(
get,
path = "/v2/updates/publisher_stake_caps/latest",
responses(
(status = 200, description = "Publisher stake caps update data retrieved succesfully", body = Vec<PriceFeedMetadata>)
(status = 200, description = "Publisher stake caps update data retrieved successfully", body = LatestPublisherStakeCapsUpdateDataResponse)
),
params(
LatestPublisherStakeCapsUpdateData
Expand Down
15 changes: 10 additions & 5 deletions apps/hermes/server/src/api/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use {
Deserialize,
Serialize,
},
solana_sdk::pubkey::Pubkey,
std::{
collections::BTreeMap,
fmt::{
Expand Down Expand Up @@ -273,18 +272,24 @@ impl From<PriceFeedUpdate> for ParsedPriceUpdate {
}
}

#[derive(Debug, PartialEq, serde::Serialize, serde::Deserialize, Clone)]
#[derive(Debug, PartialEq, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
pub struct ParsedPublisherStakeCapsUpdate {
pub publisher_stake_caps: Vec<ParsedPublisherStakeCap>,
}

#[derive(Debug, PartialEq, serde::Serialize, serde::Deserialize, Clone)]
#[derive(Debug, PartialEq, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
pub struct ParsedPublisherStakeCap {
#[serde(with = "pyth_sdk::utils::as_string")]
pub publisher: Pubkey,
pub publisher: String,
pub cap: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct LatestPublisherStakeCapsUpdateDataResponse {
pub binary: BinaryUpdate,
#[serde(skip_serializing_if = "Option::is_none")]
pub parsed: Option<Vec<ParsedPublisherStakeCapsUpdate>>,
}

#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct PriceUpdate {
pub binary: BinaryUpdate,
Expand Down
2 changes: 1 addition & 1 deletion apps/hermes/server/src/state/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ where
.caps
.iter()
.map(|cap| ParsedPublisherStakeCap {
publisher: Pubkey::from(cap.publisher),
publisher: Pubkey::from(cap.publisher).to_string(),
cap: cap.cap,
})
.collect(),
Expand Down

0 comments on commit cac1a8e

Please sign in to comment.