Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix: parse privat keys correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Aug 11, 2023
1 parent 20dcdd0 commit 8064174
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ethers-core/src/utils/anvil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl Anvil {
}

if is_private_key && line.starts_with('(') {
let key_str = &line[6..line.len() - 1];
let key_str = line.split("0x").last().unwrap_or_else(|| panic!("could not parse private key: {}", line)).trim();
let key_hex = hex::decode(key_str).expect("could not parse as hex");
let key = K256SecretKey::from_bytes(&GenericArray::clone_from_slice(&key_hex))
.expect("did not get private key");
Expand All @@ -293,4 +293,9 @@ mod tests {
fn can_launch_anvil() {
let _ = Anvil::new().spawn();
}

#[test]
fn can_launch_anvil_with_more_accounts() {
let _ = Anvil::new().arg("--accounts").arg("20").spawn();
}
}

0 comments on commit 8064174

Please sign in to comment.