Repository: gakonst/ethers-rs
Pull request #2409 (2023-05-09 13:44:09)

Remove the eip712 feature flag and have it enabled by default
<!--
Thank you for your Pull Request. Please provide a description above and review
the requirements below.

Bug fixes and new features should include tests.

Contributors guide: https://github.com/gakonst/ethers-rs/blob/master/CONTRIBUTING.md

The contributors guide includes instructions for running rustfmt and building the
documentation.
-->

## Motivation
Closes https://github.com/gakonst/ethers-rs/issues/2408

## Solution
Remove feature flag enabling by default.

## PR Checklist

-   [ ] Added Tests
-   [ ] Added Documentation
-   [ ] Breaking changes


dbelv: Muscle memory had me doing `cargo fmt` which is unfortunately why large amount of touched files within the same commit vs the actual implementation of the issue.
dbelv: Sorry I have overloaded the PR for clippy fixes as well

Patch:
diff --git a/ethers-contract/Cargo.toml b/ethers-contract/Cargo.toml
index fe8bcbe9..c6ff98d5 100644
--- a/ethers-contract/Cargo.toml
+++ b/ethers-contract/Cargo.toml
@@ -60,4 +60,4 @@ rustls = ["ethers-contract-abigen/rustls"]
 openssl = ["ethers-contract-abigen/openssl"]
 
 # Deprecated
-eip712 = []
+eip712 = []
\ No newline at end of file
diff --git a/ethers-core/Cargo.toml b/ethers-core/Cargo.toml
index 03cc9d41..8350c38c 100644
--- a/ethers-core/Cargo.toml
+++ b/ethers-core/Cargo.toml
@@ -72,4 +72,4 @@ legacy = []
 macros = ["syn", "cargo_metadata", "once_cell"]
 
 # Deprecated
-eip712 = []
+eip712 = []
\ No newline at end of file
diff --git a/ethers-core/README.md b/ethers-core/README.md
index d4131855..d202258b 100644
--- a/ethers-core/README.md
+++ b/ethers-core/README.md
@@ -12,7 +12,7 @@ For more information, please refer to the [book](https://gakonst.com/ethers-rs).
 
 ## Feature flags
 
--   `eip712`: Provides the `Eip712` trait and derive procedural macro for EIP-712 encoding of typed data.
+-   `eip712`: Does nothing.
 
 ## ABI
 
diff --git a/ethers-core/src/types/serde_helpers.rs b/ethers-core/src/types/serde_helpers.rs
index e36a97f4..72c5f733 100644
--- a/ethers-core/src/types/serde_helpers.rs
+++ b/ethers-core/src/types/serde_helpers.rs
@@ -301,7 +301,6 @@ mod tests {
     use crate::types::U256;
 
     #[test]
-    #[cfg(feature = "eip712")]
     fn test_deserialize_string_chain_id() {
         use crate::types::transaction::eip712::EIP712Domain;
 
diff --git a/ethers-core/src/types/signature.rs b/ethers-core/src/types/signature.rs
index 47ac9cfd..6b0959e1 100644
--- a/ethers-core/src/types/signature.rs
+++ b/ethers-core/src/types/signature.rs
@@ -69,22 +69,6 @@ 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>
@@ -130,6 +114,19 @@ impl Signature {
         Ok(Address::from_slice(&hash[12..]))
     }
 
+    /// 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)
+    }
+
     /// Retrieves the recovery signature.
     fn as_signature(&self) -> Result<(RecoverableSignature, RecoveryId), SignatureError> {
         let recovery_id = self.recovery_id()?;
diff --git a/ethers-providers/src/rpc/transports/retry.rs b/ethers-providers/src/rpc/transports/retry.rs
index ba283b31..454e59be 100644
--- a/ethers-providers/src/rpc/transports/retry.rs
+++ b/ethers-providers/src/rpc/transports/retry.rs
@@ -561,7 +561,7 @@ mod tests {
         let err: JsonRpcError = serde_json::from_str(s).unwrap();
         let err = ClientError::JsonRpcError(err);
 
-        let should_retry = HttpRateLimitRetryPolicy::default().should_retry(&err);
+        let should_retry = HttpRateLimitRetryPolicy.should_retry(&err);
         assert!(should_retry);
     }
 
@@ -574,7 +574,7 @@ mod tests {
             text: s.to_string(),
         };
 
-        let should_retry = HttpRateLimitRetryPolicy::default().should_retry(&err);
+        let should_retry = HttpRateLimitRetryPolicy.should_retry(&err);
         assert!(should_retry);
     }
 }


Test patch:
diff --git a/ethers-contract/tests/it/abigen.rs b/ethers-contract/tests/it/abigen.rs
index 7a1cd79b..7c6f79dd 100644
--- a/ethers-contract/tests/it/abigen.rs
+++ b/ethers-contract/tests/it/abigen.rs
@@ -667,7 +667,7 @@ fn can_generate_seaport_1_0() {
     assert_eq!(hex::encode(FulfillAdvancedOrderCall::selector()), "e7acab24");
 
     assert_codec::<SeaportErrors>();
-    let err = SeaportErrors::BadContractSignature(BadContractSignature::default());
+    let err = SeaportErrors::BadContractSignature(BadContractSignature);
 
     let encoded = err.clone().encode();
     assert_eq!(err, SeaportErrors::decode(encoded.clone()).unwrap());