[][src]Macro srml_support::construct_runtime

macro_rules! construct_runtime {
    (
		pub enum $runtime:ident
			where
				Block = $block:ident,
				NodeBlock = $node_block:ty,
				UncheckedExtrinsic = $uncheckedextrinsic:ident
		{
			$( $rest:tt )*
		}
	) => { ... };
    (
		{ $( $preset:tt )* };
		{ $( $expanded:tt )* };
		$name:ident: $module:ident,
		$( $rest:tt )*
	) => { ... };
    (
		{ $( $preset:tt )* };
		{ $( $expanded:tt )* };
		$name:ident: $module:ident::{
			default,
			$(
				$modules:ident
					$( <$modules_generic:ident $(, $modules_instance:ident)?> )*
					$( ( $( $modules_args:ident ),* ) )*
			),*
		},
		$( $rest:tt )*
	) => { ... };
    (
		{ $( $preset:tt )* };
		{ $( $expanded:tt )* };
		$name:ident: $module:ident::{
			$(
				$modules:ident
					$( <$modules_generic:ident> )*
					$( ( $( $modules_args:ident ),* ) )*
			),*
		},
		$( $rest:tt )*
	) => { ... };
    ( // Instance module: we indicate the generic instance `I` with the full instance path
		{ $( $preset:tt )* };
		{ $( $expanded:tt )* };
		$name:ident: $module:ident ::< $module_instance:ident >::{
			$(
				$modules:ident
					$( <$modules_generic:ident $(, $modules_instance:ident )?> )*
					$( ( $( $modules_args:ident ),* ) )*
			),*
		},
		$( $rest:tt )*
	) => { ... };
    (
		{
			$runtime:ident;
			$block:ident;
			$node_block:ty;
			$uncheckedextrinsic:ident;
		};
		{
			$(
				$name:ident: $module:ident :: $( < $module_instance:ident >:: )? {
					$(
						$modules:ident
							$( <$modules_generic:ident $(, I=$modules_instance:path)?> )*
							$( ( $( $modules_args:ident ),* ) )*
					),*
				},
			)*
		};
	) => { ... };
}

Construct a runtime, with the given name and the given modules.

The parameters here are specific types for Block, NodeBlock, and InherentData and the modules 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 = runtime::Block,
        UncheckedExtrinsic = UncheckedExtrinsic
    {
        System: system,
        Test: test::{default},
        Test2: test_with_long_module::{Module},

        // Module with instances
        Test3_Instance1: test3::<Instance1>::{Module, Call, Storage, Event<T, I>, Config<T, I>, Origin<T, I>},
        Test3_DefaultInstance: test3::{Module, Call, Storage, Event<T>, Config<T>, Origin<T>},
    }
)

The module System: system will expand to System: system::{Module, Call, Storage, Event<T>, Config<T>}. The identifier System is the name of the module and the lower case identifier system is the name of the Rust module/crate for this Substrate module.

The module Test: test::{default} will expand to Test: test::{Module, Call, Storage, Event<T>, Config<T>}.

The module Test2: test_with_long_module::{Module} will expand to Test2: test_with_long_module::{Module}.

We provide support for the following types in a module:

Note

The population of the genesis storage depends on the order of modules. So, if one of your modules depends on another module, the module that is depended upon needs to come before the module depending on it.