git.delta.rocks / unique-network / refs/commits / 8121b0fc537f

difftreelog

source

runtime/src/lib.rs32.0 KiBsourcehistory
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, OpaqueMetadata };18// #[cfg(any(feature = "std", test))]19// pub use sp_runtime::BuildStorage;20use sp_runtime::traits::{21	AccountIdLookup, AccountIdConversion, BlakeTwo256, Block as BlockT, ConvertInto, IdentifyAccount, Verify,22};23use sp_runtime::{24    Permill, Perbill, Percent,25    create_runtime_str, generic, impl_opaque_keys,26    transaction_validity::{TransactionSource, TransactionValidity},27    ApplyExtrinsicResult, MultiSignature,28};2930use sp_std::prelude::*;3132#[cfg(feature = "std")]33use sp_version::NativeVersion;34use sp_version::RuntimeVersion;35pub use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo};36// A few exports that help ease life for downstream crates.37pub use pallet_balances::Call as BalancesCall;38pub use frame_support::{39    construct_runtime,40	match_type,41    dispatch::DispatchResult,42	PalletId,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_arithmetic::{traits::{BaseArithmetic, Unsigned}};62use smallvec::smallvec;6364pub use pallet_timestamp::Call as TimestampCall;65pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;6667// Polkadot imports68use pallet_xcm::XcmPassthrough;69use polkadot_parachain::primitives::Sibling;70use xcm::v0::Xcm;71use xcm::v0::{BodyId, Junction::*, MultiAsset, MultiLocation, MultiLocation::*, NetworkId};72use xcm_builder::{73	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,74	EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,75	ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,76	SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,77	SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,78};79use xcm_executor::{Config, XcmExecutor};808182mod chain_extension;83use crate::chain_extension::{ NFTExtension, Imbalance };8485/// Re-export a nft pallet86/// TODO: Check this re-export. Is this safe and good style?87extern crate pallet_nft;88pub use pallet_nft::*;8990/// An index to a block.91pub type BlockNumber = u32;9293/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.94pub type Signature = MultiSignature;9596/// Some way of identifying an account on the chain. We intentionally make it equivalent97/// to the public key of our transaction signing scheme.98pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;99100/// The type for looking up accounts. We don't expect more than 4 billion of them, but you101/// never know...102pub type AccountIndex = u32;103104/// Balance of an account.105pub type Balance = u128;106107/// Index of a transaction in the chain.108pub type Index = u32;109110/// A hash of some data used by the chain.111pub type Hash = sp_core::H256;112113/// Digest item type.114pub type DigestItem = generic::DigestItem<Hash>;115116mod nft_weights;117118/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know119/// the specifics of the runtime. They can then be made to be agnostic over specific formats120/// of data like extrinsics, allowing for them to continue syncing the network through upgrades121/// to even the core data structures.122pub mod opaque {123    use super::*;124125    pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;126127    /// Opaque block type.128    pub type Block = generic::Block<Header, UncheckedExtrinsic>;129130    pub type SessionHandlers = ();131132	impl_opaque_keys! {133        pub struct SessionKeys {}134    }135}136137/// This runtime version.138pub const VERSION: RuntimeVersion = RuntimeVersion {139    spec_name: create_runtime_str!("nft"),140    impl_name: create_runtime_str!("nft"),141    authoring_version: 1,142    spec_version: 3,143    impl_version: 1,144    apis: RUNTIME_API_VERSIONS,145    transaction_version: 1,146};147148pub const MILLISECS_PER_BLOCK: u64 = 12000;149150pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;151152// These time units are defined in number of blocks.153pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);154pub const HOURS: BlockNumber = MINUTES * 60;155pub const DAYS: BlockNumber = HOURS * 24;156157#[derive(codec::Encode, codec::Decode)]158pub enum XCMPMessage<XAccountId, XBalance> {159    /// Transfer tokens to the given account from the Parachain account.160    TransferToken(XAccountId, XBalance),161}162163/// The version information used to identify this runtime when compiled natively.164#[cfg(feature = "std")]165pub fn native_version() -> NativeVersion {166    NativeVersion {167        runtime_version: VERSION,168        can_author_with: Default::default(),169    }170}171172type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;173174pub struct DealWithFees;175impl OnUnbalanced<NegativeImbalance> for DealWithFees {176	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {177		if let Some(fees) = fees_then_tips.next() {178			// for fees, 100% to treasury179			let mut split = fees.ration(100, 0);180			if let Some(tips) = fees_then_tips.next() {181				// for tips, if any, 100% to treasury182				tips.ration_merge_into(100, 0, &mut split);183			}184			Treasury::on_unbalanced(split.0);185			// Author::on_unbalanced(split.1);186		}187	}188}189190// impl OnUnbalanced<NegativeImbalance> for DealWithFees {191// 	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {192// 		if let Some(fees) = fees_then_tips.next() {193// 			// for fees, 100% to treasury194// 			let mut split = fees.ration(100, 0);195// 			if let Some(tips) = fees_then_tips.next() {196// 				// for tips, if any, 100% to treasury197// 				tips.ration_merge_into(100, 0, &mut split);198// 			}199// 			Treasury::on_unbalanced(split.0);200// 			// Author::on_unbalanced(split.1);201// 		}202// 	}203// }204205/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.206/// This is used to limit the maximal weight of a single extrinsic.207const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);208/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used209/// by  Operational  extrinsics.210const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);211/// We allow for 2 seconds of compute with a 6 second average block time.212const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;213214parameter_types! {215    pub const BlockHashCount: BlockNumber = 2400;216	pub RuntimeBlockLength: BlockLength =217		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);218    pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);219    pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;220	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()221		.base_block(BlockExecutionWeight::get())222		.for_class(DispatchClass::all(), |weights| {223			weights.base_extrinsic = ExtrinsicBaseWeight::get();224		})225		.for_class(DispatchClass::Normal, |weights| {226			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);227		})228		.for_class(DispatchClass::Operational, |weights| {229			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);230			// Operational transactions have some extra reserved space, so that they231			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.232			weights.reserved = Some(233				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT234			);235		})236		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)237		.build_or_panic();238    pub const Version: RuntimeVersion = VERSION;239    pub const SS58Prefix: u8 = 42;240}241242impl system::Config for Runtime {243    /// The data to be stored in an account.244    type AccountData = pallet_balances::AccountData<Balance>;245    /// The identifier used to distinguish between accounts.246    type AccountId = AccountId;247    /// The basic call filter to use in dispatchable.248    type BaseCallFilter = ();249    /// Maximum number of block number to block hash mappings to keep (oldest pruned first).250    type BlockHashCount = BlockHashCount;251    /// The maximum length of a block (in bytes).252	type BlockLength = RuntimeBlockLength;253    /// The index type for blocks.254    type BlockNumber = BlockNumber;255    /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.256	type BlockWeights = RuntimeBlockWeights;257    /// The aggregated dispatch type that is available for extrinsics.258    type Call = Call;259    /// The weight of database operations that the runtime can invoke.260    type DbWeight = RocksDbWeight;261    /// The ubiquitous event type.262    type Event = Event;263    /// The type for hashing blocks and tries.264    type Hash = Hash;265	/// The hashing algorithm used.266    type Hashing = BlakeTwo256;267    /// The header type.268    type Header = generic::Header<BlockNumber, BlakeTwo256>;269    /// The index type for storing how many extrinsics an account has signed.270    type Index = Index;271    /// The lookup mechanism to get account ID from whatever is passed in dispatchers.272    type Lookup = AccountIdLookup<AccountId, ()>;273    /// What to do if an account is fully reaped from the system.274    type OnKilledAccount = ();275    /// What to do if a new account is created.276    type OnNewAccount = ();277    type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;278    /// The ubiquitous origin type.279    type Origin = Origin;280 	/// This type is being generated by `construct_runtime!`.281    type PalletInfo = PalletInfo;282    /// This is used as an identifier of the chain. 42 is the generic substrate prefix.283	type SS58Prefix = SS58Prefix;284	/// Weight information for the extrinsics of this pallet.285    type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;286    /// Version of the runtime.287    type Version = Version;288}289290parameter_types! {291    pub const MinimumPeriod: u64 = SLOT_DURATION / 2;292}293294impl pallet_timestamp::Config for Runtime {295	/// A timestamp: milliseconds since the unix epoch.296	type Moment = u64;297	type OnTimestampSet = ();298	type MinimumPeriod = MinimumPeriod;299	type WeightInfo = ();300}301302parameter_types! {303    // pub const ExistentialDeposit: u128 = 500;304    pub const ExistentialDeposit: u128 = 0;305	pub const MaxLocks: u32 = 50;306}307308impl pallet_balances::Config for Runtime {309	type MaxLocks = MaxLocks;310	/// The type for recording an account's balance.311	type Balance = Balance;312	/// The ubiquitous event type.313	type Event = Event;314	type DustRemoval = Treasury;315	type ExistentialDeposit = ExistentialDeposit;316	type AccountStore = System;317	type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;318}319320pub const MICROUNIQUE: Balance = 1_000_000_000;321pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;322pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;323pub const UNIQUE: Balance      = 100 * CENTIUNIQUE;324325pub const fn deposit(items: u32, bytes: u32) -> Balance {326    items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE327}328329parameter_types! {330	pub TombstoneDeposit: Balance = deposit(331		1,332		sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,333	);334	pub DepositPerContract: Balance = TombstoneDeposit::get();335	pub const DepositPerStorageByte: Balance = deposit(0, 1);336	pub const DepositPerStorageItem: Balance = deposit(1, 0);337	pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);338	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;339	pub const SignedClaimHandicap: u32 = 2;340	pub const MaxDepth: u32 = 32;341	pub const MaxValueSize: u32 = 16 * 1024;342	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb 343	// The lazy deletion runs inside on_initialize.344	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *345		RuntimeBlockWeights::get().max_block;346	// The weight needed for decoding the queue should be less or equal than a fifth347	// of the overall weight dedicated to the lazy deletion.348	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (349			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -350			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)351		)) / 5) as u32;352	pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();353}354355impl pallet_contracts::Config for Runtime {356	type Time = Timestamp;357	type Randomness = RandomnessCollectiveFlip;358	type Currency = Balances;359	type Event = Event;360	type RentPayment = ();361	type SignedClaimHandicap = SignedClaimHandicap;362	type TombstoneDeposit = TombstoneDeposit;363	type DepositPerContract = DepositPerContract;364	type DepositPerStorageByte = DepositPerStorageByte;365	type DepositPerStorageItem = DepositPerStorageItem;366	type RentFraction = RentFraction;367	type SurchargeReward = SurchargeReward;368	// type MaxDepth = MaxDepth;369	// type MaxValueSize = MaxValueSize;370	type WeightPrice = pallet_transaction_payment::Module<Self>;371	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;372	type ChainExtension = NFTExtension;373	type DeletionQueueDepth = DeletionQueueDepth;374	type DeletionWeightLimit = DeletionWeightLimit;375	// type MaxCodeSize = MaxCodeSize;376	type Schedule = Schedule;377	type CallStack = [pallet_contracts::Frame<Self>; 31];378}379380parameter_types! {381	pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer 382}383384/// Linear implementor of `WeightToFeePolynomial` 385pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);386387impl<T> WeightToFeePolynomial for LinearFee<T> where388	T: BaseArithmetic + From<u32> + Copy + Unsigned389{390	type Balance = T;391392	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {393		smallvec!(WeightToFeeCoefficient {394			coeff_integer: 146_700u32.into(), // Targeting 0.1 Unique per NFT transfer395			coeff_frac: Perbill::zero(),396			negative: false,397			degree: 1,398		})399	}400}401402impl pallet_transaction_payment::Config for Runtime {403	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;404	type TransactionByteFee = TransactionByteFee;405	type WeightToFee = LinearFee<Balance>;406	type FeeMultiplierUpdate = ();407}408409parameter_types! {410	pub const ProposalBond: Permill = Permill::from_percent(5);411	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;412	pub const SpendPeriod: BlockNumber = 5 * MINUTES;413	pub const Burn: Permill = Permill::from_percent(0);414	pub const TipCountdown: BlockNumber = 1 * DAYS;415	pub const TipFindersFee: Percent = Percent::from_percent(20);416	pub const TipReportDepositBase: Balance = 1 * UNIQUE;417	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;418	pub const BountyDepositBase: Balance = 1 * UNIQUE;419	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;420	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");421	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;422	pub const MaximumReasonLength: u32 = 16384;423	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);424	pub const BountyValueMinimum: Balance = 5 * UNIQUE;425	pub const MaxApprovals: u32 = 100;426}427428impl pallet_treasury::Config for Runtime {429	type PalletId = TreasuryModuleId;430	type Currency = Balances;431	type ApproveOrigin = EnsureRoot<AccountId>;432	type RejectOrigin = EnsureRoot<AccountId>;433	type Event = Event;434	type OnSlash = ();435	type ProposalBond = ProposalBond;436	type ProposalBondMinimum = ProposalBondMinimum;437	type SpendPeriod = SpendPeriod;438	type Burn = Burn;439	type BurnDestination = ();440	type SpendFunds = ();441	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;442	type MaxApprovals = MaxApprovals;443}444445impl pallet_sudo::Config for Runtime {446    type Event = Event;447    type Call = Call;448}449450parameter_types! {451	pub const MinVestedTransfer: Balance = 10 * UNIQUE;452}453454impl pallet_vesting::Config for Runtime {455	type Event = Event;456	type Currency = Balances;457	type BlockNumberToBalance = ConvertInto;458	type MinVestedTransfer = MinVestedTransfer;459	type WeightInfo = ();460}461462parameter_types! {463	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;464	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;465}466467impl cumulus_pallet_parachain_system::Config for Runtime {468	type Event = Event;469	type OnValidationData = ();470	type SelfParaId = parachain_info::Pallet<Runtime>;471	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<472	// 	MaxDownwardMessageWeight,473	// 	XcmExecutor<XcmConfig>,474	// 	Call,475	// >;476	type OutboundXcmpMessageSource = XcmpQueue;477	type DmpMessageHandler = DmpQueue;478	type ReservedDmpWeight = ReservedDmpWeight;479	type ReservedXcmpWeight = ReservedXcmpWeight;480	type XcmpMessageHandler = XcmpQueue;481}482483impl parachain_info::Config for Runtime {}484485impl cumulus_pallet_aura_ext::Config for Runtime {}486487parameter_types! {488	pub const RelayLocation: MultiLocation = X1(Parent);489	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;490	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();491	pub Ancestry: MultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));492}493494/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used495/// when determining ownership of accounts for asset transacting and when attempting to use XCM496/// `Transact` in order to determine the dispatch Origin.497pub type LocationToAccountId = (498	// The parent (Relay-chain) origin converts to the default `AccountId`.499	ParentIsDefault<AccountId>,500	// Sibling parachain origins convert to AccountId via the `ParaId::into`.501	SiblingParachainConvertsVia<Sibling, AccountId>,502	// Straight up local `AccountId32` origins just alias directly to `AccountId`.503	AccountId32Aliases<RelayNetwork, AccountId>,504);505506/// Means for transacting assets on this chain.507pub type LocalAssetTransactor = CurrencyAdapter<508	// Use this currency:509	Balances,510	// Use this currency when it is a fungible asset matching the given location or name:511	IsConcrete<RelayLocation>,512	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:513	LocationToAccountId,514	// Our chain's account ID type (we can't get away without mentioning it explicitly):515	AccountId,516	// We don't track any teleports.517	(),518>;519520/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,521/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can522/// biases the kind of local `Origin` it will become.523pub type XcmOriginToTransactDispatchOrigin = (524	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location525	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for526	// foreign chains who want to have a local sovereign account on this chain which they control.527	SovereignSignedViaLocation<LocationToAccountId, Origin>,528	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when529	// recognised.530	RelayChainAsNative<RelayOrigin, Origin>,531	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when532	// recognised.533	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,534	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a535	// transaction from the Root origin.536	ParentAsSuperuser<Origin>,537	// Native signed account converter; this just converts an `AccountId32` origin into a normal538	// `Origin::Signed` origin of the same 32-byte value.539	SignedAccountId32AsNative<RelayNetwork, Origin>,540	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.541	XcmPassthrough<Origin>,542);543544parameter_types! {545	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.546	pub UnitWeightCost: Weight = 1_000_000;547	// 1200 UNIQUEs buy 1 second of weight.548	pub const WeightPrice: (MultiLocation, u128) = (X1(Parent), 1_200 * UNIQUE);549}550551match_type! {552	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {553		X1(Parent) | X2(Parent, Plurality { id: BodyId::Unit, .. })554	};555}556557pub type Barrier = (558	TakeWeightCredit,559	AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,560	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,561	// ^^^ Parent & its unit plurality gets free execution562);563564pub struct XcmConfig;565impl Config for XcmConfig {566	type Call = Call;567	type XcmSender = XcmRouter;568	// How to withdraw and deposit an asset.569	type AssetTransactor = LocalAssetTransactor;570	type OriginConverter = XcmOriginToTransactDispatchOrigin;571	type IsReserve = NativeAsset;572	type IsTeleporter = NativeAsset;	// <- should be enough to allow teleportation of ROC573	type LocationInverter = LocationInverter<Ancestry>;574	type Barrier = Barrier;575	type Weigher = FixedWeightBounds<UnitWeightCost, Call>;576	type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;577	type ResponseHandler = ();	// Don't handle responses for now.578}579580// parameter_types! {581// 	pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;582// }583584/// No local origins on this chain are allowed to dispatch XCM sends/executions.585pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);586587/// The means for routing XCM messages which are not for local execution into the right message588/// queues.589pub type XcmRouter = (590	// Two routers - use UMP to communicate with the relay chain:591	cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,592	// ..and XCMP to communicate with the sibling chains.593	XcmpQueue,594);595596impl pallet_xcm::Config for Runtime {597	type Event = Event;598	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;599	type XcmRouter = XcmRouter;600	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;601	type XcmExecuteFilter = All<(MultiLocation, Xcm<Call>)>;602	type XcmExecutor = XcmExecutor<XcmConfig>;603	type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;604	type XcmReserveTransferFilter = ();605	type Weigher = FixedWeightBounds<UnitWeightCost, Call>;606}607608impl cumulus_pallet_xcm::Config for Runtime {609	type Event = Event;610	type XcmExecutor = XcmExecutor<XcmConfig>;611}612613impl cumulus_pallet_xcmp_queue::Config for Runtime {614	type Event = Event;615	type XcmExecutor = XcmExecutor<XcmConfig>;616	type ChannelInfo = ParachainSystem;617}618619impl cumulus_pallet_dmp_queue::Config for Runtime {620	type Event = Event;621	type XcmExecutor = XcmExecutor<XcmConfig>;622	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;623}624625impl pallet_aura::Config for Runtime {626	type AuthorityId = AuraId;627}628629parameter_types! {630	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();631	pub const CollectionCreationPrice: Balance = 100 * UNIQUE;632}633634/// Used for the pallet nft in `./nft.rs`635impl pallet_nft::Config for Runtime {636    type Event = Event;637    type WeightInfo = nft_weights::WeightInfo;638	type Currency = Balances;639	type CollectionCreationPrice = CollectionCreationPrice;640	type TreasuryAccountId = TreasuryAccountId;641}642643/// Reimport pallet inflation644extern crate pallet_inflation;645pub use pallet_inflation::*;646647parameter_types! {648	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied649}650651/// Used for the pallet inflation652impl pallet_inflation::Config for Runtime {653	type Currency = Balances;654	type TreasuryAccountId = TreasuryAccountId;655	type InflationBlockInterval = InflationBlockInterval;656}657658construct_runtime!(659    pub enum Runtime where660        Block = Block,661        NodeBlock = opaque::Block,662        UncheckedExtrinsic = UncheckedExtrinsic663    {664		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,665		Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>},666		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},667		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},668		TransactionPayment: pallet_transaction_payment::{Pallet, Storage},669        Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},670		Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>},671		System: system::{Pallet, Call, Storage, Config, Event<T>},672        Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>},673674		ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,675		ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,676677		Aura: pallet_aura::{Pallet, Config<T>},678		AuraExt: cumulus_pallet_aura_ext::{Pallet, Config},679680		// XCM helpers.681		XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,682		PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,683		CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,684		DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,685686687		// Unique Pallets688        Inflation: pallet_inflation::{Pallet, Call, Storage},689        Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>},690    }691);692693/// The address format for describing accounts.694pub type Address = sp_runtime::MultiAddress<AccountId, ()>;695/// Block header type as expected by this runtime.696pub type Header = generic::Header<BlockNumber, BlakeTwo256>;697/// Block type as expected by this runtime.698pub type Block = generic::Block<Header, UncheckedExtrinsic>;699/// A Block signed with a Justification700pub type SignedBlock = generic::SignedBlock<Block>;701/// BlockId type as expected by this runtime.702pub type BlockId = generic::BlockId<Block>;703/// The SignedExtension to the basic transaction logic.704pub type SignedExtra = (705    system::CheckSpecVersion<Runtime>,706    // system::CheckTxVersion<Runtime>,707    system::CheckGenesis<Runtime>,708    system::CheckEra<Runtime>,709    system::CheckNonce<Runtime>,710    system::CheckWeight<Runtime>,711    pallet_nft::ChargeTransactionPayment<Runtime>,712);713/// Unchecked extrinsic type as expected by this runtime.714pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;715/// Extrinsic type that has already been checked.716pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;717/// Executive: handles dispatch to the various modules.718pub type Executive = frame_executive::Executive<719    Runtime,720    Block,721    frame_system::ChainContext<Runtime>,722    Runtime,723    AllPallets,724>;725726impl_opaque_keys! {727	pub struct SessionKeys {728		pub aura: Aura,729	}730}731732impl_runtime_apis! {733    impl sp_api::Core<Block> for Runtime {734        fn version() -> RuntimeVersion {735            VERSION736        }737738        fn execute_block(block: Block) {739            Executive::execute_block(block)740        }741742        fn initialize_block(header: &<Block as BlockT>::Header) {743            Executive::initialize_block(header)744        }745    }746747    impl sp_api::Metadata<Block> for Runtime {748        fn metadata() -> OpaqueMetadata {749            Runtime::metadata().into()750        }751    }752753    impl sp_block_builder::BlockBuilder<Block> for Runtime {754        fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {755            Executive::apply_extrinsic(extrinsic)756        }757758        fn finalize_block() -> <Block as BlockT>::Header {759            Executive::finalize_block()760        }761762        fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {763            data.create_extrinsics()764        }765766        fn check_inherents(767            block: Block,768            data: sp_inherents::InherentData,769        ) -> sp_inherents::CheckInherentsResult {770            data.check_extrinsics(&block)771        }772773        // fn random_seed() -> <Block as BlockT>::Hash {774        //     RandomnessCollectiveFlip::random_seed().0775        // }776    }777778    impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {779        fn validate_transaction(780            source: TransactionSource,781            tx: <Block as BlockT>::Extrinsic,782        ) -> TransactionValidity {783            Executive::validate_transaction(source, tx)784        }785    }786787	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {788		fn offchain_worker(header: &<Block as BlockT>::Header) {789			Executive::offchain_worker(header)790		}791	}792793	impl sp_session::SessionKeys<Block> for Runtime {794		fn decode_session_keys(795			encoded: Vec<u8>,796		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {797			SessionKeys::decode_into_raw_public_keys(&encoded)798		}799800		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {801			SessionKeys::generate(seed)802		}803	}804805	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {806		fn slot_duration() -> sp_consensus_aura::SlotDuration {807			sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())808		}809810		fn authorities() -> Vec<AuraId> {811			Aura::authorities()812		}813	}814815	impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {816		fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {817			ParachainSystem::collect_collation_info()818		}819	}820821	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {822		fn account_nonce(account: AccountId) -> Index {823			System::account_nonce(account)824		}825	}826827	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {828		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {829			TransactionPayment::query_info(uxt, len)830		}831		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {832			TransactionPayment::query_fee_details(uxt, len)833		}834	}835836	impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>837		for Runtime838	{839		fn call(840			origin: AccountId,841			dest: AccountId,842			value: Balance,843			gas_limit: u64,844			input_data: Vec<u8>,845		) -> pallet_contracts_primitives::ContractExecResult {846			Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)847		}848849		fn instantiate(850			origin: AccountId,851			endowment: Balance,852			gas_limit: u64,853			code: pallet_contracts_primitives::Code<Hash>,854			data: Vec<u8>,855			salt: Vec<u8>,856		) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>857		{858			Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)859		}860861		fn get_storage(862			address: AccountId,863			key: [u8; 32],864		) -> pallet_contracts_primitives::GetStorageResult {865			Contracts::get_storage(address, key)866		}867868		fn rent_projection(869			address: AccountId,870		) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {871			Contracts::rent_projection(address)872		}873	}874875    #[cfg(feature = "runtime-benchmarks")]876	impl frame_benchmarking::Benchmark<Block> for Runtime {877		fn dispatch_benchmark(878			config: frame_benchmarking::BenchmarkConfig879		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {880			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};881882			let whitelist: Vec<TrackedStorageKey> = vec![883				// Alice account884				hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),885				// // Total Issuance886				// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),887				// // Execution Phase888				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),889				// // Event Count890				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),891				// // System Events892				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),893            ];894895			let mut batches = Vec::<BenchmarkBatch>::new();896			let params = (&config, &whitelist);897898			add_benchmark!(params, batches, pallet_nft, Nft);899			add_benchmark!(params, batches, pallet_inflation, Inflation);900901			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }902			Ok(batches)903		}904	}905}