ERC712Extended
Inherits: IERC712Extended
Author: M^0 Labs
An abstract implementation to satisfy EIP-712: https://eips.ethereum.org/EIPS/eip-712
State Variables
_EIP712_DOMAIN_HASH
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
_EIP712_VERSION_HASH
keccak256("1")
_INITIAL_CHAIN_ID
Initial Chain ID set at deployment.
_INITIAL_DOMAIN_SEPARATOR
Initial EIP-712 domain separator set at deployment.
_name
The name of the contract.
Functions
constructor
Constructs the EIP-712 domain separator.
Parameters
Name | Type | Description |
---|---|---|
|
| The name of the contract. |
eip712Domain
Returns the fields and values that describe the domain separator used by this contract for EIP-712.
DOMAIN_SEPARATOR
Returns the EIP712 domain separator used in the encoding of a signed digest.
_getDomainSeparator
Computes the EIP-712 domain separator.
Returns
Name | Type | Description |
---|---|---|
|
| The EIP-712 domain separator. |
_getDigest
Returns the digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).
Parameters
Name | Type | Description |
---|---|---|
|
| The internal digest. |
Returns
Name | Type | Description |
---|---|---|
|
| The digest to be signed. |
_revertIfExpired
Revert if the signature is expired.
Parameters
Name | Type | Description |
---|---|---|
|
| Timestamp at which the signature expires or max uint256 for no expiry. |
_revertIfInvalidSignature
Revert if the signature is invalid.
We first validate if the signature is a valid ECDSA signature and return early if it is the case. Then, we validate if it is a valid ERC-1271 signature, and return early if it is the case. If not, we revert with the error from the ECDSA signature validation.
Parameters
Name | Type | Description |
---|---|---|
|
| The signer of the signature. |
|
| The digest that was signed. |
|
| The signature. |
_getSignerAndRevertIfInvalidSignature
Returns the signer of a signed digest, via EIP-712, and reverts if the signature is invalid.
Parameters
Name | Type | Description |
---|---|---|
|
| The digest that was signed. |
|
| v of the signature. |
|
| r of the signature. |
|
| s of the signature. |
Returns
Name | Type | Description |
---|---|---|
|
| The signer of the digest. |
_revertIfInvalidSignature
Revert if the signature is invalid.
Parameters
Name | Type | Description |
---|---|---|
|
| The signer of the signature. |
|
| The digest that was signed. |
|
| An ECDSA/secp256k1 signature parameter. |
|
| An ECDSA/secp256k1 short signature parameter. |
_revertIfInvalidSignature
Revert if the signature is invalid.
Parameters
Name | Type | Description |
---|---|---|
|
| The signer of the signature. |
|
| The digest that was signed. |
|
| v of the signature. |
|
| r of the signature. |
|
| s of the signature. |
_revertIfError
Revert if error.
Parameters
Name | Type | Description |
---|---|---|
|
| The SignatureChecker Error enum. |