-
Notifications
You must be signed in to change notification settings - Fork 2k
chore: bump to rust edition 2024 #10802
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ pub struct HexIdProvider { | |
|
||
impl HexIdProvider { | ||
/// Generates a random hex encoded Id | ||
pub fn gen(&self) -> String { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
pub fn generate(&self) -> String { | ||
let id: String = | ||
(&mut rng()).sample_iter(Alphanumeric).map(char::from).take(self.len).collect(); | ||
let out = hex::encode(id); | ||
|
@@ -62,5 +62,5 @@ impl Default for HexIdProvider { | |
|
||
/// Returns a new random hex identifier | ||
pub fn hex_id() -> String { | ||
HexIdProvider::default().gen() | ||
HexIdProvider::default().generate() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ use foundry_config::{Chain, Config, FigmentProviders}; | |
use futures::FutureExt; | ||
use rand_08::{rngs::StdRng, SeedableRng}; | ||
use std::{ | ||
future::Future, | ||
net::IpAddr, | ||
path::{Path, PathBuf}, | ||
pin::Pin, | ||
|
@@ -287,27 +286,27 @@ impl NodeArgs { | |
} | ||
|
||
fn account_generator(&self) -> AccountGenerator { | ||
let mut gen = AccountGenerator::new(self.accounts as usize) | ||
let mut generate = AccountGenerator::new(self.accounts as usize) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generator |
||
.phrase(DEFAULT_MNEMONIC) | ||
.chain_id(self.evm.chain_id.unwrap_or(CHAIN_ID.into())); | ||
if let Some(ref mnemonic) = self.mnemonic { | ||
gen = gen.phrase(mnemonic); | ||
generate = generate.phrase(mnemonic); | ||
} else if let Some(count) = self.mnemonic_random { | ||
let mut rng = rand_08::thread_rng(); | ||
let mnemonic = match Mnemonic::<English>::new_with_count(&mut rng, count) { | ||
Ok(mnemonic) => mnemonic.to_phrase(), | ||
Err(_) => DEFAULT_MNEMONIC.to_string(), | ||
}; | ||
gen = gen.phrase(mnemonic); | ||
generate = generate.phrase(mnemonic); | ||
} else if let Some(seed) = self.mnemonic_seed { | ||
let mut seed = StdRng::seed_from_u64(seed); | ||
let mnemonic = Mnemonic::<English>::new(&mut seed).to_phrase(); | ||
gen = gen.phrase(mnemonic); | ||
generate = generate.phrase(mnemonic); | ||
} | ||
if let Some(ref derivation) = self.derivation_path { | ||
gen = gen.derivation_path(derivation); | ||
generate = generate.derivation_path(derivation); | ||
} | ||
gen | ||
generate | ||
} | ||
|
||
/// Returns the location where to dump the state to. | ||
|
@@ -920,11 +919,11 @@ mod tests { | |
["::1", "1.1.1.1", "2.2.2.2"].map(|ip| ip.parse::<IpAddr>().unwrap()).to_vec() | ||
); | ||
|
||
env::set_var("ANVIL_IP_ADDR", "1.1.1.1"); | ||
unsafe { env::set_var("ANVIL_IP_ADDR", "1.1.1.1"); } | ||
let args = NodeArgs::parse_from(["anvil"]); | ||
assert_eq!(args.host, vec!["1.1.1.1".parse::<IpAddr>().unwrap()]); | ||
|
||
env::set_var("ANVIL_IP_ADDR", "::1,1.1.1.1,2.2.2.2"); | ||
unsafe { env::set_var("ANVIL_IP_ADDR", "::1,1.1.1.1,2.2.2.2"); } | ||
let args = NodeArgs::parse_from(["anvil"]); | ||
assert_eq!( | ||
args.host, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,7 +232,7 @@ Private Keys | |
let _ = write!(s, "\n({idx}) 0x{hex}"); | ||
} | ||
|
||
if let Some(ref gen) = self.account_generator { | ||
if let Some(ref generate) = self.account_generator { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generator |
||
let _ = write!( | ||
s, | ||
r#" | ||
|
@@ -242,8 +242,8 @@ Wallet | |
Mnemonic: {} | ||
Derivation path: {} | ||
"#, | ||
gen.phrase, | ||
gen.get_derivation_path() | ||
generate.phrase, | ||
generate.get_derivation_path() | ||
); | ||
} | ||
|
||
|
@@ -365,9 +365,9 @@ Genesis Number | |
private_keys.push(format!("0x{}", hex::encode(wallet.credential().to_bytes()))); | ||
} | ||
|
||
if let Some(ref gen) = self.account_generator { | ||
let phrase = gen.get_phrase().to_string(); | ||
let derivation_path = gen.get_derivation_path().to_string(); | ||
if let Some(ref generate) = self.account_generator { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generator |
||
let phrase = generate.get_phrase().to_string(); | ||
let derivation_path = generate.get_derivation_path().to_string(); | ||
|
||
wallet_description.insert("derivation_path".to_string(), derivation_path); | ||
wallet_description.insert("mnemonic".to_string(), phrase); | ||
|
@@ -430,7 +430,7 @@ impl Default for NodeConfig { | |
fn default() -> Self { | ||
// generate some random wallets | ||
let genesis_accounts = | ||
AccountGenerator::new(10).phrase(DEFAULT_MNEMONIC).gen().expect("Invalid mnemonic."); | ||
AccountGenerator::new(10).phrase(DEFAULT_MNEMONIC).generate().expect("Invalid mnemonic."); | ||
Self { | ||
chain_id: None, | ||
gas_limit: None, | ||
|
@@ -719,7 +719,7 @@ impl NodeConfig { | |
/// Sets both the genesis accounts and the signer accounts | ||
/// so that `genesis_accounts == accounts` | ||
pub fn with_account_generator(mut self, generator: AccountGenerator) -> eyre::Result<Self> { | ||
let accounts = generator.gen()?; | ||
let accounts = generator.generate()?; | ||
self.account_generator = Some(generator); | ||
Ok(self.with_signer_accounts(accounts.clone()).with_genesis_accounts(accounts)) | ||
} | ||
|
@@ -1551,7 +1551,7 @@ impl AccountGenerator { | |
} | ||
|
||
impl AccountGenerator { | ||
pub fn gen(&self) -> eyre::Result<Vec<PrivateKeySigner>> { | ||
pub fn generate(&self) -> eyre::Result<Vec<PrivateKeySigner>> { | ||
let builder = MnemonicBuilder::<English>::default().phrase(self.phrase.as_str()); | ||
|
||
// use the derivation path | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
use std::{ | ||
collections::BTreeMap, | ||
fmt, | ||
future::Future, | ||
pin::Pin, | ||
sync::Arc, | ||
task::{Context, Poll}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ use futures::{ | |
FutureExt, | ||
}; | ||
use std::{ | ||
future::Future, | ||
pin::Pin, | ||
task::{Context, Poll}, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ impl Cheatcode for setEnvCall { | |
} else if value.contains('\0') { | ||
Err(fmt_err!("environment variable value can't contain NUL character `\\0`")) | ||
} else { | ||
env::set_var(key, value); | ||
unsafe { env::set_var(key, value); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Ok(Default::default()) | ||
} | ||
} | ||
|
@@ -308,10 +308,10 @@ mod tests { | |
fn parse_env_uint() { | ||
let key = "parse_env_uint"; | ||
let value = "t"; | ||
env::set_var(key, value); | ||
unsafe { env::set_var(key, value); } | ||
|
||
let err = env(key, &DynSolType::Uint(256)).unwrap_err().to_string(); | ||
assert_eq!(err.matches("$parse_env_uint").count(), 2, "{err:?}"); | ||
env::remove_var(key); | ||
unsafe { env::remove_var(key); } | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found out we were pinning to this specific nightly, this seems unintended / resolved