Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Remove the eip712 feature flag and have it enabled by default #2409

Merged
merged 8 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ethers-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ rustls = ["ethers-contract-abigen/rustls"]
openssl = ["ethers-contract-abigen/openssl"]

# Deprecated
eip712 = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add them back here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, yep.

eip712 = []
2 changes: 1 addition & 1 deletion ethers-contract/tests/it/abigen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion ethers-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ legacy = []
macros = ["syn", "cargo_metadata", "once_cell"]

# Deprecated
eip712 = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

eip712 = []
2 changes: 1 addition & 1 deletion ethers-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modify to say "does nothing"

- `eip712`: Does nothing.

## ABI

Expand Down
1 change: 0 additions & 1 deletion ethers-core/src/types/serde_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
29 changes: 13 additions & 16 deletions ethers-core/src/types/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,6 @@ impl fmt::Display for Signature {
}
}

#[cfg(feature = "eip712")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combine with main impl block

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>
Expand Down Expand Up @@ -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()?;
Expand Down
4 changes: 2 additions & 2 deletions ethers-providers/src/rpc/transports/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}
}