Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI
on:
pull_request:
push:
branches: [main]

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2025-02-25
components: rustfmt
- run: cargo +nightly-2025-02-25 fmt --all --check

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85
components: clippy
- name: Install protoc
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
protoc --version
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-targets --all-features
env:
RUSTFLAGS: -D warnings

test-stable:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.85
- name: Install protoc
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
protoc --version
- uses: Swatinem/rust-cache@v2
- run: cargo test --all-features --no-fail-fast
2 changes: 1 addition & 1 deletion src/config/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn default_log_level() -> String {
impl Default for LoggingConfig {
fn default() -> Self {
LoggingConfig {
log_level: default_log_level()
log_level: default_log_level(),
}
}
}
2 changes: 1 addition & 1 deletion src/server/builder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::server::pre_sign::PreSignHook;
use crate::server::Server;
use crate::server::pre_sign::PreSignHook;
use crate::signer::signature::ecdsa::EcdsaSignature;
use crate::signer::{EvmSigner, Signer};
use std::collections::HashMap;
Expand Down
9 changes: 6 additions & 3 deletions src/server/middleware/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ const DEFAULT_HEADER_API_KEY: &str = "api-key";
#[derive(Debug, Clone, Default)]
pub struct AuthMiddlewareLayer<S: Store> {
pub store: S,
pub header_api_key: String
pub header_api_key: String,
}

impl<S: Store> AuthMiddlewareLayer<S> {
pub fn new(store: S, header_api_key: Option<String>) -> Self {
let header_api_key = header_api_key.unwrap_or_else(|| DEFAULT_HEADER_API_KEY.to_string());
Self { store, header_api_key }
let header_api_key = header_api_key.unwrap_or_else(|| DEFAULT_HEADER_API_KEY.to_string());
Self {
store,
header_api_key,
}
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/server/middleware/auth/store/sql.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::marker::PhantomData;

use sea_orm::{entity::EntityTrait, DatabaseConnection, DbErr, PrimaryKeyTrait};
use sea_orm::{DatabaseConnection, DbErr, PrimaryKeyTrait, entity::EntityTrait};

use super::Store;

Expand All @@ -15,14 +15,17 @@ where
<<E as EntityTrait>::PrimaryKey as PrimaryKeyTrait>::ValueType: From<String>,
{
pub fn new(db_conn: DatabaseConnection) -> Self {
Self { db_conn, _entity: PhantomData }
Self {
db_conn,
_entity: PhantomData,
}
}
}

#[async_trait::async_trait]
impl<E: EntityTrait> Store for SqlDb<E>
where
for <'a> <<E as EntityTrait>::PrimaryKey as PrimaryKeyTrait>::ValueType: From<&'a str>,
for<'a> <<E as EntityTrait>::PrimaryKey as PrimaryKeyTrait>::ValueType: From<&'a str>,
{
type Error = DbErr;
async fn verify_api_key(&self, api_key: &str) -> Result<(), Self::Error> {
Expand Down
Loading