Skip to content

Commit

Permalink
address comments for the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Jun 7, 2022
1 parent 4fa970e commit fd72798
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
12 changes: 6 additions & 6 deletions contracts/mocks/SafeERC20Helper.sol
Expand Up @@ -114,7 +114,7 @@ contract ERC20PermitNoRevertMock is
return block.chainid;
}

function permitRevert(
function permitThatMayRevert(
address owner,
address spender,
uint256 value,
Expand All @@ -135,7 +135,7 @@ contract ERC20PermitNoRevertMock is
bytes32 r,
bytes32 s
) public virtual override {
try this.permitRevert(owner, spender, value, deadline, v, r, s) {
try this.permitThatMayRevert(owner, spender, value, deadline, v, r, s) {
// do nothing
} catch {
// do nothing
Expand All @@ -144,11 +144,11 @@ contract ERC20PermitNoRevertMock is
}

contract SafeERC20Wrapper is Context {
using SafeERC20 for IERC20Permit;
using SafeERC20 for IERC20;

IERC20Permit private _token;
IERC20 private _token;

constructor(IERC20Permit token) {
constructor(IERC20 token) {
_token = token;
}

Expand Down Expand Up @@ -181,7 +181,7 @@ contract SafeERC20Wrapper is Context {
bytes32 r,
bytes32 s
) public {
_token.safePermit(owner, spender, value, deadline, v, r, s);
SafeERC20.safePermit(IERC20Permit(address(_token)), owner, spender, value, deadline, v, r, s);
}

function setAllowance(uint256 allowance_) public {
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC20/extensions/draft-IERC20Permit.sol
Expand Up @@ -13,7 +13,7 @@ import "../IERC20.sol";
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit is IERC20 {
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
Expand Down
5 changes: 1 addition & 4 deletions contracts/token/ERC20/utils/SafeERC20.sol
Expand Up @@ -91,10 +91,7 @@ library SafeERC20 {
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
_callOptionalReturn(
token,
abi.encodeWithSelector(token.permit.selector, owner, spender, value, deadline, v, r, s)
);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
Expand Down

0 comments on commit fd72798

Please sign in to comment.