From 2648206394e753dac36c193d1842ef7ad36ec8d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Tue, 26 Feb 2019 12:39:02 -0300 Subject: [PATCH 1/2] Merge pull request #1647 from nventuro/safeerc20-bugfix Fix SafeERC20.safeApprove bug (cherry picked from commit 3111291b4a8928a385b7993e32daf84fa3217f13) --- contracts/mocks/SafeERC20Helper.sol | 8 ++++---- contracts/token/ERC20/SafeERC20.sol | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/mocks/SafeERC20Helper.sol b/contracts/mocks/SafeERC20Helper.sol index 7e639f86f..f6c28308d 100644 --- a/contracts/mocks/SafeERC20Helper.sol +++ b/contracts/mocks/SafeERC20Helper.sol @@ -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; @@ -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]; } } diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index 2774afa08..66143a723 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -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)); } From 5a64eb2e14e2cb307707c638283ad0a925909463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Tue, 26 Feb 2019 16:41:00 -0300 Subject: [PATCH 2/2] Release v2.0.1 --- ethpm.json | 2 +- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ethpm.json b/ethpm.json index a60b4a603..780239366 100644 --- a/ethpm.json +++ b/ethpm.json @@ -1,6 +1,6 @@ { "package_name": "zeppelin", - "version": "2.0.0", + "version": "2.0.1", "description": "Secure Smart Contract library for Solidity", "authors": [ "OpenZeppelin Community " diff --git a/package-lock.json b/package-lock.json index 9e2fe893b..6d17a7498 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "openzeppelin-solidity", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f97f1050a..9b977ac0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openzeppelin-solidity", - "version": "2.0.0", + "version": "2.0.1", "description": "Secure Smart Contract library for Solidity", "files": [ "build",