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

(cherry picked from commit 3111291)
  • Loading branch information
nventuro committed Feb 26, 2019
1 parent 06e265b commit 2648206
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 @@ -24,7 +24,7 @@ contract ERC20FailingMock {
}

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

function transfer(address, uint256) public returns (bool) {
return true;
Expand All @@ -39,11 +39,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 @@ -44,7 +44,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 2648206

Please sign in to comment.