chain_spec_guide_runtime/
runtime.rs1#[cfg(feature = "std")]
22include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
23
24use crate::{
25 pallets::{pallet_bar, pallet_foo},
26 presets::*,
27};
28use alloc::{vec, vec::Vec};
29use frame::{
30 deps::frame_support::{
31 genesis_builder_helper::{build_state, get_preset},
32 runtime,
33 },
34 prelude::*,
35 runtime::{apis, prelude::*},
36};
37use sp_genesis_builder::PresetId;
38
39#[runtime_version]
41pub const VERSION: RuntimeVersion = RuntimeVersion {
42 spec_name: alloc::borrow::Cow::Borrowed("minimal-template-runtime"),
43 impl_name: alloc::borrow::Cow::Borrowed("minimal-template-runtime"),
44 authoring_version: 1,
45 spec_version: 0,
46 impl_version: 1,
47 apis: RUNTIME_API_VERSIONS,
48 transaction_version: 1,
49 system_version: 1,
50};
51
52type SignedExtra = ();
54
55#[runtime]
57mod runtime {
58 #[runtime::runtime]
60 #[runtime::derive(
61 RuntimeCall,
62 RuntimeEvent,
63 RuntimeError,
64 RuntimeOrigin,
65 RuntimeTask,
66 RuntimeViewFunction
67 )]
68 pub struct Runtime;
69
70 #[runtime::pallet_index(0)]
72 pub type System = frame_system;
73
74 #[runtime::pallet_index(1)]
76 pub type Bar = pallet_bar;
77
78 #[runtime::pallet_index(2)]
80 pub type Foo = pallet_foo;
81}
82
83parameter_types! {
84 pub const Version: RuntimeVersion = VERSION;
85}
86
87#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
89impl frame_system::Config for Runtime {
90 type Block = Block;
91 type Version = Version;
92}
93
94impl pallet_bar::Config for Runtime {}
95impl pallet_foo::Config for Runtime {}
96
97type Block = frame::runtime::types_common::BlockOf<Runtime, SignedExtra>;
98type Header = HeaderFor<Runtime>;
99
100#[docify::export(runtime_impl)]
101impl_runtime_apis! {
102 impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
103 fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
104 build_state::<RuntimeGenesisConfig>(config)
105 }
106
107 fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
108 get_preset::<RuntimeGenesisConfig>(id, get_builtin_preset)
109 }
110
111 fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
112 vec![
113 PresetId::from(PRESET_1),
114 PresetId::from(PRESET_2),
115 PresetId::from(PRESET_3),
116 PresetId::from(PRESET_4),
117 PresetId::from(PRESET_INVALID)
118 ]
119 }
120 }
121
122 impl apis::Core<Block> for Runtime {
123 fn version() -> RuntimeVersion { VERSION }
124 fn execute_block(_: Block) { }
125 fn initialize_block(_: &Header) -> ExtrinsicInclusionMode { ExtrinsicInclusionMode::default() }
126 }
127}