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
ba86e8e0
Commit
ba86e8e0
authored
Jul 05, 2017
by
Manuel Aráoz
Committed by
GitHub
Jul 05, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #296 from frangio/fix/293-tokentimelock-claim
Add TokenTimelock#release function that anyone can call
parents
7434b3d6
5e423bc3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
TokenTimelock.sol
contracts/token/TokenTimelock.sol
+9
-1
TokenTimelock.js
test/TokenTimelock.js
+11
-11
No files found.
contracts/token/TokenTimelock.sol
View file @
ba86e8e0
...
...
@@ -27,10 +27,18 @@ contract TokenTimelock {
}
/**
* @dev beneficiary claims tokens held by time lock
* @notice Transfers tokens held by timelock to beneficiary.
* Deprecated: please use TokenTimelock#release instead.
*/
function claim() {
require(msg.sender == beneficiary);
release();
}
/**
* @notice Transfers tokens held by timelock to beneficiary.
*/
function release() {
require(now >= releaseTime);
uint amount = token.balanceOf(this);
...
...
test/TokenTimelock.js
View file @
ba86e8e0
...
...
@@ -24,33 +24,33 @@ contract('TokenTimelock', function ([_, owner, beneficiary]) {
await
this
.
token
.
mint
(
this
.
timelock
.
address
,
amount
,
{
from
:
owner
})
})
it
(
'cannot be
claim
ed before time limit'
,
async
function
()
{
await
this
.
timelock
.
claim
({
from
:
beneficiary
}
).
should
.
be
.
rejected
it
(
'cannot be
releas
ed before time limit'
,
async
function
()
{
await
this
.
timelock
.
release
(
).
should
.
be
.
rejected
})
it
(
'cannot be
claim
ed just before time limit'
,
async
function
()
{
it
(
'cannot be
releas
ed just before time limit'
,
async
function
()
{
await
increaseTime
(
moment
.
duration
(
0.99
,
'year'
))
await
this
.
timelock
.
claim
({
from
:
beneficiary
}
).
should
.
be
.
rejected
await
this
.
timelock
.
release
(
).
should
.
be
.
rejected
})
it
(
'can be
claim
ed just after limit'
,
async
function
()
{
it
(
'can be
releas
ed just after limit'
,
async
function
()
{
await
increaseTime
(
moment
.
duration
(
1.01
,
'year'
))
await
this
.
timelock
.
claim
({
from
:
beneficiary
}
).
should
.
be
.
fulfilled
await
this
.
timelock
.
release
(
).
should
.
be
.
fulfilled
const
balance
=
await
this
.
token
.
balanceOf
(
beneficiary
)
balance
.
should
.
be
.
bignumber
.
equal
(
amount
)
})
it
(
'can be
claim
ed after time limit'
,
async
function
()
{
it
(
'can be
releas
ed after time limit'
,
async
function
()
{
await
increaseTime
(
moment
.
duration
(
2
,
'year'
))
await
this
.
timelock
.
claim
({
from
:
beneficiary
}
).
should
.
be
.
fulfilled
await
this
.
timelock
.
release
(
).
should
.
be
.
fulfilled
const
balance
=
await
this
.
token
.
balanceOf
(
beneficiary
)
balance
.
should
.
be
.
bignumber
.
equal
(
amount
)
})
it
(
'cannot be
claim
ed twice'
,
async
function
()
{
it
(
'cannot be
releas
ed twice'
,
async
function
()
{
await
increaseTime
(
moment
.
duration
(
2
,
'year'
))
await
this
.
timelock
.
claim
({
from
:
beneficiary
}
).
should
.
be
.
fulfilled
await
this
.
timelock
.
claim
({
from
:
beneficiary
}
).
should
.
be
.
rejected
await
this
.
timelock
.
release
(
).
should
.
be
.
fulfilled
await
this
.
timelock
.
release
(
).
should
.
be
.
rejected
const
balance
=
await
this
.
token
.
balanceOf
(
beneficiary
)
balance
.
should
.
be
.
bignumber
.
equal
(
amount
)
})
...
...
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