Commit 726840b8 by Manuel Araoz

make Bounty inheritance explicit

parent 5c9a18e1
...@@ -206,7 +206,7 @@ ___ ...@@ -206,7 +206,7 @@ ___
To create a bounty for your contract, inherit from the base `Bounty` contract and provide an implementation for `deployContract()` returning the new contract address. To create a bounty for your contract, inherit from the base `Bounty` contract and provide an implementation for `deployContract()` returning the new contract address.
``` ```
import "./zeppelin/Bounty.sol"; import {Bounty, Target} from "./zeppelin/Bounty.sol";
import "./YourContract.sol"; import "./YourContract.sol";
contract YourBounty is Bounty { contract YourBounty is Bounty {
...@@ -221,9 +221,10 @@ Next, implement invariant logic into your smart contract ...@@ -221,9 +221,10 @@ Next, implement invariant logic into your smart contract
At contracts/YourContract.sol At contracts/YourContract.sol
``` ```
contract YourContract { import {Bounty, Target} from "./zeppelin/Bounty.sol";
contract YourContract is Target {
function checkInvariant() returns(bool) { function checkInvariant() returns(bool) {
// Implement your logic to make sure that none of the state is broken. // Implement your logic to make sure that none of the invariants are broken.
} }
} }
``` ```
......
pragma solidity ^0.4.4; pragma solidity ^0.4.4;
import './PullPayment.sol'; import './PullPayment.sol';
import './Killable.sol'; import './Killable.sol';
/* /*
* Bounty * Bounty
* This bounty will pay out to a researcher if he/she breaks invariant logic of *
* the contract you bet reward against. * This bounty will pay out to a researcher if they break invariant logic of the contract.
*/ */
contract Target {
function checkInvariant() returns(bool);
}
contract Bounty is PullPayment, Killable { contract Bounty is PullPayment, Killable {
Target target; Target target;
bool public claimed; bool public claimed;
...@@ -48,3 +46,9 @@ contract Bounty is PullPayment, Killable { ...@@ -48,3 +46,9 @@ contract Bounty is PullPayment, Killable {
} }
} }
contract Target {
function checkInvariant() returns(bool);
}
pragma solidity ^0.4.4; pragma solidity ^0.4.4;
import "../Bounty.sol";
contract InsecureTargetMock { import {Bounty, Target} from "../Bounty.sol";
contract InsecureTargetMock is Target {
function checkInvariant() returns(bool){ function checkInvariant() returns(bool){
return false; return false;
} }
......
pragma solidity ^0.4.4; pragma solidity ^0.4.4;
import "../Bounty.sol";
contract SecureTargetMock { import {Bounty, Target} from "../Bounty.sol";
function checkInvariant() returns(bool){
contract SecureTargetMock is Target {
function checkInvariant() returns(bool) {
return true; return true;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment