From 4bfc2ba858103aabdbb818ef714b57dc7728c033 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 11 Aug 2016 18:21:15 -0300 Subject: [PATCH] stoppable and stoppablebid example --- contracts/Stoppable.sol | 25 +++++++++++++++++++++++++ contracts/StoppableBid.sol | 26 ++++++++++++++++++++++++++ migrations/2_deploy_contracts.js | 2 -- 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 contracts/Stoppable.sol create mode 100644 contracts/StoppableBid.sol diff --git a/contracts/Stoppable.sol b/contracts/Stoppable.sol new file mode 100644 index 000000000..11f4b88b3 --- /dev/null +++ b/contracts/Stoppable.sol @@ -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; + } + +} diff --git a/contracts/StoppableBid.sol b/contracts/StoppableBid.sol new file mode 100644 index 000000000..fa5ac0707 --- /dev/null +++ b/contracts/StoppableBid.sol @@ -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); + } + +} diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index 1cb418de3..86e1b0b12 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -1,6 +1,4 @@ module.exports = function(deployer) { - deployer.deploy(BadFailEarly); - deployer.deploy(GoodFailEarly); deployer.deploy(PullPaymentBid); deployer.deploy(BadArrayUse); deployer.deploy(Bounty);