Skip to content

Commit

Permalink
Merge pull request #5 from renegade-fi/joey/funds-manager-backend
Browse files Browse the repository at this point in the history
funds-manager: Refactor into HTTP server setup
  • Loading branch information
joeykraut authored Jul 18, 2024
2 parents 16ae591 + bf02ad0 commit f9783e9
Show file tree
Hide file tree
Showing 23 changed files with 454 additions and 225 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"compliance/compliance-api",
"dealer/renegade-dealer",
"dealer/renegade-dealer-api",
"fee-sweeper",
"funds-manager",
"price-reporter",
]

Expand Down
125 changes: 0 additions & 125 deletions fee-sweeper/src/indexer/index_fees.rs

This file was deleted.

5 changes: 4 additions & 1 deletion fee-sweeper/Cargo.toml → funds-manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[package]
name = "fee-sweeper"
description = "Manages custody of funds for protocol operator"
version = "0.1.0"
edition = "2021"

[dependencies]
# === CLI + Runtime === #
# === CLI + Server === #
clap = { version = "4.5.3", features = ["derive", "env"] }
http-body-util = "0.1.0"
tokio = { version = "1.10", features = ["full"] }
warp = "0.3"

# === Infra === #
aws-sdk-secretsmanager = "1.37"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
69 changes: 69 additions & 0 deletions funds-manager/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//! Error types for the funds manager

use std::{error::Error, fmt::Display};

use warp::reject::Reject;

/// The error type emitted by the funds manager
#[derive(Debug, Clone)]
pub enum FundsManagerError {
/// An error with the arbitrum client
Arbitrum(String),
/// An error with a database query
Db(String),
/// An error executing an HTTP request
Http(String),
/// An error parsing a value
Parse(String),
/// An error with AWS secrets manager
SecretsManager(String),
/// A miscellaneous error
Custom(String),
}

impl FundsManagerError {
/// Create an arbitrum error
pub fn arbitrum<T: ToString>(msg: T) -> FundsManagerError {

Check failure on line 26 in funds-manager/src/error.rs

View workflow job for this annotation

GitHub Actions / clippy

this argument is passed by value, but not consumed in the function body

error: this argument is passed by value, but not consumed in the function body --> funds-manager/src/error.rs:26:39 | 26 | pub fn arbitrum<T: ToString>(msg: T) -> FundsManagerError { | ^ help: consider taking a reference instead: `&T` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value = note: requested on the command line with `-D clippy::needless-pass-by-value`
FundsManagerError::Arbitrum(msg.to_string())
}

/// Create a database error
pub fn db<T: ToString>(msg: T) -> FundsManagerError {

Check failure on line 31 in funds-manager/src/error.rs

View workflow job for this annotation

GitHub Actions / clippy

this argument is passed by value, but not consumed in the function body

error: this argument is passed by value, but not consumed in the function body --> funds-manager/src/error.rs:31:33 | 31 | pub fn db<T: ToString>(msg: T) -> FundsManagerError { | ^ help: consider taking a reference instead: `&T` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
FundsManagerError::Db(msg.to_string())
}

/// Create an HTTP error
pub fn http<T: ToString>(msg: T) -> FundsManagerError {

Check failure on line 36 in funds-manager/src/error.rs

View workflow job for this annotation

GitHub Actions / clippy

this argument is passed by value, but not consumed in the function body

error: this argument is passed by value, but not consumed in the function body --> funds-manager/src/error.rs:36:35 | 36 | pub fn http<T: ToString>(msg: T) -> FundsManagerError { | ^ help: consider taking a reference instead: `&T` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
FundsManagerError::Http(msg.to_string())
}

/// Create a parse error
pub fn parse<T: ToString>(msg: T) -> FundsManagerError {

Check failure on line 41 in funds-manager/src/error.rs

View workflow job for this annotation

GitHub Actions / clippy

this argument is passed by value, but not consumed in the function body

error: this argument is passed by value, but not consumed in the function body --> funds-manager/src/error.rs:41:36 | 41 | pub fn parse<T: ToString>(msg: T) -> FundsManagerError { | ^ help: consider taking a reference instead: `&T` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
FundsManagerError::Parse(msg.to_string())
}

/// Create a secrets manager error
pub fn secrets_manager<T: ToString>(msg: T) -> FundsManagerError {

Check failure on line 46 in funds-manager/src/error.rs

View workflow job for this annotation

GitHub Actions / clippy

this argument is passed by value, but not consumed in the function body

error: this argument is passed by value, but not consumed in the function body --> funds-manager/src/error.rs:46:46 | 46 | pub fn secrets_manager<T: ToString>(msg: T) -> FundsManagerError { | ^ help: consider taking a reference instead: `&T` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
FundsManagerError::SecretsManager(msg.to_string())
}

/// Create a custom error
pub fn custom<T: ToString>(msg: T) -> FundsManagerError {

Check failure on line 51 in funds-manager/src/error.rs

View workflow job for this annotation

GitHub Actions / clippy

this argument is passed by value, but not consumed in the function body

error: this argument is passed by value, but not consumed in the function body --> funds-manager/src/error.rs:51:37 | 51 | pub fn custom<T: ToString>(msg: T) -> FundsManagerError { | ^ help: consider taking a reference instead: `&T` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
FundsManagerError::Custom(msg.to_string())
}
}

impl Display for FundsManagerError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
FundsManagerError::Arbitrum(e) => write!(f, "Arbitrum error: {}", e),
FundsManagerError::Db(e) => write!(f, "Database error: {}", e),
FundsManagerError::Http(e) => write!(f, "HTTP error: {}", e),
FundsManagerError::Parse(e) => write!(f, "Parse error: {}", e),
FundsManagerError::SecretsManager(e) => write!(f, "Secrets manager error: {}", e),
FundsManagerError::Custom(e) => write!(f, "Custom error: {}", e),
}
}
}
impl Error for FundsManagerError {}
impl Reject for FundsManagerError {}
Loading

0 comments on commit f9783e9

Please sign in to comment.