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::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, ConvertInto, IdentifyAccount19};20use sp_api::impl_runtime_apis;21use sp_consensus_aura::sr25519::AuthorityId as AuraId;22use grandpa::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 StorageValue, construct_runtime, parameter_types,36 traits::Randomness,37 weights::Weight,38};394041pub use nft;424344pub type BlockNumber = u32;454647pub type Signature = MultiSignature;48495051pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;52535455pub type AccountIndex = u32;565758pub type Balance = u128;596061pub type Index = u32;626364pub type Hash = sp_core::H256;656667pub type DigestItem = generic::DigestItem<Hash>;686970717273pub mod opaque {74 use super::*;7576 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;7778 79 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;80 81 pub type Block = generic::Block<Header, UncheckedExtrinsic>;82 83 pub type BlockId = generic::BlockId<Block>;8485 impl_opaque_keys! {86 pub struct SessionKeys {87 pub aura: Aura,88 pub grandpa: Grandpa,89 }90 }91}929394pub const VERSION: RuntimeVersion = RuntimeVersion {95 spec_name: create_runtime_str!("nft"),96 impl_name: create_runtime_str!("nft"),97 authoring_version: 1,98 spec_version: 1,99 impl_version: 1,100 apis: RUNTIME_API_VERSIONS,101};102103pub const MILLISECS_PER_BLOCK: u64 = 6000;104105pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;106107108pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);109pub const HOURS: BlockNumber = MINUTES * 60;110pub const DAYS: BlockNumber = HOURS * 24;111112113#[cfg(feature = "std")]114pub fn native_version() -> NativeVersion {115 NativeVersion {116 runtime_version: VERSION,117 can_author_with: Default::default(),118 }119}120121parameter_types! {122 pub const BlockHashCount: BlockNumber = 250;123 pub const MaximumBlockWeight: Weight = 1_000_000_000;124 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);125 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;126 pub const Version: RuntimeVersion = VERSION;127}128129impl system::Trait for Runtime {130 131 type AccountId = AccountId;132 133 type Call = Call;134 135 type Lookup = IdentityLookup<AccountId>;136 137 type Index = Index;138 139 type BlockNumber = BlockNumber;140 141 type Hash = Hash;142 143 type Hashing = BlakeTwo256;144 145 type Header = generic::Header<BlockNumber, BlakeTwo256>;146 147 type Event = Event;148 149 type Origin = Origin;150 151 type BlockHashCount = BlockHashCount;152 153 type MaximumBlockWeight = MaximumBlockWeight;154 155 type MaximumBlockLength = MaximumBlockLength;156 157 type AvailableBlockRatio = AvailableBlockRatio;158 159 type Version = Version;160 161 162 163 type ModuleToIndex = ModuleToIndex;164 165 type OnNewAccount = ();166 167 type OnKilledAccount = ();168 169 type AccountData = balances::AccountData<Balance>;170}171172impl aura::Trait for Runtime {173 type AuthorityId = AuraId;174}175176impl grandpa::Trait for Runtime {177 type Event = Event;178}179180parameter_types! {181 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;182}183184impl timestamp::Trait for Runtime {185 186 type Moment = u64;187 type OnTimestampSet = Aura;188 type MinimumPeriod = MinimumPeriod;189}190191parameter_types! {192 pub const ExistentialDeposit: u128 = 500;193}194195impl balances::Trait for Runtime {196 197 type Balance = Balance;198 199 type Event = Event;200 type DustRemoval = ();201 type ExistentialDeposit = ExistentialDeposit;202 type AccountStore = System;203}204205parameter_types! {206 pub const TransactionBaseFee: Balance = 0;207 pub const TransactionByteFee: Balance = 1;208}209210impl transaction_payment::Trait for Runtime {211 type Currency = balances::Module<Runtime>;212 type OnTransactionPayment = ();213 type TransactionBaseFee = TransactionBaseFee;214 type TransactionByteFee = TransactionByteFee;215 type WeightToFee = ConvertInto;216 type FeeMultiplierUpdate = ();217}218219impl sudo::Trait for Runtime {220 type Event = Event;221 type Call = Call;222}223224225impl nft::Trait for Runtime {226 type Event = Event;227}228229construct_runtime!(230 pub enum Runtime where231 Block = Block,232 NodeBlock = opaque::Block,233 UncheckedExtrinsic = UncheckedExtrinsic234 {235 System: system::{Module, Call, Config, Storage, Event<T>},236 RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},237 Timestamp: timestamp::{Module, Call, Storage, Inherent},238 Aura: aura::{Module, Config<T>, Inherent(Timestamp)},239 Grandpa: grandpa::{Module, Call, Storage, Config, Event},240 Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},241 TransactionPayment: transaction_payment::{Module, Storage},242 Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},243 244 Nft: nft::{Module, Call, Storage, Event<T>},245 }246);247248249pub type Address = AccountId;250251pub type Header = generic::Header<BlockNumber, BlakeTwo256>;252253pub type Block = generic::Block<Header, UncheckedExtrinsic>;254255pub type SignedBlock = generic::SignedBlock<Block>;256257pub type BlockId = generic::BlockId<Block>;258259pub type SignedExtra = (260 system::CheckVersion<Runtime>,261 system::CheckGenesis<Runtime>,262 system::CheckEra<Runtime>,263 system::CheckNonce<Runtime>,264 system::CheckWeight<Runtime>,265 transaction_payment::ChargeTransactionPayment<Runtime>266);267268pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;269270pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;271272pub type Executive = frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;273274impl_runtime_apis! {275 impl sp_api::Core<Block> for Runtime {276 fn version() -> RuntimeVersion {277 VERSION278 }279280 fn execute_block(block: Block) {281 Executive::execute_block(block)282 }283284 fn initialize_block(header: &<Block as BlockT>::Header) {285 Executive::initialize_block(header)286 }287 }288289 impl sp_api::Metadata<Block> for Runtime {290 fn metadata() -> OpaqueMetadata {291 Runtime::metadata().into()292 }293 }294295 impl sp_block_builder::BlockBuilder<Block> for Runtime {296 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {297 Executive::apply_extrinsic(extrinsic)298 }299300 fn finalize_block() -> <Block as BlockT>::Header {301 Executive::finalize_block()302 }303304 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {305 data.create_extrinsics()306 }307308 fn check_inherents(309 block: Block,310 data: sp_inherents::InherentData,311 ) -> sp_inherents::CheckInherentsResult {312 data.check_extrinsics(&block)313 }314315 fn random_seed() -> <Block as BlockT>::Hash {316 RandomnessCollectiveFlip::random_seed()317 }318 }319320 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {321 fn validate_transaction(322 source: TransactionSource,323 tx: <Block as BlockT>::Extrinsic,324 ) -> TransactionValidity {325 Executive::validate_transaction(source, tx)326 }327 }328329 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {330 fn offchain_worker(header: &<Block as BlockT>::Header) {331 Executive::offchain_worker(header)332 }333 }334335 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {336 fn slot_duration() -> u64 {337 Aura::slot_duration()338 }339340 fn authorities() -> Vec<AuraId> {341 Aura::authorities()342 }343 }344345 impl sp_session::SessionKeys<Block> for Runtime {346 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {347 opaque::SessionKeys::generate(seed)348 }349350 fn decode_session_keys(351 encoded: Vec<u8>,352 ) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {353 opaque::SessionKeys::decode_into_raw_public_keys(&encoded)354 }355 }356357 impl fg_primitives::GrandpaApi<Block> for Runtime {358 fn grandpa_authorities() -> GrandpaAuthorityList {359 Grandpa::grandpa_authorities()360 }361 }362}