pub struct Pallet<T>(_);
Expand description

The pallet implementing the on-chain logic.

Implementations

A dispatch that will fill the block weight up to the given ratio.

Make some on-chain remark.

  • O(1)

Set the number of pages in the WebAssembly environment’s heap.

Set the new runtime code.

  • O(C + S) where C length of code and S complexity of can_set_code
  • 1 call to can_set_code: O(S) (calls sp_io::misc::runtime_version which is expensive).
  • 1 storage write (codec O(C)).
  • 1 digest item.
  • 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.

Set the new runtime code without doing any checks of the given code.

  • O(C) where C length of code
  • 1 storage write (codec O(C)).
  • 1 digest item.
  • 1 event. The weight of this function is dependent on the runtime. We will treat this as a full block. #

Set some items of storage.

Kill some items from storage.

Kill all storage items with a key that starts with the given prefix.

NOTE: We rely on the Root origin to provide us the number of subkeys under the prefix we are removing to accurately calculate the weight of this function.

Make some on-chain remark and emit event.

  • O(b) where b is the length of the remark.
  • 1 event.

The full account information for a particular account ID.

The current weight for the block.

Map of block numbers to block hashes.

Extrinsics data for the current block (maps an extrinsic’s index to its data).

The current block number being processed. Set by execute_block.

Hash of the previous block.

Digest of the current block, also part of the block header.

The number of events in the Events<T> list.

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.

Write code to the storage and emit related events and digest items.

Note this function almost never should be used directly. It is exposed for OnSetCode implementations that defer actual code being written to the storage (for instance in case of parachains).

👎 Deprecated:

Use inc_consumers instead

Increment the reference counter on an account.

👎 Deprecated:

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.

👎 Deprecated:

Use consumers instead

The number of outstanding references for the account who.

👎 Deprecated:

Use !is_provider_required instead

True if the account has no outstanding references.

Increment the provider reference counter on an account.

Decrement the provider reference counter on an account.

This MUST only be done once for every time you called inc_providers on who.

Increment the self-sufficient reference counter on an account.

Decrement the sufficients reference counter on an account.

This MUST only be done once for every time you called inc_sufficients on who.

The number of outstanding provider references for the account who.

The number of outstanding sufficient references for the account who.

The number of outstanding provider and sufficient references for the account who.

Increment the reference counter on an account.

The account who’s providers must be non-zero or this will return an error.

Decrement the reference counter on an account. This MUST only be done once for every time you called inc_consumers on who.

The number of outstanding references for the account who.

True if the account has some outstanding consumer references.

True if the account has no outstanding consumer references or more than one provider.

True if the account has at least one provider reference.

Deposits an event into this block’s event record.

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.

Gets the index of extrinsic that is currently executing.

Gets extrinsics count.

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.

Start the execution of a particular block.

Remove temporary “environment” entries in storage, compute the storage root and return the resulting header for this block.

Deposits a log and ensures it matches the block’s log data.

  • O(1)
  • 1 storage write (codec O(1))

Get the basic externalities for this pallet, useful for tests.

Get the current events deposited by the runtime.

NOTE: This should only be used in tests. Reading events from the runtime can have a large impact on the PoV size of a block. Users should use alternative and well bounded storage items for any behavior like this.

Get the current events deposited by the runtime.

Should only be called if you know what you are doing and outside of the runtime block execution else it can have a large impact on the PoV size of a block.

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.

Sets the index of extrinsic that is currently executing.

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.

Set the current block weight. This should only be used in some integration tests.

Reset events. Can be used as an alternative to initialize for tests that don’t need to bother with the other environment entries.

Assert the given event exists.

Assert the last event equal to the given event.

Return the chain’s current runtime version.

Retrieve the account transaction counter from storage.

Increment a particular account’s nonce by 1.

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.

To be called immediately after an extrinsic has been applied.

To be called immediately after note_applied_extrinsic of the last extrinsic of the block has been called.

To be called immediately after finishing the initialization of the block (e.g., called on_initialize for all pallets).

An account is being created.

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

Type of BlockNumber to provide.

Returns the current block number. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the current storage version as supported by the pallet.

Returns the on-chain storage version of the pallet as stored in the storage.

Perform a module upgrade. Read more

Run integrity test. Read more

The block is being finalized. Implement to have something happen.

This will be run when the block is being finalized (before on_finalize). Implement to have something happen using the remaining weight. Will not fire if the remaining weight is 0. Return the weight used, the hook will subtract it from current weight used and pass the result to the next on_idle hook if it exists. Read more

The block is being initialized. Implement to have something happen. Read more

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

Run integrity test. Read more

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

The block is being finalized. Implement to have something happen. Read more

Something that should happen at genesis.

The block is being finalized. Implement to have something happen in case there is leftover weight. Check the passed remaining_weight to make sure it is high enough to allow for your pallet’s extra computation. Read more

The block is being initialized. Implement to have something happen. Read more

Perform a module upgrade. Read more

Index of the pallet as configured in the runtime.

Name of the pallet as configured in the runtime.

Name of the Rust module containing the pallet.

Version of the crate containing the pallet.

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

Extend the given vector by all of the pallets’ information that this type represents. Read more

All of the pallets’ information that this type represents.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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.

Get the item, or its default if it doesn’t yet exist; we make no distinction between the two. Read more

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

Mutate the item.

Mutate the item, removing or resetting to default value if it has been mutated to None. Read more

Set the item to something new.

Remove the item or otherwise replace it with its default value; we don’t care which.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert from a value of T into an equivalent instance of Option<Self>. Read more

Consume self to return Some equivalent value of Option<T>. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Cast reference.

Cast reference.

Cast mutable reference.

Cast mutable reference.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

Should always be Self

Convert from a value of T into an equivalent instance of Self. Read more

Consume self to return an equivalent value of T. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The counterpart to unchecked_from.

Consume self to return an equivalent value of T.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more