diff --git a/contracts/Bounty.sol b/contracts/Bounty.sol index 46699b1b3..a90d2e44a 100644 --- a/contracts/Bounty.sol +++ b/contracts/Bounty.sol @@ -1,8 +1,8 @@ pragma solidity ^0.4.4; -import './PullPayment.sol'; -import './Killable.sol'; +import './payment/PullPayment.sol'; +import './lifecycle/Killable.sol'; /* diff --git a/contracts/DayLimit.sol b/contracts/DayLimit.sol index 41f9e4994..8fd07255b 100644 --- a/contracts/DayLimit.sol +++ b/contracts/DayLimit.sol @@ -1,7 +1,7 @@ pragma solidity ^0.4.4; -import './Shareable.sol'; +import './ownership/Shareable.sol'; /* diff --git a/contracts/MultisigWallet.sol b/contracts/MultisigWallet.sol index 867de28ff..245ae3e1a 100644 --- a/contracts/MultisigWallet.sol +++ b/contracts/MultisigWallet.sol @@ -1,8 +1,8 @@ pragma solidity ^0.4.4; -import "./Multisig.sol"; -import "./Shareable.sol"; +import "./ownership/Multisig.sol"; +import "./ownership/Shareable.sol"; import "./DayLimit.sol"; diff --git a/contracts/examples/BadArrayUse.sol b/contracts/examples/BadArrayUse.sol deleted file mode 100644 index dd8a65344..000000000 --- a/contracts/examples/BadArrayUse.sol +++ /dev/null @@ -1,23 +0,0 @@ -pragma solidity ^0.4.4; - - -import '../PullPayment.sol'; - - -// UNSAFE CODE, DO NOT USE! -contract BadArrayUse is PullPayment { - address[] employees; - - function payBonus() { - for (var i = 0; i < employees.length; i++) { - address employee = employees[i]; - uint bonus = calculateBonus(employee); - asyncSend(employee, bonus); - } - } - - function calculateBonus(address employee) returns (uint) { - // some expensive computation... - } - -} diff --git a/contracts/examples/BadFailEarly.sol b/contracts/examples/BadFailEarly.sol deleted file mode 100644 index ee26bdd1d..000000000 --- a/contracts/examples/BadFailEarly.sol +++ /dev/null @@ -1,17 +0,0 @@ -pragma solidity ^0.4.4; - - -// UNSAFE CODE, DO NOT USE! -contract BadFailEarly { - - uint constant DEFAULT_SALARY = 50000; - mapping(string => uint) nameToSalary; - - function getSalary(string name) constant returns (uint) { - if (bytes(name).length != 0 && nameToSalary[name] != 0) { - return nameToSalary[name]; - } else { - return DEFAULT_SALARY; - } - } -} diff --git a/contracts/examples/BadPushPayments.sol b/contracts/examples/BadPushPayments.sol deleted file mode 100644 index 7bc11c665..000000000 --- a/contracts/examples/BadPushPayments.sol +++ /dev/null @@ -1,23 +0,0 @@ -pragma solidity ^0.4.4; - - -// UNSAFE CODE, DO NOT USE! -contract BadPushPayments { - - address highestBidder; - uint highestBid; - - function bid() payable { - if (msg.value < highestBid) throw; - - if (highestBidder != 0) { - // return bid to previous winner - if (!highestBidder.send(highestBid)) { - throw; - } - } - - highestBidder = msg.sender; - highestBid = msg.value; - } -} diff --git a/contracts/examples/GoodArrayUse.sol b/contracts/examples/GoodArrayUse.sol deleted file mode 100644 index 8995702a8..000000000 --- a/contracts/examples/GoodArrayUse.sol +++ /dev/null @@ -1,25 +0,0 @@ -pragma solidity ^0.4.4; - - -import '../PullPayment.sol'; - - -contract GoodArrayUse is PullPayment { - address[] employees; - mapping(address => uint) bonuses; - - function payBonus() { - for (uint i = 0; i < employees.length; i++) { - address employee = employees[i]; - uint bonus = bonuses[employee]; - asyncSend(employee, bonus); - } - } - - function calculateBonus(address employee) returns (uint) { - uint bonus = 0; - // some expensive computation... - bonuses[employee] = bonus; - } - -} diff --git a/contracts/examples/GoodFailEarly.sol b/contracts/examples/GoodFailEarly.sol deleted file mode 100644 index dce0eac44..000000000 --- a/contracts/examples/GoodFailEarly.sol +++ /dev/null @@ -1,15 +0,0 @@ -pragma solidity ^0.4.4; - - -contract GoodFailEarly { - - uint constant DEFAULT_SALARY = 50000; - mapping(string => uint) nameToSalary; - - function getSalary(string name) constant returns (uint) { - if (bytes(name).length == 0) throw; - if (nameToSalary[name] == 0) throw; - - return nameToSalary[name]; - } -} diff --git a/contracts/examples/GoodPullPayments.sol b/contracts/examples/GoodPullPayments.sol deleted file mode 100644 index fc0cd986b..000000000 --- a/contracts/examples/GoodPullPayments.sol +++ /dev/null @@ -1,27 +0,0 @@ -pragma solidity ^0.4.4; - - -contract GoodPullPayments { - address highestBidder; - uint highestBid; - mapping(address => uint) refunds; - - function bid() external payable { - if (msg.value < highestBid) throw; - - if (highestBidder != 0) { - refunds[highestBidder] += highestBid; - } - - highestBidder = msg.sender; - highestBid = msg.value; - } - - function withdrawBid() external { - uint refund = refunds[msg.sender]; - refunds[msg.sender] = 0; - if (!msg.sender.send(refund)) { - refunds[msg.sender] = refund; - } - } -} diff --git a/contracts/examples/ProofOfExistence.sol b/contracts/examples/ProofOfExistence.sol deleted file mode 100644 index 0bf7ca220..000000000 --- a/contracts/examples/ProofOfExistence.sol +++ /dev/null @@ -1,38 +0,0 @@ -pragma solidity ^0.4.4; - - -/* - * Proof of Existence example contract - * see https://medium.com/zeppelin-blog/the-hitchhikers-guide-to-smart-contracts-in-ethereum-848f08001f05 - */ -contract ProofOfExistence { - - mapping (bytes32 => bool) public proofs; - - // store a proof of existence in the contract state - function storeProof(bytes32 proof) { - proofs[proof] = true; - } - - // calculate and store the proof for a document - function notarize(string document) { - var proof = calculateProof(document); - storeProof(proof); - } - - // helper function to get a document's sha256 - function calculateProof(string document) constant returns (bytes32) { - return sha256(document); - } - - // check if a document has been notarized - function checkDocument(string document) constant returns (bool) { - var proof = calculateProof(document); - return hasProof(proof); - } - - // returns true if proof is stored - function hasProof(bytes32 proof) constant returns (bool) { - return proofs[proof]; - } -} diff --git a/contracts/examples/PullPaymentBid.sol b/contracts/examples/PullPaymentBid.sol deleted file mode 100644 index 8ba51422f..000000000 --- a/contracts/examples/PullPaymentBid.sol +++ /dev/null @@ -1,20 +0,0 @@ -pragma solidity ^0.4.4; - - -import '../PullPayment.sol'; - - -contract PullPaymentBid is PullPayment { - address public highestBidder; - uint public highestBid; - - function bid() external payable { - if (msg.value <= highestBid) throw; - - if (highestBidder != 0) { - asyncSend(highestBidder, highestBid); - } - highestBidder = msg.sender; - highestBid = msg.value; - } -} diff --git a/contracts/examples/StoppableBid.sol b/contracts/examples/StoppableBid.sol deleted file mode 100644 index 53e1aebdc..000000000 --- a/contracts/examples/StoppableBid.sol +++ /dev/null @@ -1,26 +0,0 @@ -pragma solidity ^0.4.4; - - -import '../PullPayment.sol'; -import '../Stoppable.sol'; - - -contract StoppableBid is Stoppable, PullPayment { - address public highestBidder; - uint public highestBid; - - function bid() external payable stopInEmergency { - if (msg.value <= highestBid) throw; - - if (highestBidder != 0) { - asyncSend(highestBidder, highestBid); - } - highestBidder = msg.sender; - highestBid = msg.value; - } - - function withdraw() onlyInEmergency { - selfdestruct(owner); - } - -} diff --git a/contracts/Killable.sol b/contracts/lifecycle/Killable.sol similarity index 86% rename from contracts/Killable.sol rename to contracts/lifecycle/Killable.sol index 10621d63e..7ec3e2b51 100644 --- a/contracts/Killable.sol +++ b/contracts/lifecycle/Killable.sol @@ -1,7 +1,7 @@ pragma solidity ^0.4.4; -import "./Ownable.sol"; +import "../ownership/Ownable.sol"; /* diff --git a/contracts/Migrations.sol b/contracts/lifecycle/Migrations.sol similarity index 91% rename from contracts/Migrations.sol rename to contracts/lifecycle/Migrations.sol index 010f551fc..8b981e774 100644 --- a/contracts/Migrations.sol +++ b/contracts/lifecycle/Migrations.sol @@ -1,7 +1,7 @@ pragma solidity ^0.4.4; -import './Ownable.sol'; +import '../ownership/Ownable.sol'; contract Migrations is Ownable { diff --git a/contracts/Stoppable.sol b/contracts/lifecycle/Stoppable.sol similarity index 94% rename from contracts/Stoppable.sol rename to contracts/lifecycle/Stoppable.sol index 5c018844a..2dc37d6fc 100644 --- a/contracts/Stoppable.sol +++ b/contracts/lifecycle/Stoppable.sol @@ -1,7 +1,7 @@ pragma solidity ^0.4.4; -import "./Ownable.sol"; +import "../ownership/Ownable.sol"; /* diff --git a/contracts/Claimable.sol b/contracts/ownership/Claimable.sol similarity index 100% rename from contracts/Claimable.sol rename to contracts/ownership/Claimable.sol diff --git a/contracts/DelayedClaimable.sol b/contracts/ownership/DelayedClaimable.sol similarity index 100% rename from contracts/DelayedClaimable.sol rename to contracts/ownership/DelayedClaimable.sol diff --git a/contracts/Multisig.sol b/contracts/ownership/Multisig.sol similarity index 100% rename from contracts/Multisig.sol rename to contracts/ownership/Multisig.sol diff --git a/contracts/Ownable.sol b/contracts/ownership/Ownable.sol similarity index 100% rename from contracts/Ownable.sol rename to contracts/ownership/Ownable.sol diff --git a/contracts/Shareable.sol b/contracts/ownership/Shareable.sol similarity index 100% rename from contracts/Shareable.sol rename to contracts/ownership/Shareable.sol diff --git a/contracts/PullPayment.sol b/contracts/payment/PullPayment.sol similarity index 100% rename from contracts/PullPayment.sol rename to contracts/payment/PullPayment.sol diff --git a/contracts/test-helpers/PullPaymentMock.sol b/contracts/test-helpers/PullPaymentMock.sol index 2d6ca1e2f..223f8d0d1 100644 --- a/contracts/test-helpers/PullPaymentMock.sol +++ b/contracts/test-helpers/PullPaymentMock.sol @@ -1,7 +1,7 @@ pragma solidity ^0.4.4; -import '../PullPayment.sol'; +import '../payment/PullPayment.sol'; // mock class using PullPayment diff --git a/contracts/test-helpers/ShareableMock.sol b/contracts/test-helpers/ShareableMock.sol index ebf06546e..0d30958af 100644 --- a/contracts/test-helpers/ShareableMock.sol +++ b/contracts/test-helpers/ShareableMock.sol @@ -1,5 +1,5 @@ pragma solidity ^0.4.4; -import "../Shareable.sol"; +import "../ownership/Shareable.sol"; contract ShareableMock is Shareable { diff --git a/contracts/test-helpers/StoppableMock.sol b/contracts/test-helpers/StoppableMock.sol index 44c12bbcf..32e456a20 100644 --- a/contracts/test-helpers/StoppableMock.sol +++ b/contracts/test-helpers/StoppableMock.sol @@ -1,7 +1,7 @@ pragma solidity ^0.4.4; -import '../Stoppable.sol'; +import '../lifecycle/Stoppable.sol'; // mock class using Stoppable