pub type ConvictionVoting = Pallet<Runtime>;

Aliased Type§

struct ConvictionVoting(/* private fields */);

Implementations

§

impl<T, I> Pallet<T, I>
where T: Config<I>, I: 'static,

pub fn vote( origin: <T as Config>::RuntimeOrigin, poll_index: <<T as Config<I>>::Polls as Polling<Tally<<<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance, <T as Config<I>>::MaxTurnout>>>::Index, vote: AccountVote<<<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance> ) -> Result<(), DispatchError>

Vote in a poll. If vote.is_aye(), the vote is to enact the proposal; otherwise it is a vote to keep the status quo.

The dispatch origin of this call must be Signed.

  • poll_index: The index of the poll to vote for.
  • vote: The vote configuration.

Weight: O(R) where R is the number of polls the voter has voted on.

pub fn delegate( origin: <T as Config>::RuntimeOrigin, class: <<T as Config<I>>::Polls as Polling<Tally<<<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance, <T as Config<I>>::MaxTurnout>>>::Class, to: <<T as Config>::Lookup as StaticLookup>::Source, conviction: Conviction, balance: <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

Delegate the voting power (with some given conviction) of the sending account for a particular class of polls.

The balance delegated is locked for as long as it’s delegated, and thereafter for the time appropriate for the conviction’s lock period.

The dispatch origin of this call must be Signed, and the signing account must either:

  • be delegating already; or

  • have no voting activity (if there is, then it will need to be removed through remove_vote).

  • to: The account whose voting the target account’s voting power will follow.

  • class: The class of polls to delegate. To delegate multiple classes, multiple calls to this function are required.

  • conviction: The conviction that will be attached to the delegated votes. When the account is undelegated, the funds will be locked for the corresponding period.

  • balance: The amount of the account’s balance to be used in delegating. This must not be more than the account’s current balance.

Emits Delegated.

Weight: O(R) where R is the number of polls the voter delegating to has voted on. Weight is initially charged as if maximum votes, but is refunded later.

pub fn undelegate( origin: <T as Config>::RuntimeOrigin, class: <<T as Config<I>>::Polls as Polling<Tally<<<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance, <T as Config<I>>::MaxTurnout>>>::Class ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

Undelegate the voting power of the sending account for a particular class of polls.

Tokens may be unlocked following once an amount of time consistent with the lock period of the conviction with which the delegation was issued has passed.

The dispatch origin of this call must be Signed and the signing account must be currently delegating.

  • class: The class of polls to remove the delegation from.

Emits Undelegated.

Weight: O(R) where R is the number of polls the voter delegating to has voted on. Weight is initially charged as if maximum votes, but is refunded later.

pub fn unlock( origin: <T as Config>::RuntimeOrigin, class: <<T as Config<I>>::Polls as Polling<Tally<<<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance, <T as Config<I>>::MaxTurnout>>>::Class, target: <<T as Config>::Lookup as StaticLookup>::Source ) -> Result<(), DispatchError>

Remove the lock caused by prior voting/delegating which has expired within a particular class.

The dispatch origin of this call must be Signed.

  • class: The class of polls to unlock.
  • target: The account to remove the lock on.

Weight: O(R) with R number of vote of target.

pub fn remove_vote( origin: <T as Config>::RuntimeOrigin, class: Option<<<T as Config<I>>::Polls as Polling<Tally<<<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance, <T as Config<I>>::MaxTurnout>>>::Class>, index: <<T as Config<I>>::Polls as Polling<Tally<<<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance, <T as Config<I>>::MaxTurnout>>>::Index ) -> Result<(), DispatchError>

Remove a vote for a poll.

If:

  • the poll was cancelled, or
  • the poll is ongoing, or
  • the poll has ended such that
    • the vote of the account was in opposition to the result; or
    • there was no conviction to the account’s vote; or
    • the account made a split vote …then the vote is removed cleanly and a following call to unlock may result in more funds being available.

If, however, the poll has ended and:

  • it finished corresponding to the vote of the account, and
  • the account made a standard vote with conviction, and
  • the lock period of the conviction is not over …then the lock will be aggregated into the overall account’s lock, which may involve overlocking (where the two locks are combined into a single lock that is the maximum of both the amount locked and the time is it locked for).

The dispatch origin of this call must be Signed, and the signer must have a vote registered for poll index.

  • index: The index of poll of the vote to be removed.
  • class: Optional parameter, if given it indicates the class of the poll. For polls which have finished or are cancelled, this must be Some.

Weight: O(R + log R) where R is the number of polls that target has voted on. Weight is calculated for the maximum number of vote.

pub fn remove_other_vote( origin: <T as Config>::RuntimeOrigin, target: <<T as Config>::Lookup as StaticLookup>::Source, class: <<T as Config<I>>::Polls as Polling<Tally<<<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance, <T as Config<I>>::MaxTurnout>>>::Class, index: <<T as Config<I>>::Polls as Polling<Tally<<<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance, <T as Config<I>>::MaxTurnout>>>::Index ) -> Result<(), DispatchError>

Remove a vote for a poll.

If the target is equal to the signer, then this function is exactly equivalent to remove_vote. If not equal to the signer, then the vote must have expired, either because the poll was cancelled, because the voter lost the poll or because the conviction period is over.

The dispatch origin of this call must be Signed.

  • target: The account of the vote to be removed; this account must have voted for poll index.
  • index: The index of poll of the vote to be removed.
  • class: The class of the poll.

Weight: O(R + log R) where R is the number of polls that target has voted on. Weight is calculated for the maximum number of vote.

Trait Implementations

§

impl<T, I> PalletInfoAccess for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn index() -> usize

Index of the pallet as configured in the runtime.
§

fn name() -> &'static str

Name of the pallet as configured in the runtime.
§

fn name_hash() -> [u8; 16]

Two128 hash of name.
§

fn module_name() -> &'static str

Name of the Rust module containing the pallet.
§

fn crate_version() -> CrateVersion

Version of the crate containing the pallet.
§

impl<T, I> Debug for Pallet<T, I>

§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T, I> WhitelistedStorageKeys for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>

Returns a Vec<TrackedStorageKey> indicating the storage keys that should be whitelisted during benchmarking. This means that those keys will be excluded from the benchmarking performance calculation.
§

impl<T, I> GetStorageVersion for Pallet<T, I>
where T: Config<I>, I: 'static,

§

type InCodeStorageVersion = NoStorageVersionSet

This type is generated by the pallet macro. Read more
§

fn in_code_storage_version( ) -> <Pallet<T, I> as GetStorageVersion>::InCodeStorageVersion

Returns the in-code storage version as specified in the storage_version attribute, or [NoStorageVersionSet] if the attribute is missing.
§

fn on_chain_storage_version() -> StorageVersion

Returns the storage version of the pallet as last set in the actual on-chain storage.
§

fn current_storage_version() -> Self::InCodeStorageVersion

👎Deprecated: This method has been renamed to in_code_storage_version and will be removed after March 2024.
DEPRECATED: Use [Self::current_storage_version] instead. Read more
§

impl<T, I> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn offchain_worker( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number )

This function is being called after every block import (when fully synced). Read more
§

impl<T, I> OnRuntimeUpgrade for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn on_runtime_upgrade() -> Weight

See [Hooks::on_runtime_upgrade].
§

impl<T, I> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn on_idle( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, remaining_weight: Weight ) -> Weight

See [Hooks::on_idle].
§

impl<T, I> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn on_initialize(_n: BlockNumber) -> Weight

Block initialization hook. This is called at the very beginning of block execution. Read more
§

fn on_finalize(_n: BlockNumber)

Block finalization hook. This is called at the very end of block execution. Read more
§

fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight

Hook to consume a block’s idle time. This will run when the block is being finalized (before [Hooks::on_finalize]). Read more
§

fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)

A hook to run logic after inherent application. Read more
§

fn on_runtime_upgrade() -> Weight

Hook executed when a code change (aka. a “runtime upgrade”) is detected by the FRAME Executive pallet. Read more
§

fn offchain_worker(_n: BlockNumber)

Implementing this function on a pallet allows you to perform long-running tasks that are dispatched as separate threads, and entirely independent of the main blockchain execution. Read more
§

fn integrity_test()

Check the integrity of this pallet’s configuration. Read more
§

impl<T, I> PalletsInfoAccess for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn count() -> usize

The number of pallets’ information that this type represents. Read more
§

fn infos() -> Vec<PalletInfoData>

All of the pallets’ information that this type represents.
§

impl<T, I> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn on_initialize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number ) -> Weight

See [Hooks::on_initialize].
§

impl<T, I> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn on_finalize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number )

See [Hooks::on_finalize].
§

impl<T, I> Callable<T> for Pallet<T, I>
where T: Config<I>, I: 'static,

§

type RuntimeCall = Call<T, I>

§

impl<T, I> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn on_poll( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, weight: &mut WeightMeter )

Code to execute every now and then at the beginning of the block after inherent application. Read more
§

impl<T, I> OnGenesis for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn on_genesis()

Something that should happen at genesis.
§

impl<T, I> PartialEq for Pallet<T, I>

§

fn eq(&self, other: &Pallet<T, I>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T, I> Eq for Pallet<T, I>

§

impl<T, I> Clone for Pallet<T, I>

§

fn clone(&self) -> Pallet<T, I>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T, I> BeforeAllRuntimeMigrations for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn before_all_runtime_migrations() -> Weight

Something that should happen before runtime migrations are executed.
§

impl<T, I> IntegrityTest for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn integrity_test()

See [Hooks::integrity_test].
§

impl<T, I> StorageInfoTrait for Pallet<T, I>
where T: Config<I>, I: 'static,

§

fn storage_info() -> Vec<StorageInfo>