diff --git a/api/src/api_docs.rs b/api/src/api_docs.rs index 2d4dfe2d..cbd8f057 100644 --- a/api/src/api_docs.rs +++ b/api/src/api_docs.rs @@ -1,6 +1,7 @@ -use crate::{dto::ValidatorBondRecord, handlers::{ - bonds, docs -}}; +use crate::{ + dto::ValidatorBondRecord, + handlers::{bonds, docs}, +}; use utoipa::OpenApi; #[derive(OpenApi)] @@ -13,13 +14,7 @@ use utoipa::OpenApi; url = "https://www.apache.org/licenses/LICENSE-2.0" ) ), - components( - schemas(ValidatorBondRecord), - schemas(bonds::BondsResponse), - ), - paths( - docs::handler, - bonds::handler, - ) + components(schemas(ValidatorBondRecord), schemas(bonds::BondsResponse),), + paths(docs::handler, bonds::handler,) )] pub struct ApiDoc; diff --git a/api/src/bin/api.rs b/api/src/bin/api.rs index e089cb0c..a9c8bc32 100644 --- a/api/src/bin/api.rs +++ b/api/src/bin/api.rs @@ -30,9 +30,7 @@ async fn main() -> anyhow::Result<()> { } }); - let context = Arc::new(RwLock::new(Context::new( - psql_client, - )?)); + let context = Arc::new(RwLock::new(Context::new(psql_client)?)); let cors = warp::cors() .allow_any_origin() diff --git a/api/src/context.rs b/api/src/context.rs index 17c56ab4..6c736f50 100644 --- a/api/src/context.rs +++ b/api/src/context.rs @@ -7,12 +7,8 @@ pub struct Context { } impl Context { - pub fn new( - psql_client: Client, - ) -> anyhow::Result { - Ok(Self { - psql_client, - }) + pub fn new(psql_client: Client) -> anyhow::Result { + Ok(Self { psql_client }) } } diff --git a/api/src/data/data.rs b/api/src/data/data.rs index 2d31e99d..481ae604 100644 --- a/api/src/data/data.rs +++ b/api/src/data/data.rs @@ -3,9 +3,7 @@ use tokio_postgres::Client; use crate::dto::ValidatorBondRecord; -pub async fn get_bonds( - psql_client: &Client, -) -> anyhow::Result> { +pub async fn get_bonds(psql_client: &Client) -> anyhow::Result> { let rows = psql_client .query( " @@ -29,4 +27,4 @@ pub async fn get_bonds( } Ok(bonds) -} \ No newline at end of file +} diff --git a/api/src/data/mod.rs b/api/src/data/mod.rs index 12e35bbf..7a345e4c 100644 --- a/api/src/data/mod.rs +++ b/api/src/data/mod.rs @@ -1 +1 @@ -pub mod data; \ No newline at end of file +pub mod data; diff --git a/api/src/dto.rs b/api/src/dto.rs index 0820805f..ccc9bbb6 100644 --- a/api/src/dto.rs +++ b/api/src/dto.rs @@ -8,4 +8,4 @@ pub struct ValidatorBondRecord { pub authority: String, pub revenue_share: Decimal, pub epoch: u64, -} \ No newline at end of file +} diff --git a/api/src/handlers/bonds.rs b/api/src/handlers/bonds.rs index f779bb6c..3ea7a910 100644 --- a/api/src/handlers/bonds.rs +++ b/api/src/handlers/bonds.rs @@ -1,6 +1,9 @@ use crate::{context::WrappedContext, data::data::get_bonds, dto::ValidatorBondRecord}; use serde::{Deserialize, Serialize}; -use warp::{reject::Reject, reply::{json, Reply}}; +use warp::{ + reject::Reject, + reply::{json, Reply}, +}; #[derive(Serialize, Debug, utoipa::ToSchema)] pub struct BondsResponse { @@ -9,8 +12,7 @@ pub struct BondsResponse { #[derive(Deserialize, Serialize, Debug, utoipa::IntoParams)] #[into_params(parameter_in = Query)] -pub struct QueryParams { -} +pub struct QueryParams {} #[derive(Debug)] struct CustomError { @@ -33,11 +35,9 @@ pub async fn handler( context: WrappedContext, ) -> Result { match get_bonds(&context.read().await.psql_client).await { - Ok(bonds) => { - Ok(json(&BondsResponse { bonds })) - }, - Err(_) => { - Err(warp::reject::custom(CustomError { message: "Failed to fetch bonds".into() })) - } + Ok(bonds) => Ok(json(&BondsResponse { bonds })), + Err(_) => Err(warp::reject::custom(CustomError { + message: "Failed to fetch bonds".into(), + })), } } diff --git a/api/src/handlers/mod.rs b/api/src/handlers/mod.rs index eef8ff33..9e515ab3 100644 --- a/api/src/handlers/mod.rs +++ b/api/src/handlers/mod.rs @@ -1,2 +1,2 @@ pub mod bonds; -pub mod docs; \ No newline at end of file +pub mod docs; diff --git a/api/src/lib.rs b/api/src/lib.rs index caa9923a..876910e4 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -1,5 +1,5 @@ -pub mod handlers; +pub mod api_docs; pub mod context; pub mod data; -pub mod api_docs; -pub mod dto; \ No newline at end of file +pub mod dto; +pub mod handlers; diff --git a/store/src/commands/bonds.rs b/store/src/commands/bonds.rs index 60c34513..800b2281 100644 --- a/store/src/commands/bonds.rs +++ b/store/src/commands/bonds.rs @@ -11,9 +11,7 @@ use super::common::CommonStoreOptions; const DEFAULT_CHUNK_SIZE: usize = 500; -pub async fn store_bonds( - options: CommonStoreOptions, -) -> anyhow::Result<()> { +pub async fn store_bonds(options: CommonStoreOptions) -> anyhow::Result<()> { let (mut psql_client, psql_conn) = tokio_postgres::connect(&options.postgres_url, NoTls).await?;