diff --git a/Cargo.toml b/Cargo.toml index 1d25c1d9411..d522d4eff3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,6 +57,7 @@ tracing-subscriber = "0.3.18" tempfile = "3.8" +auto_impl = "1.1" assert_matches = "1.5" base64 = "0.21" bimap = "0.6" diff --git a/crates/signer/Cargo.toml b/crates/signer/Cargo.toml index 7c3b8b023ba..53a5eb2d7f7 100644 --- a/crates/signer/Cargo.toml +++ b/crates/signer/Cargo.toml @@ -16,6 +16,7 @@ alloy-primitives.workspace = true # TODO # alloy-rpc-types.workspace = true +auto_impl.workspace = true elliptic-curve.workspace = true k256.workspace = true rand.workspace = true diff --git a/crates/signer/src/signer.rs b/crates/signer/src/signer.rs index dad630d26fb..319f3b31cfa 100644 --- a/crates/signer/src/signer.rs +++ b/crates/signer/src/signer.rs @@ -1,6 +1,7 @@ use crate::{Result, Signature}; use alloy_primitives::{eip191_hash_message, Address, B256}; use async_trait::async_trait; +use auto_impl::auto_impl; #[cfg(feature = "eip712")] use alloy_sol_types::{Eip712Domain, SolStruct}; @@ -15,6 +16,7 @@ use alloy_sol_types::{Eip712Domain, SolStruct}; /// Synchronous signers should implement both this trait and [`SignerSync`]. #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] #[cfg_attr(not(target_arch = "wasm32"), async_trait)] +#[auto_impl(&mut, Box)] pub trait Signer: Send + Sync { /// Signs the given hash. async fn sign_hash(&self, hash: &B256) -> Result; @@ -62,6 +64,7 @@ pub trait Signer: Send + Sync { /// Sets the signer's chain ID and returns `self`. #[inline] #[must_use] + #[auto_impl(keep_default_for(&mut, Box))] fn with_chain_id(mut self, chain_id: u64) -> Self where Self: Sized, @@ -80,6 +83,7 @@ pub trait Signer: Send + Sync { /// /// Synchronous signers should also implement [`Signer`], as they are always able to by delegating /// the asynchronous methods to the synchronous ones. +#[auto_impl(&, &mut, Box, Rc, Arc)] pub trait SignerSync { /// Signs the given hash. fn sign_hash_sync(&self, hash: &B256) -> Result;