From 6e0aa66ae77d206bd71f960c07feaec1d32d017c Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 23 Jul 2024 10:35:24 +0200 Subject: [PATCH] update the if statement wrapping permit call --- mainnet-contracts/src/PufLocker.sol | 6 +----- mainnet-contracts/src/PufferL2Depositor.sol | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/mainnet-contracts/src/PufLocker.sol b/mainnet-contracts/src/PufLocker.sol index da19676..f1e2f62 100644 --- a/mainnet-contracts/src/PufLocker.sol +++ b/mainnet-contracts/src/PufLocker.sol @@ -61,11 +61,7 @@ contract PufLocker is IPufLocker, AccessManagedUpgradeable, UUPSUpgradeable, Puf // "Although one or more Error Occurred [execution reverted] Contract Execution Completed" // To avoid that, we don't want to call the permit function if it is not necessary. - // OpenZeppelin's ERC20Permit tokens use the ECDSA.sol library to check if the signature is valid. - // We can borrow the line of code that they wrote and skip calling the permit function if `permitData.s` is not valid. - - // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/9e73c4b58120c17135bf269945d0f148810bf7f1/contracts/utils/cryptography/ECDSA.sol#L137 - if (uint256(permitData.s) < 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { + if (permitData.deadline < block.timestamp) { // https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#security_considerations try ERC20Permit(token).permit({ owner: msg.sender, diff --git a/mainnet-contracts/src/PufferL2Depositor.sol b/mainnet-contracts/src/PufferL2Depositor.sol index 446003e..4986463 100644 --- a/mainnet-contracts/src/PufferL2Depositor.sol +++ b/mainnet-contracts/src/PufferL2Depositor.sol @@ -60,11 +60,7 @@ contract PufferL2Depositor is IPufferL2Depositor, AccessManaged { // "Although one or more Error Occurred [execution reverted] Contract Execution Completed" // To avoid that, we don't want to call the permit function if it is not necessary. - // OpenZeppelin's ERC20Permit tokens use the ECDSA.sol library to check if the signature is valid. - // We can borrow the line of code that they wrote and skip calling the permit function if `permitData.s` is not valid. - - // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/9e73c4b58120c17135bf269945d0f148810bf7f1/contracts/utils/cryptography/ECDSA.sol#L137 - if (uint256(permitData.s) < 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { + if (permitData.deadline < block.timestamp) { // https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#security_considerations try ERC20Permit(token).permit({ owner: msg.sender,