diff --git a/crates/signer-ledger/Cargo.toml b/crates/signer-ledger/Cargo.toml index c7a321c6f62..d673b5ff34d 100644 --- a/crates/signer-ledger/Cargo.toml +++ b/crates/signer-ledger/Cargo.toml @@ -25,6 +25,7 @@ tracing.workspace = true # eip712 alloy-sol-types = { workspace = true, optional = true } +alloy-dyn-abi = { workspace = true, optional = true } alloy-network.workspace = true [dev-dependencies] @@ -35,7 +36,7 @@ serial_test.workspace = true tracing-subscriber.workspace = true [features] -eip712 = ["alloy-signer/eip712", "dep:alloy-sol-types"] +eip712 = ["alloy-signer/eip712", "dep:alloy-sol-types", "dep:alloy-dyn-abi"] # WASM support browser = ["coins-ledger/browser"] diff --git a/crates/signer-ledger/src/signer.rs b/crates/signer-ledger/src/signer.rs index 028a229e0fa..ad8b26767e6 100644 --- a/crates/signer-ledger/src/signer.rs +++ b/crates/signer-ledger/src/signer.rs @@ -11,6 +11,8 @@ use coins_ledger::{ }; use futures_util::lock::Mutex; +#[cfg(feature = "eip712")] +use alloy_dyn_abi::TypedData; #[cfg(feature = "eip712")] use alloy_sol_types::{Eip712Domain, SolStruct}; @@ -71,7 +73,17 @@ impl Signer for LedgerSigner { payload: &T, domain: &Eip712Domain, ) -> Result { - self.sign_typed_data_(payload, domain).await.map_err(alloy_signer::Error::other) + self.sign_typed_data_(&payload.eip712_hash_struct(), domain) + .await + .map_err(alloy_signer::Error::other) + } + + #[cfg(feature = "eip712")] + #[inline] + async fn sign_dynamic_typed_data(&self, payload: &TypedData) -> Result { + self.sign_typed_data_(&payload.hash_struct()?, &payload.domain) + .await + .map_err(alloy_signer::Error::other) } #[inline] @@ -192,9 +204,9 @@ impl LedgerSigner { } #[cfg(feature = "eip712")] - async fn sign_typed_data_( + async fn sign_typed_data_( &self, - payload: &T, + hash_struct: &B256, domain: &Eip712Domain, ) -> Result { // See comment for v1.6.0 requirement @@ -210,7 +222,7 @@ impl LedgerSigner { let mut data = Self::path_to_bytes(&self.derivation); data.extend_from_slice(domain.separator().as_slice()); - data.extend_from_slice(payload.eip712_hash_struct().as_slice()); + data.extend_from_slice(hash_struct.as_slice()); self.sign_payload(INS::SIGN_ETH_EIP_712, &data).await } diff --git a/crates/signer/src/signer.rs b/crates/signer/src/signer.rs index 2bbe730a2da..bd3ebd657c1 100644 --- a/crates/signer/src/signer.rs +++ b/crates/signer/src/signer.rs @@ -55,8 +55,7 @@ pub trait Signer { #[cfg(feature = "eip712")] #[inline] async fn sign_dynamic_typed_data(&self, payload: &TypedData) -> Result { - let hash = payload.eip712_signing_hash()?; - self.sign_hash(&hash).await + self.sign_hash(&payload.eip712_signing_hash()?).await } /// Returns the signer's Ethereum Address.