pub struct Pallet<T>(/* private fields */);Expand description
The Pallet struct, the main type that implements traits and standalone
functions within the pallet.
Implementations§
Source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
Sourcepub fn batch(
origin: OriginFor<T>,
calls: Vec<<T as Config>::RuntimeCall>,
) -> DispatchResultWithPostInfo
pub fn batch( origin: OriginFor<T>, calls: Vec<<T as Config>::RuntimeCall>, ) -> DispatchResultWithPostInfo
Send a batch of dispatch calls.
May be called from any origin except None.
calls: The calls to be dispatched from the same origin. The number of call must not exceed the constant:batched_calls_limit(available in constant metadata).
If origin is root then the calls are dispatched without checking origin filter. (This
includes bypassing frame_system::Config::BaseCallFilter).
§Complexity
- O(C) where C is the number of calls to be batched.
This will return Ok in all circumstances. To determine the success of the batch, an
event is deposited. If a call failed and the batch was interrupted, then the
BatchInterrupted event is deposited, along with the number of successful calls made
and the error of the failed call. If all were successful, then the BatchCompleted
event is deposited.
Sourcepub fn as_derivative(
origin: OriginFor<T>,
index: u16,
call: Box<<T as Config>::RuntimeCall>,
) -> DispatchResultWithPostInfo
pub fn as_derivative( origin: OriginFor<T>, index: u16, call: Box<<T as Config>::RuntimeCall>, ) -> DispatchResultWithPostInfo
Send a call through an indexed pseudonym of the sender.
Filter from origin are passed along. The call will be dispatched with an origin which use the same filter as the origin of this call.
NOTE: If you need to ensure that any account-based filtering is not honored (i.e.
because you expect proxy to have been used prior in the call stack and you do not want
the call restrictions to apply to any sub-accounts), then use as_multi_threshold_1
in the Multisig pallet instead.
NOTE: Prior to version *12, this was called as_limited_sub.
The dispatch origin for this call must be Signed.
Sourcepub fn batch_all(
origin: OriginFor<T>,
calls: Vec<<T as Config>::RuntimeCall>,
) -> DispatchResultWithPostInfo
pub fn batch_all( origin: OriginFor<T>, calls: Vec<<T as Config>::RuntimeCall>, ) -> DispatchResultWithPostInfo
Send a batch of dispatch calls and atomically execute them. The whole transaction will rollback and fail if any of the calls failed.
May be called from any origin except None.
calls: The calls to be dispatched from the same origin. The number of call must not exceed the constant:batched_calls_limit(available in constant metadata).
If origin is root then the calls are dispatched without checking origin filter. (This
includes bypassing frame_system::Config::BaseCallFilter).
§Complexity
- O(C) where C is the number of calls to be batched.
Sourcepub fn dispatch_as(
origin: OriginFor<T>,
as_origin: Box<T::PalletsOrigin>,
call: Box<<T as Config>::RuntimeCall>,
) -> DispatchResult
pub fn dispatch_as( origin: OriginFor<T>, as_origin: Box<T::PalletsOrigin>, call: Box<<T as Config>::RuntimeCall>, ) -> DispatchResult
Dispatches a function call with a provided origin.
The dispatch origin for this call must be Root.
§Complexity
- O(1).
Sourcepub fn force_batch(
origin: OriginFor<T>,
calls: Vec<<T as Config>::RuntimeCall>,
) -> DispatchResultWithPostInfo
pub fn force_batch( origin: OriginFor<T>, calls: Vec<<T as Config>::RuntimeCall>, ) -> DispatchResultWithPostInfo
Send a batch of dispatch calls.
Unlike batch, it allows errors and won’t interrupt.
May be called from any origin except None.
calls: The calls to be dispatched from the same origin. The number of call must not exceed the constant:batched_calls_limit(available in constant metadata).
If origin is root then the calls are dispatch without checking origin filter. (This
includes bypassing frame_system::Config::BaseCallFilter).
§Complexity
- O(C) where C is the number of calls to be batched.
Sourcepub fn with_weight(
origin: OriginFor<T>,
call: Box<<T as Config>::RuntimeCall>,
weight: Weight,
) -> DispatchResult
pub fn with_weight( origin: OriginFor<T>, call: Box<<T as Config>::RuntimeCall>, weight: Weight, ) -> DispatchResult
Dispatch a function call with a specified weight.
This function does not check the weight of the call, and instead allows the Root origin to specify the weight of the call.
The dispatch origin for this call must be Root.
Sourcepub fn if_else(
origin: OriginFor<T>,
main: Box<<T as Config>::RuntimeCall>,
fallback: Box<<T as Config>::RuntimeCall>,
) -> DispatchResultWithPostInfo
pub fn if_else( origin: OriginFor<T>, main: Box<<T as Config>::RuntimeCall>, fallback: Box<<T as Config>::RuntimeCall>, ) -> DispatchResultWithPostInfo
Dispatch a fallback call in the event the main call fails to execute.
May be called from any origin except None.
This function first attempts to dispatch the main call.
If the main call fails, the fallback is attemted.
if the fallback is successfully dispatched, the weights of both calls
are accumulated and an event containing the main call error is deposited.
In the event of a fallback failure the whole call fails with the weights returned.
main: The main call to be dispatched. This is the primary action to execute.fallback: The fallback call to be dispatched in case themaincall fails.
§Dispatch Logic
- If the origin is
root, both the main and fallback calls are executed without applying any origin filters. - If the origin is not
root, the origin filter is applied to both themainandfallbackcalls.
§Use Case
- Some use cases might involve submitting a
batchtype call in either main, fallback or both.
Sourcepub fn dispatch_as_fallible(
origin: OriginFor<T>,
as_origin: Box<T::PalletsOrigin>,
call: Box<<T as Config>::RuntimeCall>,
) -> DispatchResult
pub fn dispatch_as_fallible( origin: OriginFor<T>, as_origin: Box<T::PalletsOrigin>, call: Box<<T as Config>::RuntimeCall>, ) -> DispatchResult
Dispatches a function call with a provided origin.
Almost the same as Pallet::dispatch_as but forwards any error of the inner call.
The dispatch origin for this call must be Root.
Trait Implementations§
Source§impl<T: Config> BeforeAllRuntimeMigrations for Pallet<T>
impl<T: Config> BeforeAllRuntimeMigrations for Pallet<T>
Source§fn before_all_runtime_migrations() -> Weight
fn before_all_runtime_migrations() -> Weight
Source§impl<T: Config> DispatchViewFunction for Pallet<T>
impl<T: Config> DispatchViewFunction for Pallet<T>
fn dispatch_view_function<O: Output>( id: &ViewFunctionId, input: &mut &[u8], output: &mut O, ) -> Result<(), ViewFunctionDispatchError>
Source§impl<T: Config> GetStorageVersion for Pallet<T>
impl<T: Config> GetStorageVersion for Pallet<T>
Source§fn in_code_storage_version() -> Self::InCodeStorageVersion
fn in_code_storage_version() -> Self::InCodeStorageVersion
storage_version attribute, or
NoStorageVersionSet if the attribute is missing.Source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
Source§fn current_storage_version() -> Self::InCodeStorageVersion
fn current_storage_version() -> Self::InCodeStorageVersion
in_code_storage_version and will be removed after March 2024.Self::current_storage_version instead. Read moreSource§impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Source§fn integrity_test()
fn integrity_test()
Source§fn on_initialize(_n: BlockNumber) -> Weight
fn on_initialize(_n: BlockNumber) -> Weight
Source§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
Source§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
Hooks::on_finalize). Read moreSource§fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Executive pallet. Read moreSource§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
Source§impl<T: Config> IntegrityTest for Pallet<T>
impl<T: Config> IntegrityTest for Pallet<T>
Source§impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Source§fn offchain_worker(n: BlockNumberFor<T>)
fn offchain_worker(n: BlockNumberFor<T>)
Source§impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Source§fn on_finalize(n: BlockNumberFor<T>)
fn on_finalize(n: BlockNumberFor<T>)
Hooks::on_finalize.Source§impl<T: Config> OnGenesis for Pallet<T>
impl<T: Config> OnGenesis for Pallet<T>
Source§fn on_genesis()
fn on_genesis()
Source§impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Source§fn on_idle(n: BlockNumberFor<T>, remaining_weight: Weight) -> Weight
fn on_idle(n: BlockNumberFor<T>, remaining_weight: Weight) -> Weight
Hooks::on_idle.Source§impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Source§fn on_initialize(n: BlockNumberFor<T>) -> Weight
fn on_initialize(n: BlockNumberFor<T>) -> Weight
Hooks::on_initialize.Source§impl<T: Config> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Source§fn on_poll(n: BlockNumberFor<T>, weight: &mut WeightMeter)
fn on_poll(n: BlockNumberFor<T>, weight: &mut WeightMeter)
Source§impl<T: Config> OnRuntimeUpgrade for Pallet<T>
impl<T: Config> OnRuntimeUpgrade for Pallet<T>
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Source§impl<T: Config> PalletInfoAccess for Pallet<T>
impl<T: Config> PalletInfoAccess for Pallet<T>
Source§fn module_name() -> &'static str
fn module_name() -> &'static str
Source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
Source§impl<T: Config> PalletsInfoAccess for Pallet<T>
impl<T: Config> PalletsInfoAccess for Pallet<T>
Source§impl<T: Config> StorageInfoTrait for Pallet<T>
impl<T: Config> StorageInfoTrait for Pallet<T>
fn storage_info() -> Vec<StorageInfo>
Source§impl<T: Config> WhitelistedStorageKeys for Pallet<T>
impl<T: Config> WhitelistedStorageKeys for Pallet<T>
Source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
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> Eq for Pallet<T>
Auto Trait Implementations§
impl<T> Freeze for Pallet<T>
impl<T> RefUnwindSafe for Pallet<T>where
T: RefUnwindSafe,
impl<T> Send for Pallet<T>where
T: Send,
impl<T> Sync for Pallet<T>where
T: Sync,
impl<T> Unpin for Pallet<T>where
T: Unpin,
impl<T> UnwindSafe for Pallet<T>where
T: UnwindSafe,
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
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> DefensiveTruncateInto<U> for Twhere
U: DefensiveTruncateFrom<T>,
impl<T, U> DefensiveTruncateInto<U> for Twhere
U: DefensiveTruncateFrom<T>,
Source§fn defensive_truncate_into(self) -> U
fn defensive_truncate_into(self) -> U
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
Source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moreSource§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.