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
d9749240
Commit
d9749240
authored
Dec 29, 2016
by
AugustoL
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added claimAfterBlock variable and tests changes to support changes
parent
e310e672
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
11 deletions
+36
-11
DelayedClaimable.sol
contracts/DelayedClaimable.sol
+9
-3
DelayedClaimble.js
test/DelayedClaimble.js
+27
-8
No files found.
contracts/DelayedClaimable.sol
View file @
d9749240
...
@@ -4,18 +4,24 @@ import './Claimable.sol';
...
@@ -4,18 +4,24 @@ import './Claimable.sol';
/*
/*
* DelayedClaimable
* DelayedClaimable
* Extension for the Claimable contract, where the ownership needs to be claimed before certain block number
* Extension for the Claimable contract, where the ownership needs to be claimed before
/after
certain block number
*/
*/
contract DelayedClaimable is Ownable, Claimable {
contract DelayedClaimable is Ownable, Claimable {
uint public claimBeforeBlock;
uint public claimBeforeBlock;
uint public claimAfterBlock;
function setClaimBefore(uint _claimBeforeBlock) onlyOwner {
function setClaimBlocks(uint _claimBeforeBlock, uint _claimAfterBlock) onlyOwner {
if (_claimAfterBlock > claimBeforeBlock)
throw;
claimBeforeBlock = _claimBeforeBlock;
claimBeforeBlock = _claimBeforeBlock;
claimAfterBlock = _claimAfterBlock;
}
}
function claimOwnership() onlyPendingOwner {
function claimOwnership() onlyPendingOwner {
if (block.number > claimBeforeBlock) throw;
if ((block.number > claimBeforeBlock) || (block.number < claimAfterBlock))
throw;
owner = pendingOwner;
owner = pendingOwner;
pendingOwner = 0x0;
pendingOwner = 0x0;
claimBeforeBlock = 0;
claimBeforeBlock = 0;
...
...
test/DelayedClaimble.js
View file @
d9749240
...
@@ -7,16 +7,20 @@ contract('DelayedClaimable', function(accounts) {
...
@@ -7,16 +7,20 @@ contract('DelayedClaimable', function(accounts) {
});
});
});
});
it
(
"
changes pendingOwner after transfer succesfu
l"
,
function
(
done
)
{
it
(
"
Changes pendingOwner after transfer succesful
l"
,
function
(
done
)
{
return
delayedClaimable
.
transferOwnership
(
accounts
[
2
])
return
delayedClaimable
.
transferOwnership
(
accounts
[
2
])
.
then
(
function
(){
.
then
(
function
(){
return
delayedClaimable
.
setClaimB
efore
(
1000
)
return
delayedClaimable
.
setClaimB
locks
(
1000
,
0
);
})
})
.
then
(
function
(){
.
then
(
function
(){
return
delayedClaimable
.
claimBeforeBlock
();
return
delayedClaimable
.
claimBeforeBlock
();
})
})
.
then
(
function
(
claimBeforeBlock
)
{
.
then
(
function
(
claimBeforeBlock
)
{
assert
.
isTrue
(
claimBeforeBlock
==
1000
);
assert
.
isTrue
(
claimBeforeBlock
==
1000
);
return
delayedClaimable
.
claimAfterBlock
();
})
.
then
(
function
(
claimAfterBlock
)
{
assert
.
isTrue
(
claimAfterBlock
==
0
);
return
delayedClaimable
.
pendingOwner
();
return
delayedClaimable
.
pendingOwner
();
})
})
.
then
(
function
(
pendingOwner
)
{
.
then
(
function
(
pendingOwner
)
{
...
@@ -29,19 +33,23 @@ contract('DelayedClaimable', function(accounts) {
...
@@ -29,19 +33,23 @@ contract('DelayedClaimable', function(accounts) {
.
then
(
function
(
owner
)
{
.
then
(
function
(
owner
)
{
assert
.
isTrue
(
owner
===
accounts
[
2
]);
assert
.
isTrue
(
owner
===
accounts
[
2
]);
})
})
.
then
(
done
)
.
then
(
done
)
;
});
});
it
(
"
c
hanges pendingOwner after transfer fails"
,
function
(
done
)
{
it
(
"
C
hanges pendingOwner after transfer fails"
,
function
(
done
)
{
return
delayedClaimable
.
transferOwnership
(
accounts
[
1
])
return
delayedClaimable
.
transferOwnership
(
accounts
[
1
])
.
then
(
function
(){
.
then
(
function
(){
return
delayedClaimable
.
setClaimB
efore
(
1
)
return
delayedClaimable
.
setClaimB
locks
(
11000
,
10000
);
})
})
.
then
(
function
(){
.
then
(
function
(){
return
delayedClaimable
.
claimBeforeBlock
();
return
delayedClaimable
.
claimBeforeBlock
();
})
})
.
then
(
function
(
claimBeforeBlock
)
{
.
then
(
function
(
claimBeforeBlock
)
{
assert
.
isTrue
(
claimBeforeBlock
==
1
);
assert
.
isTrue
(
claimBeforeBlock
==
11000
);
return
delayedClaimable
.
claimAfterBlock
();
})
.
then
(
function
(
claimAfterBlock
)
{
assert
.
isTrue
(
claimAfterBlock
==
10000
);
return
delayedClaimable
.
pendingOwner
();
return
delayedClaimable
.
pendingOwner
();
})
})
.
then
(
function
(
pendingOwner
)
{
.
then
(
function
(
pendingOwner
)
{
...
@@ -49,7 +57,7 @@ contract('DelayedClaimable', function(accounts) {
...
@@ -49,7 +57,7 @@ contract('DelayedClaimable', function(accounts) {
return
delayedClaimable
.
claimOwnership
({
from
:
accounts
[
1
]});
return
delayedClaimable
.
claimOwnership
({
from
:
accounts
[
1
]});
})
})
.
catch
(
function
(
error
)
{
.
catch
(
function
(
error
)
{
if
(
error
.
message
.
search
(
'invalid JUMP'
)
==
-
1
)
throw
error
if
(
error
.
message
.
search
(
'invalid JUMP'
)
==
-
1
)
throw
error
;
})
})
.
then
(
function
()
{
.
then
(
function
()
{
return
delayedClaimable
.
owner
();
return
delayedClaimable
.
owner
();
...
@@ -57,7 +65,18 @@ contract('DelayedClaimable', function(accounts) {
...
@@ -57,7 +65,18 @@ contract('DelayedClaimable', function(accounts) {
.
then
(
function
(
owner
)
{
.
then
(
function
(
owner
)
{
assert
.
isTrue
(
owner
!=
accounts
[
1
]);
assert
.
isTrue
(
owner
!=
accounts
[
1
]);
})
})
.
then
(
done
)
.
then
(
done
);
});
it
(
"Set claimBeforeBlock and claimAfterBlock invalid values fail"
,
function
(
done
)
{
return
delayedClaimable
.
transferOwnership
(
accounts
[
1
])
.
then
(
function
(){
return
delayedClaimable
.
setClaimBlocks
(
1000
,
10000
);
})
.
catch
(
function
(
error
)
{
if
(
error
.
message
.
search
(
'invalid JUMP'
)
==
-
1
)
throw
error
;
})
.
then
(
done
);
});
});
});
});
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