abstract_std::objects::voting

Struct SimpleVoting

Source
pub struct SimpleVoting<'a> { /* private fields */ }
Expand description

Simple voting helper

Implementations§

Source§

impl SimpleVoting<'_>

Source

pub const fn new( proposals_key: &'static str, id_key: &'static str, proposals_info_key: &'static str, vote_config_key: &'static str, ) -> Self

Source

pub fn instantiate( &self, store: &mut dyn Storage, vote_config: &VoteConfig, ) -> VoteResult<()>

SimpleVoting setup during instantiation

Source

pub fn update_vote_config( &self, store: &mut dyn Storage, new_vote_config: &VoteConfig, ) -> StdResult<()>

Source

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

Source

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

Source

pub fn cancel_proposal( &self, store: &mut dyn Storage, block: &BlockInfo, proposal_id: ProposalId, ) -> VoteResult<ProposalInfo>

Cancel proposal

Source

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

Source

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

Source

pub fn load_vote( &self, store: &dyn Storage, proposal_id: ProposalId, voter: &Addr, ) -> VoteResult<Option<Vote>>

Load vote by address

Source

pub fn load_proposal( &self, store: &dyn Storage, block: &BlockInfo, proposal_id: ProposalId, ) -> VoteResult<ProposalInfo>

Load proposal by id with updated status if required

Source

pub fn load_config(&self, store: &dyn Storage) -> StdResult<VoteConfig>

Load current vote config

Source

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

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V