Skip to content

Commit

Permalink
Merge pull request #9 from renegade-fi/joey/custody-skeleton
Browse files Browse the repository at this point in the history
funds-manager: funds-manager-api: Refactor crates for custody API
  • Loading branch information
joeykraut authored Jul 23, 2024
2 parents 6ef7200 + 7650509 commit 5ac9f4a
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ members = [
"compliance/compliance-api",
"dealer/renegade-dealer",
"dealer/renegade-dealer-api",
"funds-manager",
"funds-manager/funds-manager-api",
"funds-manager/funds-manager-server",
"price-reporter",
]

Expand Down
4 changes: 2 additions & 2 deletions funds-manager/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ WORKDIR /build
RUN apt-get update && \
apt-get install -y pkg-config libssl-dev libclang-dev libpq-dev

# Update Cargo.toml to include only "funds-manager" in workspace members
RUN sed -i '/members[[:space:]]*=[[:space:]]*\[/,/\]/c\members = ["funds-manager"]' Cargo.toml
# Update Cargo.toml to include only "funds-manager/funds-manager-server" in workspace members
RUN sed -i '/members[[:space:]]*=[[:space:]]*\[/,/\]/c\members = ["funds-manager/funds-manager-server"]' Cargo.toml
RUN cargo chef prepare --recipe-path recipe.json --bin funds-manager

# Build only the dependencies to cache them in this layer
Expand Down
2 changes: 1 addition & 1 deletion funds-manager/diesel.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# see https://diesel.rs/guides/configuring-diesel-cli

[print_schema]
file = "src/db/schema.rs"
file = "funds-manager-server/src/db/schema.rs"
custom_type_derives = ["diesel::query_builder::QueryId", "Clone"]

[migrations_directory]
Expand Down
6 changes: 6 additions & 0 deletions funds-manager/funds-manager-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "funds-manager-api"
version = "0.1.0"
edition = "2021"

[dependencies]
14 changes: 14 additions & 0 deletions funds-manager/funds-manager-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! The API for the funds manager
#![deny(missing_docs)]
#![deny(clippy::missing_docs_in_private_items)]

// --------------
// | Api Routes |
// --------------

/// The ping route
pub const PING_ROUTE: &str = "ping";
/// The route through which a client may start the fee indexing process
pub const INDEX_FEES_ROUTE: &str = "index-fees";
/// The route through which a client may start the fee redemption process
pub const REDEEM_FEES_ROUTE: &str = "redeem-fees";
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ edition = "2021"
[dependencies]
# === CLI + Server === #
clap = { version = "4.5.3", features = ["derive", "env"] }
funds-manager-api = { path = "../funds-manager-api" }
http-body-util = "0.1.0"
tokio = { version = "1.10", features = ["full"] }
warp = "0.3"


# === Infra === #
aws-sdk-secretsmanager = "1.37"
aws-config = "1.5"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

pub mod db;
pub mod error;
pub mod indexer;
pub mod fee_indexer;
pub mod relayer_client;

use aws_config::{BehaviorVersion, Region, SdkConfig};
use error::FundsManagerError;
use ethers::signers::LocalWallet;
use indexer::Indexer;
use fee_indexer::Indexer;
use funds_manager_api::{INDEX_FEES_ROUTE, PING_ROUTE, REDEEM_FEES_ROUTE};
use relayer_client::RelayerClient;
use renegade_circuit_types::elgamal::DecryptionKey;
use renegade_util::{err_str, raw_err_str, telemetry::configure_telemetry};
Expand Down Expand Up @@ -178,16 +179,16 @@ async fn main() -> Result<(), Box<dyn Error>> {
// --- Routes --- //

let ping = warp::get()
.and(warp::path("ping"))
.and(warp::path(PING_ROUTE))
.map(|| warp::reply::with_status("PONG", warp::http::StatusCode::OK));

let index_fees = warp::post()
.and(warp::path("index-fees"))
.and(warp::path(INDEX_FEES_ROUTE))
.and(with_server(Arc::new(server.clone())))
.and_then(index_fees_handler);

let redeem_fees = warp::post()
.and(warp::path("redeem-fees"))
.and(warp::path(REDEEM_FEES_ROUTE))
.and(with_server(Arc::new(server.clone())))
.and_then(redeem_fees_handler);

Expand Down
File renamed without changes.

0 comments on commit 5ac9f4a

Please sign in to comment.