[][src]Macro srml_support::construct_runtime

macro_rules! construct_runtime {
    (
		pub enum $runtime:ident with Log ($log_internal:ident: DigestItem<$( $log_genarg:ty ),+>)
			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;
			$log_internal:ident <$( $log_genarg:ty ),+>;
		};
		{
			$(
				$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 (TODO: describe the difference between Block and NodeBlock) and the modules that are used by the runtime.

Example:

construct_runtime!(
    pub enum Runtime with Log(interalIdent: DigestItem<SessionKey>) where
        Block = Block,
        NodeBlock = runtime::Block,
        UncheckedExtrinsic = UncheckedExtrinsic
    {
        System: system,
        Test: test::{default, Log(Test)},
        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, Log(Test)} will expand to Test: test::{Module, Call, Storage, Event<T>, Config<T>, Log(Test)}.

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 dependent module need to come before the module depending on it.