pub struct SimpleVoting<'a> { /* private fields */ }Expand description
Simple voting helper
Implementations§
Source§impl SimpleVoting<'_>
impl SimpleVoting<'_>
pub const fn new( proposals_key: &'static str, id_key: &'static str, proposals_info_key: &'static str, vote_config_key: &'static str, ) -> SimpleVoting<'_>
Sourcepub fn instantiate(
&self,
store: &mut dyn Storage,
vote_config: &VoteConfig,
) -> Result<(), VoteError>
pub fn instantiate( &self, store: &mut dyn Storage, vote_config: &VoteConfig, ) -> Result<(), VoteError>
SimpleVoting setup during instantiation
pub fn update_vote_config( &self, store: &mut dyn Storage, new_vote_config: &VoteConfig, ) -> Result<(), StdError>
Sourcepub fn new_proposal(
&self,
store: &mut dyn Storage,
end: Timestamp,
initial_voters: &[Addr],
) -> Result<u64, VoteError>
pub fn new_proposal( &self, store: &mut dyn Storage, end: Timestamp, initial_voters: &[Addr], ) -> Result<u64, VoteError>
Create new proposal initial_voters is a list of whitelisted to vote
Sourcepub fn cast_vote(
&self,
store: &mut dyn Storage,
block: &BlockInfo,
proposal_id: u64,
voter: &Addr,
vote: Vote,
) -> Result<ProposalInfo, VoteError>
pub fn cast_vote( &self, store: &mut dyn Storage, block: &BlockInfo, proposal_id: u64, voter: &Addr, vote: Vote, ) -> Result<ProposalInfo, VoteError>
Assign vote for the voter
Sourcepub fn cancel_proposal(
&self,
store: &mut dyn Storage,
block: &BlockInfo,
proposal_id: u64,
) -> Result<ProposalInfo, VoteError>
pub fn cancel_proposal( &self, store: &mut dyn Storage, block: &BlockInfo, proposal_id: u64, ) -> Result<ProposalInfo, VoteError>
Cancel proposal
Sourcepub fn count_votes(
&self,
store: &mut dyn Storage,
block: &BlockInfo,
proposal_id: u64,
) -> Result<(ProposalInfo, ProposalOutcome), VoteError>
pub fn count_votes( &self, store: &mut dyn Storage, block: &BlockInfo, proposal_id: u64, ) -> Result<(ProposalInfo, ProposalOutcome), VoteError>
Count votes and finish or move to the veto period(if configured) for this proposal
Sourcepub fn veto_proposal(
&self,
store: &mut dyn Storage,
block: &BlockInfo,
proposal_id: u64,
) -> Result<ProposalInfo, VoteError>
pub fn veto_proposal( &self, store: &mut dyn Storage, block: &BlockInfo, proposal_id: u64, ) -> Result<ProposalInfo, VoteError>
Called by veto admin Finish or Veto this proposal
Sourcepub fn load_vote(
&self,
store: &dyn Storage,
proposal_id: u64,
voter: &Addr,
) -> Result<Option<Vote>, VoteError>
pub fn load_vote( &self, store: &dyn Storage, proposal_id: u64, voter: &Addr, ) -> Result<Option<Vote>, VoteError>
Load vote by address
Sourcepub fn load_proposal(
&self,
store: &dyn Storage,
block: &BlockInfo,
proposal_id: u64,
) -> Result<ProposalInfo, VoteError>
pub fn load_proposal( &self, store: &dyn Storage, block: &BlockInfo, proposal_id: u64, ) -> Result<ProposalInfo, VoteError>
Load proposal by id with updated status if required
Sourcepub fn load_config(&self, store: &dyn Storage) -> Result<VoteConfig, StdError>
pub fn load_config(&self, store: &dyn Storage) -> Result<VoteConfig, StdError>
Load current vote config
Sourcepub fn query_by_id(
&self,
store: &dyn Storage,
proposal_id: u64,
start_after: Option<&Addr>,
limit: Option<u64>,
) -> Result<Vec<(Addr, Option<Vote>)>, VoteError>
pub fn query_by_id( &self, store: &dyn Storage, proposal_id: u64, start_after: Option<&Addr>, limit: Option<u64>, ) -> Result<Vec<(Addr, Option<Vote>)>, VoteError>
List of votes by proposal id
pub fn query_list( &self, store: &dyn Storage, start_after: Option<(u64, &Addr)>, limit: Option<u64>, ) -> Result<Vec<((u64, Addr), Option<Vote>)>, VoteError>
Auto Trait Implementations§
impl<'a> Freeze for SimpleVoting<'a>
impl<'a> RefUnwindSafe for SimpleVoting<'a>
impl<'a> Send for SimpleVoting<'a>
impl<'a> Sync for SimpleVoting<'a>
impl<'a> Unpin for SimpleVoting<'a>
impl<'a> UnwindSafe for SimpleVoting<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more