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
0f3a8051
Commit
0f3a8051
authored
Nov 02, 2016
by
AugustoL
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Claimable contract as an extension of Ownable with the Claimable tests
parent
c70a0cfd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
0 deletions
+87
-0
Claimable.sol
contracts/Claimable.sol
+26
-0
2_deploy_contracts.js
migrations/2_deploy_contracts.js
+1
-0
Claimable.js
test/Claimable.js
+60
-0
No files found.
contracts/Claimable.sol
0 → 100644
View file @
0f3a8051
pragma solidity ^0.4.0;
import './Ownable.sol';
/*
* Claimable
* Extension for the Ownable contract, where the ownership needs to be claimed
*/
contract Claimable is Ownable {
address public pendingOwner;
modifier onlyPendingOwner() {
if (msg.sender == pendingOwner)
_;
}
function transfer(address newOwner) onlyOwner {
pendingOwner = newOwner;
}
function claimOwnership() onlyPendingOwner {
owner = pendingOwner;
pendingOwner = 0x0;
}
}
migrations/2_deploy_contracts.js
View file @
0f3a8051
...
@@ -3,6 +3,7 @@ module.exports = function(deployer) {
...
@@ -3,6 +3,7 @@ module.exports = function(deployer) {
deployer
.
deploy
(
BadArrayUse
);
deployer
.
deploy
(
BadArrayUse
);
deployer
.
deploy
(
ProofOfExistence
);
deployer
.
deploy
(
ProofOfExistence
);
deployer
.
deploy
(
Ownable
);
deployer
.
deploy
(
Ownable
);
deployer
.
deploy
(
Claimable
);
deployer
.
deploy
(
LimitFunds
);
deployer
.
deploy
(
LimitFunds
);
if
(
deployer
.
network
==
'test'
){
if
(
deployer
.
network
==
'test'
){
deployer
.
deploy
(
SecureTargetMock
);
deployer
.
deploy
(
SecureTargetMock
);
...
...
test/Claimable.js
0 → 100644
View file @
0f3a8051
contract
(
'Claimable'
,
function
(
accounts
)
{
it
(
"should have an owner"
,
function
(
done
)
{
var
claimable
=
Claimable
.
deployed
();
return
claimable
.
owner
()
.
then
(
function
(
owner
)
{
assert
.
isTrue
(
owner
!=
0
);
})
.
then
(
done
)
});
it
(
"changes pendingOwner after transfer"
,
function
(
done
)
{
var
claimable
=
Claimable
.
deployed
();
return
claimable
.
transfer
(
accounts
[
1
])
.
then
(
function
()
{
return
claimable
.
pendingOwner
();
})
.
then
(
function
(
pendingOwner
)
{
assert
.
isTrue
(
pendingOwner
===
accounts
[
1
]);
})
.
then
(
done
)
});
it
(
"should prevent to claimOwnership from no pendingOwner"
,
function
(
done
)
{
var
claimable
=
Claimable
.
deployed
();
return
claimable
.
claimOwnership
({
from
:
accounts
[
2
]})
.
then
(
function
()
{
return
claimable
.
owner
();
})
.
then
(
function
(
owner
)
{
assert
.
isTrue
(
owner
!=
accounts
[
2
]);
})
.
then
(
done
)
});
it
(
"changes allow pending owner to claim ownership"
,
function
(
done
)
{
var
claimable
=
Claimable
.
deployed
();
return
claimable
.
claimOwnership
({
from
:
accounts
[
1
]})
.
then
(
function
()
{
return
claimable
.
owner
();
})
.
then
(
function
(
owner
)
{
assert
.
isTrue
(
owner
===
accounts
[
1
]);
})
.
then
(
done
)
});
it
(
"should prevent non-owners from transfering"
,
function
(
done
)
{
var
claimable
=
Claimable
.
deployed
();
return
claimable
.
transfer
(
accounts
[
2
],
{
from
:
accounts
[
2
]})
.
then
(
function
()
{
return
claimable
.
pendingOwner
();
})
.
then
(
function
(
pendingOwner
)
{
assert
.
isFalse
(
pendingOwner
===
accounts
[
2
]);
})
.
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