Update contracts to support Solidity 0.8.x (#2442)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity >=0.6.0 <0.8.0;
|
||||
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.
|
||||
@ -43,13 +43,13 @@ abstract contract EIP712 {
|
||||
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
|
||||
* contract upgrade].
|
||||
*/
|
||||
constructor(string memory name, string memory version) internal {
|
||||
constructor(string memory name, string memory version) {
|
||||
bytes32 hashedName = keccak256(bytes(name));
|
||||
bytes32 hashedVersion = keccak256(bytes(version));
|
||||
bytes32 typeHash = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
|
||||
_HASHED_NAME = hashedName;
|
||||
_HASHED_VERSION = hashedVersion;
|
||||
_CACHED_CHAIN_ID = _getChainId();
|
||||
_CACHED_CHAIN_ID = block.chainid;
|
||||
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
|
||||
_TYPE_HASH = typeHash;
|
||||
}
|
||||
@ -58,7 +58,7 @@ abstract contract EIP712 {
|
||||
* @dev Returns the domain separator for the current chain.
|
||||
*/
|
||||
function _domainSeparatorV4() internal view returns (bytes32) {
|
||||
if (_getChainId() == _CACHED_CHAIN_ID) {
|
||||
if (block.chainid == _CACHED_CHAIN_ID) {
|
||||
return _CACHED_DOMAIN_SEPARATOR;
|
||||
} else {
|
||||
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
|
||||
@ -71,7 +71,7 @@ abstract contract EIP712 {
|
||||
typeHash,
|
||||
name,
|
||||
version,
|
||||
_getChainId(),
|
||||
block.chainid,
|
||||
address(this)
|
||||
)
|
||||
);
|
||||
@ -95,11 +95,4 @@ abstract contract EIP712 {
|
||||
function _hashTypedDataV4(bytes32 structHash) internal view returns (bytes32) {
|
||||
return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash));
|
||||
}
|
||||
|
||||
function _getChainId() private pure returns (uint256 chainId) {
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly {
|
||||
chainId := chainid()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity >=0.6.5 <0.8.0;
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../token/ERC20/ERC20.sol";
|
||||
import "./IERC20Permit.sol";
|
||||
@ -29,7 +29,7 @@ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
|
||||
*
|
||||
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
|
||||
*/
|
||||
constructor(string memory name) internal EIP712(name, "1") {
|
||||
constructor(string memory name) EIP712(name, "1") {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity >=0.6.0 <0.8.0;
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
/**
|
||||
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
|
||||
|
||||
Reference in New Issue
Block a user