Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
3da7c314
Commit
3da7c314
authored
Aug 29, 2017
by
Francisco Giordano
Committed by
Martín Triay
Oct 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add revocable flag
parent
998c72ab
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
TokenVesting.sol
contracts/token/TokenVesting.sol
+10
-2
TokenVesting.js
test/TokenVesting.js
+1
-1
No files found.
contracts/token/TokenVesting.sol
View file @
3da7c314
...
...
@@ -8,7 +8,8 @@ import '../math/SafeMath.sol';
/**
* @title TokenVesting
* @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 {
using SafeMath for uint256;
...
...
@@ -20,6 +21,8 @@ contract TokenVesting is Ownable {
uint256 start;
uint256 end;
bool revocable;
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 _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 _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(_cliff > now);
require(_end > _cliff);
...
...
@@ -38,6 +42,8 @@ contract TokenVesting is Ownable {
beneficiary = _beneficiary;
cliff = _cliff;
end = _end;
revocable = _revocable;
start = now;
}
...
...
@@ -60,6 +66,8 @@ contract TokenVesting is Ownable {
* @param token ERC20 token which is being vested
*/
function revoke(ERC20Basic token) onlyOwner {
require(revocable);
uint256 balance = token.balanceOf(this);
uint256 vested = vestedAmount(token);
...
...
test/TokenVesting.js
View file @
3da7c314
...
...
@@ -22,7 +22,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
this
.
cliff
=
latestTime
()
+
duration
.
years
(
1
);
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment