Trait pallet_default_config_example::pallet::Config
source · pub trait Config: Config {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>;
type RuntimeTask: Task;
type WithDefaultValue: Get<u32>;
type OverwrittenDefaultValue: Get<u32>;
type CanDeriveDefaultFromSystem: Get<Self::AccountId>;
type HasNoDefault: Get<u32>;
type CannotHaveDefault: Get<Self::RuntimeCall>;
type WithDefaultType;
type OverwrittenDefaultType;
}
Expand description
Configuration trait of this pallet.
The main purpose of this trait is to act as an interface between this pallet and the runtime in which it is embedded in. A type, function, or constant in this trait is essentially left to be configured by the runtime that includes this pallet.
Consequently, a runtime that wants to include this pallet must implement this trait.
This pallet is annotated to have a default config. This will auto-generate
DefaultConfig
.
It will be an identical, but won’t have anything that is #[pallet::no_default]
.
Required Associated Types§
sourcetype RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>
type RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>
The overarching event type. This is coming from the runtime, and cannot have a default.
In general, Runtime*
-oriented types cannot have a sensible default.
sourcetype RuntimeTask: Task
type RuntimeTask: Task
The overarching task type.
sourcetype WithDefaultValue: Get<u32>
type WithDefaultValue: Get<u32>
An input parameter to this pallet. This value can have a default, because it is not
reliant on frame_system::Config
or the overarching runtime in any way.
sourcetype OverwrittenDefaultValue: Get<u32>
type OverwrittenDefaultValue: Get<u32>
Same as Config::WithDefaultValue
, but we don’t intend to define a default for this
in our tests below.
sourcetype CanDeriveDefaultFromSystem: Get<Self::AccountId>
type CanDeriveDefaultFromSystem: Get<Self::AccountId>
An input parameter that relies on <Self as frame_system::Config>::AccountId
. This can
too have a default, as long as as it is present in frame_system::DefaultConfig
.
sourcetype HasNoDefault: Get<u32>
type HasNoDefault: Get<u32>
We might chose to declare as one that doesn’t have a default, for whatever semantical reason.
sourcetype CannotHaveDefault: Get<Self::RuntimeCall>
type CannotHaveDefault: Get<Self::RuntimeCall>
Some types can technically have no default, such as those the rely on
frame_system::Config
but are not present in frame_system::DefaultConfig
. For
example, a RuntimeCall
cannot reasonably have a default.
sourcetype WithDefaultType
type WithDefaultType
Something that is a normal type, with default.
sourcetype OverwrittenDefaultType
type OverwrittenDefaultType
Same as Config::WithDefaultType
, but we don’t intend to define a default for this
in our tests below.