Skip to content

Commit

Permalink
Move driver models into infra (#2409)
Browse files Browse the repository at this point in the history
# Description
No new functionality. Fixes
#2286

# Changes
Moved driver api model into `infra`
Removed quote model since not used.

## How to test
Existing e2e tests
  • Loading branch information
sunce86 authored Feb 20, 2024
1 parent 1cb7019 commit a0e3ec7
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 258 deletions.
12 changes: 5 additions & 7 deletions crates/autopilot/src/boundary/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use {crate::domain, ethrpc::Web3, std::collections::HashMap, url::Url};
pub use {
crate::{
database::{
competition::Competition,
order_events::{store_order_events, OrderEventLabel},
},
driver_model::{reveal, settle, solve},
crate::database::{
competition::Competition,
order_events::{store_order_events, OrderEventLabel},
},
database,
model::{
app_data::AppDataHash,
bytes_hex,
interaction::InteractionData,
order::{
BuyTokenDestination,
Expand All @@ -26,6 +23,7 @@ pub use {
},
shared::order_validation::{is_order_outside_market_price, Amounts},
};
use {crate::domain, ethrpc::Web3, std::collections::HashMap, url::Url};

pub mod events;
pub mod order;
Expand Down
187 changes: 0 additions & 187 deletions crates/autopilot/src/driver_model.rs

This file was deleted.

6 changes: 6 additions & 0 deletions crates/autopilot/src/infra/solvers/dto/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! Types for communicating with drivers as defined in
//! `crates/driver/openapi.yml`.

pub mod reveal;
pub mod settle;
pub mod solve;
30 changes: 30 additions & 0 deletions crates/autopilot/src/infra/solvers/dto/reveal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use {
crate::boundary::bytes_hex,
serde::{Deserialize, Serialize},
serde_with::serde_as,
};

#[serde_as]
#[derive(Clone, Debug, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Request {
/// Unique ID of the solution (per driver competition), to reveal.
#[serde_as(as = "serde_with::DisplayFromStr")]
pub solution_id: u64,
}

#[serde_as]
#[derive(Clone, Debug, Default, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Calldata {
#[serde(with = "bytes_hex")]
pub internalized: Vec<u8>,
#[serde(with = "bytes_hex")]
pub uninternalized: Vec<u8>,
}

#[derive(Clone, Debug, Default, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Response {
pub calldata: Calldata,
}
33 changes: 33 additions & 0 deletions crates/autopilot/src/infra/solvers/dto/settle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use {
crate::boundary::bytes_hex,
primitive_types::H256,
serde::{Deserialize, Serialize},
serde_with::serde_as,
};

#[serde_as]
#[derive(Clone, Debug, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Request {
/// Unique ID of the solution (per driver competition), to settle.
#[serde_as(as = "serde_with::DisplayFromStr")]
pub solution_id: u64,
}

#[serde_as]
#[derive(Clone, Debug, Default, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Response {
pub calldata: Calldata,
pub tx_hash: H256,
}

#[serde_as]
#[derive(Clone, Debug, Default, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Calldata {
#[serde(with = "bytes_hex")]
pub internalized: Vec<u8>,
#[serde(with = "bytes_hex")]
pub uninternalized: Vec<u8>,
}
Loading

0 comments on commit a0e3ec7

Please sign in to comment.