Skip to content

Commit

Permalink
Merge pull request #1647 from nventuro/safeerc20-bugfix
Browse files Browse the repository at this point in the history
Fix SafeERC20.safeApprove bug
  • Loading branch information
nventuro authored Feb 26, 2019
2 parents 14ec984 + b14c9f4 commit 3111291
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions contracts/mocks/SafeERC20Helper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract ERC20FailingMock {
}

contract ERC20SucceedingMock {
uint256 private _allowance;
mapping (address => uint256) private _allowances;

// IERC20's functions are not pure, but these mock implementations are: to prevent Solidity from issuing warnings,
// we write to a dummy state variable.
Expand All @@ -54,11 +54,11 @@ contract ERC20SucceedingMock {
}

function setAllowance(uint256 allowance_) public {
_allowance = allowance_;
_allowances[msg.sender] = allowance_;
}

function allowance(address, address) public view returns (uint256) {
return _allowance;
function allowance(address owner, address) public view returns (uint256) {
return _allowances[owner];
}
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC20/SafeERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ library SafeERC20 {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require((value == 0) || (token.allowance(msg.sender, spender) == 0));
require((value == 0) || (token.allowance(address(this), spender) == 0));
require(token.approve(spender, value));
}

Expand Down

0 comments on commit 3111291

Please sign in to comment.