Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub actions #29

Merged
merged 3 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused.


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,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


#[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 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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