Browse Source

WIP Target contract creation via factory pattern

Makoto Inoue 9 years ago
parent
commit
f2ec8790e8

+ 6 - 2
contracts/bounties/SimpleTokenBounty.sol

@@ -8,6 +8,10 @@ import '../PullPayment.sol';
  * have sufficient ether for everyone to withdraw.
  */
 
+contract Factory {
+  function deployContract() returns (address);
+}
+
 contract Target {
   function checkInvariant() returns(bool);
 }
@@ -21,8 +25,8 @@ contract Bounty is PullPayment {
     if (claimed) throw;
   }
 
-  function createTarget(address targetAddress) returns(Target) {
-    target = Target(targetAddress);
+  function createTarget(address factoryAddress) returns(Target) {
+    target = Target(Factory(factoryAddress).deployContract());
     researchers[target] = msg.sender;
     return target;
   }

+ 6 - 0
contracts/test-helpers/InsecureTargetMock.sol

@@ -5,3 +5,9 @@ contract InsecureTargetMock {
     return false;
   }
 }
+
+contract Deployer {
+  function deployContract() returns (address) {
+    return new InsecureTargetMock();
+  }
+}

+ 6 - 0
contracts/test-helpers/SecureTargetMock.sol

@@ -5,3 +5,9 @@ contract SecureTargetMock {
     return true;
   }
 }
+
+contract Deployer {
+  function deployContract() returns (address) {
+    return new SecureTargetMock();
+  }
+}