Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improve encapsulation on BreakInvariantBounty
  • Loading branch information
Leo Arias authored and frangio committed Sep 3, 2018
commit b10f7a34f84c24a569612dca32810173866e6800
14 changes: 11 additions & 3 deletions contracts/bounties/BreakInvariantBounty.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "../payment/PullPayment.sol";
* @dev This bounty will pay out to a researcher if they break invariant logic of the contract.
*/
contract BreakInvariantBounty is PullPayment, Ownable {
bool public claimed;
bool private claimed_;
mapping(address => address) public researchers;

event TargetCreated(address createdAddress);
Expand All @@ -18,7 +18,15 @@ contract BreakInvariantBounty is PullPayment, Ownable {
* @dev Fallback function allowing the contract to receive funds, if they haven't already been claimed.
*/
function() external payable {
require(!claimed);
require(!claimed_);
}

/**
* @dev Determine if the bounty was claimed.
* @return true if the bounty was claimed, false otherwise.
*/
function wasClaimed() public view returns(bool) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frangio what should I do here? Rename the function to claimed or rename the variable to wasClaimed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like claimed. I'm not sure about wasClaimed because in English the correct thing would be "has been claimed".

return claimed_;
}

/**
Expand All @@ -43,7 +51,7 @@ contract BreakInvariantBounty is PullPayment, Ownable {
// Check Target contract invariants
require(!_target.checkInvariant());
_asyncTransfer(researcher, address(this).balance);
claimed = true;
claimed_ = true;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/BreakInvariantBounty.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ contract('BreakInvariantBounty', function ([_, owner, researcher, nonTarget]) {

it('can claim reward', async function () {
await this.bounty.claim(this.targetAddress, { from: researcher });
const claim = await this.bounty.claimed();
const claim = await this.bounty.wasClaimed();

claim.should.equal(true);

Expand Down