Struct abstract_std::objects::voting::SimpleVoting
source · pub struct SimpleVoting<'a> { /* private fields */ }
Expand description
Simple voting helper
Implementations§
source§impl<'a> SimpleVoting<'a>
impl<'a> SimpleVoting<'a>
pub const fn new( proposals_key: &'a str, id_key: &'a str, proposals_info_key: &'a str, vote_config_key: &'a 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