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::new
method - Inside instantiate contract method use
SimpleVoting::instantiate
method - Add
VoteError
type 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_proposal
method could be used to Veto proposal
§Cancel proposal
During active voting:
SimpleVoting::cancel_proposal
method 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§
- Simple voting helper
- Vote struct