-
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.
- Loading branch information
Showing
73 changed files
with
2,986 additions
and
3,385 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
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
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
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,81 @@ | ||
use crate::utils::{parse_address, parse_u256, parse_uopool_mode}; | ||
use aa_bundler_primitives::UoPoolMode; | ||
use clap::Parser; | ||
use ethers::types::{Address, U256}; | ||
use std::net::SocketAddr; | ||
|
||
#[derive(Clone, Copy, Debug, Parser, PartialEq)] | ||
pub struct UoPoolServiceOpts { | ||
#[clap(long, default_value = "127.0.0.1:3001")] | ||
pub uopool_grpc_listen_address: SocketAddr, | ||
|
||
#[clap(long, value_parser=parse_u256, default_value = "1")] | ||
pub min_stake: U256, | ||
|
||
#[clap(long, value_parser=parse_u256, default_value = "0")] | ||
pub min_unstake_delay: U256, | ||
|
||
#[clap(long, value_parser=parse_u256, default_value = "0")] | ||
pub min_priority_fee_per_gas: U256, | ||
|
||
#[clap(long, default_value = "standard", value_parser=parse_uopool_mode)] | ||
pub uo_pool_mode: UoPoolMode, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, Parser, PartialEq)] | ||
pub struct BundlerServiceOpts { | ||
#[clap(long, value_parser=parse_address)] | ||
pub beneficiary: Address, | ||
|
||
#[clap(long, default_value = "1", value_parser=parse_u256)] | ||
pub gas_factor: U256, | ||
|
||
#[clap(long, value_parser=parse_u256)] | ||
pub min_balance: U256, | ||
|
||
#[clap(long, default_value = "127.0.0.1:3002")] | ||
pub bundler_grpc_listen_address: SocketAddr, | ||
|
||
#[clap(long, default_value = "10")] | ||
pub bundle_interval: u64, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use std::{ | ||
net::{IpAddr, Ipv4Addr}, | ||
str::FromStr, | ||
}; | ||
|
||
#[test] | ||
fn bundler_opts() { | ||
let args = vec![ | ||
"bundleropts", | ||
"--beneficiary", | ||
"0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990", | ||
"--gas-factor", | ||
"600", | ||
"--min-balance", | ||
"1", | ||
"--bundler-grpc-listen-address", | ||
"127.0.0.1:3002", | ||
"--bundle-interval", | ||
"10", | ||
]; | ||
assert_eq!( | ||
BundlerServiceOpts { | ||
beneficiary: Address::from_str("0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990") | ||
.unwrap(), | ||
gas_factor: U256::from(600), | ||
min_balance: U256::from(1), | ||
bundler_grpc_listen_address: SocketAddr::new( | ||
IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), | ||
3002 | ||
), | ||
bundle_interval: 10, | ||
}, | ||
BundlerServiceOpts::try_parse_from(args).unwrap() | ||
); | ||
} | ||
} |
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,2 @@ | ||
pub mod cli; | ||
pub mod utils; |
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,18 @@ | ||
use aa_bundler_primitives::UoPoolMode; | ||
use ethers::types::{Address, U256}; | ||
use std::str::FromStr; | ||
|
||
/// Parses address from string | ||
pub fn parse_address(s: &str) -> Result<Address, String> { | ||
Address::from_str(s).map_err(|_| format!("String {s} is not a valid address")) | ||
} | ||
|
||
/// Parses U256 from string | ||
pub fn parse_u256(s: &str) -> Result<U256, String> { | ||
U256::from_str_radix(s, 10).map_err(|_| format!("String {s} is not a valid U256")) | ||
} | ||
|
||
/// Parses UoPoolMode from string | ||
pub fn parse_uopool_mode(s: &str) -> Result<UoPoolMode, String> { | ||
UoPoolMode::from_str(s).map_err(|_| format!("String {s} is not a valid UoPoolMode")) | ||
} |
Oops, something went wrong.