Skip to content

Commit

Permalink
update the if statement wrapping permit call
Browse files Browse the repository at this point in the history
  • Loading branch information
bxmmm1 committed Jul 23, 2024
1 parent ff2ead8 commit 6e0aa66
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 1 addition & 5 deletions mainnet-contracts/src/PufLocker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 1 addition & 5 deletions mainnet-contracts/src/PufferL2Depositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6e0aa66

Please sign in to comment.