add revocable flag
This commit is contained in:
committed by
Martín Triay
parent
998c72ab5b
commit
3da7c31484
@ -8,7 +8,8 @@ import '../math/SafeMath.sol';
|
|||||||
/**
|
/**
|
||||||
* @title TokenVesting
|
* @title TokenVesting
|
||||||
* @dev A token holder contract that can release its token balance gradually like a
|
* @dev A token holder contract that can release its token balance gradually like a
|
||||||
* typical vesting scheme, with a cliff and vesting period. Revokable by the owner.
|
* typical vesting scheme, with a cliff and vesting period. Optionally revocable by the
|
||||||
|
* owner.
|
||||||
*/
|
*/
|
||||||
contract TokenVesting is Ownable {
|
contract TokenVesting is Ownable {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
@ -20,6 +21,8 @@ contract TokenVesting is Ownable {
|
|||||||
uint256 start;
|
uint256 start;
|
||||||
uint256 end;
|
uint256 end;
|
||||||
|
|
||||||
|
bool revocable;
|
||||||
|
|
||||||
mapping (address => uint256) released;
|
mapping (address => uint256) released;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,8 +32,9 @@ contract TokenVesting is Ownable {
|
|||||||
* @param _beneficiary address of the beneficiary to whom vested tokens are transferred
|
* @param _beneficiary address of the beneficiary to whom vested tokens are transferred
|
||||||
* @param _cliff timestamp of the moment when tokens will begin to vest
|
* @param _cliff timestamp of the moment when tokens will begin to vest
|
||||||
* @param _end timestamp of the moment when all balance will have been vested
|
* @param _end timestamp of the moment when all balance will have been vested
|
||||||
|
* @param _revocable whether the vesting is revocable or not
|
||||||
*/
|
*/
|
||||||
function TokenVesting(address _beneficiary, uint256 _cliff, uint256 _end) {
|
function TokenVesting(address _beneficiary, uint256 _cliff, uint256 _end, bool _revocable) {
|
||||||
require(_beneficiary != 0x0);
|
require(_beneficiary != 0x0);
|
||||||
require(_cliff > now);
|
require(_cliff > now);
|
||||||
require(_end > _cliff);
|
require(_end > _cliff);
|
||||||
@ -38,6 +42,8 @@ contract TokenVesting is Ownable {
|
|||||||
beneficiary = _beneficiary;
|
beneficiary = _beneficiary;
|
||||||
cliff = _cliff;
|
cliff = _cliff;
|
||||||
end = _end;
|
end = _end;
|
||||||
|
revocable = _revocable;
|
||||||
|
|
||||||
start = now;
|
start = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +66,8 @@ contract TokenVesting is Ownable {
|
|||||||
* @param token ERC20 token which is being vested
|
* @param token ERC20 token which is being vested
|
||||||
*/
|
*/
|
||||||
function revoke(ERC20Basic token) onlyOwner {
|
function revoke(ERC20Basic token) onlyOwner {
|
||||||
|
require(revocable);
|
||||||
|
|
||||||
uint256 balance = token.balanceOf(this);
|
uint256 balance = token.balanceOf(this);
|
||||||
|
|
||||||
uint256 vested = vestedAmount(token);
|
uint256 vested = vestedAmount(token);
|
||||||
|
|||||||
@ -22,7 +22,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
|
|||||||
this.cliff = latestTime() + duration.years(1);
|
this.cliff = latestTime() + duration.years(1);
|
||||||
this.end = latestTime() + duration.years(2);
|
this.end = latestTime() + duration.years(2);
|
||||||
|
|
||||||
this.vesting = await TokenVesting.new(beneficiary, this.cliff, this.end, { from: owner });
|
this.vesting = await TokenVesting.new(beneficiary, this.cliff, this.end, true, { from: owner });
|
||||||
|
|
||||||
this.start = latestTime(); // gets the timestamp at construction
|
this.start = latestTime(); // gets the timestamp at construction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user