Skip to content

Commit

Permalink
fix: set chain id for eth signer (alloy-rs#1425)
Browse files Browse the repository at this point in the history
* fix: set chain id for eth signer

* move import

* dep aloy signer

* ffs

* another test
  • Loading branch information
mattsse authored and yutianwu committed Oct 21, 2024
1 parent a2792f0 commit 40ae795
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crates/provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ alloy-network.workspace = true
alloy-network-primitives.workspace = true
alloy-node-bindings = { workspace = true, optional = true }
alloy-signer-local = { workspace = true, optional = true }
alloy-signer = { workspace = true, optional = true }
alloy-rpc-client.workspace = true
alloy-rpc-types-admin = { workspace = true, optional = true }
alloy-rpc-types-anvil = { workspace = true, optional = true }
Expand Down Expand Up @@ -107,6 +108,7 @@ anvil-node = [
"reqwest",
"dep:alloy-node-bindings",
"dep:alloy-signer-local",
"dep:alloy-signer",
]
debug-api = ["dep:alloy-rpc-types-trace"]
erc4337-api = []
Expand Down
5 changes: 4 additions & 1 deletion crates/provider/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,14 +482,17 @@ impl<L, F> ProviderBuilder<L, F, Ethereum> {
alloy_transport_http::Http<reqwest::Client>,
>,
{
use alloy_signer::Signer;

let anvil_layer = crate::layers::AnvilLayer::from(f(Default::default()));
let url = anvil_layer.endpoint_url();

let default_keys = anvil_layer.instance().keys().to_vec();
let (default_key, remaining_keys) =
default_keys.split_first().ok_or(alloy_node_bindings::NodeError::NoKeysAvailable)?;

let default_signer = alloy_signer_local::LocalSigner::from(default_key.clone());
let default_signer = alloy_signer_local::LocalSigner::from(default_key.clone())
.with_chain_id(Some(anvil_layer.instance().chain_id()));
let mut wallet = alloy_network::EthereumWallet::from(default_signer);

remaining_keys.iter().for_each(|key| {
Expand Down
2 changes: 1 addition & 1 deletion crates/provider/src/fillers/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ mod tests {
let node_hash = *builder.tx_hash();
assert_eq!(
node_hash,
b256!("eb56033eab0279c6e9b685a5ec55ea0ff8d06056b62b7f36974898d4fbb57e64")
b256!("4b56f1a6bdceb76d1b843e978c70ab88e38aa19f1a67be851b10ce4eec65b7d4")
);

let pending = builder.register().await.unwrap();
Expand Down

0 comments on commit 40ae795

Please sign in to comment.