Skip to content

Commit

Permalink
Fix open api schema (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
danimhr authored Oct 2, 2024
1 parent 57dcf2b commit 98ef255
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion auction-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 auction-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "auction-server"
version = "0.11.0"
version = "0.11.1"
edition = "2021"
license-file = "license.txt"

Expand Down
1 change: 1 addition & 0 deletions auction-server/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ pub async fn start_api(run_options: RunOptions, store: Arc<StoreNew>) -> Result<
opportunity_api::OpportunityParamsSvm,
opportunity_api::OpportunityParamsEvm,
opportunity_api::OpportunityParamsV1Svm,
opportunity_api::OpportunityParamsV1Evm,
ErrorBodyResponse,
ClientRequest,
Expand Down
6 changes: 4 additions & 2 deletions auction-server/src/opportunity/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ use {
std::sync::Arc,
time::OffsetDateTime,
utoipa::{
schema,
IntoParams,
ToResponse,
ToSchema,
Expand Down Expand Up @@ -196,7 +197,8 @@ pub enum OpportunityCreateEvm {
}


pub type OpportunityParamsV1Evm = OpportunityCreateV1Evm;
#[derive(Serialize, Deserialize, ToSchema, Clone, PartialEq, Debug, ToResponse)]
pub struct OpportunityParamsV1Evm(pub OpportunityCreateV1Evm);

#[derive(Serialize, Deserialize, ToSchema, Clone, PartialEq, Debug, ToResponse)]
#[serde(tag = "version")]
Expand Down Expand Up @@ -348,7 +350,7 @@ pub struct OpportunitySvm {
impl OpportunityEvm {
pub fn get_chain_id(&self) -> &ChainId {
match &self.params {
OpportunityParamsEvm::V1(params) => &params.chain_id,
OpportunityParamsEvm::V1(params) => &params.0.chain_id,
}
}
}
Expand Down
40 changes: 21 additions & 19 deletions auction-server/src/opportunity/entities/opportunity_evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,27 @@ impl From<OpportunityEvm> for api::OpportunityEvm {
api::OpportunityEvm {
opportunity_id: val.id,
creation_time: val.creation_time,
params: api::OpportunityParamsEvm::V1(api::OpportunityParamsV1Evm {
permission_key: val.permission_key.clone(),
chain_id: val.chain_id.clone(),
target_contract: val.target_contract,
target_calldata: val.target_calldata.clone(),
target_call_value: val.target_call_value,
sell_tokens: val
.sell_tokens
.clone()
.into_iter()
.map(|t| t.into())
.collect(),
buy_tokens: val
.buy_tokens
.clone()
.into_iter()
.map(|t| t.into())
.collect(),
}),
params: api::OpportunityParamsEvm::V1(api::OpportunityParamsV1Evm(
api::OpportunityCreateV1Evm {
permission_key: val.permission_key.clone(),
chain_id: val.chain_id.clone(),
target_contract: val.target_contract,
target_calldata: val.target_calldata.clone(),
target_call_value: val.target_call_value,
sell_tokens: val
.sell_tokens
.clone()
.into_iter()
.map(|t| t.into())
.collect(),
buy_tokens: val
.buy_tokens
.clone()
.into_iter()
.map(|t| t.into())
.collect(),
},
)),
}
}
}
Expand Down

0 comments on commit 98ef255

Please sign in to comment.