pub trait Signer<Sig = PrimitiveSignature> {
// Required methods
fn sign_hash<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 B256,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn address(&self) -> Address;
fn chain_id(&self) -> Option<ChainId>;
fn set_chain_id(&mut self, chain_id: Option<ChainId>);
// Provided methods
fn sign_message<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn sign_typed_data<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
payload: &'life1 T,
domain: &'life2 Eip712Domain,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>
where Self: Sized + Sync + 'async_trait,
T: 'async_trait + SolStruct + Send + Sync,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn sign_dynamic_typed_data<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 TypedData,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn with_chain_id(self, chain_id: Option<ChainId>) -> Self
where Self: Sized { ... }
}
Expand description
Asynchronous Ethereum signer.
All provided implementations rely on sign_hash
. A signer may not always
be able to implement this method, in which case it should return
UnsupportedOperation
, and implement all the signing
methods directly.
Synchronous signers should implement both this trait and SignerSync
.
Required Methods§
Sourcefn sign_hash<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 B256,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sign_hash<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 B256,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Signs the given hash.
Sourcefn set_chain_id(&mut self, chain_id: Option<ChainId>)
fn set_chain_id(&mut self, chain_id: Option<ChainId>)
Sets the signer’s chain ID.
Provided Methods§
Sourcefn sign_message<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sign_message<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Signs the hash of the provided message after prefixing it, as specified in EIP-191.
Sourcefn sign_typed_data<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
payload: &'life1 T,
domain: &'life2 Eip712Domain,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>
Available on crate feature eip712
only.
fn sign_typed_data<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, payload: &'life1 T, domain: &'life2 Eip712Domain, ) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>
eip712
only.Encodes and signs the typed data according to EIP-712.
Sourcefn sign_dynamic_typed_data<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 TypedData,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Available on crate feature eip712
only.
fn sign_dynamic_typed_data<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 TypedData,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
eip712
only.Encodes and signs the typed data according to [EIP-712] for Signers that are not dynamically sized.
Sourcefn with_chain_id(self, chain_id: Option<ChainId>) -> Selfwhere
Self: Sized,
fn with_chain_id(self, chain_id: Option<ChainId>) -> Selfwhere
Self: Sized,
Sets the signer’s chain ID and returns self
.
Implementations on Foreign Types§
Source§impl<'a, Sig, U: 'a + Signer<Sig> + ?Sized + Sync> Signer<Sig> for &'a mut U
impl<'a, Sig, U: 'a + Signer<Sig> + ?Sized + Sync> Signer<Sig> for &'a mut U
fn sign_hash<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 B256,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sign_message<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn sign_dynamic_typed_data<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 TypedData,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sign_dynamic_typed_data<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 TypedData,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Available on crate feature
eip712
only.fn address(&self) -> Address
fn chain_id(&self) -> Option<ChainId>
fn set_chain_id(&mut self, chain_id: Option<ChainId>)
Source§impl<Sig, U: Signer<Sig> + ?Sized + Sync> Signer<Sig> for Box<U>
impl<Sig, U: Signer<Sig> + ?Sized + Sync> Signer<Sig> for Box<U>
fn sign_hash<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 B256,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sign_message<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn sign_dynamic_typed_data<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 TypedData,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sign_dynamic_typed_data<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 TypedData,
) -> Pin<Box<dyn Future<Output = Result<Sig>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Available on crate feature
eip712
only.