Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
37 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
pragma solidity ^0.5.12; | ||
|
||
import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; | ||
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract CanReclaimTokens is Ownable { | ||
|
||
mapping(address => bool) private recoverableTokensBlacklist; | ||
|
||
function blacklistRecoverableToken(address _token) public { | ||
recoverableTokensBlacklist[_token] = true; | ||
} | ||
|
||
/// @notice Allow the owner of the contract to recover funds accidentally | ||
/// sent to the contract. To withdraw ETH, the token should be set to `0x0`. | ||
function recoverTokens(address _token) external onlyOwner { | ||
require(!recoverableTokensBlacklist[_token], "CanReclaimTokens: token is not recoverable"); | ||
|
||
if (_token == address(0x0)) { | ||
msg.sender.transfer(address(this).balance); | ||
} else { | ||
ERC20(_token).transfer(msg.sender, ERC20(_token).balanceOf(address(this))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters