Expand description
§Simple voting
Simple voting is a state object to enable voting mechanism on a contract
§Setting up
- Create SimpleVoting object in similar way to the cw-storage-plus objects using
SimpleVoting::newmethod - Inside instantiate contract method use
SimpleVoting::instantiatemethod - Add
VoteErrortype to your application errors
§Creating a new proposal
To create a new proposal use SimpleVoting::new_proposal method, it will return ProposalId
§Whitelisting voters
Initial whitelist passed during SimpleVoting::new_proposal method and currently has no way to edit this
§Voting
To cast a vote use SimpleVoting::cast_vote method
§Count voting
To count votes use SimpleVoting::count_votes method during ProposalStatus::WaitingForCount
§Veto
In case your VoteConfig has veto duration set-up, after proposal.end_timestamp veto period will start
- During veto period
SimpleVoting::veto_proposalmethod could be used to Veto proposal
§Cancel proposal
During active voting:
SimpleVoting::cancel_proposalmethod could be used to cancel proposal
§Queries
- Single-item queries methods allowed by
load_prefix - List of items queries allowed by
query_prefix
§Details
All methods that modify proposal will return ProposalInfo to allow logging or checking current status of proposal.
Each proposal goes through the following stages:
- Active: proposal is active and can be voted on. It can also be canceled during this period.
- VetoPeriod (optional): voting is counted and veto period is active.
- WaitingForCount: voting period is finished and awaiting counting.
- Finished: proposal is finished and count is done. The proposal then has one of the following end states:
- Passed: proposal passed
- Failed: proposal failed
- Canceled: proposal was canceled
- Vetoed: proposal was vetoed
Structs§
- Proposal
Info - Simple
Voting - Simple voting helper
- Vote
- Vote struct
- Vote
Config