-
-
Save 0xnakato/2c803385ac4c47c0455d6d0de105538f to your computer and use it in GitHub Desktop.
Uninitialized ERC20Permit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol) | |
pragma solidity ^0.8.0; | |
/** | |
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. | |
* | |
* The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, | |
* thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding | |
* they need in their contracts using a combination of `abi.encode` and `keccak256`. | |
* | |
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding | |
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA | |
* ({_hashTypedDataV4}). | |
* | |
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating | |
* the chain id to protect against replay attacks on an eventual fork of the chain. | |
* | |
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method | |
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. | |
* | |
* _Available since v3.4._ | |
* | |
* @custom:storage-size 52 | |
*/ | |
contract EIP712Upgradeable { | |
/* solhint-disable var-name-mixedcase */ | |
bytes32 private _HASHED_NAME; | |
bytes32 private _HASHED_VERSION; | |
bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); | |
/** | |
* @dev Returns the domain separator for the current chain. | |
*/ | |
function _domainSeparatorV4() public view returns (bytes32) { | |
return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash()); | |
} | |
function _buildDomainSeparator( | |
bytes32 typeHash, | |
bytes32 nameHash, | |
bytes32 versionHash | |
) public view returns (bytes32) { | |
return keccak256(abi.encode(typeHash, nameHash, versionHash, 280, 0x3e7676937A7E96CFB7616f255b9AD9FF47363D4b)); // zkSync Era testnet DAI | |
} | |
/** | |
* @dev The hash of the name parameter for the EIP712 domain. | |
* | |
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs | |
* are a concern. | |
*/ | |
function _EIP712NameHash() public virtual view returns (bytes32) { | |
return _HASHED_NAME; | |
} | |
/** | |
* @dev The hash of the version parameter for the EIP712 domain. | |
* | |
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs | |
* are a concern. | |
*/ | |
function _EIP712VersionHash() public virtual view returns (bytes32) { | |
return _HASHED_VERSION; | |
} | |
/** | |
* @dev This empty reserved space is put in place to allow future versions to add new | |
* variables without shifting down storage in the inheritance chain. | |
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps | |
*/ | |
uint256[50] private __gap; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment