Skip to content

Commit

Permalink
Merge pull request #29 from zsluedem/github-actions
Browse files Browse the repository at this point in the history
Add GitHub actions
  • Loading branch information
zsluedem authored Jan 2, 2023
2 parents ff18a04 + 1240f2f commit 174d672
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 29 deletions.
25 changes: 25 additions & 0 deletions .github/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on: [push]

name: CI

jobs:
build_and_test:
name: Rust project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: Setup
run: |
make fetch-thirdparty
- name: Lint
run: |
make lint
- name: Test
run: |
make cargo-test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Rust
/target
/target
.local
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ run-create-wallet:
cargo-fmt:
cargo fmt --all

lint:
cargo fmt --all -- --check
cargo clippy -- -D warnings -A clippy::derive_partial_eq_without_eq

cargo-test:
cargo test

Expand Down
1 change: 0 additions & 1 deletion bin/bundler-rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use anyhow::Result;
use clap::Parser;
use jsonrpsee::{core::server::rpc_module::Methods, server::ServerBuilder, tracing::info};
use std::future::pending;
use tracing_subscriber;

use aa_bundler::rpc::{eth::EthApiServerImpl, eth_api::EthApiServer};

Expand Down
2 changes: 1 addition & 1 deletion bin/bundler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use aa_bundler::{
bundler::bundler::Bundler,
bundler::Bundler,
models::wallet::Wallet,
rpc::{eth::EthApiServerImpl, eth_api::EthApiServer},
};
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ethers::solc::{Project, ProjectPathsConfig};

fn config() -> prost_build::Config {
let mut config = prost_build::Config::new();
config.bytes(&["."]);
config.bytes(["."]);
config
}

Expand Down
11 changes: 0 additions & 11 deletions src/bundler/bundler.rs

This file was deleted.

14 changes: 12 additions & 2 deletions src/bundler/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pub mod bundler;

use std::str::FromStr;

use clap::Parser;
use ethers::types::{Address, U256};

use crate::models::wallet::Wallet;

#[derive(Debug, Parser, PartialEq)]
pub struct BundlerOpts {
#[clap(long, value_parser=parse_address)]
Expand Down Expand Up @@ -34,6 +34,16 @@ fn parse_u256(s: &str) -> Result<U256, String> {
U256::from_str_radix(s, 10).map_err(|_| format!("{} is not a valid U256", s))
}

pub struct Bundler {
pub wallet: Wallet,
}

impl Bundler {
pub fn new(wallet: Wallet) -> Self {
Self { wallet }
}
}

#[cfg(test)]
mod test {
use super::*;
Expand Down
13 changes: 6 additions & 7 deletions src/contracts/entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::sync::Arc;

use anyhow;
use ethers::abi::AbiDecode;
use ethers::prelude::ContractError;
use ethers::providers::Middleware;
use ethers::types::{Address, Bytes};
use regex::Regex;
Expand All @@ -23,7 +22,7 @@ impl<M: Middleware + 'static> EntryPoint<M> {
let api = EntryPointAPI::new(entry_point_address, provider.clone());
Self {
provider,
entry_point_address: entry_point_address,
entry_point_address,
api,
}
}
Expand All @@ -39,7 +38,7 @@ impl<M: Middleware + 'static> EntryPoint<M> {
fn deserialize_error_msg(
err_msg: &str,
) -> Result<entry_point_api::EntryPointAPIErrors, EntryPointErr> {
JsonRpcError::from_str(&err_msg)
JsonRpcError::from_str(err_msg)
.map_err(|_| {
EntryPointErr::DecodeErr(format!(
"{:?} is not a valid JsonRpcError message",
Expand Down Expand Up @@ -115,7 +114,7 @@ impl<M: Middleware + 'static> EntryPoint<M> {
})
}

async fn get_sender_address<U: Into<UserOperation>>(
pub async fn get_sender_address<U: Into<UserOperation>>(
&self,
initcode: Bytes,
) -> Result<entry_point_api::SenderAddressResult, EntryPointErr> {
Expand All @@ -141,10 +140,10 @@ impl<M: Middleware + 'static> EntryPoint<M> {
}
}

async fn handle_aggregated_ops<U: Into<UserOperation>>(
pub async fn handle_aggregated_ops<U: Into<UserOperation>>(
&self,
ops_per_aggregator: Vec<U>,
beneficiary: Address,
_ops_per_aggregator: Vec<U>,
_beneficiary: Address,
) -> Result<(), EntryPointErr> {
todo!()
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Wallet {
pub fn new(output_path: ExpandedPathBuf) -> Self {
let mut rng = rand::thread_rng();

fs::create_dir_all(output_path.to_path_buf()).unwrap();
fs::create_dir_all(&output_path).unwrap();

Self {
signer: MnemonicBuilder::<English>::default()
Expand Down
2 changes: 1 addition & 1 deletion src/types/user_operation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ethers::abi::AbiEncode;
use ethers::prelude::{EthAbiCodec, EthAbiType};
use ethers::types::{Address, Bytes, H256, U256, TransactionReceipt};
use ethers::types::{Address, Bytes, TransactionReceipt, H256, U256};
use ethers::utils::keccak256;
use serde::{Deserialize, Serialize};
use std::str::FromStr;
Expand Down
8 changes: 7 additions & 1 deletion src/uopool/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
types::user_operation::{UserOperation, UserOperationHash},
uopool::{server::server::uo_pool_server::UoPoolServer, services::UoPoolService},
uopool::{server::uopool_server::uo_pool_server::UoPoolServer, services::UoPoolService},
};
use anyhow::Result;
use clap::Parser;
Expand All @@ -26,6 +26,12 @@ impl UserOperationPool {
}
}

impl Default for UserOperationPool {
fn default() -> Self {
Self::new()
}
}

#[derive(Educe, Parser)]
#[educe(Debug)]
pub struct UoPoolOpts {
Expand Down
2 changes: 1 addition & 1 deletion src/uopool/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ mod types {
tonic::include_proto!("types");
}

pub mod server {
pub mod uopool_server {
tonic::include_proto!("uopool");
}
2 changes: 1 addition & 1 deletion src/uopool/services/uopool.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use crate::uopool::{
server::server::{
server::uopool_server::{
uo_pool_server::UoPool, AddRequest, AddResponse, AllRequest, AllResponse, RemoveRequest,
RemoveResponse,
},
Expand Down

0 comments on commit 174d672

Please sign in to comment.