Manuel Araoz 8 роки тому
батько
коміт
ca8f2f2362

+ 2 - 2
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';
 
 
 /*

+ 1 - 1
contracts/DayLimit.sol

@@ -1,7 +1,7 @@
 pragma solidity ^0.4.4;
 
 
-import './Shareable.sol';
+import './ownership/Shareable.sol';
 
 
 /*

+ 2 - 2
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";
 
 

+ 0 - 23
contracts/examples/BadArrayUse.sol

@@ -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...
-  }
-
-}

+ 0 - 17
contracts/examples/BadFailEarly.sol

@@ -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;
-    }
-  }
-}

+ 0 - 23
contracts/examples/BadPushPayments.sol

@@ -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;
-	}
-}

+ 0 - 25
contracts/examples/GoodArrayUse.sol

@@ -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;
-  }
-
-}

+ 0 - 15
contracts/examples/GoodFailEarly.sol

@@ -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];
-  }
-}

+ 0 - 27
contracts/examples/GoodPullPayments.sol

@@ -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;
-    }
-  }
-}

+ 0 - 38
contracts/examples/ProofOfExistence.sol

@@ -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];
-  }
-}

+ 0 - 20
contracts/examples/PullPaymentBid.sol

@@ -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;
-  }
-}

+ 0 - 26
contracts/examples/StoppableBid.sol

@@ -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);
-  }
-
-}

+ 1 - 1
contracts/Killable.sol → contracts/lifecycle/Killable.sol

@@ -1,7 +1,7 @@
 pragma solidity ^0.4.4;
 
 
-import "./Ownable.sol";
+import "../ownership/Ownable.sol";
 
 
 /*

+ 1 - 1
contracts/Migrations.sol → contracts/lifecycle/Migrations.sol

@@ -1,7 +1,7 @@
 pragma solidity ^0.4.4;
 
 
-import './Ownable.sol';
+import '../ownership/Ownable.sol';
 
 
 contract Migrations is Ownable {

+ 1 - 1
contracts/Stoppable.sol → contracts/lifecycle/Stoppable.sol

@@ -1,7 +1,7 @@
 pragma solidity ^0.4.4;
 
 
-import "./Ownable.sol";
+import "../ownership/Ownable.sol";
 
 
 /*

+ 0 - 0
contracts/Claimable.sol → contracts/ownership/Claimable.sol


+ 0 - 0
contracts/DelayedClaimable.sol → contracts/ownership/DelayedClaimable.sol


+ 0 - 0
contracts/Multisig.sol → contracts/ownership/Multisig.sol


+ 0 - 0
contracts/Ownable.sol → contracts/ownership/Ownable.sol


+ 0 - 0
contracts/Shareable.sol → contracts/ownership/Shareable.sol


+ 0 - 0
contracts/PullPayment.sol → contracts/payment/PullPayment.sol


+ 1 - 1
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

+ 1 - 1
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 {
 

+ 1 - 1
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