I cloned the substrate repository. In bin/node-template/runtime/src/lib.rs
, construct_runtime!
is called to create the runtime. I found the definition of construct_runtime
in frame/support/procedural/src/construct_runtime/mod.rs
. It calls construct_runtime_parsed
which builds a block of code during runtime.
let res = quote!(
#scrate_decl
#[derive(Clone, Copy, PartialEq, Eq, #scrate::sp_runtime::RuntimeDebug)]
pub struct #name;
impl #scrate::sp_runtime::traits::GetNodeBlockType for #name {
type NodeBlock = #node_block;
}
impl #scrate::sp_runtime::traits::GetRuntimeBlockType for #name {
type RuntimeBlock = #block;
}
#outer_event
#outer_origin
#all_modules
#module_to_index
#dispatch
#metadata
#outer_config
#inherent
#validate_unsigned
#integrity_test
);
Are there any ways that I can print or check the code passed to quote!
that is built by construct_runtime_parsed
?
You can point cargo expand
at the runtime/src/lib.rs
file and it will output the expanded source code.