Skip to content

Commit 654f78d

Browse files
authored
emit organization address (instead of organizationId) at events. (#19)
* emit organization address (instead of organizationId) at events. * version 08
1 parent 8e6ba3d commit 654f78d

File tree

10 files changed

+94
-73
lines changed

10 files changed

+94
-73
lines changed

contracts/VotingMachines/AbsoluteVote.sol

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ contract AbsoluteVote is IntVoteInterface {
3939

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

4344
uint public constant MAX_NUM_OF_CHOICES = 10;
4445
uint public proposalsCnt; // Total amount of proposals
@@ -86,7 +87,14 @@ contract AbsoluteVote is IntVoteInterface {
8687
proposal.owner = msg.sender;
8788
proposal.open = true;
8889
proposals[proposalId] = proposal;
89-
emit NewProposal(proposalId, proposal.organizationId, _numOfChoices, msg.sender, _paramsHash);
90+
if (organizations[proposal.organizationId] == 0) {
91+
if (_organization == address(0)) {
92+
organizations[proposal.organizationId] = msg.sender;
93+
} else {
94+
organizations[proposal.organizationId] = _organization;
95+
}
96+
}
97+
emit NewProposal(proposalId, organizations[proposal.organizationId], _numOfChoices, msg.sender, _paramsHash);
9098
return proposalId;
9199
}
92100

@@ -100,7 +108,7 @@ contract AbsoluteVote is IntVoteInterface {
100108
}
101109
bytes32 organizationId = proposals[_proposalId].organizationId;
102110
deleteProposal(_proposalId);
103-
emit CancelProposal(_proposalId, organizationId);
111+
emit CancelProposal(_proposalId, organizations[organizationId]);
104112
return true;
105113
}
106114

@@ -241,7 +249,7 @@ contract AbsoluteVote is IntVoteInterface {
241249
proposal.votes[voter.vote] = (proposal.votes[voter.vote]).sub(voter.reputation);
242250
proposal.totalVotes = (proposal.totalVotes).sub(voter.reputation);
243251
delete proposal.voters[_voter];
244-
emit CancelVoting(_proposalId, proposal.organizationId, _voter);
252+
emit CancelVoting(_proposalId, organizations[proposal.organizationId], _voter);
245253
}
246254

247255
function deleteProposal(bytes32 _proposalId) internal {
@@ -267,7 +275,7 @@ contract AbsoluteVote is IntVoteInterface {
267275
if (proposal.votes[cnt] > totalReputation*precReq/100) {
268276
Proposal memory tmpProposal = proposal;
269277
deleteProposal(_proposalId);
270-
emit ExecuteProposal(_proposalId, tmpProposal.organizationId, cnt, totalReputation);
278+
emit ExecuteProposal(_proposalId, organizations[tmpProposal.organizationId], cnt, totalReputation);
271279
ProposalExecuteInterface(tmpProposal.callbacks).executeProposal(_proposalId,int(cnt));
272280
return true;
273281
}
@@ -307,7 +315,7 @@ contract AbsoluteVote is IntVoteInterface {
307315
vote: _vote
308316
});
309317
// Event:
310-
emit VoteProposal(_proposalId, proposal.organizationId, _voter, _vote, reputation);
318+
emit VoteProposal(_proposalId, organizations[proposal.organizationId], _voter, _vote, reputation);
311319
emit AVVoteProposal(_proposalId, (_voter != msg.sender));
312320
// execute the proposal if this vote was decisive:
313321
return _execute(_proposalId);

contracts/VotingMachines/GenesisProtocol.sol

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ contract GenesisProtocol is IntVoteInterface {
8888
mapping(address => Staker ) stakers;
8989
}
9090

91-
event Stake(bytes32 indexed _proposalId, bytes32 indexed _organizationId, address indexed _staker,uint _vote,uint _amount);
92-
event Redeem(bytes32 indexed _proposalId, bytes32 indexed _organizationId, address indexed _beneficiary,uint _amount);
93-
event RedeemDaoBounty(bytes32 indexed _proposalId, bytes32 indexed _organizationId, address indexed _beneficiary,uint _amount);
94-
event RedeemReputation(bytes32 indexed _proposalId, bytes32 indexed _organizationId, address indexed _beneficiary,uint _amount);
91+
event Stake(bytes32 indexed _proposalId, address indexed _organization, address indexed _staker,uint _vote,uint _amount);
92+
event Redeem(bytes32 indexed _proposalId, address indexed _organization, address indexed _beneficiary,uint _amount);
93+
event RedeemDaoBounty(bytes32 indexed _proposalId, address indexed _organization, address indexed _beneficiary,uint _amount);
94+
event RedeemReputation(bytes32 indexed _proposalId, address indexed _organization, address indexed _beneficiary,uint _amount);
9595
event GPExecuteProposal(bytes32 indexed _proposalId, ExecutionState _executionState);
9696

9797
mapping(bytes32=>Parameters) public parameters; // A mapping from hashes to parameters
@@ -103,6 +103,8 @@ contract GenesisProtocol is IntVoteInterface {
103103
uint public proposalsCnt; // Total number of proposals
104104
mapping(bytes32=>uint) public orgBoostedProposalsCnt;
105105
mapping(bytes32=>OrderStatisticTree.Tree) proposalsExpiredTimes; //proposals expired times
106+
//organizationId => organization
107+
mapping(bytes32 => address ) organizations;
106108
StandardToken public stakingToken;
107109
mapping(bytes=>bool) stakeSignatures; //stake signatures
108110
address constant GEN_TOKEN_ADDRESS = 0x543Ff227F64Aa17eA132Bf9886cAb5DB55DCAddf;
@@ -169,7 +171,14 @@ contract GenesisProtocol is IntVoteInterface {
169171
proposal.winningVote = NO;
170172
proposal.paramsHash = _paramsHash;
171173
proposals[proposalId] = proposal;
172-
emit NewProposal(proposalId, proposal.organizationId, _numOfChoices, _proposer, _paramsHash);
174+
if (organizations[proposal.organizationId] == 0) {
175+
if (_organization == address(0)) {
176+
organizations[proposal.organizationId] = msg.sender;
177+
} else {
178+
organizations[proposal.organizationId] = _organization;
179+
}
180+
}
181+
emit NewProposal(proposalId, organizations[proposal.organizationId], _numOfChoices, _proposer, _paramsHash);
173182
return proposalId;
174183
}
175184

@@ -506,11 +515,11 @@ contract GenesisProtocol is IntVoteInterface {
506515
if (amount != 0) {
507516
proposal.totalStakes[1] = proposal.totalStakes[1].sub(amount);
508517
require(stakingToken.transfer(_beneficiary, amount));
509-
emit Redeem(_proposalId,proposal.organizationId,_beneficiary,amount);
518+
emit Redeem(_proposalId,organizations[proposal.organizationId],_beneficiary,amount);
510519
}
511520
if (reputation != 0 ) {
512521
VotingMachineCallbacksInterface(proposal.callbacks).mintReputation(reputation,_beneficiary,_proposalId);
513-
emit RedeemReputation(_proposalId,proposal.organizationId,_beneficiary,reputation);
522+
emit RedeemReputation(_proposalId,organizations[proposal.organizationId],_beneficiary,reputation);
514523
}
515524
}
516525

@@ -549,7 +558,7 @@ contract GenesisProtocol is IntVoteInterface {
549558
require(VotingMachineCallbacksInterface(proposal.callbacks).stakingTokenTransfer(stakingToken,_beneficiary,potentialAmount,_proposalId));
550559
proposal.stakers[_beneficiary].amountForBounty = 0;
551560
redeemedAmount = potentialAmount;
552-
emit RedeemDaoBounty(_proposalId,proposal.organizationId,_beneficiary,redeemedAmount);
561+
emit RedeemDaoBounty(_proposalId,organizations[proposal.organizationId],_beneficiary,redeemedAmount);
553562
}
554563
}
555564

@@ -766,7 +775,7 @@ contract GenesisProtocol is IntVoteInterface {
766775
}
767776
proposal.daoBountyRemain = daoBountyRemain;
768777
}
769-
emit ExecuteProposal(_proposalId, proposal.organizationId, proposal.winningVote, totalReputation);
778+
emit ExecuteProposal(_proposalId, organizations[proposal.organizationId], proposal.winningVote, totalReputation);
770779
emit GPExecuteProposal(_proposalId, executionState);
771780
ProposalExecuteInterface(proposal.callbacks).executeProposal(_proposalId,int(proposal.winningVote));
772781
}
@@ -815,7 +824,7 @@ contract GenesisProtocol is IntVoteInterface {
815824
amount = amount - ((params.stakerFeeRatioForVoters*amount)/100);
816825
proposal.totalStakes[0] = amount.add(proposal.totalStakes[0]);
817826
// Event:
818-
emit Stake(_proposalId, proposal.organizationId, _staker, _vote, _amount);
827+
emit Stake(_proposalId, organizations[proposal.organizationId], _staker, _vote, _amount);
819828
// execute the proposal if this vote was decisive:
820829
return _execute(_proposalId);
821830
}
@@ -886,7 +895,7 @@ contract GenesisProtocol is IntVoteInterface {
886895
VotingMachineCallbacksInterface(proposal.callbacks).burnReputation(reputationDeposit,_voter,_proposalId);
887896
}
888897
// Event:
889-
emit VoteProposal(_proposalId, proposal.organizationId, _voter, _vote, rep);
898+
emit VoteProposal(_proposalId, organizations[proposal.organizationId], _voter, _vote, rep);
890899
// execute the proposal if this vote was decisive:
891900
return _execute(_proposalId);
892901
}

contracts/VotingMachines/IntVoteInterface.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ interface IntVoteInterface {
66
modifier onlyProposalOwner(bytes32 _proposalId) {revert(); _;}
77
modifier votable(bytes32 _proposalId) {revert(); _;}
88

9-
event NewProposal(bytes32 indexed _proposalId, bytes32 indexed _organizationId, uint _numOfChoices, address _proposer, bytes32 _paramsHash);
10-
event ExecuteProposal(bytes32 indexed _proposalId, bytes32 indexed _organizationId, uint _decision, uint _totalReputation);
11-
event VoteProposal(bytes32 indexed _proposalId, bytes32 indexed _organizationId, address indexed _voter, uint _vote, uint _reputation);
12-
event CancelProposal(bytes32 indexed _proposalId, bytes32 indexed _organizationId );
13-
event CancelVoting(bytes32 indexed _proposalId, bytes32 indexed _organizationId, address indexed _voter);
9+
event NewProposal(bytes32 indexed _proposalId, address indexed _organization, uint _numOfChoices, address _proposer, bytes32 _paramsHash);
10+
event ExecuteProposal(bytes32 indexed _proposalId, address indexed _organization, uint _decision, uint _totalReputation);
11+
event VoteProposal(bytes32 indexed _proposalId, address indexed _organization, address indexed _voter, uint _vote, uint _reputation);
12+
event CancelProposal(bytes32 indexed _proposalId, address indexed _organization );
13+
event CancelVoting(bytes32 indexed _proposalId, address indexed _organization, address indexed _voter);
1414

1515
/**
1616
* @dev register a new proposal with the given parameters. Every proposal has a unique ID which is being

contracts/VotingMachines/QuorumVote.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ contract QuorumVote is AbsoluteVote {
3434
}
3535
Proposal memory tmpProposal = proposal;
3636
deleteProposal(_proposalId);
37-
emit ExecuteProposal(_proposalId, tmpProposal.organizationId, maxInd, totalReputation);
37+
emit ExecuteProposal(_proposalId, organizations[tmpProposal.organizationId], maxInd, totalReputation);
3838
ProposalExecuteInterface(tmpProposal.callbacks).executeProposal(_proposalId,int(maxInd));
3939
return true;
4040
}

package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@daostack/infra",
3-
"version": "0.0.0-alpha.07",
3+
"version": "0.0.0-alpha.08",
44
"description": "Base layer DAO's components",
55
"files": [
66
"contracts/",

0 commit comments

Comments
 (0)