stoppable and stoppablebid example
This commit is contained in:
25
contracts/Stoppable.sol
Normal file
25
contracts/Stoppable.sol
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Stoppable
|
||||||
|
*/
|
||||||
|
contract Stoppable {
|
||||||
|
address public curator;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
stopped = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
26
contracts/StoppableBid.sol
Normal file
26
contracts/StoppableBid.sol
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import './PullPaymentCapable.sol';
|
||||||
|
import './Stoppable.sol';
|
||||||
|
|
||||||
|
contract StoppableBid is Stoppable, PullPaymentCapable {
|
||||||
|
address public highestBidder;
|
||||||
|
uint public highestBid;
|
||||||
|
|
||||||
|
function StoppableBid(address _curator)
|
||||||
|
Stoppable(_curator)
|
||||||
|
PullPaymentCapable() {}
|
||||||
|
|
||||||
|
function bid() external stopInEmergency {
|
||||||
|
if (msg.value <= highestBid) throw;
|
||||||
|
|
||||||
|
if (highestBidder != 0) {
|
||||||
|
asyncSend(highestBidder, highestBid);
|
||||||
|
}
|
||||||
|
highestBidder = msg.sender;
|
||||||
|
highestBid = msg.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function withdraw() onlyInEmergency {
|
||||||
|
suicide(curator);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,6 +1,4 @@
|
|||||||
module.exports = function(deployer) {
|
module.exports = function(deployer) {
|
||||||
deployer.deploy(BadFailEarly);
|
|
||||||
deployer.deploy(GoodFailEarly);
|
|
||||||
deployer.deploy(PullPaymentBid);
|
deployer.deploy(PullPaymentBid);
|
||||||
deployer.deploy(BadArrayUse);
|
deployer.deploy(BadArrayUse);
|
||||||
deployer.deploy(Bounty);
|
deployer.deploy(Bounty);
|
||||||
|
|||||||
Reference in New Issue
Block a user