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;38pub use contracts::Schedule as ContractsSchedule;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}204205206pub const MILLICENTS: Balance = 1_000_000_000;207pub const CENTS: Balance = 1_000 * MILLICENTS;208pub const DOLLARS: Balance = 100 * CENTS;209210parameter_types! {211 pub const TombstoneDeposit: Balance = 16 * MILLICENTS;212 pub const RentByteFee: Balance = 4 * MILLICENTS;213 pub const RentDepositOffset: Balance = 1000 * MILLICENTS;214 pub const SurchargeReward: Balance = 150 * MILLICENTS;215 pub const ContractTransactionBaseFee: Balance = 1 * CENTS;216 pub const ContractTransactionByteFee: Balance = 10 * MILLICENTS;217 pub const ContractFee: Balance = 1 * CENTS;218}219220impl contracts::Trait for Runtime {221 type Currency = Balances;222 type Time = Timestamp;223 type Randomness = RandomnessCollectiveFlip;224 type Call = Call;225 type Event = Event;226 type DetermineContractAddress = contracts::SimpleAddressDeterminer<Runtime>;227 type ComputeDispatchFee = contracts::DefaultDispatchFeeComputor<Runtime>;228 type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;229 type GasPayment = ();230 type RentPayment = ();231 type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;232 type TombstoneDeposit = TombstoneDeposit;233 type StorageSizeOffset = contracts::DefaultStorageSizeOffset;234 type RentByteFee = RentByteFee;235 type RentDepositOffset = RentDepositOffset;236 type SurchargeReward = SurchargeReward;237 type TransactionBaseFee = ContractTransactionBaseFee;238 type TransactionByteFee = ContractTransactionByteFee;239 type ContractFee = ContractFee;240 type CallBaseFee = contracts::DefaultCallBaseFee;241 type InstantiateBaseFee = contracts::DefaultInstantiateBaseFee;242 type MaxDepth = contracts::DefaultMaxDepth;243 type MaxValueSize = contracts::DefaultMaxValueSize;244 type BlockGasLimit = contracts::DefaultBlockGasLimit;245}246247parameter_types! {248 pub const TransactionBaseFee: Balance = 0;249 pub const TransactionByteFee: Balance = 1;250}251252impl transaction_payment::Trait for Runtime {253 type Currency = balances::Module<Runtime>;254 type OnTransactionPayment = ();255 type TransactionBaseFee = TransactionBaseFee;256 type TransactionByteFee = TransactionByteFee;257 type WeightToFee = ConvertInto;258 type FeeMultiplierUpdate = ();259}260261impl sudo::Trait for Runtime {262 type Event = Event;263 type Call = Call;264}265266267impl nft::Trait for Runtime {268 type Event = Event;269}270271construct_runtime!(272 pub enum Runtime where273 Block = Block,274 NodeBlock = opaque::Block,275 UncheckedExtrinsic = UncheckedExtrinsic,276 {277 System: system::{Module, Call, Config, Storage, Event<T>},278 RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},279 Timestamp: timestamp::{Module, Call, Storage, Inherent},280 Aura: aura::{Module, Config<T>, Inherent(Timestamp)},281 Grandpa: grandpa::{Module, Call, Storage, Config, Event},282 Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},283 TransactionPayment: transaction_payment::{Module, Storage},284 Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},285 Contracts: contracts::{Module, Call, Config<T>, Storage, Event<T>},286 287 Nft: nft::{Module, Call, Storage, Event<T>},288 }289);290291292pub type Address = AccountId;293294pub type Header = generic::Header<BlockNumber, BlakeTwo256>;295296pub type Block = generic::Block<Header, UncheckedExtrinsic>;297298pub type SignedBlock = generic::SignedBlock<Block>;299300pub type BlockId = generic::BlockId<Block>;301302pub type SignedExtra = (303 system::CheckVersion<Runtime>,304 system::CheckGenesis<Runtime>,305 system::CheckEra<Runtime>,306 system::CheckNonce<Runtime>,307 system::CheckWeight<Runtime>,308 transaction_payment::ChargeTransactionPayment<Runtime>,309);310311pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;312313pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;314315pub type Executive =316 frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;317318impl_runtime_apis! {319 impl sp_api::Core<Block> for Runtime {320 fn version() -> RuntimeVersion {321 VERSION322 }323324 fn execute_block(block: Block) {325 Executive::execute_block(block)326 }327328 fn initialize_block(header: &<Block as BlockT>::Header) {329 Executive::initialize_block(header)330 }331 }332333 impl sp_api::Metadata<Block> for Runtime {334 fn metadata() -> OpaqueMetadata {335 Runtime::metadata().into()336 }337 }338339 impl sp_block_builder::BlockBuilder<Block> for Runtime {340 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {341 Executive::apply_extrinsic(extrinsic)342 }343344 fn finalize_block() -> <Block as BlockT>::Header {345 Executive::finalize_block()346 }347348 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {349 data.create_extrinsics()350 }351352 fn check_inherents(353 block: Block,354 data: sp_inherents::InherentData,355 ) -> sp_inherents::CheckInherentsResult {356 data.check_extrinsics(&block)357 }358359 fn random_seed() -> <Block as BlockT>::Hash {360 RandomnessCollectiveFlip::random_seed()361 }362 }363364 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {365 fn validate_transaction(366 source: TransactionSource,367 tx: <Block as BlockT>::Extrinsic,368 ) -> TransactionValidity {369 Executive::validate_transaction(source, tx)370 }371 }372373 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {374 fn offchain_worker(header: &<Block as BlockT>::Header) {375 Executive::offchain_worker(header)376 }377 }378379 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {380 fn slot_duration() -> u64 {381 Aura::slot_duration()382 }383384 fn authorities() -> Vec<AuraId> {385 Aura::authorities()386 }387 }388389 impl sp_session::SessionKeys<Block> for Runtime {390 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {391 opaque::SessionKeys::generate(seed)392 }393394 fn decode_session_keys(395 encoded: Vec<u8>,396 ) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {397 opaque::SessionKeys::decode_into_raw_public_keys(&encoded)398 }399 }400401 impl fg_primitives::GrandpaApi<Block> for Runtime {402 fn grandpa_authorities() -> GrandpaAuthorityList {403 Grandpa::grandpa_authorities()404 }405 }406}