Browse Source

Swap SimpleToken with Target

Makoto Inoue 9 years ago
parent
commit
9345436957
1 changed files with 15 additions and 9 deletions
  1. 15 9
      contracts/Bounty.sol

+ 15 - 9
contracts/Bounty.sol

@@ -1,15 +1,21 @@
 pragma solidity ^0.4.0;
 pragma solidity ^0.4.0;
 import './PullPayment.sol';
 import './PullPayment.sol';
-import './token/SimpleToken.sol';
 
 
 /*
 /*
  * Bounty
  * Bounty
  * This bounty will pay out if you can cause a SimpleToken's balance
  * This bounty will pay out if you can cause a SimpleToken's balance
- * to be lower than its totalSupply, which would mean that it doesn't 
+ * to be lower than its totalSupply, which would mean that it doesn't
  * have sufficient ether for everyone to withdraw.
  * have sufficient ether for everyone to withdraw.
  */
  */
-contract Bounty is PullPayment {
 
 
+contract Target {
+  function checkInvarient() returns(bool){
+    return true;
+  }
+}
+
+contract Bounty is PullPayment {
+  Target target;
   bool public claimed;
   bool public claimed;
   mapping(address => address) public researchers;
   mapping(address => address) public researchers;
 
 
@@ -17,22 +23,22 @@ contract Bounty is PullPayment {
     if (claimed) throw;
     if (claimed) throw;
   }
   }
 
 
-  function createTarget() returns(SimpleToken) {
-    SimpleToken target = new SimpleToken();
+  function createTarget() returns(Target) {
+    target = new Target();
     researchers[target] = msg.sender;
     researchers[target] = msg.sender;
     return target;
     return target;
   }
   }
 
 
   function checkInvarient() returns(bool){
   function checkInvarient() returns(bool){
-    return true;
+    return target.checkInvarient();
   }
   }
 
 
-  function claim(SimpleToken target) {
+  function claim(Target target) {
     address researcher = researchers[target];
     address researcher = researchers[target];
     if (researcher == 0) throw;
     if (researcher == 0) throw;
-    // Check SimpleToken contract invariants
+    // Check Target contract invariants
     // Customize this to the specifics of your contract
     // Customize this to the specifics of your contract
-    if (target.totalSupply() == target.balance) {
+    if (!target.checkInvarient()) {
       throw;
       throw;
     }
     }
     asyncSend(researcher, this.balance);
     asyncSend(researcher, this.balance);