Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SafeERC20 to transfer tokens safely #430

Merged
merged 1 commit into from
Sep 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions contracts/ownership/CanReclaimToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pragma solidity ^0.4.11;

import "./Ownable.sol";
import "../token/ERC20Basic.sol";
import "../token/SafeERC20.sol";

/**
* @title Contracts that should be able to recover tokens
Expand All @@ -10,14 +11,15 @@ import "../token/ERC20Basic.sol";
* This will prevent any accidental loss of tokens.
*/
contract CanReclaimToken is Ownable {
using SafeERC20 for ERC20Basic;

/**
* @dev Reclaim all ERC20Basic compatible tokens
* @param token ERC20Basic The address of the token contract
*/
function reclaimToken(ERC20Basic token) external onlyOwner {
uint256 balance = token.balanceOf(this);
token.transfer(owner, balance);
token.safeTransfer(owner, balance);
}

}
}
4 changes: 3 additions & 1 deletion contracts/token/TokenTimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ pragma solidity ^0.4.11;


import './ERC20Basic.sol';
import "../token/SafeERC20.sol";

/**
* @title TokenTimelock
* @dev TokenTimelock is a token holder contract that will allow a
* beneficiary to extract the tokens after a given release time
*/
contract TokenTimelock {
using SafeERC20 for ERC20Basic;

// ERC20 basic token contract being held
ERC20Basic token;
Expand Down Expand Up @@ -44,6 +46,6 @@ contract TokenTimelock {
uint256 amount = token.balanceOf(this);
require(amount > 0);

token.transfer(beneficiary, amount);
token.safeTransfer(beneficiary, amount);
}
}