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
4599fbf2
Commit
4599fbf2
authored
Nov 01, 2016
by
Federico Bond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Stoppable a subclass of Ownable. Fixes #47
parent
c70a0cfd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
23 deletions
+14
-23
Ownable.sol
contracts/Ownable.sol
+1
-0
Stoppable.sol
contracts/Stoppable.sol
+5
-11
StoppableBid.sol
contracts/examples/StoppableBid.sol
+1
-5
StoppableMock.sol
contracts/test-helpers/StoppableMock.sol
+2
-2
Stoppable.js
test/Stoppable.js
+5
-5
No files found.
contracts/Ownable.sol
View file @
4599fbf2
pragma solidity ^0.4.0;
/*
* Ownable
* Base contract with an owner
...
...
contracts/Stoppable.sol
View file @
4599fbf2
pragma solidity ^0.4.0;
import "./Ownable.sol";
/*
* Stoppable
* Abstract contract that allows children to implement an
* emergency stop mechanism.
*/
contract Stoppable {
address public curator;
contract Stoppable is Ownable {
bool public stopped;
modifier stopInEmergency { if (!stopped) _; }
modifier onlyInEmergency { if (stopped) _; }
function Stoppable(address _curator) {
if (_curator == 0) throw;
curator = _curator;
}
function emergencyStop() external {
if (msg.sender != curator) throw;
function emergencyStop() external onlyOwner {
stopped = true;
}
function release() external onlyInEmergency {
if (msg.sender != curator) throw;
function release() external onlyOwner onlyInEmergency {
stopped = false;
}
...
...
contracts/examples/StoppableBid.sol
View file @
4599fbf2
...
...
@@ -7,10 +7,6 @@ contract StoppableBid is Stoppable, PullPayment {
address public highestBidder;
uint public highestBid;
function StoppableBid(address _curator)
Stoppable(_curator)
PullPayment() {}
function bid() external stopInEmergency {
if (msg.value <= highestBid) throw;
...
...
@@ -22,7 +18,7 @@ contract StoppableBid is Stoppable, PullPayment {
}
function withdraw() onlyInEmergency {
suicide(
curato
r);
suicide(
owne
r);
}
}
contracts/test-helpers/StoppableMock.sol
View file @
4599fbf2
...
...
@@ -2,11 +2,11 @@ pragma solidity ^0.4.0;
import '../Stoppable.sol';
// mock class using Stoppable
contract StoppableMock is Stoppable
(msg.sender)
{
contract StoppableMock is Stoppable {
bool public drasticMeasureTaken;
uint public count;
function StoppableMock()
Stoppable(msg.sender)
{
function StoppableMock() {
drasticMeasureTaken = false;
count = 0;
}
...
...
test/Stoppable.js
View file @
4599fbf2
...
...
@@ -2,7 +2,7 @@ contract('Stoppable', function(accounts) {
it
(
"can perform normal process in non-emergency"
,
function
(
done
)
{
var
stoppable
;
return
StoppableMock
.
new
(
accounts
[
0
]
)
return
StoppableMock
.
new
()
.
then
(
function
(
_stoppable
)
{
stoppable
=
_stoppable
;
return
stoppable
.
count
();
...
...
@@ -24,7 +24,7 @@ contract('Stoppable', function(accounts) {
it
(
"can not perform normal process in emergency"
,
function
(
done
)
{
var
stoppable
;
return
StoppableMock
.
new
(
accounts
[
0
]
)
return
StoppableMock
.
new
()
.
then
(
function
(
_stoppable
)
{
stoppable
=
_stoppable
;
return
stoppable
.
emergencyStop
();
...
...
@@ -50,7 +50,7 @@ contract('Stoppable', function(accounts) {
it
(
"can not take drastic measure in non-emergency"
,
function
(
done
)
{
var
stoppable
;
return
StoppableMock
.
new
(
accounts
[
0
]
)
return
StoppableMock
.
new
()
.
then
(
function
(
_stoppable
)
{
stoppable
=
_stoppable
;
return
stoppable
.
drasticMeasure
();
...
...
@@ -66,7 +66,7 @@ contract('Stoppable', function(accounts) {
it
(
"can take a drastic measure in an emergency"
,
function
(
done
)
{
var
stoppable
;
return
StoppableMock
.
new
(
accounts
[
0
]
)
return
StoppableMock
.
new
()
.
then
(
function
(
_stoppable
)
{
stoppable
=
_stoppable
;
return
stoppable
.
emergencyStop
();
...
...
@@ -85,7 +85,7 @@ contract('Stoppable', function(accounts) {
it
(
"should resume allowing normal process after emergency is over"
,
function
(
done
)
{
var
stoppable
;
return
StoppableMock
.
new
(
accounts
[
0
]
)
return
StoppableMock
.
new
()
.
then
(
function
(
_stoppable
)
{
stoppable
=
_stoppable
;
return
stoppable
.
emergencyStop
();
...
...
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