Skip to content

Commit

Permalink
emit organization address (instead of organizationId) at events. (#19)
Browse files Browse the repository at this point in the history
* emit organization address  (instead of organizationId) at events.

* version 08
  • Loading branch information
orenyodfat authored Oct 8, 2018
1 parent 8e6ba3d commit 654f78d
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 73 deletions.
18 changes: 13 additions & 5 deletions contracts/VotingMachines/AbsoluteVote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ contract AbsoluteVote is IntVoteInterface {

mapping(bytes32=>Parameters) public parameters; // A mapping from hashes to parameters
mapping(bytes32=>Proposal) public proposals; // Mapping from the ID of the proposal to the proposal itself.
mapping(bytes32 => address ) organizations;

uint public constant MAX_NUM_OF_CHOICES = 10;
uint public proposalsCnt; // Total amount of proposals
Expand Down Expand Up @@ -86,7 +87,14 @@ contract AbsoluteVote is IntVoteInterface {
proposal.owner = msg.sender;
proposal.open = true;
proposals[proposalId] = proposal;
emit NewProposal(proposalId, proposal.organizationId, _numOfChoices, msg.sender, _paramsHash);
if (organizations[proposal.organizationId] == 0) {
if (_organization == address(0)) {
organizations[proposal.organizationId] = msg.sender;
} else {
organizations[proposal.organizationId] = _organization;
}
}
emit NewProposal(proposalId, organizations[proposal.organizationId], _numOfChoices, msg.sender, _paramsHash);
return proposalId;
}

Expand All @@ -100,7 +108,7 @@ contract AbsoluteVote is IntVoteInterface {
}
bytes32 organizationId = proposals[_proposalId].organizationId;
deleteProposal(_proposalId);
emit CancelProposal(_proposalId, organizationId);
emit CancelProposal(_proposalId, organizations[organizationId]);
return true;
}

Expand Down Expand Up @@ -241,7 +249,7 @@ contract AbsoluteVote is IntVoteInterface {
proposal.votes[voter.vote] = (proposal.votes[voter.vote]).sub(voter.reputation);
proposal.totalVotes = (proposal.totalVotes).sub(voter.reputation);
delete proposal.voters[_voter];
emit CancelVoting(_proposalId, proposal.organizationId, _voter);
emit CancelVoting(_proposalId, organizations[proposal.organizationId], _voter);
}

function deleteProposal(bytes32 _proposalId) internal {
Expand All @@ -267,7 +275,7 @@ contract AbsoluteVote is IntVoteInterface {
if (proposal.votes[cnt] > totalReputation*precReq/100) {
Proposal memory tmpProposal = proposal;
deleteProposal(_proposalId);
emit ExecuteProposal(_proposalId, tmpProposal.organizationId, cnt, totalReputation);
emit ExecuteProposal(_proposalId, organizations[tmpProposal.organizationId], cnt, totalReputation);
ProposalExecuteInterface(tmpProposal.callbacks).executeProposal(_proposalId,int(cnt));
return true;
}
Expand Down Expand Up @@ -307,7 +315,7 @@ contract AbsoluteVote is IntVoteInterface {
vote: _vote
});
// Event:
emit VoteProposal(_proposalId, proposal.organizationId, _voter, _vote, reputation);
emit VoteProposal(_proposalId, organizations[proposal.organizationId], _voter, _vote, reputation);
emit AVVoteProposal(_proposalId, (_voter != msg.sender));
// execute the proposal if this vote was decisive:
return _execute(_proposalId);
Expand Down
31 changes: 20 additions & 11 deletions contracts/VotingMachines/GenesisProtocol.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ contract GenesisProtocol is IntVoteInterface {
mapping(address => Staker ) stakers;
}

event Stake(bytes32 indexed _proposalId, bytes32 indexed _organizationId, address indexed _staker,uint _vote,uint _amount);
event Redeem(bytes32 indexed _proposalId, bytes32 indexed _organizationId, address indexed _beneficiary,uint _amount);
event RedeemDaoBounty(bytes32 indexed _proposalId, bytes32 indexed _organizationId, address indexed _beneficiary,uint _amount);
event RedeemReputation(bytes32 indexed _proposalId, bytes32 indexed _organizationId, address indexed _beneficiary,uint _amount);
event Stake(bytes32 indexed _proposalId, address indexed _organization, address indexed _staker,uint _vote,uint _amount);
event Redeem(bytes32 indexed _proposalId, address indexed _organization, address indexed _beneficiary,uint _amount);
event RedeemDaoBounty(bytes32 indexed _proposalId, address indexed _organization, address indexed _beneficiary,uint _amount);
event RedeemReputation(bytes32 indexed _proposalId, address indexed _organization, address indexed _beneficiary,uint _amount);
event GPExecuteProposal(bytes32 indexed _proposalId, ExecutionState _executionState);

mapping(bytes32=>Parameters) public parameters; // A mapping from hashes to parameters
Expand All @@ -103,6 +103,8 @@ contract GenesisProtocol is IntVoteInterface {
uint public proposalsCnt; // Total number of proposals
mapping(bytes32=>uint) public orgBoostedProposalsCnt;
mapping(bytes32=>OrderStatisticTree.Tree) proposalsExpiredTimes; //proposals expired times
//organizationId => organization
mapping(bytes32 => address ) organizations;
StandardToken public stakingToken;
mapping(bytes=>bool) stakeSignatures; //stake signatures
address constant GEN_TOKEN_ADDRESS = 0x543Ff227F64Aa17eA132Bf9886cAb5DB55DCAddf;
Expand Down Expand Up @@ -169,7 +171,14 @@ contract GenesisProtocol is IntVoteInterface {
proposal.winningVote = NO;
proposal.paramsHash = _paramsHash;
proposals[proposalId] = proposal;
emit NewProposal(proposalId, proposal.organizationId, _numOfChoices, _proposer, _paramsHash);
if (organizations[proposal.organizationId] == 0) {
if (_organization == address(0)) {
organizations[proposal.organizationId] = msg.sender;
} else {
organizations[proposal.organizationId] = _organization;
}
}
emit NewProposal(proposalId, organizations[proposal.organizationId], _numOfChoices, _proposer, _paramsHash);
return proposalId;
}

Expand Down Expand Up @@ -506,11 +515,11 @@ contract GenesisProtocol is IntVoteInterface {
if (amount != 0) {
proposal.totalStakes[1] = proposal.totalStakes[1].sub(amount);
require(stakingToken.transfer(_beneficiary, amount));
emit Redeem(_proposalId,proposal.organizationId,_beneficiary,amount);
emit Redeem(_proposalId,organizations[proposal.organizationId],_beneficiary,amount);
}
if (reputation != 0 ) {
VotingMachineCallbacksInterface(proposal.callbacks).mintReputation(reputation,_beneficiary,_proposalId);
emit RedeemReputation(_proposalId,proposal.organizationId,_beneficiary,reputation);
emit RedeemReputation(_proposalId,organizations[proposal.organizationId],_beneficiary,reputation);
}
}

Expand Down Expand Up @@ -549,7 +558,7 @@ contract GenesisProtocol is IntVoteInterface {
require(VotingMachineCallbacksInterface(proposal.callbacks).stakingTokenTransfer(stakingToken,_beneficiary,potentialAmount,_proposalId));
proposal.stakers[_beneficiary].amountForBounty = 0;
redeemedAmount = potentialAmount;
emit RedeemDaoBounty(_proposalId,proposal.organizationId,_beneficiary,redeemedAmount);
emit RedeemDaoBounty(_proposalId,organizations[proposal.organizationId],_beneficiary,redeemedAmount);
}
}

Expand Down Expand Up @@ -766,7 +775,7 @@ contract GenesisProtocol is IntVoteInterface {
}
proposal.daoBountyRemain = daoBountyRemain;
}
emit ExecuteProposal(_proposalId, proposal.organizationId, proposal.winningVote, totalReputation);
emit ExecuteProposal(_proposalId, organizations[proposal.organizationId], proposal.winningVote, totalReputation);
emit GPExecuteProposal(_proposalId, executionState);
ProposalExecuteInterface(proposal.callbacks).executeProposal(_proposalId,int(proposal.winningVote));
}
Expand Down Expand Up @@ -815,7 +824,7 @@ contract GenesisProtocol is IntVoteInterface {
amount = amount - ((params.stakerFeeRatioForVoters*amount)/100);
proposal.totalStakes[0] = amount.add(proposal.totalStakes[0]);
// Event:
emit Stake(_proposalId, proposal.organizationId, _staker, _vote, _amount);
emit Stake(_proposalId, organizations[proposal.organizationId], _staker, _vote, _amount);
// execute the proposal if this vote was decisive:
return _execute(_proposalId);
}
Expand Down Expand Up @@ -886,7 +895,7 @@ contract GenesisProtocol is IntVoteInterface {
VotingMachineCallbacksInterface(proposal.callbacks).burnReputation(reputationDeposit,_voter,_proposalId);
}
// Event:
emit VoteProposal(_proposalId, proposal.organizationId, _voter, _vote, rep);
emit VoteProposal(_proposalId, organizations[proposal.organizationId], _voter, _vote, rep);
// execute the proposal if this vote was decisive:
return _execute(_proposalId);
}
Expand Down
10 changes: 5 additions & 5 deletions contracts/VotingMachines/IntVoteInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ interface IntVoteInterface {
modifier onlyProposalOwner(bytes32 _proposalId) {revert(); _;}
modifier votable(bytes32 _proposalId) {revert(); _;}

event NewProposal(bytes32 indexed _proposalId, bytes32 indexed _organizationId, uint _numOfChoices, address _proposer, bytes32 _paramsHash);
event ExecuteProposal(bytes32 indexed _proposalId, bytes32 indexed _organizationId, uint _decision, uint _totalReputation);
event VoteProposal(bytes32 indexed _proposalId, bytes32 indexed _organizationId, address indexed _voter, uint _vote, uint _reputation);
event CancelProposal(bytes32 indexed _proposalId, bytes32 indexed _organizationId );
event CancelVoting(bytes32 indexed _proposalId, bytes32 indexed _organizationId, address indexed _voter);
event NewProposal(bytes32 indexed _proposalId, address indexed _organization, uint _numOfChoices, address _proposer, bytes32 _paramsHash);
event ExecuteProposal(bytes32 indexed _proposalId, address indexed _organization, uint _decision, uint _totalReputation);
event VoteProposal(bytes32 indexed _proposalId, address indexed _organization, address indexed _voter, uint _vote, uint _reputation);
event CancelProposal(bytes32 indexed _proposalId, address indexed _organization );
event CancelVoting(bytes32 indexed _proposalId, address indexed _organization, address indexed _voter);

/**
* @dev register a new proposal with the given parameters. Every proposal has a unique ID which is being
Expand Down
2 changes: 1 addition & 1 deletion contracts/VotingMachines/QuorumVote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract QuorumVote is AbsoluteVote {
}
Proposal memory tmpProposal = proposal;
deleteProposal(_proposalId);
emit ExecuteProposal(_proposalId, tmpProposal.organizationId, maxInd, totalReputation);
emit ExecuteProposal(_proposalId, organizations[tmpProposal.organizationId], maxInd, totalReputation);
ProposalExecuteInterface(tmpProposal.callbacks).executeProposal(_proposalId,int(maxInd));
return true;
}
Expand Down
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@daostack/infra",
"version": "0.0.0-alpha.07",
"version": "0.0.0-alpha.08",
"description": "Base layer DAO's components",
"files": [
"contracts/",
Expand Down
Loading

0 comments on commit 654f78d

Please sign in to comment.