Module pallet_example_kitchensink::pallet
source · Expand description
The pallet
module in each FRAME pallet hosts the most important items needed
to construct this pallet.
The main components of this pallet are:
Pallet
, which implements all of the dispatchable extrinsics of the pallet, among other public functions.- The subset of the functions that are dispatchable can be identified either in the
dispatchables
module or in theCall
enum.
- The subset of the functions that are dispatchable can be identified either in the
storage_types
, which contains the list of all types that are representing a storage item. Otherwise, all storage items are listed among Type Definitions.Config
, which contains the configuration trait of this pallet.Event
andError
, which are listed among the Enums.
Re-exports§
pub use __tt_error_token_1 as tt_error_token;
pub use __tt_default_parts_7 as tt_default_parts;
pub use __tt_extra_parts_7 as tt_extra_parts;
pub use __tt_default_parts_v2_7 as tt_default_parts_v2;
Modules§
- Auto-generated docs-only module listing all defined dispatchables for this pallet.
- Auto-generated docs-only module listing all (public and private) defined storage types for this pallet.
Structs§
- The genesis config type. This allows the pallet to define how it should initialized upon genesis.
- The pallet struct. There’s nothing special to FRAME about this; it can implement functions in an impl blocks, traits and so on.
Enums§
- The call declaration. This states the entry points that we handle. The macro takes care of the marshalling of arguments and dispatch.
- The error enum. Must always be generic over
<T>
, which is expanded to<T: Config>
. - The event type. This exactly like a normal Rust enum.
- Allows you to define an enum on the pallet which will then instruct
construct_runtime
to amalgamate all similarly-named enums from other pallets into an aggregate enum.
Traits§
- Configuration trait of this pallet.
Functions§
Type Aliases§
- In all of these examples, we chose a syntax where the storage item is defined using the explicit generic syntax (
X = Y
). Alternatively: - Lastly, all storage items, as you saw, had to be generic over
T
. If they want to use an item fromConfig
,<T: Config>
should be used. - A storage map. This creates a mapping from keys of type
u32
to values of typeu32
. - A storage value. We mark this as unbounded, alter its prefix, and define a custom storage getter for it.
- Storage type is [
StorageValue
] with value typeu32
. - ModuleDeprecatedType alias to
Pallet
, to be used byconstruct_runtime
. - Allows you to define some origin for the pallet.
- Same as
StorageDoubleMap
, but with arbitrary number of keys. - Conceptually same as
StorageMap<>
where the key is a tuple of(u32, u32)
. On top, it provides some functions to iterate or remove items based on only the first key.