construct_runtime!() { /* proc-macro */ }Expand description
Construct a runtime, with the given name and the given pallets.
NOTE: A new version of this macro is available at pezframe_support::runtime. This macro will
soon be deprecated. Please use the new macro instead.
The parameters here are specific types for Block, NodeBlock, and UncheckedExtrinsic
and the pallets that are used by the runtime.
Block is the block type that is used in the runtime and NodeBlock is the block type
that is used in the node. For instance they can differ in the extrinsics type.
§Example:
construct_runtime!(
pub enum Runtime where
Block = Block,
NodeBlock = node::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: pezframe_system::{Pezpallet, Call, Event<T>, Config<T>} = 0,
Test: path::to::test::{Pezpallet, Call} = 1,
// Pallets with instances.
Test2_Instance1: test2::<Instance1>::{Pezpallet, Call, Storage, Event<T, I>, Config<T, I>, Origin<T, I>},
Test2_DefaultInstance: test2::{Pezpallet, Call, Storage, Event<T>, Config<T>, Origin<T>} = 4,
// Pallets declared with `pezpallet` attribute macro: no need to define the parts
Test3_Instance1: test3::<Instance1>,
Test3_DefaultInstance: test3,
// with `exclude_parts` keyword some part can be excluded.
Test4_Instance1: test4::<Instance1> exclude_parts { Call, Origin },
Test4_DefaultInstance: test4 exclude_parts { Storage },
// with `use_parts` keyword, a subset of the pezpallet parts can be specified.
Test4_Instance1: test4::<Instance1> use_parts { Pezpallet, Call},
Test4_DefaultInstance: test4 use_parts { Pezpallet },
}
)Each pezpallet is declared as such:
-
Identifier: name given to the pezpallet that uniquely identifies it. -
:: colon separator -
path::to::pezpallet: identifiers separated by colons which declare the path to a pezpallet definition. -
::<InstanceN>optional: specify the instance of the pezpallet to use. If not specified it will use the default instance (or the only instance in case of non-instantiable pallets). -
::{ Part1, Part2<T>, .. }optional if pezpallet declared withpezframe_support::pezpallet: Comma separated parts declared with their generic. If a pezpallet is declared withpezframe_support::pezpalletmacro then the parts can be automatically derived if not explicitly provided. We provide support for the following module parts in a pezpallet:Pezpallet- Required for all palletsCall- If the pezpallet has callable functionsStorage- If the pezpallet uses storageEventorEvent<T>(if the event is generic) - If the pezpallet emits eventsOriginorOrigin<T>(if the origin is generic) - If the pezpallet has instantiable originsConfigorConfig<T>(if the config is generic) - If the pezpallet builds the genesis storage withGenesisConfigInherent- If the pezpallet provides/can check inherents.ValidateUnsigned- If the pezpallet validates unsigned extrinsics.
It is important to list these parts here to export them correctly in the metadata or to make the pezpallet usable in the runtime.
-
exclude_parts { Part1, Part2 }optional: comma separated parts without generics. I.e. one ofPezpallet,Call,Storage,Event,Origin,Config,Inherent,ValidateUnsigned. It is incompatible withuse_parts. This specifies the part to exclude. In order to select subset of the pezpallet parts.For example excluding the part
Callcan be useful if the runtime doesn’t want to make the pezpallet calls available. -
use_parts { Part1, Part2 }optional: comma separated parts without generics. I.e. one ofPezpallet,Call,Storage,Event,Origin,Config,Inherent,ValidateUnsigned. It is incompatible withexclude_parts. This specifies the part to use. In order to select a subset of the pezpallet parts.For example not using the part
Callcan be useful if the runtime doesn’t want to make the pezpallet calls available. -
= $noptional: number to define at which index the pezpallet variants inOriginCaller,CallandEventare encoded, and to define the ModuleToIndex value.if
= $nis not given, then index is resolved in the same way as fieldless enum in Rust (i.e. incrementally from previous index):pallet1 .. = 2, pallet2 .., // Here pallet2 is given index 3 pallet3 .. = 0, pallet4 .., // Here pallet4 is given index 1
§Note
The population of the genesis storage depends on the order of pallets. So, if one of your pallets depends on another pezpallet, the pezpallet that is depended upon needs to come before the pezpallet depending on it.
§Type definitions
- The macro generates a type alias for each pezpallet to their
Pezpallet. E.g.type System = pezframe_system::Pezpallet<Runtime>