123#![cfg_attr(not(feature = "std"), no_std)]45#![recursion_limit="256"]678#[cfg(feature = "std")]9include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1011use sp_std::prelude::*;12use sp_core::{crypto::KeyTypeId, OpaqueMetadata};13use sp_runtime::{14 ApplyExtrinsicResult, generic, create_runtime_str, impl_opaque_keys, MultiSignature,15 transaction_validity::{TransactionValidity, TransactionSource},16};17use sp_runtime::traits::{18 BlakeTwo256, Block as BlockT, IdentityLookup, Verify, IdentifyAccount, NumberFor, Saturating,19};20use sp_api::impl_runtime_apis;21use sp_consensus_aura::sr25519::AuthorityId as AuraId;22use grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};23use grandpa::fg_primitives;24use sp_version::RuntimeVersion;25#[cfg(feature = "std")]26use sp_version::NativeVersion;272829#[cfg(any(feature = "std", test))]30pub use sp_runtime::BuildStorage;31pub use timestamp::Call as TimestampCall;32pub use balances::Call as BalancesCall;33pub use sp_runtime::{Permill, Perbill};34pub use frame_support::{35 construct_runtime, parameter_types, StorageValue,36 traits::{KeyOwnerProofSystem, Randomness},37 weights::{38 Weight, IdentityFee,39 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},40 },41};424344pub use nft;454647pub type BlockNumber = u32;484950pub type Signature = MultiSignature;51525354pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;55565758pub type AccountIndex = u32;596061pub type Balance = u128;626364pub type Index = u32;656667pub type Hash = sp_core::H256;686970pub type DigestItem = generic::DigestItem<Hash>;717273747576pub mod opaque {77 use super::*;7879 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;8081 82 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;83 84 pub type Block = generic::Block<Header, UncheckedExtrinsic>;85 86 pub type BlockId = generic::BlockId<Block>;8788 impl_opaque_keys! {89 pub struct SessionKeys {90 pub aura: Aura,91 pub grandpa: Grandpa,92 }93 }94}959697pub const VERSION: RuntimeVersion = RuntimeVersion {98 spec_name: create_runtime_str!("nft"),99 impl_name: create_runtime_str!("nft"),100 authoring_version: 1,101 spec_version: 1,102 impl_version: 1,103 apis: RUNTIME_API_VERSIONS,104 transaction_version: 1,105};106107pub const MILLISECS_PER_BLOCK: u64 = 6000;108109pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;110111112pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);113pub const HOURS: BlockNumber = MINUTES * 60;114pub const DAYS: BlockNumber = HOURS * 24;115116117#[cfg(feature = "std")]118pub fn native_version() -> NativeVersion {119 NativeVersion {120 runtime_version: VERSION,121 can_author_with: Default::default(),122 }123}124125parameter_types! {126 pub const BlockHashCount: BlockNumber = 2400;127 128 pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;129 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);130 131 pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()132 .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();133 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;134 pub const Version: RuntimeVersion = VERSION;135}136137impl system::Trait for Runtime {138 139 type BaseCallFilter = ();140 141 type AccountId = AccountId;142 143 type Call = Call;144 145 type Lookup = IdentityLookup<AccountId>;146 147 type Index = Index;148 149 type BlockNumber = BlockNumber;150 151 type Hash = Hash;152 153 type Hashing = BlakeTwo256;154 155 type Header = generic::Header<BlockNumber, BlakeTwo256>;156 157 type Event = Event;158 159 type Origin = Origin;160 161 type BlockHashCount = BlockHashCount;162 163 type MaximumBlockWeight = MaximumBlockWeight;164 165 type DbWeight = RocksDbWeight;166 167 168 type BlockExecutionWeight = BlockExecutionWeight;169 170 171 type ExtrinsicBaseWeight = ExtrinsicBaseWeight;172 173 174 175 type MaximumExtrinsicWeight = MaximumExtrinsicWeight;176 177 type MaximumBlockLength = MaximumBlockLength;178 179 type AvailableBlockRatio = AvailableBlockRatio;180 181 type Version = Version;182 183 184 185 type ModuleToIndex = ModuleToIndex;186 187 type OnNewAccount = ();188 189 type OnKilledAccount = ();190 191 type AccountData = balances::AccountData<Balance>;192}193194impl aura::Trait for Runtime {195 type AuthorityId = AuraId;196}197198impl grandpa::Trait for Runtime {199 type Event = Event;200 type Call = Call;201202 type KeyOwnerProofSystem = ();203204 type KeyOwnerProof =205 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;206207 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(208 KeyTypeId,209 GrandpaId,210 )>>::IdentificationTuple;211212 type HandleEquivocation = ();213}214215parameter_types! {216 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;217}218219impl timestamp::Trait for Runtime {220 221 type Moment = u64;222 type OnTimestampSet = Aura;223 type MinimumPeriod = MinimumPeriod;224}225226parameter_types! {227 pub const ExistentialDeposit: u128 = 500;228}229230impl balances::Trait for Runtime {231 232 type Balance = Balance;233 234 type Event = Event;235 type DustRemoval = ();236 type ExistentialDeposit = ExistentialDeposit;237 type AccountStore = System;238}239240parameter_types! {241 pub const TransactionByteFee: Balance = 1;242}243244impl transaction_payment::Trait for Runtime {245 type Currency = balances::Module<Runtime>;246 type OnTransactionPayment = ();247 type TransactionByteFee = TransactionByteFee;248 type WeightToFee = IdentityFee<Balance>;249 type FeeMultiplierUpdate = ();250}251252impl sudo::Trait for Runtime {253 type Event = Event;254 type Call = Call;255}256257258impl nft::Trait for Runtime {259 type Event = Event;260}261262construct_runtime!(263 pub enum Runtime where264 Block = Block,265 NodeBlock = opaque::Block,266 UncheckedExtrinsic = UncheckedExtrinsic267 {268 System: system::{Module, Call, Config, Storage, Event<T>},269 RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},270 Timestamp: timestamp::{Module, Call, Storage, Inherent},271 Aura: aura::{Module, Config<T>, Inherent(Timestamp)},272 Grandpa: grandpa::{Module, Call, Storage, Config, Event},273 Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},274 TransactionPayment: transaction_payment::{Module, Storage},275 Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},276 277 Nft: nft::{Module, Call, Storage, Event<T>},278 }279);280281282pub type Address = AccountId;283284pub type Header = generic::Header<BlockNumber, BlakeTwo256>;285286pub type Block = generic::Block<Header, UncheckedExtrinsic>;287288pub type SignedBlock = generic::SignedBlock<Block>;289290pub type BlockId = generic::BlockId<Block>;291292pub type SignedExtra = (293 system::CheckSpecVersion<Runtime>,294 system::CheckTxVersion<Runtime>,295 system::CheckGenesis<Runtime>,296 system::CheckEra<Runtime>,297 system::CheckNonce<Runtime>,298 system::CheckWeight<Runtime>,299 transaction_payment::ChargeTransactionPayment<Runtime>300);301302pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;303304pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;305306pub type Executive = frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;307308impl_runtime_apis! {309 impl sp_api::Core<Block> for Runtime {310 fn version() -> RuntimeVersion {311 VERSION312 }313314 fn execute_block(block: Block) {315 Executive::execute_block(block)316 }317318 fn initialize_block(header: &<Block as BlockT>::Header) {319 Executive::initialize_block(header)320 }321 }322323 impl sp_api::Metadata<Block> for Runtime {324 fn metadata() -> OpaqueMetadata {325 Runtime::metadata().into()326 }327 }328329 impl sp_block_builder::BlockBuilder<Block> for Runtime {330 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {331 Executive::apply_extrinsic(extrinsic)332 }333334 fn finalize_block() -> <Block as BlockT>::Header {335 Executive::finalize_block()336 }337338 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {339 data.create_extrinsics()340 }341342 fn check_inherents(343 block: Block,344 data: sp_inherents::InherentData,345 ) -> sp_inherents::CheckInherentsResult {346 data.check_extrinsics(&block)347 }348349 fn random_seed() -> <Block as BlockT>::Hash {350 RandomnessCollectiveFlip::random_seed()351 }352 }353354 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {355 fn validate_transaction(356 source: TransactionSource,357 tx: <Block as BlockT>::Extrinsic,358 ) -> TransactionValidity {359 Executive::validate_transaction(source, tx)360 }361 }362363 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {364 fn offchain_worker(header: &<Block as BlockT>::Header) {365 Executive::offchain_worker(header)366 }367 }368369 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {370 fn slot_duration() -> u64 {371 Aura::slot_duration()372 }373374 fn authorities() -> Vec<AuraId> {375 Aura::authorities()376 }377 }378379 impl sp_session::SessionKeys<Block> for Runtime {380 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {381 opaque::SessionKeys::generate(seed)382 }383384 fn decode_session_keys(385 encoded: Vec<u8>,386 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {387 opaque::SessionKeys::decode_into_raw_public_keys(&encoded)388 }389 }390391 impl fg_primitives::GrandpaApi<Block> for Runtime {392 fn grandpa_authorities() -> GrandpaAuthorityList {393 Grandpa::grandpa_authorities()394 }395396 fn submit_report_equivocation_extrinsic(397 _equivocation_proof: fg_primitives::EquivocationProof<398 <Block as BlockT>::Hash,399 NumberFor<Block>,400 >,401 _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,402 ) -> Option<()> {403 None404 }405406 fn generate_key_ownership_proof(407 _set_id: fg_primitives::SetId,408 _authority_id: GrandpaId,409 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {410 411 412 413 None414 }415 }416}