WIP Target contract creation via factory pattern

This commit is contained in:
Makoto Inoue
2016-10-22 23:29:13 +01:00
parent 48badda96f
commit f2ec8790e8
3 changed files with 18 additions and 2 deletions

View File

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

View File

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

View File

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