Skip to main content

IMajorityVoting

Description

The interface of majority voting plugin.

Implementation

enum VoteOption

enum VoteOption {
None,
Abstain,
Yes,
No
}

event VoteCast

Emitted when a vote is cast by a voter.

event VoteCast(uint256 proposalId, address voter, enum IMajorityVoting.VoteOption voteOption, uint256 votingPower)
InputTypeDescription
proposalIduint256The ID of the proposal.
voteraddressThe voter casting the vote.
voteOptionenum IMajorityVoting.VoteOptionThe casted vote option.
votingPoweruint256The voting power behind this vote.

external function supportThreshold

Returns the support threshold parameter stored in the voting settings.

function supportThreshold() external view returns (uint32)
OutputTypeDescription
0uint32The support threshold parameter.

external function minParticipation

Returns the minimum participation parameter stored in the voting settings.

function minParticipation() external view returns (uint32)
OutputTypeDescription
0uint32The minimum participation parameter.

external function isSupportThresholdReached

Checks if the support value defined as support=NyesNyes+Nno\texttt{support} = \frac{N_\text{yes}}{N_\text{yes}+N_\text{no}} for a proposal vote is greater than the support threshold.

function isSupportThresholdReached(uint256 _proposalId) external view returns (bool)
InputTypeDescription
_proposalIduint256The ID of the proposal.
Output
0boolReturns true if the support is greater than the support threshold and false otherwise.

external function isSupportThresholdReachedEarly

Checks if the worst-case support value defined as worstCaseSupport=NyesNtotalNabstain\texttt{worstCaseSupport} = \frac{N_\text{yes}}{ N_\text{total}-N_\text{abstain}} for a proposal vote is greater than the support threshold.

function isSupportThresholdReachedEarly(uint256 _proposalId) external view returns (bool)
InputTypeDescription
_proposalIduint256The ID of the proposal.
Output
0boolReturns true if the worst-case support is greater than the support threshold and false otherwise.

external function isMinParticipationReached

Checks if the participation value defined as participation=Nyes+Nno+NabstainNtotal\texttt{participation} = \frac{N_\text{yes}+N_\text{no}+N_\text{abstain}}{N_\text{total}} for a proposal vote is greater or equal than the minimum participation value.

function isMinParticipationReached(uint256 _proposalId) external view returns (bool)
InputTypeDescription
_proposalIduint256The ID of the proposal.
Output
0boolReturns true if the participation is greater than the minimum participation and false otherwise.

external function canVote

Checks if an account can participate on a proposal vote. This can be because the vote

  • has not started,
  • has ended,
  • was executed, or
  • the voter doesn't have voting powers.
function canVote(uint256 _proposalId, address _account, enum IMajorityVoting.VoteOption _voteOption) external view returns (bool)
InputTypeDescription
_proposalIduint256The proposal Id.
_accountaddressThe account address to be checked.
_voteOptionenum IMajorityVoting.VoteOptionWhether the voter abstains, supports or opposes the proposal.
Output
0boolReturns true if the account is allowed to vote.

The function assumes the queried proposal exists.

external function canExecute

Checks if a proposal can be executed.

function canExecute(uint256 _proposalId) external view returns (bool)
InputTypeDescription
_proposalIduint256The ID of the proposal to be checked.
Output
0boolTrue if the proposal can be executed, false otherwise.

external function vote

Votes for a vote option and, optionally, executes the proposal.

function vote(uint256 _proposalId, enum IMajorityVoting.VoteOption _voteOption, bool _tryEarlyExecution) external
InputTypeDescription
_proposalIduint256The ID of the proposal.
_voteOptionenum IMajorityVoting.VoteOptionThe chosen vote option.
_tryEarlyExecutionboolIf true, early execution is tried after the vote cast. The call does not revert if early execution is not possible.

_voteOption, 1 -> abstain, 2 -> yes, 3 -> no

external function execute

Executes a proposal.

function execute(uint256 _proposalId) external
InputTypeDescription
_proposalIduint256The ID of the proposal to be executed.

external function getVoteOption

Returns whether the account has voted for the proposal. Note, that this does not check if the account has voting power.

function getVoteOption(uint256 _proposalId, address _account) external view returns (enum IMajorityVoting.VoteOption)
InputTypeDescription
_proposalIduint256The ID of the proposal.
_accountaddressThe account address to be checked.
Output
0enum IMajorityVoting.VoteOptionThe vote option cast by a voter for a certain proposal.
© 2024