feature: allow signature to recover typed_data payloads (#2120)
* feature: allow signature to recover typed_data payloads * fix: under feature flag and Changelog * fix: undo accidental doc mangling
This commit is contained in:
parent
0236de8d2a
commit
e5e4da07c5
|
@ -4,6 +4,7 @@
|
|||
|
||||
### Unreleased
|
||||
|
||||
- Add `Signature::recover_typed_data` [#2120](https://github.com/gakonst/ethers-rs/pull/2120)
|
||||
- Add `abi::encode_packed` [#2104](https://github.com/gakonst/ethers-rs/pull/2104)
|
||||
- Add support for custom JavaScript tracer to `debug_traceCall` and `debug_traceTransaction` [#2064](https://github.com/gakonst/ethers-rs/pull/2064)
|
||||
- Add a `Send` bound to the `IntoFuture` implementation of `ContractCall` [#2083](https://github.com/gakonst/ethers-rs/pull/2083)
|
||||
|
|
|
@ -69,6 +69,22 @@ impl fmt::Display for Signature {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "eip712")]
|
||||
impl Signature {
|
||||
/// Recovers the ethereum address which was used to sign a given EIP712
|
||||
/// typed data payload.
|
||||
///
|
||||
/// Recovery signature data uses 'Electrum' notation, this means the `v`
|
||||
/// value is expected to be either `27` or `28`.
|
||||
pub fn recover_typed_data<T>(&self, payload: T) -> Result<Address, SignatureError>
|
||||
where
|
||||
T: super::transaction::eip712::Eip712,
|
||||
{
|
||||
let encoded = payload.encode_eip712().map_err(|_| SignatureError::RecoveryError)?;
|
||||
self.recover(encoded)
|
||||
}
|
||||
}
|
||||
|
||||
impl Signature {
|
||||
/// Verifies that signature on `message` was produced by `address`
|
||||
pub fn verify<M, A>(&self, message: M, address: A) -> Result<(), SignatureError>
|
||||
|
|
Loading…
Reference in New Issue