Struct frame_system::pallet::Pallet
source · [−]pub struct Pallet<T>(_);
Implementations
sourceimpl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn set_code(
origin: OriginFor<T>,
code: Vec<u8>
) -> DispatchResultWithPostInfo
pub fn set_code(
origin: OriginFor<T>,
code: Vec<u8>
) -> DispatchResultWithPostInfo
Set the new runtime code.
O(C + S)
whereC
length ofcode
andS
complexity ofcan_set_code
- 1 storage write (codec
O(C)
). - 1 call to
can_set_code
:O(S)
(callssp_io::misc::runtime_version
which is expensive). - 1 event. The weight of this function is dependent on the runtime, but generally this is very expensive. We will treat this as a full block.
sourcepub fn set_code_without_checks(
origin: OriginFor<T>,
code: Vec<u8>
) -> DispatchResultWithPostInfo
pub fn set_code_without_checks(
origin: OriginFor<T>,
code: Vec<u8>
) -> DispatchResultWithPostInfo
sourcepub fn set_changes_trie_config(
origin: OriginFor<T>,
changes_trie_config: Option<ChangesTrieConfiguration>
) -> DispatchResultWithPostInfo
pub fn set_changes_trie_config(
origin: OriginFor<T>,
changes_trie_config: Option<ChangesTrieConfiguration>
) -> DispatchResultWithPostInfo
sourceimpl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn account<KArg>(k: KArg) -> AccountInfo<T::Index, T::AccountData> where
KArg: EncodeLike<T::AccountId>,
pub fn account<KArg>(k: KArg) -> AccountInfo<T::Index, T::AccountData> where
KArg: EncodeLike<T::AccountId>,
The full account information for a particular account ID.
sourceimpl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn block_weight() -> ConsumedWeight
pub fn block_weight() -> ConsumedWeight
The current weight for the block.
sourceimpl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn block_hash<KArg>(k: KArg) -> T::Hash where
KArg: EncodeLike<T::BlockNumber>,
pub fn block_hash<KArg>(k: KArg) -> T::Hash where
KArg: EncodeLike<T::BlockNumber>,
Map of block numbers to block hashes.
sourceimpl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn block_number() -> T::BlockNumber
pub fn block_number() -> T::BlockNumber
The current block number being processed. Set by execute_block
.
sourceimpl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn event_count() -> u32
pub fn event_count() -> u32
The number of events in the Events<T>
list.
sourceimpl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn event_topics<KArg>(k: KArg) -> Vec<(T::BlockNumber, u32)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
where
KArg: EncodeLike<T::Hash>,
pub fn event_topics<KArg>(k: KArg) -> Vec<(T::BlockNumber, u32)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
where
KArg: EncodeLike<T::Hash>,
A: Allocator,
Mapping between a topic (represented by T::Hash) and a vector of indexes
of events in the <Events<T>>
list.
All topic vectors have deterministic storage locations depending on the topic. This allows light-clients to leverage the changes trie storage tracking mechanism and in case of changes fetch the list of events of interest.
The value has the type (T::BlockNumber, EventIndex)
because if we used only just
the EventIndex
then in case if the topic has the same contents on the next block
no notification will be triggered thus the event might be lost.
sourceimpl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
pub fn account_exists(who: &T::AccountId) -> bool
sourcepub fn inc_ref(who: &T::AccountId)
👎 Deprecated: Use inc_consumers
instead
pub fn inc_ref(who: &T::AccountId)
Use inc_consumers
instead
Increment the reference counter on an account.
sourcepub fn dec_ref(who: &T::AccountId)
👎 Deprecated: Use dec_consumers
instead
pub fn dec_ref(who: &T::AccountId)
Use dec_consumers
instead
Decrement the reference counter on an account. This MUST only be done once for every time
you called inc_consumers
on who
.
sourcepub fn refs(who: &T::AccountId) -> RefCount
👎 Deprecated: Use consumers
instead
pub fn refs(who: &T::AccountId) -> RefCount
Use consumers
instead
The number of outstanding references for the account who
.
sourcepub fn allow_death(who: &T::AccountId) -> bool
👎 Deprecated: Use !is_provider_required
instead
pub fn allow_death(who: &T::AccountId) -> bool
Use !is_provider_required
instead
True if the account has no outstanding references.
sourcepub fn inc_providers(who: &T::AccountId) -> IncRefStatus
pub fn inc_providers(who: &T::AccountId) -> IncRefStatus
Increment the reference counter on an account.
The account who
’s providers
must be non-zero or this will return an error.
sourcepub fn dec_providers(who: &T::AccountId) -> Result<DecRefStatus, DecRefError>
pub fn dec_providers(who: &T::AccountId) -> Result<DecRefStatus, DecRefError>
Decrement the reference counter on an account. This MUST only be done once for every time
you called inc_consumers
on who
.
sourcepub fn providers(who: &T::AccountId) -> RefCount
pub fn providers(who: &T::AccountId) -> RefCount
The number of outstanding references for the account who
.
sourcepub fn inc_consumers(who: &T::AccountId) -> Result<(), IncRefError>
pub fn inc_consumers(who: &T::AccountId) -> Result<(), IncRefError>
Increment the reference counter on an account.
The account who
’s providers
must be non-zero or this will return an error.
sourcepub fn dec_consumers(who: &T::AccountId)
pub fn dec_consumers(who: &T::AccountId)
Decrement the reference counter on an account. This MUST only be done once for every time
you called inc_consumers
on who
.
sourcepub fn consumers(who: &T::AccountId) -> RefCount
pub fn consumers(who: &T::AccountId) -> RefCount
The number of outstanding references for the account who
.
sourcepub fn is_provider_required(who: &T::AccountId) -> bool
pub fn is_provider_required(who: &T::AccountId) -> bool
True if the account has some outstanding references.
sourcepub fn deposit_event(event: impl Into<T::Event>)
pub fn deposit_event(event: impl Into<T::Event>)
Deposits an event into this block’s event record.
sourcepub fn deposit_event_indexed(topics: &[T::Hash], event: T::Event)
pub fn deposit_event_indexed(topics: &[T::Hash], event: T::Event)
Deposits an event into this block’s event record adding this event to the corresponding topic indexes.
This will update storage entries that correspond to the specified topics. It is expected that light-clients could subscribe to this topics.
sourcepub fn extrinsic_index() -> Option<u32>
pub fn extrinsic_index() -> Option<u32>
Gets the index of extrinsic that is currently executing.
sourcepub fn extrinsic_count() -> u32
pub fn extrinsic_count() -> u32
Gets extrinsics count.
pub fn all_extrinsics_len() -> u32
sourcepub fn register_extra_weight_unchecked(weight: Weight, class: DispatchClass)
pub fn register_extra_weight_unchecked(weight: Weight, class: DispatchClass)
Inform the system pallet of some additional weight that should be accounted for, in the current block.
NOTE: use with extra care; this function is made public only be used for certain pallets
that need it. A runtime that does not have dynamic calls should never need this and should
stick to static weights. A typical use case for this is inner calls or smart contract calls.
Furthermore, it only makes sense to use this when it is presumably cheap to provide the
argument weight
; In other words, if this function is to be used to account for some
unknown, user provided call’s weight, it would only make sense to use it if you are sure you
can rapidly compute the weight of the inner call.
Even more dangerous is to note that this function does NOT take any action, if the new sum of block weight is more than the block weight limit. This is what the unchecked.
Another potential use-case could be for the on_initialize
and on_finalize
hooks.
sourcepub fn initialize(
number: &T::BlockNumber,
parent_hash: &T::Hash,
digest: &DigestOf<T>,
kind: InitKind
)
pub fn initialize(
number: &T::BlockNumber,
parent_hash: &T::Hash,
digest: &DigestOf<T>,
kind: InitKind
)
Start the execution of a particular block.
sourcepub fn finalize() -> T::Header
pub fn finalize() -> T::Header
Remove temporary “environment” entries in storage, compute the storage root and return the resulting header for this block.
sourcepub fn deposit_log(item: DigestItemOf<T>)
pub fn deposit_log(item: DigestItemOf<T>)
sourcepub fn externalities() -> TestExternalities
pub fn externalities() -> TestExternalities
Get the basic externalities for this pallet, useful for tests.
sourcepub fn set_block_number(n: T::BlockNumber)
pub fn set_block_number(n: T::BlockNumber)
Set the block number to something in particular. Can be used as an alternative to
initialize
for tests that don’t need to bother with the other environment entries.
sourcepub fn set_extrinsic_index(extrinsic_index: u32)
pub fn set_extrinsic_index(extrinsic_index: u32)
Sets the index of extrinsic that is currently executing.
sourcepub fn set_parent_hash(n: T::Hash)
pub fn set_parent_hash(n: T::Hash)
Set the parent hash number to something in particular. Can be used as an alternative to
initialize
for tests that don’t need to bother with the other environment entries.
sourcepub fn set_block_consumed_resources(weight: Weight, len: usize)
pub fn set_block_consumed_resources(weight: Weight, len: usize)
Set the current block weight. This should only be used in some integration tests.
sourcepub fn reset_events()
pub fn reset_events()
Reset events. Can be used as an alternative to
initialize
for tests that don’t need to bother with the other environment entries.
sourcepub fn runtime_version() -> RuntimeVersion
pub fn runtime_version() -> RuntimeVersion
Return the chain’s current runtime version.
sourcepub fn account_nonce(who: impl EncodeLike<T::AccountId>) -> T::Index
pub fn account_nonce(who: impl EncodeLike<T::AccountId>) -> T::Index
Retrieve the account transaction counter from storage.
sourcepub fn inc_account_nonce(who: impl EncodeLike<T::AccountId>)
pub fn inc_account_nonce(who: impl EncodeLike<T::AccountId>)
Increment a particular account’s nonce by 1.
sourcepub fn note_extrinsic(encoded_xt: Vec<u8>)
pub fn note_extrinsic(encoded_xt: Vec<u8>)
Note what the extrinsic data of the current extrinsic index is.
This is required to be called before applying an extrinsic. The data will used
in Self::finalize
to calculate the correct extrinsics root.
sourcepub fn note_applied_extrinsic(
r: &DispatchResultWithPostInfo,
info: DispatchInfo
)
pub fn note_applied_extrinsic(
r: &DispatchResultWithPostInfo,
info: DispatchInfo
)
To be called immediately after an extrinsic has been applied.
sourcepub fn note_finished_extrinsics()
pub fn note_finished_extrinsics()
To be called immediately after note_applied_extrinsic
of the last extrinsic of the block
has been called.
sourcepub fn note_finished_initialize()
pub fn note_finished_initialize()
To be called immediately after finishing the initialization of the block
(e.g., called on_initialize
for all pallets).
sourcepub fn on_created_account(
who: T::AccountId,
_a: &mut AccountInfo<T::Index, T::AccountData>
)
pub fn on_created_account(
who: T::AccountId,
_a: &mut AccountInfo<T::Index, T::AccountData>
)
An account is being created.
sourcepub fn can_set_code(code: &[u8]) -> Result<(), DispatchError>
pub fn can_set_code(code: &[u8]) -> Result<(), DispatchError>
Determine whether or not it is possible to update the code.
Checks the given code if it is a valid runtime wasm blob by instantianting it and extracting the runtime version of it. It checks that the runtime version of the old and new runtime has the same spec name and that the spec version is increasing.
Trait Implementations
sourceimpl<T: Config> BlockNumberProvider for Pallet<T>
impl<T: Config> BlockNumberProvider for Pallet<T>
type BlockNumber = <T as Config>::BlockNumber
type BlockNumber = <T as Config>::BlockNumber
Type of BlockNumber
to provide.
sourcefn current_block_number() -> Self::BlockNumber
fn current_block_number() -> Self::BlockNumber
Returns the current block number. Read more
sourceimpl<T: Config> GetPalletVersion for Pallet<T>
impl<T: Config> GetPalletVersion for Pallet<T>
sourcefn current_version() -> PalletVersion
fn current_version() -> PalletVersion
Returns the current version of the pallet.
sourcefn storage_version() -> Option<PalletVersion>
fn storage_version() -> Option<PalletVersion>
Returns the version of the pallet that is stored in storage. Read more
sourceimpl<T: Config> Hooks<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> Hooks<<T as Config>::BlockNumber> for Pallet<T>
sourcefn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Perform a module upgrade. Read more
sourcefn integrity_test()
fn integrity_test()
Run integrity test. Read more
sourcefn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
The block is being finalized. Implement to have something happen.
sourcefn on_initialize(_n: BlockNumber) -> u64
fn on_initialize(_n: BlockNumber) -> u64
The block is being initialized. Implement to have something happen. Read more
sourcefn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
Implementing this function on a module allows you to perform long-running tasks that make (by default) validators generate transactions that feed results of those long-running computations back on chain. Read more
sourceimpl<T: Config> IntegrityTest for Pallet<T>
impl<T: Config> IntegrityTest for Pallet<T>
sourcefn integrity_test()
fn integrity_test()
Run integrity test. Read more
sourceimpl<T: Config> ModuleErrorMetadata for Pallet<T>
impl<T: Config> ModuleErrorMetadata for Pallet<T>
sourceimpl<T: Config> OffchainWorker<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OffchainWorker<<T as Config>::BlockNumber> for Pallet<T>
sourcefn offchain_worker(n: <T as Config>::BlockNumber)
fn offchain_worker(n: <T as Config>::BlockNumber)
This function is being called after every block import (when fully synced). Read more
sourceimpl<T: Config> OnFinalize<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OnFinalize<<T as Config>::BlockNumber> for Pallet<T>
sourcefn on_finalize(n: <T as Config>::BlockNumber)
fn on_finalize(n: <T as Config>::BlockNumber)
The block is being finalized. Implement to have something happen. Read more
sourceimpl<T: Config> OnGenesis for Pallet<T>
impl<T: Config> OnGenesis for Pallet<T>
sourcefn on_genesis()
fn on_genesis()
Something that should happen at genesis.
sourceimpl<T: Config> OnInitialize<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OnInitialize<<T as Config>::BlockNumber> for Pallet<T>
sourcefn on_initialize(n: <T as Config>::BlockNumber) -> Weight
fn on_initialize(n: <T as Config>::BlockNumber) -> Weight
The block is being initialized. Implement to have something happen. Read more
sourceimpl<T: Config> OnRuntimeUpgrade for Pallet<T>
impl<T: Config> OnRuntimeUpgrade for Pallet<T>
sourcefn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Perform a module upgrade. Read more
sourceimpl<T: Config> StoredMap<<T as Config>::AccountId, <T as Config>::AccountData> for Pallet<T>
impl<T: Config> StoredMap<<T as Config>::AccountId, <T as Config>::AccountData> for Pallet<T>
Implement StoredMap for a simple single-item, provide-when-not-default system. This works fine for storing a single item which allows the account to continue existing as long as it’s not empty/default.
Anything more complex will need more sophisticated logic.
sourcefn get(k: &T::AccountId) -> T::AccountData
fn get(k: &T::AccountId) -> T::AccountData
Get the item, or its default if it doesn’t yet exist; we make no distinction between the two. Read more
sourcefn try_mutate_exists<R, E: From<StoredMapError>>(
k: &T::AccountId,
f: impl FnOnce(&mut Option<T::AccountData>) -> Result<R, E>
) -> Result<R, E>
fn try_mutate_exists<R, E: From<StoredMapError>>(
k: &T::AccountId,
f: impl FnOnce(&mut Option<T::AccountData>) -> Result<R, E>
) -> Result<R, E>
Maybe mutate the item only if an Ok
value is returned from f
. Do nothing if an Err
is
returned. It is removed or reset to default value if it has been mutated to None
Read more
sourcefn mutate_exists<R>(
k: &K,
f: impl FnOnce(&mut Option<T>) -> R
) -> Result<R, StoredMapError>
fn mutate_exists<R>(
k: &K,
f: impl FnOnce(&mut Option<T>) -> R
) -> Result<R, StoredMapError>
Mutate the item, removing or resetting to default value if it has been mutated to None
. Read more
impl<T> Eq for Pallet<T>
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedConversion for T
impl<T> CheckedConversion for T
sourcefn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
Convert from a value of T
into an equivalent instance of Option<Self>
. Read more
sourcefn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
Consume self to return Some
equivalent value of Option<T>
. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
sourcefn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
Convert from a value of T
into an equivalent instance of Self
. Read more
sourcefn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of T
. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
sourcepub fn unchecked_into(self) -> T
pub fn unchecked_into(self) -> T
The counterpart to unchecked_from
.
sourceimpl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
sourcepub fn unique_saturated_into(self) -> T
pub fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of T
.