solochain_template_runtime/
lib.rs1#![cfg_attr(not(feature = "std"), no_std)]
2
3#[cfg(feature = "std")]
4include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
5
6pub mod apis;
7#[cfg(feature = "runtime-benchmarks")]
8mod benchmarks;
9pub mod configs;
10
11extern crate alloc;
12use alloc::vec::Vec;
13use sp_runtime::{
14 generic, impl_opaque_keys,
15 traits::{BlakeTwo256, IdentifyAccount, Verify},
16 MultiAddress, MultiSignature,
17};
18use sp_version::RuntimeVersion;
19
20pub use frame_system::Call as SystemCall;
21pub use pallet_balances::Call as BalancesCall;
22pub use pallet_timestamp::Call as TimestampCall;
23#[cfg(any(feature = "std", test))]
24pub use sp_runtime::BuildStorage;
25
26pub mod genesis_config_presets;
27
28pub mod opaque {
33 use super::*;
34 use sp_runtime::{
35 generic,
36 traits::{BlakeTwo256, Hash as HashT},
37 };
38
39 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
40
41 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
43 pub type Block = generic::Block<Header, UncheckedExtrinsic>;
45 pub type BlockId = generic::BlockId<Block>;
47 pub type Hash = <BlakeTwo256 as HashT>::Output;
49}
50
51impl_opaque_keys! {
52 pub struct SessionKeys {
53 pub aura: Aura,
54 pub grandpa: Grandpa,
55 }
56}
57
58#[sp_version::runtime_version]
61pub const VERSION: RuntimeVersion = RuntimeVersion {
62 spec_name: alloc::borrow::Cow::Borrowed("solochain-template-runtime"),
63 impl_name: alloc::borrow::Cow::Borrowed("solochain-template-runtime"),
64 authoring_version: 1,
65 spec_version: 100,
71 impl_version: 1,
72 apis: apis::RUNTIME_API_VERSIONS,
73 transaction_version: 1,
74 system_version: 1,
75};
76
77mod block_times {
78 pub const MILLI_SECS_PER_BLOCK: u64 = 6000;
85
86 pub const SLOT_DURATION: u64 = MILLI_SECS_PER_BLOCK;
89}
90pub use block_times::*;
91
92pub const MINUTES: BlockNumber = 60_000 / (MILLI_SECS_PER_BLOCK as BlockNumber);
94pub const HOURS: BlockNumber = MINUTES * 60;
95pub const DAYS: BlockNumber = HOURS * 24;
96
97pub const BLOCK_HASH_COUNT: BlockNumber = 2400;
98
99pub const UNIT: Balance = 1_000_000_000_000;
101pub const MILLI_UNIT: Balance = 1_000_000_000;
102pub const MICRO_UNIT: Balance = 1_000_000;
103
104pub const EXISTENTIAL_DEPOSIT: Balance = MILLI_UNIT;
106
107pub type Signature = MultiSignature;
109
110pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
113
114pub type Balance = u128;
116
117pub type Nonce = u32;
119
120pub type Hash = sp_core::H256;
122
123pub type BlockNumber = u32;
125
126pub type Address = MultiAddress<AccountId, ()>;
128
129pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
131
132pub type Block = generic::Block<Header, UncheckedExtrinsic>;
134
135pub type SignedBlock = generic::SignedBlock<Block>;
137
138pub type BlockId = generic::BlockId<Block>;
140
141pub type TxExtension = (
143 frame_system::AuthorizeCall<Runtime>,
144 frame_system::CheckNonZeroSender<Runtime>,
145 frame_system::CheckSpecVersion<Runtime>,
146 frame_system::CheckTxVersion<Runtime>,
147 frame_system::CheckGenesis<Runtime>,
148 frame_system::CheckEra<Runtime>,
149 frame_system::CheckNonce<Runtime>,
150 frame_system::CheckWeight<Runtime>,
151 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
152 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
153 frame_system::WeightReclaim<Runtime>,
154);
155
156pub type UncheckedExtrinsic =
158 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
159
160pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
162
163pub type Executive = frame_executive::Executive<
165 Runtime,
166 Block,
167 frame_system::ChainContext<Runtime>,
168 Runtime,
169 AllPalletsWithSystem,
170>;
171
172#[frame_support::runtime]
174mod runtime {
175 #[runtime::runtime]
176 #[runtime::derive(
177 RuntimeCall,
178 RuntimeEvent,
179 RuntimeError,
180 RuntimeOrigin,
181 RuntimeFreezeReason,
182 RuntimeHoldReason,
183 RuntimeSlashReason,
184 RuntimeLockId,
185 RuntimeTask,
186 RuntimeViewFunction
187 )]
188 pub struct Runtime;
189
190 #[runtime::pallet_index(0)]
191 pub type System = frame_system;
192
193 #[runtime::pallet_index(1)]
194 pub type Timestamp = pallet_timestamp;
195
196 #[runtime::pallet_index(2)]
197 pub type Aura = pallet_aura;
198
199 #[runtime::pallet_index(3)]
200 pub type Grandpa = pallet_grandpa;
201
202 #[runtime::pallet_index(4)]
203 pub type Balances = pallet_balances;
204
205 #[runtime::pallet_index(5)]
206 pub type TransactionPayment = pallet_transaction_payment;
207
208 #[runtime::pallet_index(6)]
209 pub type Sudo = pallet_sudo;
210
211 #[runtime::pallet_index(7)]
213 pub type Template = pallet_template;
214}