Skip to content

Commit

Permalink
changed all println! to info!, different default output path
Browse files Browse the repository at this point in the history
  • Loading branch information
Vid201 committed Nov 25, 2022
1 parent d3dab9f commit 8b4794d
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 16 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# Rust
/target

# bundler wallets
/src/res/bundler/0x*
/target
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ anyhow = "1"
async-trait = "0.1"
bytes = { version = "1", features = ["serde"] }
clap = { version = "4", features = ["derive"] }
dirs = "4.0"
educe = { version = "0.4", features = ["Debug", "Default"] }
ethereum-interfaces = { git = "https://github.com/ledgerwatch/interfaces" }
ethereum-types = { version = "0.14", features = ["codec"] }
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run-bundler:
cargo run -- --mnemonic-file ./src/res/bundler/0xF78bB01dFd478608F5738fB0560642b2806D295E
cargo run -- --mnemonic-file ${HOME}/.aa-bundler/0x129D197b2a989C6798601A49D89a4AEC822A17a3

run-bundler-uopool:
cargo run --bin bundler-uopool
Expand All @@ -8,7 +8,7 @@ run-bundler-rpc:
cargo run --bin bundler-rpc

run-create-wallet:
cargo run --bin create-wallet -- --output-folder ./src/res/bundler
cargo run --bin create-wallet -- --output-path ${HOME}/.aa-bundler

cargo-fmt:
cargo fmt --all
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ For more information: https://hackmd.io/@Vid201/aa-bundler-rust
Create wallet for bundler:

```bash
cargo run --bin create-wallet -- --output-folder ./src/res/bundler
cargo run --bin create-wallet -- --output-path ${HOME}/.aa-bundler
```

Run bundler (with user operation pool and JSON-RPC API):

```bash
cargo run -- --mnemonic-file ./src/res/bundler/0xF78bB01dFd478608F5738fB0560642b2806D295E
cargo run -- --mnemonic-file ${HOME}/.aa-bundler/0x129D197b2a989C6798601A49D89a4AEC822A17a3
```

Run only user operation pool:
Expand Down
2 changes: 1 addition & 1 deletion bin/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() -> Result<()> {
info!("Starting AA - Bundler");

let wallet = Wallet::from_file(opt.mnemonic_file);
println!("{:?}", wallet.signer);
info!("{:?}", wallet.signer);

let bundler = Bundler::new(wallet);

Expand Down
18 changes: 14 additions & 4 deletions bin/create-wallet.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
use aa_bundler::models::wallet::Wallet;
use anyhow::Result;
use clap::Parser;
use dirs::home_dir;
use expanded_pathbuf::ExpandedPathBuf;
use jsonrpsee::tracing::info;
use std::str::FromStr;

#[derive(Parser)]
#[clap(
name = "aa-bundler-create-wallet",
about = "Bundler's wallet creation for EIP-4337 Account Abstraction"
)]
pub struct Opt {
#[clap(long, default_value = "./src/res/bundler")]
pub output_folder: ExpandedPathBuf,
#[clap(long)]
pub output_path: Option<ExpandedPathBuf>,
}

fn main() -> Result<()> {
let opt: Opt = Opt::parse();

tracing_subscriber::fmt::init();

let wallet = Wallet::new(opt.output_folder);
println!("{:?}", wallet.signer);
let path = if let Some(output_path) = opt.output_path {
output_path
} else {
ExpandedPathBuf::from_str(home_dir().unwrap().join(".aa-bundler").to_str().unwrap())
.unwrap()
};

let wallet = Wallet::new(path);
info!("{:?}", wallet.signer);

Ok(())
}
3 changes: 3 additions & 0 deletions src/models/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use ethers::{
signers::{coins_bip39::English, MnemonicBuilder},
};
use expanded_pathbuf::ExpandedPathBuf;
use std::fs;

pub struct Wallet {
pub signer: ethers::signers::Wallet<SigningKey>,
Expand All @@ -12,6 +13,8 @@ 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();

Self {
signer: MnemonicBuilder::<English>::default()
.write_to(output_path.to_path_buf())
Expand Down
Empty file removed src/res/bundler/.gitkeep
Empty file.
6 changes: 3 additions & 3 deletions src/rpc/eth.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{rpc::eth_api::EthApiServer, types::user_operation::UserOperation};
use async_trait::async_trait;
use ethereum_types::{Address, U64};
use jsonrpsee::core::RpcResult;
use jsonrpsee::{core::RpcResult, tracing::info};

pub struct EthApiServerImpl {
pub call_gas_limit: u64,
Expand All @@ -22,8 +22,8 @@ impl EthApiServer for EthApiServerImpl {
user_operation: UserOperation,
entry_point: Address,
) -> RpcResult<bool> {
println!("{:?}", user_operation);
println!("{:?}", entry_point);
info!("{:?}", user_operation);
info!("{:?}", entry_point);
Ok(true)
}
}

0 comments on commit 8b4794d

Please sign in to comment.