make Bounty inheritance explicit

pull/87/head
Manuel Araoz 8 years ago
parent 5c9a18e1f6
commit 726840b8de
  1. 7
      README.md
  2. 18
      contracts/Bounty.sol
  3. 6
      contracts/test-helpers/InsecureTargetBounty.sol
  4. 8
      contracts/test-helpers/SecureTargetBounty.sol

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

@ -1,17 +1,15 @@
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 {
} }
} }
contract Target {
function checkInvariant() returns(bool);
}

@ -1,8 +1,10 @@
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;
} }

@ -1,9 +1,11 @@
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;
} }
} }

Loading…
Cancel
Save