1
- pragma solidity ^ 0.4.24 ;
1
+ pragma solidity ^ 0.4.25 ;
2
2
3
3
import "./IntVoteInterface.sol " ;
4
4
import { RealMath } from "../libs/RealMath.sol " ;
@@ -62,7 +62,7 @@ contract GenesisProtocol is IntVoteInterface {
62
62
}
63
63
64
64
struct Proposal {
65
- bytes32 organization ; // the organization unique identifier the proposal is target to.
65
+ bytes32 organizationId ; // the organization unique identifier the proposal is target to.
66
66
address callbacks; // should fulfill voting callbacks interface.
67
67
uint numOfChoices;
68
68
uint votersStakes;
@@ -88,10 +88,10 @@ contract GenesisProtocol is IntVoteInterface {
88
88
mapping (address => Staker ) stakers;
89
89
}
90
90
91
- event Stake (bytes32 indexed _proposalId , bytes32 indexed _organization , address indexed _staker ,uint _vote ,uint _amount );
92
- event Redeem (bytes32 indexed _proposalId , bytes32 indexed _organization , address indexed _beneficiary ,uint _amount );
93
- event RedeemDaoBounty (bytes32 indexed _proposalId , bytes32 indexed _organization , address indexed _beneficiary ,uint _amount );
94
- event RedeemReputation (bytes32 indexed _proposalId , bytes32 indexed _organization , address indexed _beneficiary ,uint _amount );
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 );
95
95
event GPExecuteProposal (bytes32 indexed _proposalId , ExecutionState _executionState );
96
96
97
97
mapping (bytes32 => Parameters) public parameters; // A mapping from hashes to parameters
@@ -102,11 +102,10 @@ contract GenesisProtocol is IntVoteInterface {
102
102
uint constant public YES = 1 ;
103
103
uint public proposalsCnt; // Total number of proposals
104
104
mapping (bytes32 => uint ) public orgBoostedProposalsCnt;
105
+ mapping (bytes32 => OrderStatisticTree.Tree) proposalsExpiredTimes; //proposals expired times
105
106
StandardToken public stakingToken;
106
107
mapping (bytes => bool ) stakeSignatures; //stake signatures
107
108
address constant GEN_TOKEN_ADDRESS = 0x543Ff227F64Aa17eA132Bf9886cAb5DB55DCAddf ;
108
- mapping (bytes32 => OrderStatisticTree.Tree) proposalsExpiredTimes; //proposals expired times
109
-
110
109
// Digest describing the data the user signs according EIP 712.
111
110
// Needs to match what is passed to Metamask.
112
111
bytes32 public constant DELEGATION_HASH_EIP712 =
@@ -160,7 +159,7 @@ contract GenesisProtocol is IntVoteInterface {
160
159
Proposal memory proposal;
161
160
proposal.numOfChoices = _numOfChoices;
162
161
proposal.callbacks = msg .sender ;
163
- proposal.organization = keccak256 (abi.encodePacked (msg .sender ,_organization));
162
+ proposal.organizationId = keccak256 (abi.encodePacked (msg .sender ,_organization));
164
163
165
164
proposal.state = ProposalState.PreBoosted;
166
165
// solium-disable-next-line security/no-block-members
@@ -170,7 +169,7 @@ contract GenesisProtocol is IntVoteInterface {
170
169
proposal.winningVote = NO;
171
170
proposal.paramsHash = _paramsHash;
172
171
proposals[proposalId] = proposal;
173
- emit NewProposal (proposalId, proposal.organization , _numOfChoices, _proposer, _paramsHash);
172
+ emit NewProposal (proposalId, proposal.organizationId , _numOfChoices, _proposer, _paramsHash);
174
173
return proposalId;
175
174
}
176
175
@@ -367,12 +366,12 @@ contract GenesisProtocol is IntVoteInterface {
367
366
}
368
367
369
368
/**
370
- * @dev getProposalOrganization return the organization for a given proposal
369
+ * @dev getProposalOrganization return the organizationId for a given proposal
371
370
* @param _proposalId the ID of the proposal
372
371
* @return bytes32 organization identifier
373
372
*/
374
373
function getProposalOrganization (bytes32 _proposalId ) external view returns (bytes32 ) {
375
- return (proposals[_proposalId].organization );
374
+ return (proposals[_proposalId].organizationId );
376
375
}
377
376
378
377
/**
@@ -507,11 +506,11 @@ contract GenesisProtocol is IntVoteInterface {
507
506
if (amount != 0 ) {
508
507
proposal.totalStakes[1 ] = proposal.totalStakes[1 ].sub (amount);
509
508
require (stakingToken.transfer (_beneficiary, amount));
510
- emit Redeem (_proposalId,proposal.organization ,_beneficiary,amount);
509
+ emit Redeem (_proposalId,proposal.organizationId ,_beneficiary,amount);
511
510
}
512
511
if (reputation != 0 ) {
513
512
VotingMachineCallbacksInterface (proposal.callbacks).mintReputation (reputation,_beneficiary,_proposalId);
514
- emit RedeemReputation (_proposalId,proposal.organization ,_beneficiary,reputation);
513
+ emit RedeemReputation (_proposalId,proposal.organizationId ,_beneficiary,reputation);
515
514
}
516
515
}
517
516
@@ -550,7 +549,7 @@ contract GenesisProtocol is IntVoteInterface {
550
549
require (VotingMachineCallbacksInterface (proposal.callbacks).stakingTokenTransfer (stakingToken,_beneficiary,potentialAmount,_proposalId));
551
550
proposal.stakers[_beneficiary].amountForBounty = 0 ;
552
551
redeemedAmount = potentialAmount;
553
- emit RedeemDaoBounty (_proposalId,proposal.organization ,_beneficiary,redeemedAmount);
552
+ emit RedeemDaoBounty (_proposalId,proposal.organizationId ,_beneficiary,redeemedAmount);
554
553
}
555
554
}
556
555
@@ -561,7 +560,7 @@ contract GenesisProtocol is IntVoteInterface {
561
560
*/
562
561
function shouldBoost (bytes32 _proposalId ) public view returns (bool ) {
563
562
Proposal memory proposal = proposals[_proposalId];
564
- return (_score (_proposalId) >= threshold (proposal.paramsHash,proposal.organization ));
563
+ return (_score (_proposalId) >= threshold (proposal.paramsHash,proposal.organizationId ));
565
564
}
566
565
567
566
/**
@@ -575,28 +574,28 @@ contract GenesisProtocol is IntVoteInterface {
575
574
576
575
/**
577
576
* @dev getBoostedProposalsCount return the number of boosted proposal for an organization
578
- * @param _organization the organization identifier
577
+ * @param _organizationId the organization identifier
579
578
* @return uint number of boosted proposals
580
579
*/
581
- function getBoostedProposalsCount (bytes32 _organization ) public view returns (uint ) {
580
+ function getBoostedProposalsCount (bytes32 _organizationId ) public view returns (uint ) {
582
581
uint expiredProposals;
583
- if (proposalsExpiredTimes[_organization ].count () != 0 ) {
582
+ if (proposalsExpiredTimes[_organizationId ].count () != 0 ) {
584
583
// solium-disable-next-line security/no-block-members
585
- expiredProposals = proposalsExpiredTimes[_organization ].rank (now );
584
+ expiredProposals = proposalsExpiredTimes[_organizationId ].rank (now );
586
585
}
587
- return orgBoostedProposalsCnt[_organization ].sub (expiredProposals);
586
+ return orgBoostedProposalsCnt[_organizationId ].sub (expiredProposals);
588
587
}
589
588
590
589
/**
591
590
* @dev threshold return the organization's score threshold which required by
592
591
* a proposal to shift to boosted state.
593
592
* This threshold is dynamically set and it depend on the number of boosted proposal.
594
- * @param _organization the organization identifier
593
+ * @param _organizationId the organization identifier
595
594
* @param _paramsHash the organization parameters hash
596
595
* @return int organization's score threshold.
597
596
*/
598
- function threshold (bytes32 _paramsHash ,bytes32 _organization ) public view returns (int ) {
599
- uint boostedProposals = getBoostedProposalsCount (_organization );
597
+ function threshold (bytes32 _paramsHash ,bytes32 _organizationId ) public view returns (int ) {
598
+ uint boostedProposals = getBoostedProposalsCount (_organizationId );
600
599
int216 e = 2 ;
601
600
602
601
Parameters memory params = parameters[_paramsHash];
@@ -738,23 +737,23 @@ contract GenesisProtocol is IntVoteInterface {
738
737
proposal.state = ProposalState.Boosted;
739
738
// solium-disable-next-line security/no-block-members
740
739
proposal.boostedPhaseTime = now ;
741
- proposalsExpiredTimes[proposal.organization ].insert (proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
742
- orgBoostedProposalsCnt[proposal.organization ]++ ;
740
+ proposalsExpiredTimes[proposal.organizationId ].insert (proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
741
+ orgBoostedProposalsCnt[proposal.organizationId ]++ ;
743
742
}
744
743
}
745
744
746
745
if ((proposal.state == ProposalState.Boosted) ||
747
746
(proposal.state == ProposalState.QuietEndingPeriod)) {
748
747
// solium-disable-next-line security/no-block-members
749
748
if ((now - proposal.boostedPhaseTime) >= proposal.currentBoostedVotePeriodLimit) {
750
- proposalsExpiredTimes[proposal.organization ].remove (proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
749
+ proposalsExpiredTimes[proposal.organizationId ].remove (proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
751
750
proposal.state = ProposalState.Executed;
752
- orgBoostedProposalsCnt[tmpProposal.organization ] = orgBoostedProposalsCnt[tmpProposal.organization ].sub (1 );
751
+ orgBoostedProposalsCnt[tmpProposal.organizationId ] = orgBoostedProposalsCnt[tmpProposal.organizationId ].sub (1 );
753
752
executionState = ExecutionState.BoostedTimeOut;
754
753
} else if (proposal.votes[proposal.winningVote] > executionBar) {
755
754
// someone crossed the absolute vote execution bar.
756
- orgBoostedProposalsCnt[tmpProposal.organization ] = orgBoostedProposalsCnt[tmpProposal.organization ].sub (1 );
757
- proposalsExpiredTimes[proposal.organization ].remove (proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
755
+ orgBoostedProposalsCnt[tmpProposal.organizationId ] = orgBoostedProposalsCnt[tmpProposal.organizationId ].sub (1 );
756
+ proposalsExpiredTimes[proposal.organizationId ].remove (proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
758
757
proposal.state = ProposalState.Executed;
759
758
executionState = ExecutionState.BoostedBarCrossed;
760
759
}
@@ -767,7 +766,7 @@ contract GenesisProtocol is IntVoteInterface {
767
766
}
768
767
proposal.daoBountyRemain = daoBountyRemain;
769
768
}
770
- emit ExecuteProposal (_proposalId, proposal.organization , proposal.winningVote, totalReputation);
769
+ emit ExecuteProposal (_proposalId, proposal.organizationId , proposal.winningVote, totalReputation);
771
770
emit GPExecuteProposal (_proposalId, executionState);
772
771
ProposalExecuteInterface (proposal.callbacks).executeProposal (_proposalId,int (proposal.winningVote));
773
772
}
@@ -816,7 +815,7 @@ contract GenesisProtocol is IntVoteInterface {
816
815
amount = amount - ((params.stakerFeeRatioForVoters* amount)/ 100 );
817
816
proposal.totalStakes[0 ] = amount.add (proposal.totalStakes[0 ]);
818
817
// Event:
819
- emit Stake (_proposalId, proposal.organization , _staker, _vote, _amount);
818
+ emit Stake (_proposalId, proposal.organizationId , _staker, _vote, _amount);
820
819
// execute the proposal if this vote was decisive:
821
820
return _execute (_proposalId);
822
821
}
@@ -866,13 +865,13 @@ contract GenesisProtocol is IntVoteInterface {
866
865
if ((proposal.state == ProposalState.QuietEndingPeriod) ||
867
866
((proposal.state == ProposalState.Boosted) && ((_now - proposal.boostedPhaseTime) >= (params.boostedVotePeriodLimit - params.quietEndingPeriod)))) {
868
867
//quietEndingPeriod
869
- proposalsExpiredTimes[proposal.organization ].remove (proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
868
+ proposalsExpiredTimes[proposal.organizationId ].remove (proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
870
869
if (proposal.state != ProposalState.QuietEndingPeriod) {
871
870
proposal.currentBoostedVotePeriodLimit = params.quietEndingPeriod;
872
871
proposal.state = ProposalState.QuietEndingPeriod;
873
872
}
874
873
proposal.boostedPhaseTime = _now;
875
- proposalsExpiredTimes[proposal.organization ].insert (proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
874
+ proposalsExpiredTimes[proposal.organizationId ].insert (proposal.boostedPhaseTime + proposal.currentBoostedVotePeriodLimit);
876
875
}
877
876
proposal.winningVote = _vote;
878
877
}
@@ -887,7 +886,7 @@ contract GenesisProtocol is IntVoteInterface {
887
886
VotingMachineCallbacksInterface (proposal.callbacks).burnReputation (reputationDeposit,_voter,_proposalId);
888
887
}
889
888
// Event:
890
- emit VoteProposal (_proposalId, proposal.organization , _voter, _vote, rep);
889
+ emit VoteProposal (_proposalId, proposal.organizationId , _voter, _vote, rep);
891
890
// execute the proposal if this vote was decisive:
892
891
return _execute (_proposalId);
893
892
}
0 commit comments