1// This file is part of Substrate.
23// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
56// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
1718//! A minimal runtime that shows runtime genesis state.
1920// Make the WASM binary available.
21#[cfg(feature = "std")]
22include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
2324use 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;
3839/// The runtime version.
40#[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};
5152/// The signed extensions that are added to the runtime.
53type SignedExtra = ();
5455// Composes the runtime by adding all the used pallets and deriving necessary types.
56#[runtime]
57mod runtime {
58/// The main runtime type.
59#[runtime::runtime]
60 #[runtime::derive(
61 RuntimeCall,
62 RuntimeEvent,
63 RuntimeError,
64 RuntimeOrigin,
65 RuntimeTask,
66 RuntimeViewFunction
67 )]
68pub struct Runtime;
6970/// Mandatory system pallet that should always be included in a FRAME runtime.
71#[runtime::pallet_index(0)]
72pub type System = frame_system;
7374/// Sample pallet 1
75#[runtime::pallet_index(1)]
76pub type Bar = pallet_bar;
7778/// Sample pallet 2
79#[runtime::pallet_index(2)]
80pub type Foo = pallet_foo;
81}
8283parameter_types! {
84pub const Version: RuntimeVersion = VERSION;
85}
8687/// Implements the types required for the system pallet.
88#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
89impl frame_system::Config for Runtime {
90type Block = Block;
91type Version = Version;
92}
9394impl pallet_bar::Config for Runtime {}
95impl pallet_foo::Config for Runtime {}
9697type Block = frame::runtime::types_common::BlockOf<Runtime, SignedExtra>;
98type Header = HeaderFor<Runtime>;
99100#[docify::export(runtime_impl)]
101impl_runtime_apis! {
102impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
103fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
104 build_state::<RuntimeGenesisConfig>(config)
105 }
106107fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
108 get_preset::<RuntimeGenesisConfig>(id, get_builtin_preset)
109 }
110111fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
112vec![
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 }
121122impl apis::Core<Block> for Runtime {
123fn version() -> RuntimeVersion { VERSION }
124fn execute_block(_: Block) { }
125fn initialize_block(_: &Header) -> ExtrinsicInclusionMode { ExtrinsicInclusionMode::default() }
126 }
127}