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::traits::{18 BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, Saturating, Verify,19};20use sp_runtime::{21 create_runtime_str, generic, impl_opaque_keys,22 transaction_validity::{TransactionSource, TransactionValidity},23 ApplyExtrinsicResult, MultiSignature,24};25use sp_std::prelude::*;26#[cfg(feature = "std")]27use sp_version::NativeVersion;28use sp_version::RuntimeVersion;293031pub use balances::Call as BalancesCall;32pub use contracts::Schedule as ContractsSchedule;33pub use frame_support::{34 construct_runtime, parameter_types,35 traits::{KeyOwnerProofSystem, Randomness},36 weights::{37 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},38 IdentityFee, Weight,39 },40 StorageValue,41};42#[cfg(any(feature = "std", test))]43pub use sp_runtime::BuildStorage;44pub use sp_runtime::{Perbill, Permill};45pub use timestamp::Call as TimestampCall;464748pub use nft;495051pub type BlockNumber = u32;525354pub type Signature = MultiSignature;55565758pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;59606162pub type AccountIndex = u32;636465pub type Balance = u128;666768pub type Index = u32;697071pub type Hash = sp_core::H256;727374pub type DigestItem = generic::DigestItem<Hash>;757677787980pub mod opaque {81 use super::*;8283 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;8485 86 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;87 88 pub type Block = generic::Block<Header, UncheckedExtrinsic>;89 90 pub type BlockId = generic::BlockId<Block>;9192 impl_opaque_keys! {93 pub struct SessionKeys {94 pub aura: Aura,95 pub grandpa: Grandpa,96 }97 }98}99100101pub const VERSION: RuntimeVersion = RuntimeVersion {102 spec_name: create_runtime_str!("nft"),103 impl_name: create_runtime_str!("nft"),104 authoring_version: 1,105 spec_version: 1,106 impl_version: 1,107 apis: RUNTIME_API_VERSIONS,108 transaction_version: 1,109};110111pub const MILLISECS_PER_BLOCK: u64 = 6000;112113pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;114115116pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);117pub const HOURS: BlockNumber = MINUTES * 60;118pub const DAYS: BlockNumber = HOURS * 24;119120121#[cfg(feature = "std")]122pub fn native_version() -> NativeVersion {123 NativeVersion {124 runtime_version: VERSION,125 can_author_with: Default::default(),126 }127}128129parameter_types! {130 pub const BlockHashCount: BlockNumber = 2400;131 132 pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;133 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);134 135 pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()136 .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();137 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;138 pub const Version: RuntimeVersion = VERSION;139}140141impl system::Trait for Runtime {142 143 type BaseCallFilter = ();144 145 type AccountId = AccountId;146 147 type Call = Call;148 149 type Lookup = IdentityLookup<AccountId>;150 151 type Index = Index;152 153 type BlockNumber = BlockNumber;154 155 type Hash = Hash;156 157 type Hashing = BlakeTwo256;158 159 type Header = generic::Header<BlockNumber, BlakeTwo256>;160 161 type Event = Event;162 163 type Origin = Origin;164 165 type BlockHashCount = BlockHashCount;166 167 type MaximumBlockWeight = MaximumBlockWeight;168 169 type DbWeight = RocksDbWeight;170 171 172 type BlockExecutionWeight = BlockExecutionWeight;173 174 175 type ExtrinsicBaseWeight = ExtrinsicBaseWeight;176 177 178 179 type MaximumExtrinsicWeight = MaximumExtrinsicWeight;180 181 type MaximumBlockLength = MaximumBlockLength;182 183 type AvailableBlockRatio = AvailableBlockRatio;184 185 type Version = Version;186 187 188 189 type ModuleToIndex = ModuleToIndex;190 191 type OnNewAccount = ();192 193 type OnKilledAccount = ();194 195 type AccountData = balances::AccountData<Balance>;196}197198impl aura::Trait for Runtime {199 type AuthorityId = AuraId;200}201202impl grandpa::Trait for Runtime {203 type Event = Event;204 type Call = Call;205206 type KeyOwnerProofSystem = ();207208 type KeyOwnerProof =209 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;210211 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(212 KeyTypeId,213 GrandpaId,214 )>>::IdentificationTuple;215216 type HandleEquivocation = ();217}218219parameter_types! {220 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;221}222223impl timestamp::Trait for Runtime {224 225 type Moment = u64;226 type OnTimestampSet = Aura;227 type MinimumPeriod = MinimumPeriod;228}229230parameter_types! {231 pub const ExistentialDeposit: u128 = 500;232}233234impl balances::Trait for Runtime {235 236 type Balance = Balance;237 238 type Event = Event;239 type DustRemoval = ();240 type ExistentialDeposit = ExistentialDeposit;241 type AccountStore = System;242}243244pub const MILLICENTS: Balance = 1_000_000_000;245pub const CENTS: Balance = 1_000 * MILLICENTS;246pub const DOLLARS: Balance = 100 * CENTS;247248parameter_types! {249 pub const TombstoneDeposit: Balance = 16 * MILLICENTS;250 pub const RentByteFee: Balance = 4 * MILLICENTS;251 pub const RentDepositOffset: Balance = 1000 * MILLICENTS;252 pub const SurchargeReward: Balance = 150 * MILLICENTS;253}254255impl contracts::Trait for Runtime {256 type Call = Call;257 type Time = Timestamp;258 type Randomness = RandomnessCollectiveFlip;259 type Currency = Balances;260 type Event = Event;261 type DetermineContractAddress = contracts::SimpleAddressDeterminer<Runtime>;262 type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;263 type RentPayment = ();264 type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;265 type TombstoneDeposit = TombstoneDeposit;266 type StorageSizeOffset = contracts::DefaultStorageSizeOffset;267 type RentByteFee = RentByteFee;268 type RentDepositOffset = RentDepositOffset;269 type SurchargeReward = SurchargeReward;270 type MaxDepth = contracts::DefaultMaxDepth;271 type MaxValueSize = contracts::DefaultMaxValueSize;272 type WeightPrice = transaction_payment::Module<Self>;273}274275parameter_types! {276 pub const TransactionByteFee: Balance = 1;277}278279impl transaction_payment::Trait for Runtime {280 type Currency = balances::Module<Runtime>;281 type OnTransactionPayment = ();282 type TransactionByteFee = TransactionByteFee;283 type WeightToFee = IdentityFee<Balance>;284 type FeeMultiplierUpdate = ();285}286287impl sudo::Trait for Runtime {288 type Event = Event;289 type Call = Call;290}291292293impl nft::Trait for Runtime {294 type Event = Event;295}296297construct_runtime!(298 pub enum Runtime where299 Block = Block,300 NodeBlock = opaque::Block,301 UncheckedExtrinsic = UncheckedExtrinsic302 {303 System: system::{Module, Call, Config, Storage, Event<T>},304 RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},305 Contracts: contracts::{Module, Call, Config, Storage, Event<T>},306 Timestamp: timestamp::{Module, Call, Storage, Inherent},307 Aura: aura::{Module, Config<T>, Inherent(Timestamp)},308 Grandpa: grandpa::{Module, Call, Storage, Config, Event},309 Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},310 TransactionPayment: transaction_payment::{Module, Storage},311 Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},312 Nft: nft::{Module, Call, Storage, Event<T>},313 }314);315316317pub type Address = AccountId;318319pub type Header = generic::Header<BlockNumber, BlakeTwo256>;320321pub type Block = generic::Block<Header, UncheckedExtrinsic>;322323pub type SignedBlock = generic::SignedBlock<Block>;324325pub type BlockId = generic::BlockId<Block>;326327pub type SignedExtra = (328 system::CheckSpecVersion<Runtime>,329 system::CheckTxVersion<Runtime>,330 system::CheckGenesis<Runtime>,331 system::CheckEra<Runtime>,332 system::CheckNonce<Runtime>,333 system::CheckWeight<Runtime>,334 transaction_payment::ChargeTransactionPayment<Runtime>,335);336337pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;338339pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;340341pub type Executive =342 frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;343344impl_runtime_apis! {345346 impl contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>347 for Runtime348 {349 fn call(350 origin: AccountId,351 dest: AccountId,352 value: Balance,353 gas_limit: u64,354 input_data: Vec<u8>,355 ) -> ContractExecResult {356 let exec_result =357 Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);358 match exec_result {359 Ok(v) => ContractExecResult::Success {360 status: v.status,361 data: v.data,362 },363 Err(_) => ContractExecResult::Error,364 }365 }366367 fn get_storage(368 address: AccountId,369 key: [u8; 32],370 ) -> contracts_primitives::GetStorageResult {371 Contracts::get_storage(address, key)372 }373374 fn rent_projection(375 address: AccountId,376 ) -> contracts_primitives::RentProjectionResult<BlockNumber> {377 Contracts::rent_projection(address)378 }379 }380381 impl sp_api::Core<Block> for Runtime {382 fn version() -> RuntimeVersion {383 VERSION384 }385386 fn execute_block(block: Block) {387 Executive::execute_block(block)388 }389390 fn initialize_block(header: &<Block as BlockT>::Header) {391 Executive::initialize_block(header)392 }393 }394395 impl sp_api::Metadata<Block> for Runtime {396 fn metadata() -> OpaqueMetadata {397 Runtime::metadata().into()398 }399 }400401 impl sp_block_builder::BlockBuilder<Block> for Runtime {402 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {403 Executive::apply_extrinsic(extrinsic)404 }405406 fn finalize_block() -> <Block as BlockT>::Header {407 Executive::finalize_block()408 }409410 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {411 data.create_extrinsics()412 }413414 fn check_inherents(415 block: Block,416 data: sp_inherents::InherentData,417 ) -> sp_inherents::CheckInherentsResult {418 data.check_extrinsics(&block)419 }420421 fn random_seed() -> <Block as BlockT>::Hash {422 RandomnessCollectiveFlip::random_seed()423 }424 }425426 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {427 fn validate_transaction(428 source: TransactionSource,429 tx: <Block as BlockT>::Extrinsic,430 ) -> TransactionValidity {431 Executive::validate_transaction(source, tx)432 }433 }434435 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {436 fn offchain_worker(header: &<Block as BlockT>::Header) {437 Executive::offchain_worker(header)438 }439 }440441 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {442 fn slot_duration() -> u64 {443 Aura::slot_duration()444 }445446 fn authorities() -> Vec<AuraId> {447 Aura::authorities()448 }449 }450451 impl sp_session::SessionKeys<Block> for Runtime {452 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {453 opaque::SessionKeys::generate(seed)454 }455456 fn decode_session_keys(457 encoded: Vec<u8>,458 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {459 opaque::SessionKeys::decode_into_raw_public_keys(&encoded)460 }461 }462463 impl fg_primitives::GrandpaApi<Block> for Runtime {464 fn grandpa_authorities() -> GrandpaAuthorityList {465 Grandpa::grandpa_authorities()466 }467468 fn submit_report_equivocation_extrinsic(469 _equivocation_proof: fg_primitives::EquivocationProof<470 <Block as BlockT>::Hash,471 NumberFor<Block>,472 >,473 _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,474 ) -> Option<()> {475 None476 }477478 fn generate_key_ownership_proof(479 _set_id: fg_primitives::SetId,480 _authority_id: GrandpaId,481 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {482 483 484 485 None486 }487 }488}