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 contracts_rpc_runtime_api::ContractExecResult;12use grandpa::fg_primitives;13use grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};14use sp_api::impl_runtime_apis;15use sp_consensus_aura::sr25519::AuthorityId as AuraId;16use sp_core::{crypto::KeyTypeId, OpaqueMetadata};17use sp_runtime::{18 create_runtime_str, generic, impl_opaque_keys,19 traits::{20 BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, Saturating,21 Verify,22 },23 transaction_validity::{TransactionSource, TransactionValidity},24 ApplyExtrinsicResult, MultiSignature,25};26use sp_std::prelude::*;27#[cfg(feature = "std")]28use sp_version::NativeVersion;29use sp_version::RuntimeVersion;303132pub use balances::Call as BalancesCall;33pub use contracts::Schedule as ContractsSchedule;34pub use frame_support::{35 construct_runtime,36 dispatch::DispatchResult,37 parameter_types,38 traits::{39 Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,40 WithdrawReason,41 },42 weights::{43 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},44 DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,45 WeightToFeePolynomial,46 },47 StorageValue,48};49#[cfg(any(feature = "std", test))]50pub use sp_runtime::BuildStorage;51use sp_runtime::Perbill;52use system::{self as system};5354pub use timestamp::Call as TimestampCall;55565758extern crate nft;59pub use nft::*;606162pub type BlockNumber = u32;636465pub type Signature = MultiSignature;66676869pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;70717273pub type AccountIndex = u32;747576pub type Balance = u128;777879pub type Index = u32;808182pub type Hash = sp_core::H256;838485pub type DigestItem = generic::DigestItem<Hash>;868788899091pub mod opaque {92 use super::*;9394 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;9596 97 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;98 99 pub type Block = generic::Block<Header, UncheckedExtrinsic>;100 101 pub type BlockId = generic::BlockId<Block>;102103 impl_opaque_keys! {104 pub struct SessionKeys {105 pub aura: Aura,106 pub grandpa: Grandpa,107 }108 }109}110111112pub const VERSION: RuntimeVersion = RuntimeVersion {113 spec_name: create_runtime_str!("nft"),114 impl_name: create_runtime_str!("nft"),115 authoring_version: 1,116 spec_version: 2,117 impl_version: 1,118 apis: RUNTIME_API_VERSIONS,119 transaction_version: 1,120};121122pub const MILLISECS_PER_BLOCK: u64 = 6000;123124pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;125126127pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);128pub const HOURS: BlockNumber = MINUTES * 60;129pub const DAYS: BlockNumber = HOURS * 24;130131132#[cfg(feature = "std")]133pub fn native_version() -> NativeVersion {134 NativeVersion {135 runtime_version: VERSION,136 can_author_with: Default::default(),137 }138}139140parameter_types! {141 pub const BlockHashCount: BlockNumber = 2400;142 143 pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;144 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);145 146 pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()147 .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();148 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;149 pub const Version: RuntimeVersion = VERSION;150}151152impl system::Trait for Runtime {153 154 type BaseCallFilter = ();155 156 type AccountId = AccountId;157 158 type Call = Call;159 160 type Lookup = IdentityLookup<AccountId>;161 162 type Index = Index;163 164 type BlockNumber = BlockNumber;165 166 type Hash = Hash;167 168 type Hashing = BlakeTwo256;169 170 type Header = generic::Header<BlockNumber, BlakeTwo256>;171 172 type Event = Event;173 174 type Origin = Origin;175 176 type BlockHashCount = BlockHashCount;177 178 type MaximumBlockWeight = MaximumBlockWeight;179 180 type DbWeight = RocksDbWeight;181 182 183 type BlockExecutionWeight = BlockExecutionWeight;184 185 186 type ExtrinsicBaseWeight = ExtrinsicBaseWeight;187 188 189 190 type MaximumExtrinsicWeight = MaximumExtrinsicWeight;191 192 type MaximumBlockLength = MaximumBlockLength;193 194 type AvailableBlockRatio = AvailableBlockRatio;195 196 type Version = Version;197 198 type PalletInfo = PalletInfo;199 200 type OnNewAccount = ();201 202 type OnKilledAccount = ();203 204 type AccountData = balances::AccountData<Balance>;205 206 type SystemWeightInfo = ();207}208209impl aura::Trait for Runtime {210 type AuthorityId = AuraId;211}212213impl grandpa::Trait for Runtime {214 type Event = Event;215 type Call = Call;216217 type KeyOwnerProofSystem = ();218219 type KeyOwnerProof =220 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;221222 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(223 KeyTypeId,224 GrandpaId,225 )>>::IdentificationTuple;226227 type HandleEquivocation = ();228229 type WeightInfo = ();230}231232parameter_types! {233 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;234}235236impl timestamp::Trait for Runtime {237 238 type Moment = u64;239 type OnTimestampSet = Aura;240 type MinimumPeriod = MinimumPeriod;241 type WeightInfo = ();242}243244parameter_types! {245 246 pub const ExistentialDeposit: u128 = 0;247 pub const MaxLocks: u32 = 50;248}249250impl balances::Trait for Runtime {251 type MaxLocks = MaxLocks;252 253 type Balance = Balance;254 255 type Event = Event;256 type DustRemoval = ();257 type ExistentialDeposit = ExistentialDeposit;258 type AccountStore = System;259 type WeightInfo = ();260}261262pub const MILLICENTS: Balance = 1_000_000_000;263pub const CENTS: Balance = 1_000 * MILLICENTS;264pub const DOLLARS: Balance = 100 * CENTS;265266parameter_types! {267 pub const TombstoneDeposit: Balance = 16 * MILLICENTS;268 pub const RentByteFee: Balance = 4 * MILLICENTS;269 pub const RentDepositOffset: Balance = 1000 * MILLICENTS;270 pub const SurchargeReward: Balance = 150 * MILLICENTS;271}272273impl contracts::Trait for Runtime {274 type Time = Timestamp;275 type Randomness = RandomnessCollectiveFlip;276 type Currency = Balances;277 type Event = Event;278 type DetermineContractAddress = contracts::SimpleAddressDeterminer<Runtime>;279 type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;280 type RentPayment = ();281 type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;282 type TombstoneDeposit = TombstoneDeposit;283 type StorageSizeOffset = contracts::DefaultStorageSizeOffset;284 type RentByteFee = RentByteFee;285 type RentDepositOffset = RentDepositOffset;286 type SurchargeReward = SurchargeReward;287 type MaxDepth = contracts::DefaultMaxDepth;288 type MaxValueSize = contracts::DefaultMaxValueSize;289 type WeightPrice = transaction_payment::Module<Self>;290}291292parameter_types! {293 pub const TransactionByteFee: Balance = 1;294}295296impl transaction_payment::Trait for Runtime {297 type Currency = balances::Module<Runtime>;298 type OnTransactionPayment = ();299 type TransactionByteFee = TransactionByteFee;300 type WeightToFee = IdentityFee<Balance>;301 type FeeMultiplierUpdate = ();302}303304impl sudo::Trait for Runtime {305 type Event = Event;306 type Call = Call;307}308309310impl nft::Trait for Runtime {311 type Event = Event;312}313314construct_runtime!(315 pub enum Runtime where316 Block = Block,317 NodeBlock = opaque::Block,318 UncheckedExtrinsic = UncheckedExtrinsic319 {320 System: system::{Module, Call, Config, Storage, Event<T>},321 RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},322 Contracts: contracts::{Module, Call, Config, Storage, Event<T>},323 Timestamp: timestamp::{Module, Call, Storage, Inherent},324 Aura: aura::{Module, Config<T>, Inherent},325 Grandpa: grandpa::{Module, Call, Storage, Config, Event},326 Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},327 TransactionPayment: transaction_payment::{Module, Storage},328 Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},329 Nft: nft::{Module, Call, Config<T>, Storage, Event<T>},330 }331);332333334pub type Address = AccountId;335336pub type Header = generic::Header<BlockNumber, BlakeTwo256>;337338pub type Block = generic::Block<Header, UncheckedExtrinsic>;339340pub type SignedBlock = generic::SignedBlock<Block>;341342pub type BlockId = generic::BlockId<Block>;343344pub type SignedExtra = (345 system::CheckSpecVersion<Runtime>,346 system::CheckTxVersion<Runtime>,347 system::CheckGenesis<Runtime>,348 system::CheckEra<Runtime>,349 system::CheckNonce<Runtime>,350 system::CheckWeight<Runtime>,351 nft::ChargeTransactionPayment<Runtime>,352);353354pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;355356pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;357358pub type Executive =359 frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;360361impl_runtime_apis! {362363 impl contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>364 for Runtime365 {366 fn call(367 origin: AccountId,368 dest: AccountId,369 value: Balance,370 gas_limit: u64,371 input_data: Vec<u8>,372 ) -> ContractExecResult {373 let (exec_result, gas_consumed) =374 Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);375 match exec_result {376 Ok(v) => ContractExecResult::Success {377 flags: v.flags.bits(),378 data: v.data,379 gas_consumed: gas_consumed,380 },381 Err(_) => ContractExecResult::Error,382 }383 }384385 fn get_storage(386 address: AccountId,387 key: [u8; 32],388 ) -> contracts_primitives::GetStorageResult {389 Contracts::get_storage(address, key)390 }391392 fn rent_projection(393 address: AccountId,394 ) -> contracts_primitives::RentProjectionResult<BlockNumber> {395 Contracts::rent_projection(address)396 }397 }398399 impl sp_api::Core<Block> for Runtime {400 fn version() -> RuntimeVersion {401 VERSION402 }403404 fn execute_block(block: Block) {405 Executive::execute_block(block)406 }407408 fn initialize_block(header: &<Block as BlockT>::Header) {409 Executive::initialize_block(header)410 }411 }412413 impl sp_api::Metadata<Block> for Runtime {414 fn metadata() -> OpaqueMetadata {415 Runtime::metadata().into()416 }417 }418419 impl sp_block_builder::BlockBuilder<Block> for Runtime {420 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {421 Executive::apply_extrinsic(extrinsic)422 }423424 fn finalize_block() -> <Block as BlockT>::Header {425 Executive::finalize_block()426 }427428 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {429 data.create_extrinsics()430 }431432 fn check_inherents(433 block: Block,434 data: sp_inherents::InherentData,435 ) -> sp_inherents::CheckInherentsResult {436 data.check_extrinsics(&block)437 }438439 fn random_seed() -> <Block as BlockT>::Hash {440 RandomnessCollectiveFlip::random_seed()441 }442 }443444 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {445 fn validate_transaction(446 source: TransactionSource,447 tx: <Block as BlockT>::Extrinsic,448 ) -> TransactionValidity {449 Executive::validate_transaction(source, tx)450 }451 }452453 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {454 fn offchain_worker(header: &<Block as BlockT>::Header) {455 Executive::offchain_worker(header)456 }457 }458459 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {460 fn slot_duration() -> u64 {461 Aura::slot_duration()462 }463464 fn authorities() -> Vec<AuraId> {465 Aura::authorities()466 }467 }468469 impl sp_session::SessionKeys<Block> for Runtime {470 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {471 opaque::SessionKeys::generate(seed)472 }473474 fn decode_session_keys(475 encoded: Vec<u8>,476 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {477 opaque::SessionKeys::decode_into_raw_public_keys(&encoded)478 }479 }480481 impl fg_primitives::GrandpaApi<Block> for Runtime {482 fn grandpa_authorities() -> GrandpaAuthorityList {483 Grandpa::grandpa_authorities()484 }485486 fn submit_report_equivocation_unsigned_extrinsic(487 _equivocation_proof: fg_primitives::EquivocationProof<488 <Block as BlockT>::Hash,489 NumberFor<Block>,490 >,491 _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,492 ) -> Option<()> {493 None494 }495496 fn generate_key_ownership_proof(497 _set_id: fg_primitives::SetId,498 _authority_id: GrandpaId,499 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {500 501 502 503 None504 }505 }506 507 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {508 fn account_nonce(account: AccountId) -> Index {509 System::account_nonce(account)510 }511 }512513 impl transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {514 fn query_info(515 uxt: <Block as BlockT>::Extrinsic,516 len: u32,517 ) -> transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {518 TransactionPayment::query_info(uxt, len)519 }520 }521522}