git.delta.rocks / unique-network / refs/commits / b93e7f42908f

difftreelog

source

runtime/src/lib.rs32.2 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/// Reimport pallet inflation91extern crate pallet_inflation;92pub use pallet_inflation::*;9394/// An index to a block.95pub type BlockNumber = u32;9697/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.98pub type Signature = MultiSignature;99100/// Some way of identifying an account on the chain. We intentionally make it equivalent101/// to the public key of our transaction signing scheme.102pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;103104/// The type for looking up accounts. We don't expect more than 4 billion of them, but you105/// never know...106pub type AccountIndex = u32;107108/// Balance of an account.109pub type Balance = u128;110111/// Index of a transaction in the chain.112pub type Index = u32;113114/// A hash of some data used by the chain.115pub type Hash = sp_core::H256;116117/// Digest item type.118pub type DigestItem = generic::DigestItem<Hash>;119120mod nft_weights;121122/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know123/// the specifics of the runtime. They can then be made to be agnostic over specific formats124/// of data like extrinsics, allowing for them to continue syncing the network through upgrades125/// to even the core data structures.126pub mod opaque {127    use super::*;128129    pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;130131    /// Opaque block type.132    pub type Block = generic::Block<Header, UncheckedExtrinsic>;133134    pub type SessionHandlers = ();135136	impl_opaque_keys! {137        pub struct SessionKeys {138			pub aura: Aura,139		}140    }141}142143/// This runtime version.144pub const VERSION: RuntimeVersion = RuntimeVersion {145    spec_name: create_runtime_str!("nft"),146    impl_name: create_runtime_str!("nft"),147    authoring_version: 1,148    spec_version: 3,149    impl_version: 1,150    apis: RUNTIME_API_VERSIONS,151    transaction_version: 1,152};153154pub const MILLISECS_PER_BLOCK: u64 = 12000;155156pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;157158// These time units are defined in number of blocks.159pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);160pub const HOURS: BlockNumber = MINUTES * 60;161pub const DAYS: BlockNumber = HOURS * 24;162163#[derive(codec::Encode, codec::Decode)]164pub enum XCMPMessage<XAccountId, XBalance> {165    /// Transfer tokens to the given account from the Parachain account.166    TransferToken(XAccountId, XBalance),167}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}177178type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;179180pub struct DealWithFees;181impl OnUnbalanced<NegativeImbalance> for DealWithFees {182	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {183		if let Some(fees) = fees_then_tips.next() {184			// for fees, 100% to treasury185			let mut split = fees.ration(100, 0);186			if let Some(tips) = fees_then_tips.next() {187				// for tips, if any, 100% to treasury188				tips.ration_merge_into(100, 0, &mut split);189			}190			Treasury::on_unbalanced(split.0);191			// Author::on_unbalanced(split.1);192		}193	}194}195196// impl OnUnbalanced<NegativeImbalance> for DealWithFees {197// 	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {198// 		if let Some(fees) = fees_then_tips.next() {199// 			// for fees, 100% to treasury200// 			let mut split = fees.ration(100, 0);201// 			if let Some(tips) = fees_then_tips.next() {202// 				// for tips, if any, 100% to treasury203// 				tips.ration_merge_into(100, 0, &mut split);204// 			}205// 			Treasury::on_unbalanced(split.0);206// 			// Author::on_unbalanced(split.1);207// 		}208// 	}209// }210211/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.212/// This is used to limit the maximal weight of a single extrinsic.213const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);214/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used215/// by  Operational  extrinsics.216const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);217/// We allow for 2 seconds of compute with a 6 second average block time.218const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;219220parameter_types! {221    pub const BlockHashCount: BlockNumber = 2400;222	pub RuntimeBlockLength: BlockLength =223		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);224    pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);225    pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;226	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()227		.base_block(BlockExecutionWeight::get())228		.for_class(DispatchClass::all(), |weights| {229			weights.base_extrinsic = ExtrinsicBaseWeight::get();230		})231		.for_class(DispatchClass::Normal, |weights| {232			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);233		})234		.for_class(DispatchClass::Operational, |weights| {235			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);236			// Operational transactions have some extra reserved space, so that they237			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.238			weights.reserved = Some(239				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT240			);241		})242		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)243		.build_or_panic();244    pub const Version: RuntimeVersion = VERSION;245    pub const SS58Prefix: u8 = 42;246}247248impl system::Config for Runtime {249    /// The data to be stored in an account.250    type AccountData = pallet_balances::AccountData<Balance>;251    /// The identifier used to distinguish between accounts.252    type AccountId = AccountId;253    /// The basic call filter to use in dispatchable.254    type BaseCallFilter = ();255    /// Maximum number of block number to block hash mappings to keep (oldest pruned first).256    type BlockHashCount = BlockHashCount;257    /// The maximum length of a block (in bytes).258	type BlockLength = RuntimeBlockLength;259    /// The index type for blocks.260    type BlockNumber = BlockNumber;261    /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.262	type BlockWeights = RuntimeBlockWeights;263    /// The aggregated dispatch type that is available for extrinsics.264    type Call = Call;265    /// The weight of database operations that the runtime can invoke.266    type DbWeight = RocksDbWeight;267    /// The ubiquitous event type.268    type Event = Event;269    /// The type for hashing blocks and tries.270    type Hash = Hash;271	/// The hashing algorithm used.272    type Hashing = BlakeTwo256;273    /// The header type.274    type Header = generic::Header<BlockNumber, BlakeTwo256>;275    /// The index type for storing how many extrinsics an account has signed.276    type Index = Index;277    /// The lookup mechanism to get account ID from whatever is passed in dispatchers.278    type Lookup = AccountIdLookup<AccountId, ()>;279    /// What to do if an account is fully reaped from the system.280    type OnKilledAccount = ();281    /// What to do if a new account is created.282    type OnNewAccount = ();283    type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;284    /// The ubiquitous origin type.285    type Origin = Origin;286 	/// This type is being generated by `construct_runtime!`.287    type PalletInfo = PalletInfo;288    /// This is used as an identifier of the chain. 42 is the generic substrate prefix.289	type SS58Prefix = SS58Prefix;290	/// Weight information for the extrinsics of this pallet.291    type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;292    /// Version of the runtime.293    type Version = Version;294}295296parameter_types! {297    pub const MinimumPeriod: u64 = SLOT_DURATION / 2;298}299300impl pallet_timestamp::Config for Runtime {301	/// A timestamp: milliseconds since the unix epoch.302	type Moment = u64;303	type OnTimestampSet = ();304	type MinimumPeriod = MinimumPeriod;305	type WeightInfo = ();306}307308parameter_types! {309    // pub const ExistentialDeposit: u128 = 500;310    pub const ExistentialDeposit: u128 = 0;311	pub const MaxLocks: u32 = 50;312}313314impl pallet_balances::Config for Runtime {315	type MaxLocks = MaxLocks;316	/// The type for recording an account's balance.317	type Balance = Balance;318	/// The ubiquitous event type.319	type Event = Event;320	type DustRemoval = Treasury;321	type ExistentialDeposit = ExistentialDeposit;322	type AccountStore = System;323	type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;324}325326pub const MICROUNIQUE: Balance = 1_000_000_000;327pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;328pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;329pub const UNIQUE: Balance      = 100 * CENTIUNIQUE;330331pub const fn deposit(items: u32, bytes: u32) -> Balance {332    items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE333}334335parameter_types! {336	pub TombstoneDeposit: Balance = deposit(337		1,338		sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,339	);340	pub DepositPerContract: Balance = TombstoneDeposit::get();341	pub const DepositPerStorageByte: Balance = deposit(0, 1);342	pub const DepositPerStorageItem: Balance = deposit(1, 0);343	pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);344	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;345	pub const SignedClaimHandicap: u32 = 2;346	pub const MaxDepth: u32 = 32;347	pub const MaxValueSize: u32 = 16 * 1024;348	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb 349	// The lazy deletion runs inside on_initialize.350	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *351		RuntimeBlockWeights::get().max_block;352	// The weight needed for decoding the queue should be less or equal than a fifth353	// of the overall weight dedicated to the lazy deletion.354	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (355			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -356			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)357		)) / 5) as u32;358	pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();359}360361impl pallet_contracts::Config for Runtime {362	type Time = Timestamp;363	type Randomness = RandomnessCollectiveFlip;364	type Currency = Balances;365	type Event = Event;366	type RentPayment = ();367	type SignedClaimHandicap = SignedClaimHandicap;368	type TombstoneDeposit = TombstoneDeposit;369	type DepositPerContract = DepositPerContract;370	type DepositPerStorageByte = DepositPerStorageByte;371	type DepositPerStorageItem = DepositPerStorageItem;372	type RentFraction = RentFraction;373	type SurchargeReward = SurchargeReward;374	// type MaxDepth = MaxDepth;375	// type MaxValueSize = MaxValueSize;376	type WeightPrice = pallet_transaction_payment::Module<Self>;377	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;378	type ChainExtension = NFTExtension;379	type DeletionQueueDepth = DeletionQueueDepth;380	type DeletionWeightLimit = DeletionWeightLimit;381	// type MaxCodeSize = MaxCodeSize;382	type Schedule = Schedule;383	type CallStack = [pallet_contracts::Frame<Self>; 31];384}385386parameter_types! {387	pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer 388}389390/// Linear implementor of `WeightToFeePolynomial` 391pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);392393impl<T> WeightToFeePolynomial for LinearFee<T> where394	T: BaseArithmetic + From<u32> + Copy + Unsigned395{396	type Balance = T;397398	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {399		smallvec!(WeightToFeeCoefficient {400			coeff_integer: 146_700u32.into(), // Targeting 0.1 Unique per NFT transfer401			coeff_frac: Perbill::zero(),402			negative: false,403			degree: 1,404		})405	}406}407408impl pallet_transaction_payment::Config for Runtime {409	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;410	type TransactionByteFee = TransactionByteFee;411	type WeightToFee = LinearFee<Balance>;412	type FeeMultiplierUpdate = ();413}414415parameter_types! {416	pub const ProposalBond: Permill = Permill::from_percent(5);417	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;418	pub const SpendPeriod: BlockNumber = 5 * MINUTES;419	pub const Burn: Permill = Permill::from_percent(0);420	pub const TipCountdown: BlockNumber = 1 * DAYS;421	pub const TipFindersFee: Percent = Percent::from_percent(20);422	pub const TipReportDepositBase: Balance = 1 * UNIQUE;423	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;424	pub const BountyDepositBase: Balance = 1 * UNIQUE;425	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;426	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");427	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;428	pub const MaximumReasonLength: u32 = 16384;429	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);430	pub const BountyValueMinimum: Balance = 5 * UNIQUE;431	pub const MaxApprovals: u32 = 100;432}433434impl pallet_treasury::Config for Runtime {435	type PalletId = TreasuryModuleId;436	type Currency = Balances;437	type ApproveOrigin = EnsureRoot<AccountId>;438	type RejectOrigin = EnsureRoot<AccountId>;439	type Event = Event;440	type OnSlash = ();441	type ProposalBond = ProposalBond;442	type ProposalBondMinimum = ProposalBondMinimum;443	type SpendPeriod = SpendPeriod;444	type Burn = Burn;445	type BurnDestination = ();446	type SpendFunds = ();447	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;448	type MaxApprovals = MaxApprovals;449}450451impl pallet_sudo::Config for Runtime {452    type Event = Event;453    type Call = Call;454}455456parameter_types! {457	pub const MinVestedTransfer: Balance = 10 * UNIQUE;458}459460impl pallet_vesting::Config for Runtime {461	type Event = Event;462	type Currency = Balances;463	type BlockNumberToBalance = ConvertInto;464	type MinVestedTransfer = MinVestedTransfer;465	type WeightInfo = ();466}467468parameter_types! {469	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;470	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;471}472473impl cumulus_pallet_parachain_system::Config for Runtime {474	type Event = Event;475	type OnValidationData = ();476	type SelfParaId = parachain_info::Pallet<Runtime>;477	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<478	// 	MaxDownwardMessageWeight,479	// 	XcmExecutor<XcmConfig>,480	// 	Call,481	// >;482	type OutboundXcmpMessageSource = XcmpQueue;483	type DmpMessageHandler = DmpQueue;484	type ReservedDmpWeight = ReservedDmpWeight;485	type ReservedXcmpWeight = ReservedXcmpWeight;486	type XcmpMessageHandler = XcmpQueue;487}488489impl parachain_info::Config for Runtime {}490491impl cumulus_pallet_aura_ext::Config for Runtime {}492493parameter_types! {494	pub const RelayLocation: MultiLocation = X1(Parent);495	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;496	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();497	pub Ancestry: MultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));498}499500/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used501/// when determining ownership of accounts for asset transacting and when attempting to use XCM502/// `Transact` in order to determine the dispatch Origin.503pub type LocationToAccountId = (504	// The parent (Relay-chain) origin converts to the default `AccountId`.505	ParentIsDefault<AccountId>,506	// Sibling parachain origins convert to AccountId via the `ParaId::into`.507	SiblingParachainConvertsVia<Sibling, AccountId>,508	// Straight up local `AccountId32` origins just alias directly to `AccountId`.509	AccountId32Aliases<RelayNetwork, AccountId>,510);511512/// Means for transacting assets on this chain.513pub type LocalAssetTransactor = CurrencyAdapter<514	// Use this currency:515	Balances,516	// Use this currency when it is a fungible asset matching the given location or name:517	IsConcrete<RelayLocation>,518	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:519	LocationToAccountId,520	// Our chain's account ID type (we can't get away without mentioning it explicitly):521	AccountId,522	// We don't track any teleports.523	(),524>;525526/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,527/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can528/// biases the kind of local `Origin` it will become.529pub type XcmOriginToTransactDispatchOrigin = (530	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location531	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for532	// foreign chains who want to have a local sovereign account on this chain which they control.533	SovereignSignedViaLocation<LocationToAccountId, Origin>,534	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when535	// recognised.536	RelayChainAsNative<RelayOrigin, Origin>,537	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when538	// recognised.539	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,540	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a541	// transaction from the Root origin.542	ParentAsSuperuser<Origin>,543	// Native signed account converter; this just converts an `AccountId32` origin into a normal544	// `Origin::Signed` origin of the same 32-byte value.545	SignedAccountId32AsNative<RelayNetwork, Origin>,546	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.547	XcmPassthrough<Origin>,548);549550parameter_types! {551	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.552	pub UnitWeightCost: Weight = 1_000_000;553	// 1200 UNIQUEs buy 1 second of weight.554	pub const WeightPrice: (MultiLocation, u128) = (X1(Parent), 1_200 * UNIQUE);555}556557match_type! {558	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {559		X1(Parent) | X2(Parent, Plurality { id: BodyId::Unit, .. })560	};561}562563pub type Barrier = (564	TakeWeightCredit,565	AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,566	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,567	// ^^^ Parent & its unit plurality gets free execution568);569570pub struct XcmConfig;571impl Config for XcmConfig {572	type Call = Call;573	type XcmSender = XcmRouter;574	// How to withdraw and deposit an asset.575	type AssetTransactor = LocalAssetTransactor;576	type OriginConverter = XcmOriginToTransactDispatchOrigin;577	type IsReserve = NativeAsset;578	type IsTeleporter = NativeAsset;	// <- should be enough to allow teleportation of ROC579	type LocationInverter = LocationInverter<Ancestry>;580	type Barrier = Barrier;581	type Weigher = FixedWeightBounds<UnitWeightCost, Call>;582	type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;583	type ResponseHandler = ();	// Don't handle responses for now.584}585586// parameter_types! {587// 	pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;588// }589590/// No local origins on this chain are allowed to dispatch XCM sends/executions.591pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);592593/// The means for routing XCM messages which are not for local execution into the right message594/// queues.595pub type XcmRouter = (596	// Two routers - use UMP to communicate with the relay chain:597	cumulus_primitives_utility::ParentAsUmp<ParachainSystem>,598	// ..and XCMP to communicate with the sibling chains.599	XcmpQueue,600);601602impl pallet_xcm::Config for Runtime {603	type Event = Event;604	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;605	type XcmRouter = XcmRouter;606	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;607	type XcmExecuteFilter = All<(MultiLocation, Xcm<Call>)>;608	type XcmExecutor = XcmExecutor<XcmConfig>;609	type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;610	type XcmReserveTransferFilter = ();611	type Weigher = FixedWeightBounds<UnitWeightCost, Call>;612}613614impl cumulus_pallet_xcm::Config for Runtime {615	type Event = Event;616	type XcmExecutor = XcmExecutor<XcmConfig>;617}618619impl cumulus_pallet_xcmp_queue::Config for Runtime {620	type Event = Event;621	type XcmExecutor = XcmExecutor<XcmConfig>;622	type ChannelInfo = ParachainSystem;623}624625impl cumulus_pallet_dmp_queue::Config for Runtime {626	type Event = Event;627	type XcmExecutor = XcmExecutor<XcmConfig>;628	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;629}630631impl pallet_aura::Config for Runtime {632	type AuthorityId = AuraId;633}634635parameter_types! {636	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();637	pub const CollectionCreationPrice: Balance = 100 * UNIQUE;638}639640/// Used for the pallet nft in `./nft.rs`641impl pallet_nft::Config for Runtime {642    type Event = Event;643    type WeightInfo = nft_weights::WeightInfo;644	type Currency = Balances;645	type CollectionCreationPrice = CollectionCreationPrice;646	type TreasuryAccountId = TreasuryAccountId;647}648649parameter_types! {650	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied651}652653/// Used for the pallet inflation654impl pallet_inflation::Config for Runtime {655	type Currency = Balances;656	type TreasuryAccountId = TreasuryAccountId;657	type InflationBlockInterval = InflationBlockInterval;658}659660construct_runtime!(661    pub enum Runtime where662        Block = Block,663        NodeBlock = opaque::Block,664        UncheckedExtrinsic = UncheckedExtrinsic665    {666		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,667		Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>},668		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},669		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},670		TransactionPayment: pallet_transaction_payment::{Pallet, Storage},671        Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},672		Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>},673		System: system::{Pallet, Call, Storage, Config, Event<T>},674        Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>},675676		ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,677		ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,678679		Aura: pallet_aura::{Pallet, Config<T>},680		AuraExt: cumulus_pallet_aura_ext::{Pallet, Config},681682		// XCM helpers.683		XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,684		PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,685		CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,686		DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,687688689		// Unique Pallets690        Inflation: pallet_inflation::{Pallet, Call, Storage},691        Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>},692    }693);694695/// The address format for describing accounts.696pub type Address = sp_runtime::MultiAddress<AccountId, ()>;697/// Block header type as expected by this runtime.698pub type Header = generic::Header<BlockNumber, BlakeTwo256>;699/// Block type as expected by this runtime.700pub type Block = generic::Block<Header, UncheckedExtrinsic>;701/// A Block signed with a Justification702pub type SignedBlock = generic::SignedBlock<Block>;703/// BlockId type as expected by this runtime.704pub type BlockId = generic::BlockId<Block>;705/// The SignedExtension to the basic transaction logic.706pub type SignedExtra = (707    system::CheckSpecVersion<Runtime>,708    // system::CheckTxVersion<Runtime>,709    system::CheckGenesis<Runtime>,710    system::CheckEra<Runtime>,711    system::CheckNonce<Runtime>,712    system::CheckWeight<Runtime>,713    pallet_nft::ChargeTransactionPayment<Runtime>,714);715/// Unchecked extrinsic type as expected by this runtime.716pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;717/// Extrinsic type that has already been checked.718pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;719/// Executive: handles dispatch to the various modules.720pub type Executive = frame_executive::Executive<721    Runtime,722    Block,723    frame_system::ChainContext<Runtime>,724    Runtime,725    AllPallets,726>;727728impl_opaque_keys! {729	pub struct SessionKeys {730		pub aura: Aura,731	}732}733734impl_runtime_apis! {735    impl sp_api::Core<Block> for Runtime {736        fn version() -> RuntimeVersion {737            VERSION738        }739740        fn execute_block(block: Block) {741            Executive::execute_block(block)742        }743744        fn initialize_block(header: &<Block as BlockT>::Header) {745            Executive::initialize_block(header)746        }747    }748749    impl sp_api::Metadata<Block> for Runtime {750        fn metadata() -> OpaqueMetadata {751            Runtime::metadata().into()752        }753    }754755    impl sp_block_builder::BlockBuilder<Block> for Runtime {756        fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {757            Executive::apply_extrinsic(extrinsic)758        }759760        fn finalize_block() -> <Block as BlockT>::Header {761            Executive::finalize_block()762        }763764        fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {765            data.create_extrinsics()766        }767768        fn check_inherents(769            block: Block,770            data: sp_inherents::InherentData,771        ) -> sp_inherents::CheckInherentsResult {772            data.check_extrinsics(&block)773        }774775        // fn random_seed() -> <Block as BlockT>::Hash {776        //     RandomnessCollectiveFlip::random_seed().0777        // }778    }779780    impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {781        fn validate_transaction(782            source: TransactionSource,783            tx: <Block as BlockT>::Extrinsic,784        ) -> TransactionValidity {785            Executive::validate_transaction(source, tx)786        }787    }788789	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {790		fn offchain_worker(header: &<Block as BlockT>::Header) {791			Executive::offchain_worker(header)792		}793	}794795	impl sp_session::SessionKeys<Block> for Runtime {796		fn decode_session_keys(797			encoded: Vec<u8>,798		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {799			SessionKeys::decode_into_raw_public_keys(&encoded)800		}801802		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {803			SessionKeys::generate(seed)804		}805	}806807	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {808		fn slot_duration() -> sp_consensus_aura::SlotDuration {809			sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())810		}811812		fn authorities() -> Vec<AuraId> {813			Aura::authorities()814		}815	}816817	impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {818		fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {819			ParachainSystem::collect_collation_info()820		}821	}822823	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {824		fn account_nonce(account: AccountId) -> Index {825			System::account_nonce(account)826		}827	}828829	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {830		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {831			TransactionPayment::query_info(uxt, len)832		}833		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {834			TransactionPayment::query_fee_details(uxt, len)835		}836	}837838	impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>839		for Runtime840	{841		fn call(842			origin: AccountId,843			dest: AccountId,844			value: Balance,845			gas_limit: u64,846			input_data: Vec<u8>,847		) -> pallet_contracts_primitives::ContractExecResult {848			Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)849		}850851		fn instantiate(852			origin: AccountId,853			endowment: Balance,854			gas_limit: u64,855			code: pallet_contracts_primitives::Code<Hash>,856			data: Vec<u8>,857			salt: Vec<u8>,858		) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>859		{860			Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)861		}862863		fn get_storage(864			address: AccountId,865			key: [u8; 32],866		) -> pallet_contracts_primitives::GetStorageResult {867			Contracts::get_storage(address, key)868		}869870		fn rent_projection(871			address: AccountId,872		) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {873			Contracts::rent_projection(address)874		}875	}876877    #[cfg(feature = "runtime-benchmarks")]878	impl frame_benchmarking::Benchmark<Block> for Runtime {879		fn dispatch_benchmark(880			config: frame_benchmarking::BenchmarkConfig881		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {882			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};883884			let whitelist: Vec<TrackedStorageKey> = vec![885				// Alice account886				hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),887				// // Total Issuance888				// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),889				// // Execution Phase890				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),891				// // Event Count892				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),893				// // System Events894				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),895            ];896897			let mut batches = Vec::<BenchmarkBatch>::new();898			let params = (&config, &whitelist);899900			add_benchmark!(params, batches, pallet_nft, Nft);901			add_benchmark!(params, batches, pallet_inflation, Inflation);902903			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }904			Ok(batches)905		}906	}907}908909cumulus_pallet_parachain_system::register_validate_block!(910	Runtime,911	cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,912);