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 grandpa::fg_primitives;12use grandpa::AuthorityList as GrandpaAuthorityList;13use sp_api::impl_runtime_apis;14use sp_consensus_aura::sr25519::AuthorityId as AuraId;15use sp_core::OpaqueMetadata;16use sp_runtime::traits::{17 BlakeTwo256, Block as BlockT, ConvertInto, IdentifyAccount, IdentityLookup, Verify,18};19use sp_runtime::{20 create_runtime_str, generic, impl_opaque_keys,21 transaction_validity::{TransactionSource, TransactionValidity},22 ApplyExtrinsicResult, MultiSignature,23};24use sp_std::prelude::*;25#[cfg(feature = "std")]26use sp_version::NativeVersion;27use sp_version::RuntimeVersion;282930pub use balances::Call as BalancesCall;31pub use frame_support::{32 construct_runtime, parameter_types, traits::Randomness, weights::Weight, StorageValue,33};34#[cfg(any(feature = "std", test))]35pub use sp_runtime::BuildStorage;36pub use sp_runtime::{Perbill, Permill};37pub use timestamp::Call as TimestampCall;383940pub use nft;414243pub type BlockNumber = u32;444546pub type Signature = MultiSignature;47484950pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;51525354pub type AccountIndex = u32;555657pub type Balance = u128;585960pub type Index = u32;616263pub type Hash = sp_core::H256;646566pub type DigestItem = generic::DigestItem<Hash>;676869707172pub mod opaque {73 use super::*;7475 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;7677 78 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;79 80 pub type Block = generic::Block<Header, UncheckedExtrinsic>;81 82 pub type BlockId = generic::BlockId<Block>;8384 impl_opaque_keys! {85 pub struct SessionKeys {86 pub aura: Aura,87 pub grandpa: Grandpa,88 }89 }90}919293pub const VERSION: RuntimeVersion = RuntimeVersion {94 spec_name: create_runtime_str!("nft"),95 impl_name: create_runtime_str!("nft"),96 authoring_version: 1,97 spec_version: 1,98 impl_version: 1,99 apis: RUNTIME_API_VERSIONS,100};101102pub const MILLISECS_PER_BLOCK: u64 = 6000;103104pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;105106107pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);108pub const HOURS: BlockNumber = MINUTES * 60;109pub const DAYS: BlockNumber = HOURS * 24;110111112#[cfg(feature = "std")]113pub fn native_version() -> NativeVersion {114 NativeVersion {115 runtime_version: VERSION,116 can_author_with: Default::default(),117 }118}119120parameter_types! {121 pub const BlockHashCount: BlockNumber = 250;122 pub const MaximumBlockWeight: Weight = 1_000_000_000;123 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);124 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;125 pub const Version: RuntimeVersion = VERSION;126}127128impl system::Trait for Runtime {129 130 type AccountId = AccountId;131 132 type Call = Call;133 134 type Lookup = IdentityLookup<AccountId>;135 136 type Index = Index;137 138 type BlockNumber = BlockNumber;139 140 type Hash = Hash;141 142 type Hashing = BlakeTwo256;143 144 type Header = generic::Header<BlockNumber, BlakeTwo256>;145 146 type Event = Event;147 148 type Origin = Origin;149 150 type BlockHashCount = BlockHashCount;151 152 type MaximumBlockWeight = MaximumBlockWeight;153 154 type MaximumBlockLength = MaximumBlockLength;155 156 type AvailableBlockRatio = AvailableBlockRatio;157 158 type Version = Version;159 160 161 162 type ModuleToIndex = ModuleToIndex;163 164 type OnNewAccount = ();165 166 type OnKilledAccount = ();167 168 type AccountData = balances::AccountData<Balance>;169}170171impl aura::Trait for Runtime {172 type AuthorityId = AuraId;173}174175impl grandpa::Trait for Runtime {176 type Event = Event;177}178179parameter_types! {180 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;181}182183impl timestamp::Trait for Runtime {184 185 type Moment = u64;186 type OnTimestampSet = Aura;187 type MinimumPeriod = MinimumPeriod;188}189190parameter_types! {191 pub const ExistentialDeposit: u128 = 500;192}193194impl balances::Trait for Runtime {195 196 type Balance = Balance;197 198 type Event = Event;199 type DustRemoval = ();200 type ExistentialDeposit = ExistentialDeposit;201 type AccountStore = System;202}203204parameter_types! {205 pub const TransactionBaseFee: Balance = 0;206 pub const TransactionByteFee: Balance = 1;207}208209impl transaction_payment::Trait for Runtime {210 type Currency = balances::Module<Runtime>;211 type OnTransactionPayment = ();212 type TransactionBaseFee = TransactionBaseFee;213 type TransactionByteFee = TransactionByteFee;214 type WeightToFee = ConvertInto;215 type FeeMultiplierUpdate = ();216}217218impl sudo::Trait for Runtime {219 type Event = Event;220 type Call = Call;221}222223224impl nft::Trait for Runtime {225 type Event = Event;226}227228construct_runtime!(229 pub enum Runtime where230 Block = Block,231 NodeBlock = opaque::Block,232 UncheckedExtrinsic = UncheckedExtrinsic233 {234 System: system::{Module, Call, Config, Storage, Event<T>},235 RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},236 Timestamp: timestamp::{Module, Call, Storage, Inherent},237 Aura: aura::{Module, Config<T>, Inherent(Timestamp)},238 Grandpa: grandpa::{Module, Call, Storage, Config, Event},239 Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},240 TransactionPayment: transaction_payment::{Module, Storage},241 Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},242 243 Nft: nft::{Module, Call, Storage, Event<T>},244 }245);246247248pub type Address = AccountId;249250pub type Header = generic::Header<BlockNumber, BlakeTwo256>;251252pub type Block = generic::Block<Header, UncheckedExtrinsic>;253254pub type SignedBlock = generic::SignedBlock<Block>;255256pub type BlockId = generic::BlockId<Block>;257258pub type SignedExtra = (259 system::CheckVersion<Runtime>,260 system::CheckGenesis<Runtime>,261 system::CheckEra<Runtime>,262 system::CheckNonce<Runtime>,263 system::CheckWeight<Runtime>,264 transaction_payment::ChargeTransactionPayment<Runtime>,265);266267pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;268269pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;270271pub type Executive =272 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}