Skip to content

Commit

Permalink
fix daobounty (#87)
Browse files Browse the repository at this point in the history
* fix daobounty

* lint

* more test coverage

* test coverage

* comment
  • Loading branch information
orenyodfat authored Jul 30, 2020
1 parent 2fa97ab commit e9a0fb3
Show file tree
Hide file tree
Showing 8 changed files with 2,014 additions and 1,292 deletions.
2 changes: 1 addition & 1 deletion contracts/test/GenesisProtocolCallbacksMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "./Debug.sol";


contract GenesisProtocolCallbacksMock is Debug, VotingMachineCallbacksInterface,
ProposalExecuteInterface, OwnableUpgradeSafe {
ProposalExecuteInterface, OwnableUpgradeSafe {

Reputation public reputation;
IERC20 public stakingToken;
Expand Down
20 changes: 10 additions & 10 deletions contracts/token/ERC827/ERC827Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ contract ERC827Token is ERC20UpgradeSafe, ERC827 {

super.approve(_spender, _value);

// solhint-disable-next-line avoid-call-value
(bool success,) = _spender.call{value: msg.value}(_data);
// solhint-disable-next-line avoid-call-value,indent
(bool success,) = _spender.call {value: msg.value}(_data);
require(success);

return true;
Expand Down Expand Up @@ -71,8 +71,8 @@ contract ERC827Token is ERC20UpgradeSafe, ERC827 {

super.transfer(_to, _value);

// solhint-disable-next-line avoid-call-value
(bool success,) = _to.call{value: msg.value}(_data);
// solhint-disable-next-line avoid-call-value,indent
(bool success,) = _to.call {value: msg.value}(_data);
require(success);
return true;
}
Expand All @@ -98,8 +98,8 @@ contract ERC827Token is ERC20UpgradeSafe, ERC827 {

super.transferFrom(_from, _to, _value);

// solhint-disable-next-line avoid-call-value
(bool success,) = _to.call{value: msg.value}(_data);
// solhint-disable-next-line avoid-call-value,indent
(bool success,) = _to.call {value: msg.value}(_data);
require(success);
return true;
}
Expand Down Expand Up @@ -128,8 +128,8 @@ contract ERC827Token is ERC20UpgradeSafe, ERC827 {

super.increaseAllowance(_spender, _addedValue);

// solhint-disable-next-line avoid-call-value
(bool success,) = _spender.call{value: msg.value}(_data);
// solhint-disable-next-line avoid-call-value,indent
(bool success,) = _spender.call {value: msg.value}(_data);
require(success);

return true;
Expand Down Expand Up @@ -159,8 +159,8 @@ contract ERC827Token is ERC20UpgradeSafe, ERC827 {

super.decreaseAllowance(_spender, _subtractedValue);

// solhint-disable-next-line avoid-call-value
(bool success,) = _spender.call{value: msg.value}(_data);
// solhint-disable-next-line avoid-call-value,indent
(bool success,) = _spender.call {value: msg.value}(_data);
require(success);

return true;
Expand Down
10 changes: 6 additions & 4 deletions contracts/votingMachines/GenesisProtocol.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ contract GenesisProtocol is IntVoteInterface, GenesisProtocolLogic {
GenesisProtocolLogic(_stakingToken) {
}


/**
* @dev Check that the proposal is votable
* a proposal is votable if it is in one of the following states:
Expand Down Expand Up @@ -157,9 +156,12 @@ contract GenesisProtocol is IntVoteInterface, GenesisProtocolLogic {
* generated by calculating keccak256 of a incremented counter.
* @param _proposer address
*/
function propose(uint256, bytes32 _paramsHash, address _proposer, address _organization) external override returns(bytes32) {
return _propose(_paramsHash, _proposer, _organization);
}
function propose(uint256, bytes32 _paramsHash, address _proposer, address _organization)
external
override
returns(bytes32) {
return _propose(_paramsHash, _proposer, _organization);
}

/**
* @dev execute check if the proposal has been decided, and if so, execute the proposal
Expand Down
9 changes: 5 additions & 4 deletions contracts/votingMachines/GenesisProtocolLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
proposal.daoBountyRemain = proposal.daoBountyRemain.sub(potentialAmount);
require(
VotingMachineCallbacksInterface(proposal.callbacks)
.stakingTokenTransfer(stakingToken, _beneficiary, potentialAmount, _proposalId));
.stakingTokenTransfer(stakingToken, _beneficiary, potentialAmount, _proposalId), "transfer token failed");
redeemedAmount = potentialAmount;
emit RedeemDaoBounty(_proposalId, organizations[proposal.organizationId], _beneficiary, redeemedAmount);
}
Expand Down Expand Up @@ -560,9 +560,9 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
proposal.winningVote,
totalReputation
);
proposal.daoBounty = proposal.daoBountyRemain;
emit GPExecuteProposal(_proposalId, executionState);
ProposalExecuteInterface(proposal.callbacks).executeProposal(_proposalId, int(proposal.winningVote));
proposal.daoBounty = proposal.daoBountyRemain;
}
if (tmpProposal.state != proposal.state) {
emit StateChange(_proposalId, proposal.state);
Expand Down Expand Up @@ -610,8 +610,9 @@ contract GenesisProtocolLogic is IntVoteInterfaceEvents {
"total stakes is too high");

if (_vote == YES) {
staker.amount4BountyAndVote = uint256(uint248(staker.amount4BountyAndVote)).add(amount) |
(_vote<<VOTE_BIT_INDEX);
uint256 amount4Bounty = uint256(uint248(staker.amount4BountyAndVote)).add(amount);
require(amount4Bounty < PREBOOSTED_BIT_SET, "total stake for staker is too large");
staker.amount4BountyAndVote = amount4Bounty | (_vote<<VOTE_BIT_INDEX);
} else {
staker.amount4BountyAndVote |= (_vote<<VOTE_BIT_INDEX);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/votingMachines/IntVoteInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.6.10;
interface IntVoteInterface {
//When implementing this interface please do not only override function and modifier,
//but also to keep the modifiers on the overridden functions.
modifier votable(bytes32 _proposalId) virtual {revert(); _;}
modifier votable(bytes32 _proposalId) virtual {revert("proposal is not votable"); _;}

event CancelProposal(bytes32 indexed _proposalId, address indexed _organization );
event CancelVoting(bytes32 indexed _proposalId, address indexed _organization, address indexed _voter);
Expand Down
Loading

0 comments on commit e9a0fb3

Please sign in to comment.