|
@@ -3,10 +3,8 @@ pragma solidity ^0.4.24;
|
|
import "../token/ERC20/IERC20.sol";
|
|
import "../token/ERC20/IERC20.sol";
|
|
import "../token/ERC20/SafeERC20.sol";
|
|
import "../token/ERC20/SafeERC20.sol";
|
|
|
|
|
|
-contract ERC20FailingMock is IERC20 {
|
|
|
|
- function totalSupply() public view returns (uint256) {
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
|
|
+contract ERC20FailingMock {
|
|
|
|
+ uint256 private _allowance;
|
|
|
|
|
|
function transfer(address, uint256) public returns (bool) {
|
|
function transfer(address, uint256) public returns (bool) {
|
|
return false;
|
|
return false;
|
|
@@ -20,19 +18,13 @@ contract ERC20FailingMock is IERC20 {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- function balanceOf(address) public view returns (uint256) {
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
function allowance(address, address) public view returns (uint256) {
|
|
function allowance(address, address) public view returns (uint256) {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-contract ERC20SucceedingMock is IERC20 {
|
|
|
|
- function totalSupply() public view returns (uint256) {
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
|
|
+contract ERC20SucceedingMock {
|
|
|
|
+ uint256 private _allowance;
|
|
|
|
|
|
function transfer(address, uint256) public returns (bool) {
|
|
function transfer(address, uint256) public returns (bool) {
|
|
return true;
|
|
return true;
|
|
@@ -46,12 +38,12 @@ contract ERC20SucceedingMock is IERC20 {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- function balanceOf(address) public view returns (uint256) {
|
|
|
|
- return 0;
|
|
|
|
|
|
+ function setAllowance(uint256 allowance_) public {
|
|
|
|
+ _allowance = allowance_;
|
|
}
|
|
}
|
|
|
|
|
|
function allowance(address, address) public view returns (uint256) {
|
|
function allowance(address, address) public view returns (uint256) {
|
|
- return 0;
|
|
|
|
|
|
+ return _allowance;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -62,10 +54,12 @@ contract SafeERC20Helper {
|
|
IERC20 private _succeeding;
|
|
IERC20 private _succeeding;
|
|
|
|
|
|
constructor() public {
|
|
constructor() public {
|
|
- _failing = new ERC20FailingMock();
|
|
|
|
- _succeeding = new ERC20SucceedingMock();
|
|
|
|
|
|
+ _failing = IERC20(new ERC20FailingMock());
|
|
|
|
+ _succeeding = IERC20(new ERC20SucceedingMock());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Using _failing
|
|
|
|
+
|
|
function doFailingTransfer() public {
|
|
function doFailingTransfer() public {
|
|
_failing.safeTransfer(address(0), 0);
|
|
_failing.safeTransfer(address(0), 0);
|
|
}
|
|
}
|
|
@@ -78,6 +72,16 @@ contract SafeERC20Helper {
|
|
_failing.safeApprove(address(0), 0);
|
|
_failing.safeApprove(address(0), 0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function doFailingIncreaseAllowance() public {
|
|
|
|
+ _failing.safeIncreaseAllowance(address(0), 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function doFailingDecreaseAllowance() public {
|
|
|
|
+ _failing.safeDecreaseAllowance(address(0), 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Using _succeeding
|
|
|
|
+
|
|
function doSucceedingTransfer() public {
|
|
function doSucceedingTransfer() public {
|
|
_succeeding.safeTransfer(address(0), 0);
|
|
_succeeding.safeTransfer(address(0), 0);
|
|
}
|
|
}
|
|
@@ -86,7 +90,23 @@ contract SafeERC20Helper {
|
|
_succeeding.safeTransferFrom(address(0), address(0), 0);
|
|
_succeeding.safeTransferFrom(address(0), address(0), 0);
|
|
}
|
|
}
|
|
|
|
|
|
- function doSucceedingApprove() public {
|
|
|
|
- _succeeding.safeApprove(address(0), 0);
|
|
|
|
|
|
+ function doSucceedingApprove(uint256 amount) public {
|
|
|
|
+ _succeeding.safeApprove(address(0), amount);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function doSucceedingIncreaseAllowance(uint256 amount) public {
|
|
|
|
+ _succeeding.safeIncreaseAllowance(address(0), amount);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function doSucceedingDecreaseAllowance(uint256 amount) public {
|
|
|
|
+ _succeeding.safeDecreaseAllowance(address(0), amount);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function setAllowance(uint256 allowance_) public {
|
|
|
|
+ ERC20SucceedingMock(_succeeding).setAllowance(allowance_);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function allowance() public view returns (uint256) {
|
|
|
|
+ return _succeeding.allowance(address(0), address(0));
|
|
}
|
|
}
|
|
}
|
|
}
|