-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Vid201/feat/wallet
Bundler wallet (#2)
- Loading branch information
Showing
16 changed files
with
120 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/target | ||
# Rust | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
run-bundler: | ||
cargo run -- --mnemonic-file ./src/res/bundler/0xD00D3EEc454D05d3d9bB48532BabED0c89941f17 | ||
cargo run -- --mnemonic-file ${HOME}/.aa-bundler/0x129D197b2a989C6798601A49D89a4AEC822A17a3 | ||
|
||
run-bundler-uopool: | ||
cargo run --bin bundler-uopool | ||
|
||
run-bundler-rpc: | ||
cargo run --bin bundler-rpc | ||
|
||
run-create-wallet: | ||
cargo run --bin create-wallet -- --output-path ${HOME}/.aa-bundler | ||
|
||
cargo-fmt: | ||
cargo fmt --all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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)] | ||
pub output_path: Option<ExpandedPathBuf>, | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let opt: Opt = Opt::parse(); | ||
|
||
tracing_subscriber::fmt::init(); | ||
|
||
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(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use crate::models::wallet::Wallet; | ||
|
||
pub struct Bundler { | ||
pub wallet: Wallet, | ||
} | ||
|
||
impl Bundler { | ||
pub fn new(wallet: Wallet) -> Self { | ||
Self { wallet } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod bundler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod bundler; | ||
pub mod models; | ||
pub mod rpc; | ||
pub mod types; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod chainspec; | ||
pub mod wallet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use ethers::{ | ||
prelude::{k256::ecdsa::SigningKey, rand}, | ||
signers::{coins_bip39::English, MnemonicBuilder}, | ||
}; | ||
use expanded_pathbuf::ExpandedPathBuf; | ||
use std::fs; | ||
|
||
pub struct Wallet { | ||
pub signer: ethers::signers::Wallet<SigningKey>, | ||
} | ||
|
||
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()) | ||
.build_random(&mut rng) | ||
.unwrap(), | ||
} | ||
} | ||
|
||
pub fn from_file(input_path: ExpandedPathBuf) -> Self { | ||
Self { | ||
signer: MnemonicBuilder::<English>::default() | ||
.phrase(input_path.to_path_buf()) | ||
.build() | ||
.unwrap(), | ||
} | ||
} | ||
} |
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters