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, ) -> Self
Sourcepub fn instantiate(
&self,
store: &mut dyn Storage,
vote_config: &VoteConfig,
) -> VoteResult<()>
pub fn instantiate( &self, store: &mut dyn Storage, vote_config: &VoteConfig, ) -> VoteResult<()>
SimpleVoting setup during instantiation
pub fn update_vote_config( &self, store: &mut dyn Storage, new_vote_config: &VoteConfig, ) -> StdResult<()>
Sourcepub fn new_proposal(
&self,
store: &mut dyn Storage,
end: Timestamp,
initial_voters: &[Addr],
) -> VoteResult<ProposalId>
pub fn new_proposal( &self, store: &mut dyn Storage, end: Timestamp, initial_voters: &[Addr], ) -> VoteResult<ProposalId>
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: ProposalId,
voter: &Addr,
vote: Vote,
) -> VoteResult<ProposalInfo>
pub fn cast_vote( &self, store: &mut dyn Storage, block: &BlockInfo, proposal_id: ProposalId, voter: &Addr, vote: Vote, ) -> VoteResult<ProposalInfo>
Assign vote for the voter
Sourcepub fn cancel_proposal(
&self,
store: &mut dyn Storage,
block: &BlockInfo,
proposal_id: ProposalId,
) -> VoteResult<ProposalInfo>
pub fn cancel_proposal( &self, store: &mut dyn Storage, block: &BlockInfo, proposal_id: ProposalId, ) -> VoteResult<ProposalInfo>
Cancel proposal
Sourcepub fn count_votes(
&self,
store: &mut dyn Storage,
block: &BlockInfo,
proposal_id: ProposalId,
) -> VoteResult<(ProposalInfo, ProposalOutcome)>
pub fn count_votes( &self, store: &mut dyn Storage, block: &BlockInfo, proposal_id: ProposalId, ) -> VoteResult<(ProposalInfo, ProposalOutcome)>
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: ProposalId,
) -> VoteResult<ProposalInfo>
pub fn veto_proposal( &self, store: &mut dyn Storage, block: &BlockInfo, proposal_id: ProposalId, ) -> VoteResult<ProposalInfo>
Called by veto admin Finish or Veto this proposal
Sourcepub fn load_vote(
&self,
store: &dyn Storage,
proposal_id: ProposalId,
voter: &Addr,
) -> VoteResult<Option<Vote>>
pub fn load_vote( &self, store: &dyn Storage, proposal_id: ProposalId, voter: &Addr, ) -> VoteResult<Option<Vote>>
Load vote by address
Sourcepub fn load_proposal(
&self,
store: &dyn Storage,
block: &BlockInfo,
proposal_id: ProposalId,
) -> VoteResult<ProposalInfo>
pub fn load_proposal( &self, store: &dyn Storage, block: &BlockInfo, proposal_id: ProposalId, ) -> VoteResult<ProposalInfo>
Load proposal by id with updated status if required
Sourcepub fn load_config(&self, store: &dyn Storage) -> StdResult<VoteConfig>
pub fn load_config(&self, store: &dyn Storage) -> StdResult<VoteConfig>
Load current vote config
Sourcepub fn query_by_id(
&self,
store: &dyn Storage,
proposal_id: ProposalId,
start_after: Option<&Addr>,
limit: Option<u64>,
) -> VoteResult<Vec<(Addr, Option<Vote>)>>
pub fn query_by_id( &self, store: &dyn Storage, proposal_id: ProposalId, start_after: Option<&Addr>, limit: Option<u64>, ) -> VoteResult<Vec<(Addr, Option<Vote>)>>
List of votes by proposal id
pub fn query_list( &self, store: &dyn Storage, start_after: Option<(ProposalId, &Addr)>, limit: Option<u64>, ) -> VoteResult<Vec<((ProposalId, Addr), Option<Vote>)>>
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