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};
18#[cfg(feature = "std")]
19use sp_version::NativeVersion;
20use sp_version::RuntimeVersion;
21
22pub use frame_system::Call as SystemCall;
23pub use pallet_balances::Call as BalancesCall;
24pub use pallet_timestamp::Call as TimestampCall;
25#[cfg(any(feature = "std", test))]
26pub use sp_runtime::BuildStorage;
27
28pub mod genesis_config_presets;
29
30pub mod opaque {
35 use super::*;
36 use sp_runtime::{
37 generic,
38 traits::{BlakeTwo256, Hash as HashT},
39 };
40
41 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
42
43 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
45 pub type Block = generic::Block<Header, UncheckedExtrinsic>;
47 pub type BlockId = generic::BlockId<Block>;
49 pub type Hash = <BlakeTwo256 as HashT>::Output;
51}
52
53impl_opaque_keys! {
54 pub struct SessionKeys {
55 pub aura: Aura,
56 pub grandpa: Grandpa,
57 }
58}
59
60#[sp_version::runtime_version]
63pub const VERSION: RuntimeVersion = RuntimeVersion {
64 spec_name: alloc::borrow::Cow::Borrowed("solochain-template-runtime"),
65 impl_name: alloc::borrow::Cow::Borrowed("solochain-template-runtime"),
66 authoring_version: 1,
67 spec_version: 100,
73 impl_version: 1,
74 apis: apis::RUNTIME_API_VERSIONS,
75 transaction_version: 1,
76 system_version: 1,
77};
78
79mod block_times {
80 pub const MILLI_SECS_PER_BLOCK: u64 = 6000;
87
88 pub const SLOT_DURATION: u64 = MILLI_SECS_PER_BLOCK;
91}
92pub use block_times::*;
93
94pub const MINUTES: BlockNumber = 60_000 / (MILLI_SECS_PER_BLOCK as BlockNumber);
96pub const HOURS: BlockNumber = MINUTES * 60;
97pub const DAYS: BlockNumber = HOURS * 24;
98
99pub const BLOCK_HASH_COUNT: BlockNumber = 2400;
100
101pub const UNIT: Balance = 1_000_000_000_000;
103pub const MILLI_UNIT: Balance = 1_000_000_000;
104pub const MICRO_UNIT: Balance = 1_000_000;
105
106pub const EXISTENTIAL_DEPOSIT: Balance = MILLI_UNIT;
108
109#[cfg(feature = "std")]
111pub fn native_version() -> NativeVersion {
112 NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
113}
114
115pub type Signature = MultiSignature;
117
118pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
121
122pub type Balance = u128;
124
125pub type Nonce = u32;
127
128pub type Hash = sp_core::H256;
130
131pub type BlockNumber = u32;
133
134pub type Address = MultiAddress<AccountId, ()>;
136
137pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
139
140pub type Block = generic::Block<Header, UncheckedExtrinsic>;
142
143pub type SignedBlock = generic::SignedBlock<Block>;
145
146pub type BlockId = generic::BlockId<Block>;
148
149pub type TxExtension = (
151 frame_system::AuthorizeCall<Runtime>,
152 frame_system::CheckNonZeroSender<Runtime>,
153 frame_system::CheckSpecVersion<Runtime>,
154 frame_system::CheckTxVersion<Runtime>,
155 frame_system::CheckGenesis<Runtime>,
156 frame_system::CheckEra<Runtime>,
157 frame_system::CheckNonce<Runtime>,
158 frame_system::CheckWeight<Runtime>,
159 pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
160 frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
161 frame_system::WeightReclaim<Runtime>,
162);
163
164pub type UncheckedExtrinsic =
166 generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
167
168pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
170
171pub type Executive = frame_executive::Executive<
173 Runtime,
174 Block,
175 frame_system::ChainContext<Runtime>,
176 Runtime,
177 AllPalletsWithSystem,
178>;
179
180#[frame_support::runtime]
182mod runtime {
183 #[runtime::runtime]
184 #[runtime::derive(
185 RuntimeCall,
186 RuntimeEvent,
187 RuntimeError,
188 RuntimeOrigin,
189 RuntimeFreezeReason,
190 RuntimeHoldReason,
191 RuntimeSlashReason,
192 RuntimeLockId,
193 RuntimeTask,
194 RuntimeViewFunction
195 )]
196 pub struct Runtime;
197
198 #[runtime::pallet_index(0)]
199 pub type System = frame_system;
200
201 #[runtime::pallet_index(1)]
202 pub type Timestamp = pallet_timestamp;
203
204 #[runtime::pallet_index(2)]
205 pub type Aura = pallet_aura;
206
207 #[runtime::pallet_index(3)]
208 pub type Grandpa = pallet_grandpa;
209
210 #[runtime::pallet_index(4)]
211 pub type Balances = pallet_balances;
212
213 #[runtime::pallet_index(5)]
214 pub type TransactionPayment = pallet_transaction_payment;
215
216 #[runtime::pallet_index(6)]
217 pub type Sudo = pallet_sudo;
218
219 #[runtime::pallet_index(7)]
221 pub type Template = pallet_template;
222}