Skip to content

Commit

Permalink
simplify mock
Browse files Browse the repository at this point in the history
  • Loading branch information
ZumZoom committed Mar 19, 2024
1 parent 4a3eb1c commit c36f1eb
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions contracts/tests/mocks/USDCLikePermitMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ contract USDCLikePermitMock is ERC20Permit {
revert PermitExpired();
}

bytes32 typedDataHash = _toTypedDataHash(
_domainSeparatorV4(),
bytes32 typedDataHash = _hashTypedDataV4(
keccak256(
abi.encode(
PERMIT_TYPEHASH,
Expand All @@ -61,32 +60,6 @@ contract USDCLikePermitMock is ERC20Permit {
_approve(owner, spender, value);
}

/**
* @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
* Adapted from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/21bb89ef5bfc789b9333eb05e3ba2b7b284ac77c/contracts/utils/cryptography/MessageHashUtils.sol
*
* The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
* `\x19\x01` and hashing the result. It corresponds to the hash signed by the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
*
* @param domainSeparator Domain separator
* @param structHash Hashed EIP-712 data struct
* @return digest The keccak256 digest of an EIP-712 typed data
*/
function _toTypedDataHash(bytes32 domainSeparator, bytes32 structHash)
internal
pure
returns (bytes32 digest)
{
assembly { // solhint-disable-line no-inline-assembly
let ptr := mload(0x40)
mstore(ptr, "\x19\x01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
digest := keccak256(ptr, 0x42)
}
}

function _isValidERC1271SignatureNow(
address signer,
bytes32 digest,
Expand Down

0 comments on commit c36f1eb

Please sign in to comment.