git.delta.rocks / unique-network / refs/commits / 157619d37683

difftreelog

wip parachains

Greg Zaitsev2021-06-03parent: #c803bd5.patch.diff
in: master

2 files changed

modifiedruntime/Cargo.tomldiffbeforeafterboth
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -1,66 +1,19 @@
+################################################################################
+# Package 
+
 [package]
-authors = ['UseTech Professional <https://usetech.com/blockchain>']
+authors = ['Unique Network <support@uniquenetwork.io>']
+build = 'build.rs'
+description = 'Substrate node nft'
 edition = '2018'
-homepage = 'https://substrate.io'
+homepage = 'https://unique.network'
 license = 'All Rights Reserved'
 name = 'nft-runtime'
-repository = 'https://github.com/usetech-llc/nft_parachain/'
+repository = 'https://github.com/usetech-llc/nft_private/'
 version = '3.0.0'
 
 [package.metadata.docs.rs]
 targets = ['x86_64-unknown-linux-gnu']
-
-[build-dependencies]
-substrate-wasm-builder = '4.0.0'
-
-# alias "parity-scale-code" to "codec"
-[dependencies.codec]
-default-features = false
-features = ['derive']
-package = 'parity-scale-codec'
-version = '2.0.0'
-
-[dependencies]
-hex-literal = { optional = true, version = '0.3.1' }
-serde = { features = ['derive'], optional = true, version = '1.0.119' }
-
-# local dependencies
-pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }
-pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }
-
-# Substrate dependencies
-frame-benchmarking = { default-features = false, optional = true, version = '3.0.0' }
-frame-executive = { default-features = false, version = '3.0.0' }
-frame-support = { default-features = false, version = '3.0.0' }
-frame-system = { default-features = false, version = '3.0.0' }
-frame-system-benchmarking = { default-features = false, optional = true, version = '3.0.0' }
-frame-system-rpc-runtime-api = { default-features = false, version = '3.0.0' }
-pallet-aura = { default-features = false, version = '3.0.0' }
-pallet-balances = { default-features = false, version = '3.0.0' }
-pallet-contracts = { default-features = false, version = '3.0.0' }
-pallet-contracts-primitives = { default-features = false, version = '3.0.0' }
-pallet-contracts-rpc-runtime-api = { default-features = false, version = '3.0.0' }
-pallet-grandpa = { default-features = false, version = '3.0.0' }
-pallet-randomness-collective-flip = { default-features = false, version = '3.0.0' }
-pallet-sudo = { default-features = false, version = '3.0.0' }
-pallet-timestamp = { default-features = false, version = '3.0.0' }
-pallet-transaction-payment = { default-features = false, version = '3.0.0' }
-pallet-transaction-payment-rpc-runtime-api = { default-features = false, version = '3.0.0' }
-pallet-treasury = { default-features = false, version = "3.0.0" }
-pallet-vesting = {  default-features = false, version = "3.0.0" }
-sp-arithmetic = { default-features = false, version = '3.0.0' }
-sp-api = { default-features = false, version = '3.0.0' }
-sp-block-builder = { default-features = false, version = '3.0.0' }
-sp-consensus-aura = { default-features = false, version = '0.9.0' }
-sp-core = { default-features = false, version = '3.0.0' }
-sp-inherents = { default-features = false, version = '3.0.0' }
-sp-offchain = { default-features = false, version = '3.0.0' }
-sp-runtime = { default-features = false, version = '3.0.0' }
-sp-session = { default-features = false, version = '3.0.0' }
-sp-std = { default-features = false, version = '3.0.0' }
-sp-transaction-pool = { default-features = false, version = '3.0.0' }
-sp-version = { default-features = false, version = '3.0.0' }
-smallvec = "1.4.1"
 
 [features]
 default = ['std']
@@ -78,17 +31,19 @@
 ]
 std = [
     'codec/std',
-    'serde',
+	'cumulus-pallet-parachain-system/std',
+	'cumulus-pallet-xcm/std',
+	'cumulus-pallet-xcmp-queue/std',
+	'cumulus-primitives-core/std',
+	'cumulus-primitives-utility/std',
     'frame-executive/std',
     'frame-support/std',
     'frame-system/std',
     'frame-system-rpc-runtime-api/std',
-    'pallet-aura/std',
     'pallet-balances/std',
     'pallet-contracts/std',
     'pallet-contracts-primitives/std',
     'pallet-contracts-rpc-runtime-api/std',
-    'pallet-grandpa/std',
     'pallet-randomness-collective-flip/std',
     'pallet-sudo/std',
     'pallet-timestamp/std',
@@ -96,19 +51,297 @@
     'pallet-transaction-payment-rpc-runtime-api/std',
     'pallet-treasury/std',
     'pallet-vesting/std',
-
-    'pallet-inflation/std',
-    'pallet-nft/std',
+    'serde',
     'sp-api/std',
     'sp-block-builder/std',
-    'sp-consensus-aura/std',
     'sp-core/std',
     'sp-inherents/std',
+	'sp-io/std',
     'sp-offchain/std',
     'sp-runtime/std',
     'sp-session/std',
     'sp-std/std',
     'sp-transaction-pool/std',
     'sp-version/std',
+	'xcm/std',
+	'xcm-builder/std',
+	'xcm-executor/std',
 
+    'pallet-inflation/std',
+    'pallet-nft/std',
 ]
+
+################################################################################
+# Substrate Dependencies
+
+[dependencies.codec]
+default-features = false
+features = ['derive']
+package = 'parity-scale-codec'
+version = '2.0.0'
+
+[dependencies.frame-benchmarking]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.frame-executive]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.frame-support]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.frame-system]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.frame-system-benchmarking]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.frame-system-rpc-runtime-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.hex-literal]
+optional = true
+version = '0.3.1'
+
+[dependencies.serde]
+features = ['derive']
+optional = true
+version = '1.0.119'
+
+[dependencies.pallet-balances]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+# Contracts specific packages
+[dependencies.pallet-contracts]
+git = 'https://github.com/paritytech/substrate.git'
+default-features = false
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-contracts-primitives]
+git = 'https://github.com/paritytech/substrate.git'
+default-features = false
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-contracts-rpc-runtime-api]
+git = 'https://github.com/paritytech/substrate.git'
+default-features = false
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-randomness-collective-flip]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-sudo]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-timestamp]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-transaction-payment]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-transaction-payment-rpc-runtime-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-treasury]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.pallet-vesting]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-arithmetic]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-api]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-block-builder]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-core]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-inherents]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-io]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-offchain]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-runtime]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-session]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-std]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-transaction-pool]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.sp-version]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'rococo-v1'
+version = '3.0.0'
+
+[dependencies.smallvec]
+version = '1.4.1'
+
+################################################################################
+# Cumulus dependencies
+
+[dependencies.parachain-info]
+default-features = false
+git = 'https://github.com/paritytech/cumulus.git'
+branch = 'rococo-v1'
+version = '0.1.0'
+
+[dependencies.cumulus-pallet-parachain-system]
+git = 'https://github.com/paritytech/cumulus.git'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.cumulus-primitives-core]
+git = 'https://github.com/paritytech/cumulus.git'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.cumulus-pallet-xcm]
+git = 'https://github.com/paritytech/cumulus.git'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.cumulus-pallet-xcmp-queue]
+git = 'https://github.com/paritytech/cumulus.git'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.cumulus-primitives-utility]
+git = 'https://github.com/paritytech/cumulus.git'
+branch = 'rococo-v1'
+default-features = false
+
+################################################################################
+# Polkadot dependencies
+
+[dependencies.polkadot-parachain]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.xcm]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.xcm-builder]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.xcm-executor]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'rococo-v1'
+default-features = false
+
+[dependencies.pallet-xcm]
+git = 'https://github.com/paritytech/polkadot'
+branch = 'rococo-v1'
+default-features = false
+
+
+################################################################################
+# Build Dependencies
+
+[build-dependencies]
+substrate-wasm-builder = '4.0.0'
+
+
+################################################################################
+# local dependencies
+
+pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }
+pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }
+
modifiedruntime/src/lib.rsdiffbeforeafterboth
before · runtime/src/lib.rs
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.78#![cfg_attr(not(feature = "std"), no_std)]9// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.10#![recursion_limit = "256"]1112// Make the WASM binary available.13#[cfg(feature = "std")]14include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1516use pallet_grandpa::fg_primitives;17use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};18use sp_api::impl_runtime_apis;19use sp_consensus_aura::sr25519::AuthorityId as AuraId;20use sp_core::{ crypto::KeyTypeId, crypto::Public, OpaqueMetadata };21use sp_runtime::{22    Permill, Perbill, Percent,23    ModuleId,24    create_runtime_str, generic, impl_opaque_keys,25    traits::{26        Convert, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, 27        IdentityLookup, NumberFor, Verify, AccountIdConversion,28    },29    transaction_validity::{TransactionSource, TransactionValidity},30    ApplyExtrinsicResult, MultiSignature,31};32#[cfg(feature = "std")]33use sp_version::NativeVersion;34use sp_version::RuntimeVersion;35pub use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment, CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};36// A few exports that help ease life for downstream crates.37pub use pallet_balances::Call as BalancesCall;38pub use pallet_contracts::{Schedule as ContractsSchedule };39pub use frame_support::{40    construct_runtime,41    dispatch::DispatchResult,42    parameter_types,43    StorageValue,44    traits::{45        Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,46        LockIdentifier,47    },48    weights::{49        constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},50        DispatchClass, DispatchInfo, GetDispatchInfo, Pays, PostDispatchInfo, Weight,51        WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients52    },53};54use pallet_contracts::weights::WeightInfo;55// #[cfg(any(feature = "std", test))]56use frame_system::{57    self as system,58    EnsureRoot, 59	limits::{BlockWeights, BlockLength},60};61use sp_std::{prelude::*, marker::PhantomData};62use sp_arithmetic::{traits::{BaseArithmetic, Unsigned}};63use smallvec::smallvec;6465pub use pallet_timestamp::Call as TimestampCall;6667mod chain_extension;68use crate::chain_extension::{ NFTExtension, Imbalance };6970/// Struct that handles the conversion of Balance -> `u64`. This is used for71/// staking's election calculation.72pub struct CurrencyToVoteHandler;7374impl CurrencyToVoteHandler {75	fn factor() -> Balance {76		(Balances::total_issuance() / u64::max_value() as Balance).max(1)77	}78}7980impl Convert<Balance, u64> for CurrencyToVoteHandler {81	fn convert(x: Balance) -> u64 {82		(x / Self::factor()) as u6483	}84}8586impl Convert<u128, Balance> for CurrencyToVoteHandler {87	fn convert(x: u128) -> Balance {88		x * Self::factor()89	}90}9192/// Re-export a nft pallet93/// TODO: Check this re-export. Is this safe and good style?94extern crate pallet_nft;95pub use pallet_nft::*;9697/// An index to a block.98pub type BlockNumber = u32;99100/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.101pub type Signature = MultiSignature;102103/// Some way of identifying an account on the chain. We intentionally make it equivalent104/// to the public key of our transaction signing scheme.105pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;106107/// The type for looking up accounts. We don't expect more than 4 billion of them, but you108/// never know...109pub type AccountIndex = u32;110111/// Balance of an account.112pub type Balance = u128;113114/// Index of a transaction in the chain.115pub type Index = u32;116117/// A hash of some data used by the chain.118pub type Hash = sp_core::H256;119120/// Digest item type.121pub type DigestItem = generic::DigestItem<Hash>;122123mod nft_weights;124125/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know126/// the specifics of the runtime. They can then be made to be agnostic over specific formats127/// of data like extrinsics, allowing for them to continue syncing the network through upgrades128/// to even the core data structures.129pub mod opaque {130    use super::*;131132    pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;133134    /// Opaque block header type.135    pub type Header = generic::Header<BlockNumber, BlakeTwo256>;136    /// Opaque block type.137    pub type Block = generic::Block<Header, UncheckedExtrinsic>;138    /// Opaque block identifier type.139    pub type BlockId = generic::BlockId<Block>;140141    impl_opaque_keys! {142        pub struct SessionKeys {143            pub aura: Aura,144            pub grandpa: Grandpa,145        }146    }147}148149/// This runtime version.150pub const VERSION: RuntimeVersion = RuntimeVersion {151    spec_name: create_runtime_str!("nft"),152    impl_name: create_runtime_str!("nft"),153    authoring_version: 1,154    spec_version: 3,155    impl_version: 1,156    apis: RUNTIME_API_VERSIONS,157    transaction_version: 1,158};159160pub const MILLISECS_PER_BLOCK: u64 = 6000;161162pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;163164// These time units are defined in number of blocks.165pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);166pub const HOURS: BlockNumber = MINUTES * 60;167pub const DAYS: BlockNumber = HOURS * 24;168169/// The version information used to identify this runtime when compiled natively.170#[cfg(feature = "std")]171pub fn native_version() -> NativeVersion {172    NativeVersion {173        runtime_version: VERSION,174        can_author_with: Default::default(),175    }176}177178/// Provides a membership set with only the configured aura users179pub struct ValiudatorsOnly<Runtime: pallet_aura::Config>(PhantomData<Runtime>);180impl frame_support::traits::Contains<AccountId> for ValiudatorsOnly<Runtime> {181	fn contains(t: &AccountId) -> bool {182        let arr: [u8; 32] = *t.as_ref();183        let raw_key: Vec<u8> = Vec::from(arr);184185        match pallet_aura::Module::<Runtime>::authorities().iter().find(|auth| auth.to_raw_vec() == raw_key) {186            Some(_) => true,187            None => false,188        }  189	}190	fn sorted_members() -> Vec<AccountId> {191        let mut members: Vec<AccountId> = Vec::new();192        for auth in pallet_aura::Module::<Runtime>::authorities() {193            let mut arr: [u8; 32] = Default::default(); 194            let bor_arr = auth.clone().to_raw_vec();195            let slice = bor_arr.as_slice();196            arr.copy_from_slice(slice);197            members.push(AccountId::from(arr));198        }199        members  200	}201	fn count() -> usize {202        pallet_aura::Module::<Runtime>::authorities().len()203	}204}205206impl frame_support::traits::ContainsLengthBound for ValiudatorsOnly<Runtime> {207	fn min_len() -> usize {208		1209	}210	fn max_len() -> usize {211		100212	}213}214215type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;216217pub struct DealWithFees;218impl OnUnbalanced<NegativeImbalance> for DealWithFees {219	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {220		if let Some(fees) = fees_then_tips.next() {221			// for fees, 100% to treasury222			let mut split = fees.ration(100, 0);223			if let Some(tips) = fees_then_tips.next() {224				// for tips, if any, 100% to treasury225				tips.ration_merge_into(100, 0, &mut split);226			}227			Treasury::on_unbalanced(split.0);228			// Author::on_unbalanced(split.1);229		}230	}231}232233// impl OnUnbalanced<NegativeImbalance> for DealWithFees {234// 	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {235// 		if let Some(fees) = fees_then_tips.next() {236// 			// for fees, 100% to treasury237// 			let mut split = fees.ration(100, 0);238// 			if let Some(tips) = fees_then_tips.next() {239// 				// for tips, if any, 100% to treasury240// 				tips.ration_merge_into(100, 0, &mut split);241// 			}242// 			Treasury::on_unbalanced(split.0);243// 			// Author::on_unbalanced(split.1);244// 		}245// 	}246// }247248/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.249/// This is used to limit the maximal weight of a single extrinsic.250const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);251/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used252/// by  Operational  extrinsics.253const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);254/// We allow for 2 seconds of compute with a 6 second average block time.255const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;256257parameter_types! {258    pub const BlockHashCount: BlockNumber = 2400;259	pub RuntimeBlockLength: BlockLength =260		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);261    pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);262    pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;263	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()264		.base_block(BlockExecutionWeight::get())265		.for_class(DispatchClass::all(), |weights| {266			weights.base_extrinsic = ExtrinsicBaseWeight::get();267		})268		.for_class(DispatchClass::Normal, |weights| {269			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);270		})271		.for_class(DispatchClass::Operational, |weights| {272			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);273			// Operational transactions have some extra reserved space, so that they274			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.275			weights.reserved = Some(276				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT277			);278		})279		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)280		.build_or_panic();281    pub const Version: RuntimeVersion = VERSION;282    pub const SS58Prefix: u8 = 42;283}284285impl system::Config for Runtime {286    /// The basic call filter to use in dispatchable.287    type BaseCallFilter = ();288    /// The identifier used to distinguish between accounts.289    type AccountId = AccountId;290    /// The aggregated dispatch type that is available for extrinsics.291    type Call = Call;292    /// The lookup mechanism to get account ID from whatever is passed in dispatchers.293    type Lookup = IdentityLookup<AccountId>;294    /// The index type for storing how many extrinsics an account has signed.295    type Index = Index;296    /// The index type for blocks.297    type BlockNumber = BlockNumber;298    /// The type for hashing blocks and tries.299    type Hash = Hash;300    /// The hashing algorithm used.301    type Hashing = BlakeTwo256;302    /// The header type.303    type Header = generic::Header<BlockNumber, BlakeTwo256>;304    /// The ubiquitous event type.305    type Event = Event;306    /// The ubiquitous origin type.307    type Origin = Origin;308    /// Maximum number of block number to block hash mappings to keep (oldest pruned first).309    type BlockHashCount = BlockHashCount;310    /// The weight of database operations that the runtime can invoke.311    type DbWeight = RocksDbWeight;312    /// The weight of the overhead invoked on the block import process, independent of the313    /// extrinsics included in that block.314	type BlockWeights = RuntimeBlockWeights;315    /// Version of the runtime.316    type Version = Version;317 	/// This type is being generated by `construct_runtime!`.318    type PalletInfo = PalletInfo;319    /// What to do if a new account is created.320    type OnNewAccount = ();321    /// What to do if an account is fully reaped from the system.322    type OnKilledAccount = ();323    /// The data to be stored in an account.324    type AccountData = pallet_balances::AccountData<Balance>;325	/// Weight information for the extrinsics of this pallet.326    type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;327    328	type BlockLength = RuntimeBlockLength;329	type SS58Prefix = SS58Prefix;330}331332impl pallet_aura::Config for Runtime {333    type AuthorityId = AuraId;334}335336impl pallet_grandpa::Config for Runtime {337	type Event = Event;338	type Call = Call;339340	type KeyOwnerProofSystem = ();341342	type KeyOwnerProof =343		<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;344345	type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(346		KeyTypeId,347		GrandpaId,348	)>>::IdentificationTuple;349350	type HandleEquivocation = ();351352	type WeightInfo = ();353}354355parameter_types! {356    pub const MinimumPeriod: u64 = SLOT_DURATION / 2;357}358359impl pallet_timestamp::Config for Runtime {360	/// A timestamp: milliseconds since the unix epoch.361	type Moment = u64;362	type OnTimestampSet = Aura;363	type MinimumPeriod = MinimumPeriod;364	type WeightInfo = ();365}366367parameter_types! {368    // pub const ExistentialDeposit: u128 = 500;369    pub const ExistentialDeposit: u128 = 0;370	pub const MaxLocks: u32 = 50;371}372373impl pallet_balances::Config for Runtime {374	type MaxLocks = MaxLocks;375	/// The type for recording an account's balance.376	type Balance = Balance;377	/// The ubiquitous event type.378	type Event = Event;379	type DustRemoval = Treasury;380	type ExistentialDeposit = ExistentialDeposit;381	type AccountStore = System;382	type WeightInfo = ();383}384385pub const MICROUNIQUE: Balance = 1_000_000_000;386pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;387pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;388pub const UNIQUE: Balance      = 100 * CENTIUNIQUE;389390pub const fn deposit(items: u32, bytes: u32) -> Balance {391    items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE392}393394parameter_types! {395	pub const TombstoneDeposit: Balance = deposit(396		0,397		sp_std::mem::size_of::<pallet_contracts::ContractInfo<Runtime>>() as u32398	);399	pub const DepositPerContract: Balance = TombstoneDeposit::get();400	pub const DepositPerStorageByte: Balance = deposit(0, 1);401	pub const DepositPerStorageItem: Balance = deposit(1, 0);402	pub RentFraction: Perbill = Perbill::from_rational_approximation(1u32, 30 * DAYS);403	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;404	pub const SignedClaimHandicap: u32 = 2;405	pub const MaxDepth: u32 = 32;406	pub const MaxValueSize: u32 = 16 * 1024;407	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb 408	// The lazy deletion runs inside on_initialize.409	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *410		RuntimeBlockWeights::get().max_block;411	// The weight needed for decoding the queue should be less or equal than a fifth412	// of the overall weight dedicated to the lazy deletion.413	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (414			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -415			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)416		)) / 5) as u32;417}418419420impl pallet_contracts::Config for Runtime {421	type Time = Timestamp;422	type Randomness = RandomnessCollectiveFlip;423	type Currency = Balances;424	type Event = Event;425	type RentPayment = ();426	type SignedClaimHandicap = SignedClaimHandicap;427	type TombstoneDeposit = TombstoneDeposit;428	type DepositPerContract = DepositPerContract;429	type DepositPerStorageByte = DepositPerStorageByte;430	type DepositPerStorageItem = DepositPerStorageItem;431	type RentFraction = RentFraction;432	type SurchargeReward = SurchargeReward;433	type MaxDepth = MaxDepth;434	type MaxValueSize = MaxValueSize;435	type WeightPrice = pallet_transaction_payment::Module<Self>;436	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;437	type ChainExtension = NFTExtension;438	type DeletionQueueDepth = DeletionQueueDepth;439	type DeletionWeightLimit = DeletionWeightLimit;440	type MaxCodeSize = MaxCodeSize;441}442443parameter_types! {444	pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer 445}446447/// Linear implementor of `WeightToFeePolynomial` 448pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);449450impl<T> WeightToFeePolynomial for LinearFee<T> where451	T: BaseArithmetic + From<u32> + Copy + Unsigned452{453	type Balance = T;454455	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {456		smallvec!(WeightToFeeCoefficient {457			coeff_integer: 146_700u32.into(), // Targeting 0.1 Unique per NFT transfer458			coeff_frac: Perbill::zero(),459			negative: false,460			degree: 1,461		})462	}463}464465impl pallet_transaction_payment::Config for Runtime {466	type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees>;467	type TransactionByteFee = TransactionByteFee;468	type WeightToFee = LinearFee<Balance>;469	type FeeMultiplierUpdate = ();470}471472parameter_types! {473	pub const ProposalBond: Permill = Permill::from_percent(5);474	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;475	pub const SpendPeriod: BlockNumber = 5 * MINUTES;476	pub const Burn: Permill = Permill::from_percent(0);477	pub const TipCountdown: BlockNumber = 1 * DAYS;478	pub const TipFindersFee: Percent = Percent::from_percent(20);479	pub const TipReportDepositBase: Balance = 1 * UNIQUE;480	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;481	pub const BountyDepositBase: Balance = 1 * UNIQUE;482	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;483	pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");484	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;485	pub const MaximumReasonLength: u32 = 16384;486	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);487	pub const BountyValueMinimum: Balance = 5 * UNIQUE;488}489490impl pallet_treasury::Config for Runtime {491	type ModuleId = TreasuryModuleId;492	type Currency = Balances;493	type ApproveOrigin = EnsureRoot<AccountId>;494	type RejectOrigin = EnsureRoot<AccountId>;495	type Event = Event;496	type OnSlash = ();497	type ProposalBond = ProposalBond;498	type ProposalBondMinimum = ProposalBondMinimum;499	type SpendPeriod = SpendPeriod;500	type Burn = Burn;501	type BurnDestination = ();502	type SpendFunds = ();503	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;504}505506impl pallet_sudo::Config for Runtime {507    type Event = Event;508    type Call = Call;509}510511parameter_types! {512	pub const MinVestedTransfer: Balance = 10 * UNIQUE;513}514515impl pallet_vesting::Config for Runtime {516	type Event = Event;517	type Currency = Balances;518	type BlockNumberToBalance = ConvertInto;519	type MinVestedTransfer = MinVestedTransfer;520	type WeightInfo = ();521}522523parameter_types! {524	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();525	pub const CollectionCreationPrice: Balance = 100 * UNIQUE;526}527528/// Used for the pallet nft in `./nft.rs`529impl pallet_nft::Config for Runtime {530    type Event = Event;531    type WeightInfo = nft_weights::WeightInfo;532	type Currency = Balances;533	type CollectionCreationPrice = CollectionCreationPrice;534	type TreasuryAccountId = TreasuryAccountId;535}536537/// Reimport pallet inflation538extern crate pallet_inflation;539pub use pallet_inflation::*;540541parameter_types! {542	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied543}544545/// Used for the pallet inflation546impl pallet_inflation::Config for Runtime {547	type Currency = Balances;548	type TreasuryAccountId = TreasuryAccountId;549	type InflationBlockInterval = InflationBlockInterval;550}551552construct_runtime!(553    pub enum Runtime where554        Block = Block,555        NodeBlock = opaque::Block,556        UncheckedExtrinsic = UncheckedExtrinsic557    {558        System: system::{Module, Call, Config, Storage, Event<T>},559        RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},560        Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},561        Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},562        Aura: pallet_aura::{Module, Config<T> },563        Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},564        Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},565        TransactionPayment: pallet_transaction_payment::{Module, Storage},566        Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},567        Inflation: pallet_inflation::{Module, Call, Storage},568        Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},569        Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},570        Vesting: pallet_vesting::{Module, Call, Config<T>, Storage, Event<T>},571    }572);573574/// The address format for describing accounts.575pub type Address = AccountId;576/// Block header type as expected by this runtime.577pub type Header = generic::Header<BlockNumber, BlakeTwo256>;578/// Block type as expected by this runtime.579pub type Block = generic::Block<Header, UncheckedExtrinsic>;580/// A Block signed with a Justification581pub type SignedBlock = generic::SignedBlock<Block>;582/// BlockId type as expected by this runtime.583pub type BlockId = generic::BlockId<Block>;584/// The SignedExtension to the basic transaction logic.585pub type SignedExtra = (586    system::CheckSpecVersion<Runtime>,587    system::CheckTxVersion<Runtime>,588    system::CheckGenesis<Runtime>,589    system::CheckEra<Runtime>,590    system::CheckNonce<Runtime>,591    system::CheckWeight<Runtime>,592    pallet_nft::ChargeTransactionPayment<Runtime>,593);594/// Unchecked extrinsic type as expected by this runtime.595pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;596/// Extrinsic type that has already been checked.597pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;598/// Executive: handles dispatch to the various modules.599pub type Executive =600    frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;601602impl_runtime_apis! {603604	impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>605		for Runtime606	{607		fn call(608			origin: AccountId,609			dest: AccountId,610			value: Balance,611			gas_limit: u64,612			input_data: Vec<u8>,613		) -> pallet_contracts_primitives::ContractExecResult {614			Contracts::bare_call(origin, dest, value, gas_limit, input_data)615		}616617		fn get_storage(618			address: AccountId,619			key: [u8; 32],620		) -> pallet_contracts_primitives::GetStorageResult {621			Contracts::get_storage(address, key)622		}623624		fn rent_projection(625			address: AccountId,626		) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {627			Contracts::rent_projection(address)628		}629	}630631    impl sp_api::Core<Block> for Runtime {632        fn version() -> RuntimeVersion {633            VERSION634        }635636        fn execute_block(block: Block) {637            Executive::execute_block(block)638        }639640        fn initialize_block(header: &<Block as BlockT>::Header) {641            Executive::initialize_block(header)642        }643    }644645    impl sp_api::Metadata<Block> for Runtime {646        fn metadata() -> OpaqueMetadata {647            Runtime::metadata().into()648        }649    }650651    impl sp_block_builder::BlockBuilder<Block> for Runtime {652        fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {653            Executive::apply_extrinsic(extrinsic)654        }655656        fn finalize_block() -> <Block as BlockT>::Header {657            Executive::finalize_block()658        }659660        fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {661            data.create_extrinsics()662        }663664        fn check_inherents(665            block: Block,666            data: sp_inherents::InherentData,667        ) -> sp_inherents::CheckInherentsResult {668            data.check_extrinsics(&block)669        }670671        fn random_seed() -> <Block as BlockT>::Hash {672            RandomnessCollectiveFlip::random_seed()673        }674    }675676    impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {677        fn validate_transaction(678            source: TransactionSource,679            tx: <Block as BlockT>::Extrinsic,680        ) -> TransactionValidity {681            Executive::validate_transaction(source, tx)682        }683    }684685    impl sp_offchain::OffchainWorkerApi<Block> for Runtime {686        fn offchain_worker(header: &<Block as BlockT>::Header) {687            Executive::offchain_worker(header)688        }689    }690691    impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {692        fn slot_duration() -> u64 {693            Aura::slot_duration()694        }695696        fn authorities() -> Vec<AuraId> {697            Aura::authorities()698        }699    }700701    impl sp_session::SessionKeys<Block> for Runtime {702        fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {703            opaque::SessionKeys::generate(seed)704        }705706        fn decode_session_keys(707            encoded: Vec<u8>,708        ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {709            opaque::SessionKeys::decode_into_raw_public_keys(&encoded)710        }711    }712713	impl fg_primitives::GrandpaApi<Block> for Runtime {714		fn grandpa_authorities() -> GrandpaAuthorityList {715			Grandpa::grandpa_authorities()716		}717718		fn submit_report_equivocation_unsigned_extrinsic(719			_equivocation_proof: fg_primitives::EquivocationProof<720				<Block as BlockT>::Hash,721				NumberFor<Block>,722			>,723			_key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,724		) -> Option<()> {725			None726		}727728		fn generate_key_ownership_proof(729			_set_id: fg_primitives::SetId,730			_authority_id: GrandpaId,731		) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {732			// NOTE: this is the only implementation possible since we've733			// defined our key owner proof type as a bottom type (i.e. a type734			// with no values).735			None736		}737    }738    739	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {740		fn account_nonce(account: AccountId) -> Index {741			System::account_nonce(account)742		}743	}744745	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {746		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {747			TransactionPayment::query_info(uxt, len)748		}749		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {750			TransactionPayment::query_fee_details(uxt, len)751		}752	}753754    #[cfg(feature = "runtime-benchmarks")]755	impl frame_benchmarking::Benchmark<Block> for Runtime {756		fn dispatch_benchmark(757			config: frame_benchmarking::BenchmarkConfig758		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {759			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};760761			let whitelist: Vec<TrackedStorageKey> = vec![762				// Alice account763				hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),764				// // Total Issuance765				// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),766				// // Execution Phase767				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),768				// // Event Count769				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),770				// // System Events771				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),772            ];773774			let mut batches = Vec::<BenchmarkBatch>::new();775			let params = (&config, &whitelist);776777			add_benchmark!(params, batches, pallet_nft, Nft);778			add_benchmark!(params, batches, pallet_inflation, Inflation);779780			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }781			Ok(batches)782		}783	}784}
after · runtime/src/lib.rs
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.78#![cfg_attr(not(feature = "std"), no_std)]9// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.10#![recursion_limit = "256"]1112// Make the WASM binary available.13#[cfg(feature = "std")]14include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1516use sp_api::impl_runtime_apis;17use sp_core::{ crypto::KeyTypeId, crypto::Public, OpaqueMetadata };18use sp_runtime::{19	BuildStorage,20    Permill, Perbill, Percent,21    ModuleId,22    create_runtime_str, generic, impl_opaque_keys,23    traits::{24        AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertInto, IdentifyAccount, 25        IdentityLookup, NumberFor, Verify, AccountIdConversion,26    },27    transaction_validity::{TransactionSource, TransactionValidity},28    ApplyExtrinsicResult, MultiSignature,29};3031use sp_std::prelude::*;3233#[cfg(feature = "std")]34use sp_version::NativeVersion;35use sp_version::RuntimeVersion;36pub use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment, CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};37// A few exports that help ease life for downstream crates.38pub use pallet_balances::Call as BalancesCall;39pub use pallet_contracts::{Schedule as ContractsSchedule };40pub use frame_support::{41    construct_runtime,42    dispatch::DispatchResult,43    parameter_types,44    StorageValue,45    traits::{46        All, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier, OnUnbalanced, Randomness47    },48    weights::{49        constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},50        DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,51        WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients52    },53};54use pallet_contracts::weights::WeightInfo;55// #[cfg(any(feature = "std", test))]56use frame_system::{57    self as system,58    EnsureRoot, 59	limits::{BlockWeights, BlockLength},60};61use sp_std::{prelude::*, marker::PhantomData};62use sp_arithmetic::{traits::{BaseArithmetic, Unsigned}};63use smallvec::smallvec;6465pub use pallet_timestamp::Call as TimestampCall;6667// Polkadot imports68use polkadot_parachain::primitives::Sibling;69use xcm::v0::{Junction, MultiLocation, NetworkId};70use xcm_builder::{71	AccountId32Aliases, CurrencyAdapter, LocationInverter, ParentIsDefault, RelayChainAsNative,72	SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,73	SovereignSignedViaLocation, FixedRateOfConcreteFungible, EnsureXcmOrigin,74	AllowTopLevelPaidExecutionFrom, TakeWeightCredit, FixedWeightBounds, IsConcrete, NativeAsset,75	AllowUnpaidExecutionFrom, ParentAsSuperuser,76};77use xcm_executor::{Config, XcmExecutor};787980mod chain_extension;81use crate::chain_extension::{ NFTExtension, Imbalance };8283/// Struct that handles the conversion of Balance -> `u64`. This is used for84/// staking's election calculation.85pub struct CurrencyToVoteHandler;8687impl CurrencyToVoteHandler {88	fn factor() -> Balance {89		(Balances::total_issuance() / u64::max_value() as Balance).max(1)90	}91}9293impl Convert<Balance, u64> for CurrencyToVoteHandler {94	fn convert(x: Balance) -> u64 {95		(x / Self::factor()) as u6496	}97}9899impl Convert<u128, Balance> for CurrencyToVoteHandler {100	fn convert(x: u128) -> Balance {101		x * Self::factor()102	}103}104105/// Re-export a nft pallet106/// TODO: Check this re-export. Is this safe and good style?107extern crate pallet_nft;108pub use pallet_nft::*;109110/// An index to a block.111pub type BlockNumber = u32;112113/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.114pub type Signature = MultiSignature;115116/// Some way of identifying an account on the chain. We intentionally make it equivalent117/// to the public key of our transaction signing scheme.118pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;119120/// The type for looking up accounts. We don't expect more than 4 billion of them, but you121/// never know...122pub type AccountIndex = u32;123124/// Balance of an account.125pub type Balance = u128;126127/// Index of a transaction in the chain.128pub type Index = u32;129130/// A hash of some data used by the chain.131pub type Hash = sp_core::H256;132133/// Digest item type.134pub type DigestItem = generic::DigestItem<Hash>;135136mod nft_weights;137138/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know139/// the specifics of the runtime. They can then be made to be agnostic over specific formats140/// of data like extrinsics, allowing for them to continue syncing the network through upgrades141/// to even the core data structures.142pub mod opaque {143    use super::*;144145    pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;146147    /// Opaque block header type.148    pub type Header = generic::Header<BlockNumber, BlakeTwo256>;149    /// Opaque block type.150    pub type Block = generic::Block<Header, UncheckedExtrinsic>;151    /// Opaque block identifier type.152    pub type BlockId = generic::BlockId<Block>;153154    impl_opaque_keys! {155        pub struct SessionKeys {}156    }157}158159/// This runtime version.160pub const VERSION: RuntimeVersion = RuntimeVersion {161    spec_name: create_runtime_str!("nft"),162    impl_name: create_runtime_str!("nft"),163    authoring_version: 1,164    spec_version: 3,165    impl_version: 1,166    apis: RUNTIME_API_VERSIONS,167    transaction_version: 1,168};169170pub const MILLISECS_PER_BLOCK: u64 = 6000;171172pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;173174// These time units are defined in number of blocks.175pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);176pub const HOURS: BlockNumber = MINUTES * 60;177pub const DAYS: BlockNumber = HOURS * 24;178179#[derive(codec::Encode, codec::Decode)]180pub enum XCMPMessage<XAccountId, XBalance> {181    /// Transfer tokens to the given account from the Parachain account.182    TransferToken(XAccountId, XBalance),183}184185/// The version information used to identify this runtime when compiled natively.186#[cfg(feature = "std")]187pub fn native_version() -> NativeVersion {188    NativeVersion {189        runtime_version: VERSION,190        can_author_with: Default::default(),191    }192}193194type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;195196pub struct DealWithFees;197impl OnUnbalanced<NegativeImbalance> for DealWithFees {198	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {199		if let Some(fees) = fees_then_tips.next() {200			// for fees, 100% to treasury201			let mut split = fees.ration(100, 0);202			if let Some(tips) = fees_then_tips.next() {203				// for tips, if any, 100% to treasury204				tips.ration_merge_into(100, 0, &mut split);205			}206			Treasury::on_unbalanced(split.0);207			// Author::on_unbalanced(split.1);208		}209	}210}211212// impl OnUnbalanced<NegativeImbalance> for DealWithFees {213// 	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {214// 		if let Some(fees) = fees_then_tips.next() {215// 			// for fees, 100% to treasury216// 			let mut split = fees.ration(100, 0);217// 			if let Some(tips) = fees_then_tips.next() {218// 				// for tips, if any, 100% to treasury219// 				tips.ration_merge_into(100, 0, &mut split);220// 			}221// 			Treasury::on_unbalanced(split.0);222// 			// Author::on_unbalanced(split.1);223// 		}224// 	}225// }226227/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.228/// This is used to limit the maximal weight of a single extrinsic.229const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);230/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used231/// by  Operational  extrinsics.232const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);233/// We allow for 2 seconds of compute with a 6 second average block time.234const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;235236parameter_types! {237    pub const BlockHashCount: BlockNumber = 2400;238	pub RuntimeBlockLength: BlockLength =239		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);240    pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);241    pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;242	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()243		.base_block(BlockExecutionWeight::get())244		.for_class(DispatchClass::all(), |weights| {245			weights.base_extrinsic = ExtrinsicBaseWeight::get();246		})247		.for_class(DispatchClass::Normal, |weights| {248			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);249		})250		.for_class(DispatchClass::Operational, |weights| {251			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);252			// Operational transactions have some extra reserved space, so that they253			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.254			weights.reserved = Some(255				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT256			);257		})258		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)259		.build_or_panic();260    pub const Version: RuntimeVersion = VERSION;261    pub const SS58Prefix: u8 = 42;262}263264impl system::Config for Runtime {265    /// The data to be stored in an account.266    type AccountData = pallet_balances::AccountData<Balance>;267    /// The identifier used to distinguish between accounts.268    type AccountId = AccountId;269    /// The basic call filter to use in dispatchable.270    type BaseCallFilter = ();271    /// Maximum number of block number to block hash mappings to keep (oldest pruned first).272    type BlockHashCount = BlockHashCount;273    /// The maximum length of a block (in bytes).274	type BlockLength = RuntimeBlockLength;275    /// The index type for blocks.276    type BlockNumber = BlockNumber;277    /// The weight of the overhead invoked on the block import process, independent of the278    /// extrinsics included in that block.279	type BlockWeights = RuntimeBlockWeights;280    /// The aggregated dispatch type that is available for extrinsics.281    type Call = Call;282    /// The weight of database operations that the runtime can invoke.283    type DbWeight = RocksDbWeight;284    /// The ubiquitous event type.285    type Event = Event;286    /// The type for hashing blocks and tries.287    type Hash = Hash;288	/// The hashing algorithm used.289    type Hashing = BlakeTwo256;290    /// The header type.291    type Header = generic::Header<BlockNumber, BlakeTwo256>;292    /// The index type for storing how many extrinsics an account has signed.293    type Index = Index;294    /// The lookup mechanism to get account ID from whatever is passed in dispatchers.295    type Lookup = IdentityLookup<AccountId>;296    /// What to do if an account is fully reaped from the system.297    type OnKilledAccount = ();298    /// What to do if a new account is created.299    type OnNewAccount = ();300    type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;301    /// The ubiquitous origin type.302    type Origin = Origin;303 	/// This type is being generated by `construct_runtime!`.304    type PalletInfo = PalletInfo;305    /// This is used as an identifier of the chain. 42 is the generic substrate prefix.306	type SS58Prefix = SS58Prefix;307	/// Weight information for the extrinsics of this pallet.308    type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;309    /// Version of the runtime.310    type Version = Version;311}312313parameter_types! {314    pub const MinimumPeriod: u64 = SLOT_DURATION / 2;315}316317impl pallet_timestamp::Config for Runtime {318	/// A timestamp: milliseconds since the unix epoch.319	type Moment = u64;320	type OnTimestampSet = Aura;321	type MinimumPeriod = MinimumPeriod;322	type WeightInfo = ();323}324325parameter_types! {326    // pub const ExistentialDeposit: u128 = 500;327    pub const ExistentialDeposit: u128 = 0;328	pub const MaxLocks: u32 = 50;329}330331impl pallet_balances::Config for Runtime {332	type MaxLocks = MaxLocks;333	/// The type for recording an account's balance.334	type Balance = Balance;335	/// The ubiquitous event type.336	type Event = Event;337	type DustRemoval = Treasury;338	type ExistentialDeposit = ExistentialDeposit;339	type AccountStore = System;340	type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;341}342343pub const MICROUNIQUE: Balance = 1_000_000_000;344pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;345pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;346pub const UNIQUE: Balance      = 100 * CENTIUNIQUE;347348pub const fn deposit(items: u32, bytes: u32) -> Balance {349    items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE350}351352parameter_types! {353	pub const TombstoneDeposit: Balance = deposit(354		0,355		sp_std::mem::size_of::<pallet_contracts::ContractInfo<Runtime>>() as u32356	);357	pub const DepositPerContract: Balance = TombstoneDeposit::get();358	pub const DepositPerStorageByte: Balance = deposit(0, 1);359	pub const DepositPerStorageItem: Balance = deposit(1, 0);360	pub RentFraction: Perbill = Perbill::from_rational_approximation(1u32, 30 * DAYS);361	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;362	pub const SignedClaimHandicap: u32 = 2;363	pub const MaxDepth: u32 = 32;364	pub const MaxValueSize: u32 = 16 * 1024;365	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb 366	// The lazy deletion runs inside on_initialize.367	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *368		RuntimeBlockWeights::get().max_block;369	// The weight needed for decoding the queue should be less or equal than a fifth370	// of the overall weight dedicated to the lazy deletion.371	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (372			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -373			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)374		)) / 5) as u32;375}376377378impl pallet_contracts::Config for Runtime {379	type Time = Timestamp;380	type Randomness = RandomnessCollectiveFlip;381	type Currency = Balances;382	type Event = Event;383	type RentPayment = ();384	type SignedClaimHandicap = SignedClaimHandicap;385	type TombstoneDeposit = TombstoneDeposit;386	type DepositPerContract = DepositPerContract;387	type DepositPerStorageByte = DepositPerStorageByte;388	type DepositPerStorageItem = DepositPerStorageItem;389	type RentFraction = RentFraction;390	type SurchargeReward = SurchargeReward;391	type MaxDepth = MaxDepth;392	type MaxValueSize = MaxValueSize;393	type WeightPrice = pallet_transaction_payment::Module<Self>;394	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;395	type ChainExtension = NFTExtension;396	type DeletionQueueDepth = DeletionQueueDepth;397	type DeletionWeightLimit = DeletionWeightLimit;398	type MaxCodeSize = MaxCodeSize;399}400401parame	ter_types! {402	pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer 403}404405/// Linear implementor of `WeightToFeePolynomial` 406pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);407408impl<T> WeightToFeePolynomial for LinearFee<T> where409	T: BaseArithmetic + From<u32> + Copy + Unsigned410{411	type Balance = T;412413	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {414		smallvec!(WeightToFeeCoefficient {415			coeff_integer: 146_700u32.into(), // Targeting 0.1 Unique per NFT transfer416			coeff_frac: Perbill::zero(),417			negative: false,418			degree: 1,419		})420	}421}422423impl pallet_transaction_payment::Config for Runtime {424	type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees>;425	type TransactionByteFee = TransactionByteFee;426	type WeightToFee = LinearFee<Balance>;427	type FeeMultiplierUpdate = ();428}429430parameter_types! {431	pub const ProposalBond: Permill = Permill::from_percent(5);432	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;433	pub const SpendPeriod: BlockNumber = 5 * MINUTES;434	pub const Burn: Permill = Permill::from_percent(0);435	pub const TipCountdown: BlockNumber = 1 * DAYS;436	pub const TipFindersFee: Percent = Percent::from_percent(20);437	pub const TipReportDepositBase: Balance = 1 * UNIQUE;438	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;439	pub const BountyDepositBase: Balance = 1 * UNIQUE;440	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;441	pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");442	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;443	pub const MaximumReasonLength: u32 = 16384;444	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);445	pub const BountyValueMinimum: Balance = 5 * UNIQUE;446}447448impl pallet_treasury::Config for Runtime {449	type ModuleId = TreasuryModuleId;450	type Currency = Balances;451	type ApproveOrigin = EnsureRoot<AccountId>;452	type RejectOrigin = EnsureRoot<AccountId>;453	type Event = Event;454	type OnSlash = ();455	type ProposalBond = ProposalBond;456	type ProposalBondMinimum = ProposalBondMinimum;457	type SpendPeriod = SpendPeriod;458	type Burn = Burn;459	type BurnDestination = ();460	type SpendFunds = ();461	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;462}463464impl pallet_sudo::Config for Runtime {465    type Event = Event;466    type Call = Call;467}468469parameter_types! {470	pub const MinVestedTransfer: Balance = 10 * UNIQUE;471}472473impl pallet_vesting::Config for Runtime {474	type Event = Event;475	type Currency = Balances;476	type BlockNumberToBalance = ConvertInto;477	type MinVestedTransfer = MinVestedTransfer;478	type WeightInfo = ();479}480481parameter_types! {482	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;483}484485impl cumulus_pallet_parachain_system::Config for Runtime {486	type Event = Event;487	type OnValidationData = ();488	type SelfParaId = parachain_info::Module<Runtime>;489	type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<490		MaxDownwardMessageWeight,491		XcmExecutor<XcmConfig>,492		Call,493	>;494	type OutboundXcmpMessageSource = XcmpQueue;495	type XcmpMessageHandler = XcmpQueue;496	type ReservedXcmpWeight = ReservedXcmpWeight;497}498499impl parachain_info::Config for Runtime {}500501parameter_types! {502	pub const RococoLocation: MultiLocation = MultiLocation::X1(Junction::Parent);503	pub const RococoNetwork: NetworkId = NetworkId::Polkadot;504	pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();505	pub Ancestry: MultiLocation = Junction::Parachain {506		id: ParachainInfo::parachain_id().into()507	}.into();508}509510/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used511/// when determining ownership of accounts for asset transacting and when attempting to use XCM512/// `Transact` in order to determine the dispatch Origin.513pub type LocationToAccountId = (514	// The parent (Relay-chain) origin converts to the default `AccountId`.515	ParentIsDefault<AccountId>,516	// Sibling parachain origins convert to AccountId via the `ParaId::into`.517	SiblingParachainConvertsVia<Sibling, AccountId>,518	// Straight up local `AccountId32` origins just alias directly to `AccountId`.519	AccountId32Aliases<RococoNetwork, AccountId>,520);521522/// Means for transacting assets on this chain.523pub type LocalAssetTransactor = CurrencyAdapter<524	// Use this currency:525	Balances,526	// Use this currency when it is a fungible asset matching the given location or name:527	IsConcrete<RococoLocation>,528	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:529	LocationToAccountId,530	// Our chain's account ID type (we can't get away without mentioning it explicitly):531	AccountId,532>;533534/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,535/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can536/// biases the kind of local `Origin` it will become.537pub type XcmOriginToTransactDispatchOrigin = (538	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location539	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for540	// foreign chains who want to have a local sovereign account on this chain which they control.541	SovereignSignedViaLocation<LocationToAccountId, Origin>,542	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when543	// recognised.544	RelayChainAsNative<RelayChainOrigin, Origin>,545	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when546	// recognised.547	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,548	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a549	// transaction from the Root origin.550	ParentAsSuperuser<Origin>,551	// Native signed account converter; this just converts an `AccountId32` origin into a normal552	// `Origin::Signed` origin of the same 32-byte value.553	SignedAccountId32AsNative<RococoNetwork, Origin>,554);555556parameter_types! {557	pub UnitWeightCost: Weight = 1_000;558}559560parameter_types! {561	// 1_000_000_000_000 => 1 unit of asset for 1 unit of Weight.562	// TODO: Should take the actual weight price. This is just 1_000 ROC per second of weight.563	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::X1(Junction::Parent), 1_000);564	pub AllowUnpaidFrom: Vec<MultiLocation> = vec![ MultiLocation::X1(Junction::Parent) ];565}566567pub type Barrier = (568	TakeWeightCredit,569	AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,570	AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>,	// <- Parent gets free execution571);572573574pub struct XcmConfig;575impl Config for XcmConfig {576	type Call = Call;577	type XcmSender = XcmRouter;578	// How to withdraw and deposit an asset.579	type AssetTransactor = LocalAssetTransactor;580	type OriginConverter = XcmOriginToTransactDispatchOrigin;581	type IsReserve = NativeAsset;582	type IsTeleporter = NativeAsset;	// <- should be enough to allow teleportation of ROC583	type LocationInverter = LocationInverter<Ancestry>;584	type Barrier = Barrier;585	type Weigher = FixedWeightBounds<UnitWeightCost, Call>;586	type Trader = FixedRateOfConcreteFungible<WeightPrice>;587	type ResponseHandler = ();	// Don't handle responses for now.588}589590parameter_types! {591	pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;592}593594/// No local origins on this chain are allowed to dispatch XCM sends/executions.595pub type LocalOriginToLocation = ();596597/// The means for routing XCM messages which are not for local execution into the right message598/// queues.599pub type XcmRouter = (600	// Two routers - use UMP to communicate with the relay chain:601	cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,602	// ..and XCMP to communicate with the sibling chains.603	XcmpQueue,604);605606impl pallet_xcm::Config for Runtime {607	type Event = Event;608	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;609	type XcmRouter = XcmRouter;610	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;611	type XcmExecutor = XcmExecutor<XcmConfig>;612}613614impl cumulus_pallet_xcm::Config for Runtime {}615616impl cumulus_pallet_xcmp_queue::Config for Runtime {617	type Event = Event;618	type XcmExecutor = XcmExecutor<XcmConfig>;619	type ChannelInfo = ParachainSystem;620}621622parameter_types! {623	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();624	pub const CollectionCreationPrice: Balance = 100 * UNIQUE;625}626627/// Used for the pallet nft in `./nft.rs`628impl pallet_nft::Config for Runtime {629    type Event = Event;630    type WeightInfo = nft_weights::WeightInfo;631	type Currency = Balances;632	type CollectionCreationPrice = CollectionCreationPrice;633	type TreasuryAccountId = TreasuryAccountId;634}635636/// Reimport pallet inflation637extern crate pallet_inflation;638pub use pallet_inflation::*;639640parameter_types! {641	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied642}643644/// Used for the pallet inflation645impl pallet_inflation::Config for Runtime {646	type Currency = Balances;647	type TreasuryAccountId = TreasuryAccountId;648	type InflationBlockInterval = InflationBlockInterval;649}650651construct_runtime!(652    pub enum Runtime where653        Block = Block,654        NodeBlock = opaque::Block,655        UncheckedExtrinsic = UncheckedExtrinsic656    {657        Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},658        Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},659		CumulusXcm: cumulus_pallet_xcm::{Pallet, Origin},660		ParachainInfo: parachain_info::{Pallet, Storage, Config},661		ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>},662		PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin},663		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},664        Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},665        System: system::{Module, Call, Config, Storage, Event<T>},666        Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},667        TransactionPayment: pallet_transaction_payment::{Module, Storage},668        Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},669        Vesting: pallet_vesting::{Module, Call, Config<T>, Storage, Event<T>},670		XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>},671672        Inflation: pallet_inflation::{Module, Call, Storage},673        Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},674    }675);676677/// The address format for describing accounts.678pub type Address = AccountId;679/// Block header type as expected by this runtime.680pub type Header = generic::Header<BlockNumber, BlakeTwo256>;681/// Block type as expected by this runtime.682pub type Block = generic::Block<Header, UncheckedExtrinsic>;683/// A Block signed with a Justification684pub type SignedBlock = generic::SignedBlock<Block>;685/// BlockId type as expected by this runtime.686pub type BlockId = generic::BlockId<Block>;687/// The SignedExtension to the basic transaction logic.688pub type SignedExtra = (689    system::CheckSpecVersion<Runtime>,690    system::CheckTxVersion<Runtime>,691    system::CheckGenesis<Runtime>,692    system::CheckEra<Runtime>,693    system::CheckNonce<Runtime>,694    system::CheckWeight<Runtime>,695    pallet_nft::ChargeTransactionPayment<Runtime>,696);697/// Unchecked extrinsic type as expected by this runtime.698pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;699/// Extrinsic type that has already been checked.700pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;701/// Executive: handles dispatch to the various modules.702pub type Executive =703    frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;704705impl_runtime_apis! {706    impl sp_api::Core<Block> for Runtime {707        fn version() -> RuntimeVersion {708            VERSION709        }710711        fn execute_block(block: Block) {712            Executive::execute_block(block)713        }714715        fn initialize_block(header: &<Block as BlockT>::Header) {716            Executive::initialize_block(header)717        }718    }719720    impl sp_api::Metadata<Block> for Runtime {721        fn metadata() -> OpaqueMetadata {722            Runtime::metadata().into()723        }724    }725726    impl sp_block_builder::BlockBuilder<Block> for Runtime {727        fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {728            Executive::apply_extrinsic(extrinsic)729        }730731        fn finalize_block() -> <Block as BlockT>::Header {732            Executive::finalize_block()733        }734735        fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {736            data.create_extrinsics()737        }738739        fn check_inherents(740            block: Block,741            data: sp_inherents::InherentData,742        ) -> sp_inherents::CheckInherentsResult {743            data.check_extrinsics(&block)744        }745746        fn random_seed() -> <Block as BlockT>::Hash {747            RandomnessCollectiveFlip::random_seed()748        }749    }750751    impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {752        fn validate_transaction(753            source: TransactionSource,754            tx: <Block as BlockT>::Extrinsic,755        ) -> TransactionValidity {756            Executive::validate_transaction(source, tx)757        }758    }759760    impl sp_offchain::OffchainWorkerApi<Block> for Runtime {761        fn offchain_worker(header: &<Block as BlockT>::Header) {762            Executive::offchain_worker(header)763        }764    }765766    impl sp_session::SessionKeys<Block> for Runtime {767        fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {768            opaque::SessionKeys::generate(seed)769        }770771        fn decode_session_keys(772            encoded: Vec<u8>,773        ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {774            opaque::SessionKeys::decode_into_raw_public_keys(&encoded)775        }776    }777778	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {779		fn account_nonce(account: AccountId) -> Index {780			System::account_nonce(account)781		}782	}783784	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {785		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {786			TransactionPayment::query_info(uxt, len)787		}788		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {789			TransactionPayment::query_fee_details(uxt, len)790		}791	}792793	impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>794		for Runtime795	{796		fn call(797			origin: AccountId,798			dest: AccountId,799			value: Balance,800			gas_limit: u64,801			input_data: Vec<u8>,802		) -> pallet_contracts_primitives::ContractExecResult {803			Contracts::bare_call(origin, dest, value, gas_limit, input_data)804		}805806		fn get_storage(807			address: AccountId,808			key: [u8; 32],809		) -> pallet_contracts_primitives::GetStorageResult {810			Contracts::get_storage(address, key)811		}812813		fn rent_projection(814			address: AccountId,815		) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {816			Contracts::rent_projection(address)817		}818	}819820    #[cfg(feature = "runtime-benchmarks")]821	impl frame_benchmarking::Benchmark<Block> for Runtime {822		fn dispatch_benchmark(823			config: frame_benchmarking::BenchmarkConfig824		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {825			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};826827			let whitelist: Vec<TrackedStorageKey> = vec![828				// Alice account829				hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),830				// // Total Issuance831				// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),832				// // Execution Phase833				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),834				// // Event Count835				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),836				// // System Events837				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),838            ];839840			let mut batches = Vec::<BenchmarkBatch>::new();841			let params = (&config, &whitelist);842843			add_benchmark!(params, batches, pallet_nft, Nft);844			add_benchmark!(params, batches, pallet_inflation, Inflation);845846			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }847			Ok(batches)848		}849	}850}