From 40ae7951c60438355c273788b625c19063b6a3c8 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 3 Oct 2024 11:52:32 +0200 Subject: [PATCH] fix: set chain id for eth signer (#1425) * fix: set chain id for eth signer * move import * dep aloy signer * ffs * another test --- crates/provider/Cargo.toml | 2 ++ crates/provider/src/builder.rs | 5 ++++- crates/provider/src/fillers/wallet.rs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/provider/Cargo.toml b/crates/provider/Cargo.toml index a78f5a151289..4351fd27cac8 100644 --- a/crates/provider/Cargo.toml +++ b/crates/provider/Cargo.toml @@ -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 } @@ -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 = [] diff --git a/crates/provider/src/builder.rs b/crates/provider/src/builder.rs index 8cd063346b42..47cb61f67ed2 100644 --- a/crates/provider/src/builder.rs +++ b/crates/provider/src/builder.rs @@ -482,6 +482,8 @@ impl ProviderBuilder { alloy_transport_http::Http, >, { + use alloy_signer::Signer; + let anvil_layer = crate::layers::AnvilLayer::from(f(Default::default())); let url = anvil_layer.endpoint_url(); @@ -489,7 +491,8 @@ impl ProviderBuilder { 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| { diff --git a/crates/provider/src/fillers/wallet.rs b/crates/provider/src/fillers/wallet.rs index caa321a35b35..81dd23e3a36d 100644 --- a/crates/provider/src/fillers/wallet.rs +++ b/crates/provider/src/fillers/wallet.rs @@ -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();