git.delta.rocks / unique-network / refs/commits / 9c7fc18e6abe

difftreelog

feat connect split pallets via runtime

Yaroslav Bolyukin2021-10-12parent: #b70e369.patch.diff
in: master

3 files changed

modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -5,7 +5,6 @@
 
 use cumulus_primitives_core::ParaId;
 use nft_runtime::*;
-use nft_data_structs::*;
 use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
 use sc_service::ChainType;
 use sp_core::{sr25519, Pair, Public};
@@ -175,34 +174,6 @@
 				.cloned()
 				.map(|k| (k, 1000, 100, 1 << 98))
 				.collect(),
-		},
-		nft: NftConfig {
-			collection_id: vec![(
-				1,
-				Collection {
-					owner: get_account_id_from_seed::<sr25519::Public>("Alice"),
-					mode: CollectionMode::NFT,
-					access: AccessMode::Normal,
-					decimal_points: 0,
-					name: vec![],
-					description: vec![],
-					token_prefix: vec![],
-					mint_mode: false,
-					offchain_schema: vec![],
-					schema_version: SchemaVersion::default(),
-					sponsorship: SponsorshipState::Confirmed(get_account_id_from_seed::<
-						sr25519::Public,
-					>("Alice")),
-					const_on_chain_schema: vec![],
-					variable_on_chain_schema: vec![],
-					limits: CollectionLimits::default(),
-					meta_update_permission: MetaUpdatePermission::ItemOwner,
-					transfers_enabled: true,
-				},
-			)],
-			nft_item_id: vec![],
-			fungible_item_id: vec![],
-			refungible_item_id: vec![],
 		},
 		parachain_info: nft_runtime::ParachainInfoConfig { parachain_id: id },
 		aura: nft_runtime::AuraConfig {
modifiedruntime/Cargo.tomldiffbeforeafterboth
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -26,6 +26,10 @@
     'pallet-evm-migration/runtime-benchmarks',
     'pallet-balances/runtime-benchmarks',
     'pallet-timestamp/runtime-benchmarks',
+    'pallet-common/runtime-benchmarks',
+    'pallet-fungible/runtime-benchmarks',
+    'pallet-refungible/runtime-benchmarks',
+    'pallet-nonfungible/runtime-benchmarks',
     'pallet-nft/runtime-benchmarks',
     'pallet-inflation/runtime-benchmarks',
     'pallet-xcm/runtime-benchmarks',
@@ -67,6 +71,10 @@
     'parachain-info/std',
     'serde',
     'pallet-inflation/std',
+    'pallet-common/std',
+    'pallet-fungible/std',
+    'pallet-refungible/std',
+    'pallet-nonfungible/std',
     'pallet-nft/std',
     'pallet-scheduler/std',
     'pallet-nft-charge-transaction/std',
@@ -163,19 +171,19 @@
 # [dependencies.pallet-contracts]
 # git = 'https://github.com/paritytech/substrate.git'
 # default-features = false
-# branch = 'polkadot-v0.9.9'
+# branch = 'polkadot-v0.9.10'
 # version = '4.0.0-dev'
 
 # [dependencies.pallet-contracts-primitives]
 # git = 'https://github.com/paritytech/substrate.git'
 # default-features = false
-# branch = 'polkadot-v0.9.9'
+# branch = 'polkadot-v0.9.10'
 # version = '4.0.0-dev'
 
 # [dependencies.pallet-contracts-rpc-runtime-api]
 # git = 'https://github.com/paritytech/substrate.git'
 # default-features = false
-# branch = 'polkadot-v0.9.9'
+# branch = 'polkadot-v0.9.10'
 # version = '4.0.0-dev'
 
 [dependencies.pallet-randomness-collective-flip]
@@ -385,9 +393,14 @@
 [dependencies]
 derivative = "2.2.0"
 pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }
+up-rpc = { path = "../primitives/rpc", default-features = false }
 pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }
 nft-data-structs = { path = '../primitives/nft', default-features = false, version = '0.9.0' }
 pallet-scheduler = { path = '../pallets/scheduler', default-features = false, version = '3.0.0' }
+pallet-common = { default-features = false, path = "../pallets/common" }
+pallet-fungible = { default-features = false, path = "../pallets/fungible" }
+pallet-refungible = { default-features = false, path = "../pallets/refungible" }
+pallet-nonfungible = { default-features = false, path = "../pallets/nonfungible" }
 # pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
 pallet-nft-transaction-payment = { path = '../pallets/nft-transaction-payment', default-features = false, version = '3.0.0' }
 pallet-nft-charge-transaction = { path = '../pallets/nft-charge-transaction', 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 = "1024"]11#![allow(clippy::from_over_into, clippy::identity_op)]12#![allow(clippy::fn_to_numeric_cast_with_truncation)]13// Make the WASM binary available.14#[cfg(feature = "std")]15include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1617use sp_api::impl_runtime_apis;18use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};19// #[cfg(any(feature = "std", test))]20// pub use sp_runtime::BuildStorage;2122use sp_runtime::{23	Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,24	traits::{25		AccountIdLookup, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify,26		AccountIdConversion,27	},28	transaction_validity::{TransactionSource, TransactionValidity},29	ApplyExtrinsicResult, MultiSignature,30};3132use sp_std::prelude::*;3334#[cfg(feature = "std")]35use sp_version::NativeVersion;36use sp_version::RuntimeVersion;37pub use pallet_transaction_payment::{38	Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,39};40// A few exports that help ease life for downstream crates.41pub use pallet_balances::Call as BalancesCall;42pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};43pub use frame_support::{44	construct_runtime, match_type,45	dispatch::DispatchResult,46	PalletId, parameter_types, StorageValue, ConsensusEngineId,47	traits::{48		Everything, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem,49		LockIdentifier, OnUnbalanced, Randomness, FindAuthor,50	},51	weights::{52		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},53		DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,54		WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,55	},56};57use nft_data_structs::*;58// use pallet_contracts::weights::WeightInfo;59// #[cfg(any(feature = "std", test))]60use frame_system::{61	self as system, EnsureRoot, EnsureSigned,62	limits::{BlockWeights, BlockLength},63};64use sp_arithmetic::{65	traits::{BaseArithmetic, Unsigned},66};67use smallvec::smallvec;68use codec::{Encode, Decode};69use pallet_evm::{Account as EVMAccount, FeeCalculator, OnMethodCall};70use fp_rpc::TransactionStatus;71use sp_core::crypto::Public;72use sp_runtime::{73	traits::{Dispatchable},74};7576// pub use pallet_timestamp::Call as TimestampCall;77pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;7879// Polkadot imports80use pallet_xcm::XcmPassthrough;81use polkadot_parachain::primitives::Sibling;82use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};83use xcm_builder::{84	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,85	EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,86	ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,87	SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,88	SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,89};90use xcm_executor::{Config, XcmExecutor};9192// mod chain_extension;93// use crate::chain_extension::{NFTExtension, Imbalance};9495/// An index to a block.96pub type BlockNumber = u32;9798/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.99pub type Signature = MultiSignature;100101/// Some way of identifying an account on the chain. We intentionally make it equivalent102/// to the public key of our transaction signing scheme.103pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;104105/// The type for looking up accounts. We don't expect more than 4 billion of them, but you106/// never know...107pub type AccountIndex = u32;108109/// Balance of an account.110pub type Balance = u128;111112/// Index of a transaction in the chain.113pub type Index = u32;114115/// A hash of some data used by the chain.116pub type Hash = sp_core::H256;117118/// Digest item type.119pub type DigestItem = generic::DigestItem<Hash>;120121/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know122/// the specifics of the runtime. They can then be made to be agnostic over specific formats123/// of data like extrinsics, allowing for them to continue syncing the network through upgrades124/// to even the core data structures.125pub mod opaque {126	use super::*;127128	pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;129130	/// Opaque block type.131	pub type Block = generic::Block<Header, UncheckedExtrinsic>;132133	pub type SessionHandlers = ();134135	impl_opaque_keys! {136		pub struct SessionKeys {137			pub aura: Aura,138		}139	}140}141142/// This runtime version.143pub const VERSION: RuntimeVersion = RuntimeVersion {144	spec_name: create_runtime_str!("opal"),145	impl_name: create_runtime_str!("opal"),146	authoring_version: 1,147	spec_version: 910000,148	impl_version: 1,149	apis: RUNTIME_API_VERSIONS,150	transaction_version: 1,151};152153pub const MILLISECS_PER_BLOCK: u64 = 12000;154155pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;156157// These time units are defined in number of blocks.158pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);159pub const HOURS: BlockNumber = MINUTES * 60;160pub const DAYS: BlockNumber = HOURS * 24;161162parameter_types! {163	pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;164}165166#[derive(codec::Encode, codec::Decode)]167pub enum XCMPMessage<XAccountId, XBalance> {168	/// Transfer tokens to the given account from the Parachain account.169	TransferToken(XAccountId, XBalance),170}171172/// The version information used to identify this runtime when compiled natively.173#[cfg(feature = "std")]174pub fn native_version() -> NativeVersion {175	NativeVersion {176		runtime_version: VERSION,177		can_author_with: Default::default(),178	}179}180181type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;182183pub struct DealWithFees;184impl OnUnbalanced<NegativeImbalance> for DealWithFees {185	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {186		if let Some(fees) = fees_then_tips.next() {187			// for fees, 100% to treasury188			let mut split = fees.ration(100, 0);189			if let Some(tips) = fees_then_tips.next() {190				// for tips, if any, 100% to treasury191				tips.ration_merge_into(100, 0, &mut split);192			}193			Treasury::on_unbalanced(split.0);194			// Author::on_unbalanced(split.1);195		}196	}197}198199/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.200/// This is used to limit the maximal weight of a single extrinsic.201const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);202/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used203/// by  Operational  extrinsics.204const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);205/// We allow for 2 seconds of compute with a 6 second average block time.206const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;207208parameter_types! {209	pub const BlockHashCount: BlockNumber = 2400;210	pub RuntimeBlockLength: BlockLength =211		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);212	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);213	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;214	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()215		.base_block(BlockExecutionWeight::get())216		.for_class(DispatchClass::all(), |weights| {217			weights.base_extrinsic = ExtrinsicBaseWeight::get();218		})219		.for_class(DispatchClass::Normal, |weights| {220			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);221		})222		.for_class(DispatchClass::Operational, |weights| {223			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);224			// Operational transactions have some extra reserved space, so that they225			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.226			weights.reserved = Some(227				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT228			);229		})230		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)231		.build_or_panic();232	pub const Version: RuntimeVersion = VERSION;233	pub const SS58Prefix: u8 = 42;234}235236parameter_types! {237	pub const ChainId: u64 = 8888;238}239240pub struct FixedFee;241impl FeeCalculator for FixedFee {242	fn min_gas_price() -> U256 {243		1.into()244	}245}246247impl pallet_evm::Config for Runtime {248	type BlockGasLimit = BlockGasLimit;249	type FeeCalculator = FixedFee;250	type GasWeightMapping = ();251	type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;252	type CallOrigin = EnsureAddressTruncated;253	type WithdrawOrigin = EnsureAddressTruncated;254	type AddressMapping = HashedAddressMapping<Self::Hashing>;255	type Precompiles = ();256	type Currency = Balances;257	type Event = Event;258	type OnMethodCall = (259		pallet_evm_migration::OnMethodCall<Self>,260		pallet_nft::NftErcSupport<Self>,261		pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,262	);263	type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;264	type ChainId = ChainId;265	type Runner = pallet_evm::runner::stack::Runner<Self>;266	type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;267	type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;268	type FindAuthor = EthereumFindAuthor<Aura>;269}270271impl pallet_evm_migration::Config for Runtime {272	type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;273}274275pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);276impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {277	fn find_author<'a, I>(digests: I) -> Option<H160>278	where279		I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,280	{281		if let Some(author_index) = F::find_author(digests) {282			let authority_id = Aura::authorities()[author_index as usize].clone();283			return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));284		}285		None286	}287}288289parameter_types! {290	pub BlockGasLimit: U256 = U256::from(u32::max_value());291}292293impl pallet_ethereum::Config for Runtime {294	type Event = Event;295	type StateRoot = pallet_ethereum::IntermediateStateRoot;296	type EvmSubmitLog = pallet_evm::Pallet<Self>;297}298299impl pallet_randomness_collective_flip::Config for Runtime {}300301impl system::Config for Runtime {302	/// The data to be stored in an account.303	type AccountData = pallet_balances::AccountData<Balance>;304	/// The identifier used to distinguish between accounts.305	type AccountId = AccountId;306	/// The basic call filter to use in dispatchable.307	type BaseCallFilter = Everything;308	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).309	type BlockHashCount = BlockHashCount;310	/// The maximum length of a block (in bytes).311	type BlockLength = RuntimeBlockLength;312	/// The index type for blocks.313	type BlockNumber = BlockNumber;314	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.315	type BlockWeights = RuntimeBlockWeights;316	/// The aggregated dispatch type that is available for extrinsics.317	type Call = Call;318	/// The weight of database operations that the runtime can invoke.319	type DbWeight = RocksDbWeight;320	/// The ubiquitous event type.321	type Event = Event;322	/// The type for hashing blocks and tries.323	type Hash = Hash;324	/// The hashing algorithm used.325	type Hashing = BlakeTwo256;326	/// The header type.327	type Header = generic::Header<BlockNumber, BlakeTwo256>;328	/// The index type for storing how many extrinsics an account has signed.329	type Index = Index;330	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.331	type Lookup = AccountIdLookup<AccountId, ()>;332	/// What to do if an account is fully reaped from the system.333	type OnKilledAccount = ();334	/// What to do if a new account is created.335	type OnNewAccount = ();336	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;337	/// The ubiquitous origin type.338	type Origin = Origin;339	/// This type is being generated by `construct_runtime!`.340	type PalletInfo = PalletInfo;341	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.342	type SS58Prefix = SS58Prefix;343	/// Weight information for the extrinsics of this pallet.344	type SystemWeightInfo = system::weights::SubstrateWeight<Self>;345	/// Version of the runtime.346	type Version = Version;347}348349parameter_types! {350	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;351}352353impl pallet_timestamp::Config for Runtime {354	/// A timestamp: milliseconds since the unix epoch.355	type Moment = u64;356	type OnTimestampSet = ();357	type MinimumPeriod = MinimumPeriod;358	type WeightInfo = ();359}360361parameter_types! {362	// pub const ExistentialDeposit: u128 = 500;363	pub const ExistentialDeposit: u128 = 0;364	pub const MaxLocks: u32 = 50;365}366367impl pallet_balances::Config for Runtime {368	type MaxLocks = MaxLocks;369	type MaxReserves = ();370	type ReserveIdentifier = [u8; 8];371	/// The type for recording an account's balance.372	type Balance = Balance;373	/// The ubiquitous event type.374	type Event = Event;375	type DustRemoval = Treasury;376	type ExistentialDeposit = ExistentialDeposit;377	type AccountStore = System;378	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;379}380381pub const MICROUNIQUE: Balance = 1_000_000_000;382pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;383pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;384pub const UNIQUE: Balance = 100 * CENTIUNIQUE;385386pub const fn deposit(items: u32, bytes: u32) -> Balance {387	items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE388}389390/*391parameter_types! {392	pub TombstoneDeposit: Balance = deposit(393		1,394		sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,395	);396	pub DepositPerContract: Balance = TombstoneDeposit::get();397	pub const DepositPerStorageByte: Balance = deposit(0, 1);398	pub const DepositPerStorageItem: Balance = deposit(1, 0);399	pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);400	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;401	pub const SignedClaimHandicap: u32 = 2;402	pub const MaxDepth: u32 = 32;403	pub const MaxValueSize: u32 = 16 * 1024;404	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb405	// The lazy deletion runs inside on_initialize.406	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *407		RuntimeBlockWeights::get().max_block;408	// The weight needed for decoding the queue should be less or equal than a fifth409	// of the overall weight dedicated to the lazy deletion.410	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (411			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -412			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)413		)) / 5) as u32;414	pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();415}416417impl pallet_contracts::Config for Runtime {418	type Time = Timestamp;419	type Randomness = RandomnessCollectiveFlip;420	type Currency = Balances;421	type Event = Event;422	type RentPayment = ();423	type SignedClaimHandicap = SignedClaimHandicap;424	type TombstoneDeposit = TombstoneDeposit;425	type DepositPerContract = DepositPerContract;426	type DepositPerStorageByte = DepositPerStorageByte;427	type DepositPerStorageItem = DepositPerStorageItem;428	type RentFraction = RentFraction;429	type SurchargeReward = SurchargeReward;430	type WeightPrice = pallet_transaction_payment::Pallet<Self>;431	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;432	type ChainExtension = NFTExtension;433	type DeletionQueueDepth = DeletionQueueDepth;434	type DeletionWeightLimit = DeletionWeightLimit;435	type Schedule = Schedule;436	type CallStack = [pallet_contracts::Frame<Self>; 31];437}438*/439440parameter_types! {441	pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer442}443444/// Linear implementor of `WeightToFeePolynomial`445pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);446447impl<T> WeightToFeePolynomial for LinearFee<T>448where449	T: BaseArithmetic + From<u32> + Copy + Unsigned,450{451	type Balance = T;452453	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {454		smallvec!(WeightToFeeCoefficient {455			coeff_integer: 146_700u32.into(), // Targeting 0.1 Unique per NFT transfer456			coeff_frac: Perbill::zero(),457			negative: false,458			degree: 1,459		})460	}461}462463impl pallet_transaction_payment::Config for Runtime {464	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;465	type TransactionByteFee = TransactionByteFee;466	type WeightToFee = LinearFee<Balance>;467	type FeeMultiplierUpdate = ();468}469470parameter_types! {471	pub const ProposalBond: Permill = Permill::from_percent(5);472	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;473	pub const SpendPeriod: BlockNumber = 5 * MINUTES;474	pub const Burn: Permill = Permill::from_percent(0);475	pub const TipCountdown: BlockNumber = 1 * DAYS;476	pub const TipFindersFee: Percent = Percent::from_percent(20);477	pub const TipReportDepositBase: Balance = 1 * UNIQUE;478	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;479	pub const BountyDepositBase: Balance = 1 * UNIQUE;480	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;481	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");482	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;483	pub const MaximumReasonLength: u32 = 16384;484	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);485	pub const BountyValueMinimum: Balance = 5 * UNIQUE;486	pub const MaxApprovals: u32 = 100;487}488489impl pallet_treasury::Config for Runtime {490	type PalletId = TreasuryModuleId;491	type Currency = Balances;492	type ApproveOrigin = EnsureRoot<AccountId>;493	type RejectOrigin = EnsureRoot<AccountId>;494	type Event = Event;495	type OnSlash = ();496	type ProposalBond = ProposalBond;497	type ProposalBondMinimum = ProposalBondMinimum;498	type SpendPeriod = SpendPeriod;499	type Burn = Burn;500	type BurnDestination = ();501	type SpendFunds = ();502	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;503	type MaxApprovals = MaxApprovals;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 const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;525	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;526}527528impl cumulus_pallet_parachain_system::Config for Runtime {529	type Event = Event;530	type OnValidationData = ();531	type SelfParaId = parachain_info::Pallet<Self>;532	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<533	// 	MaxDownwardMessageWeight,534	// 	XcmExecutor<XcmConfig>,535	// 	Call,536	// >;537	type OutboundXcmpMessageSource = XcmpQueue;538	type DmpMessageHandler = DmpQueue;539	type ReservedDmpWeight = ReservedDmpWeight;540	type ReservedXcmpWeight = ReservedXcmpWeight;541	type XcmpMessageHandler = XcmpQueue;542}543544impl parachain_info::Config for Runtime {}545546impl cumulus_pallet_aura_ext::Config for Runtime {}547548parameter_types! {549	pub const RelayLocation: MultiLocation = MultiLocation::parent();550	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;551	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();552	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();553}554555/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used556/// when determining ownership of accounts for asset transacting and when attempting to use XCM557/// `Transact` in order to determine the dispatch Origin.558pub type LocationToAccountId = (559	// The parent (Relay-chain) origin converts to the default `AccountId`.560	ParentIsDefault<AccountId>,561	// Sibling parachain origins convert to AccountId via the `ParaId::into`.562	SiblingParachainConvertsVia<Sibling, AccountId>,563	// Straight up local `AccountId32` origins just alias directly to `AccountId`.564	AccountId32Aliases<RelayNetwork, AccountId>,565);566567/// Means for transacting assets on this chain.568pub type LocalAssetTransactor = CurrencyAdapter<569	// Use this currency:570	Balances,571	// Use this currency when it is a fungible asset matching the given location or name:572	IsConcrete<RelayLocation>,573	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:574	LocationToAccountId,575	// Our chain's account ID type (we can't get away without mentioning it explicitly):576	AccountId,577	// We don't track any teleports.578	(),579>;580581/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,582/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can583/// biases the kind of local `Origin` it will become.584pub type XcmOriginToTransactDispatchOrigin = (585	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location586	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for587	// foreign chains who want to have a local sovereign account on this chain which they control.588	SovereignSignedViaLocation<LocationToAccountId, Origin>,589	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when590	// recognised.591	RelayChainAsNative<RelayOrigin, Origin>,592	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when593	// recognised.594	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,595	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a596	// transaction from the Root origin.597	ParentAsSuperuser<Origin>,598	// Native signed account converter; this just converts an `AccountId32` origin into a normal599	// `Origin::Signed` origin of the same 32-byte value.600	SignedAccountId32AsNative<RelayNetwork, Origin>,601	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.602	XcmPassthrough<Origin>,603);604605parameter_types! {606	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.607	pub UnitWeightCost: Weight = 1_000_000;608	// 1200 UNIQUEs buy 1 second of weight.609	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);610}611612match_type! {613	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {614		MultiLocation { parents: 1, interior: Here } |615		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }616	};617}618619pub type Barrier = (620	TakeWeightCredit,621	AllowTopLevelPaidExecutionFrom<Everything>,622	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,623	// ^^^ Parent & its unit plurality gets free execution624);625626pub struct XcmConfig;627impl Config for XcmConfig {628	type Call = Call;629	type XcmSender = XcmRouter;630	// How to withdraw and deposit an asset.631	type AssetTransactor = LocalAssetTransactor;632	type OriginConverter = XcmOriginToTransactDispatchOrigin;633	type IsReserve = NativeAsset;634	type IsTeleporter = (); // Teleportation is disabled635	type LocationInverter = LocationInverter<Ancestry>;636	type Barrier = Barrier;637	type Weigher = FixedWeightBounds<UnitWeightCost, Call>;638	type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;639	type ResponseHandler = (); // Don't handle responses for now.640	type SubscriptionService = PolkadotXcm;641}642643// parameter_types! {644// 	pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;645// }646647/// No local origins on this chain are allowed to dispatch XCM sends/executions.648pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);649650/// The means for routing XCM messages which are not for local execution into the right message651/// queues.652pub type XcmRouter = (653	// Two routers - use UMP to communicate with the relay chain:654	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,655	// ..and XCMP to communicate with the sibling chains.656	XcmpQueue,657);658659impl pallet_evm_coder_substrate::Config for Runtime {660	type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;661}662663impl pallet_xcm::Config for Runtime {664	type Event = Event;665	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;666	type XcmRouter = XcmRouter;667	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;668	type XcmExecuteFilter = Everything;669	type XcmExecutor = XcmExecutor<XcmConfig>;670	type XcmTeleportFilter = Everything;671	type XcmReserveTransferFilter = ();672	type Weigher = FixedWeightBounds<UnitWeightCost, Call>;673	type LocationInverter = LocationInverter<Ancestry>;674}675676impl cumulus_pallet_xcm::Config for Runtime {677	type Event = Event;678	type XcmExecutor = XcmExecutor<XcmConfig>;679}680681impl cumulus_pallet_xcmp_queue::Config for Runtime {682	type Event = Event;683	type XcmExecutor = XcmExecutor<XcmConfig>;684	type ChannelInfo = ParachainSystem;685	type VersionWrapper = ();686}687688impl cumulus_pallet_dmp_queue::Config for Runtime {689	type Event = Event;690	type XcmExecutor = XcmExecutor<XcmConfig>;691	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;692}693694impl pallet_aura::Config for Runtime {695	type AuthorityId = AuraId;696	type DisabledValidators = ();697}698699parameter_types! {700	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();701	pub const CollectionCreationPrice: Balance = 100 * UNIQUE;702}703704/// Used for the pallet nft in `./nft.rs`705impl pallet_nft::Config for Runtime {706	type Event = Event;707	type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;708709	type EvmBackwardsAddressMapping = pallet_nft::MapBackwardsAddressTruncated;710	type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;711	type CrossAccountId = pallet_nft::BasicCrossAccountId<Self>;712713	type Currency = Balances;714	type CollectionCreationPrice = CollectionCreationPrice;715	type TreasuryAccountId = TreasuryAccountId;716}717718parameter_types! {719	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied720}721722/// Used for the pallet inflation723impl pallet_inflation::Config for Runtime {724	type Currency = Balances;725	type TreasuryAccountId = TreasuryAccountId;726	type InflationBlockInterval = InflationBlockInterval;727}728729parameter_types! {730	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *731		RuntimeBlockWeights::get().max_block;732	pub const MaxScheduledPerBlock: u32 = 50;733}734735pub struct Sponsoring;736impl SponsoringResolve<AccountId, Call> for Sponsoring {737	fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>738	where739		Call: Dispatchable<Info = DispatchInfo>,740		AccountId: AsRef<[u8]>,741	{742		pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)743	}744}745746type SponsorshipHandler = (747	pallet_nft::NftSponsorshipHandler<Runtime>,748	//pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,749);750751impl pallet_scheduler::Config for Runtime {752	type Event = Event;753	type Origin = Origin;754	type PalletsOrigin = OriginCaller;755	type Call = Call;756	type MaximumWeight = MaximumSchedulerWeight;757	type ScheduleOrigin = EnsureSigned<AccountId>;758	type MaxScheduledPerBlock = MaxScheduledPerBlock;759	type SponsorshipHandler = SponsorshipHandler;760	type WeightInfo = ();761}762763impl pallet_nft_transaction_payment::Config for Runtime {764	type SponsorshipHandler = SponsorshipHandler;765}766767impl pallet_evm_transaction_payment::Config for Runtime {768	type SponsorshipHandler = (769		pallet_nft::NftEthSponsorshipHandler<Self>,770		pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,771	);772	type Currency = Balances;773}774775impl pallet_nft_charge_transaction::Config for Runtime {}776777// impl pallet_contract_helpers::Config for Runtime {778//	 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;779// }780781parameter_types! {782	// 0x842899ECF380553E8a4de75bF534cdf6fBF64049783	pub const HelpersContractAddress: H160 = H160([784		0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,785	]);786}787788impl pallet_evm_contract_helpers::Config for Runtime {789	type ContractAddress = HelpersContractAddress;790	type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;791}792793construct_runtime!(794	pub enum Runtime where795		Block = Block,796		NodeBlock = opaque::Block,797		UncheckedExtrinsic = UncheckedExtrinsic798	{799		ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,800		ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,801802		Aura: pallet_aura::{Pallet, Config<T>} = 22,803		AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,804805		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,806		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,807		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,808		TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,809		Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,810		Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,811		System: system::{Pallet, Call, Storage, Config, Event<T>} = 36,812		Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,813		// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,814815		// XCM helpers.816		XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,817		PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,818		CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,819		DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,820821		// Unique Pallets822		Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,823		Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>} = 61,824		Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 62,825		NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage} = 63,826		Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,827		// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,828829		// Frontier830		EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,831		Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, ValidateUnsigned} = 101,832833		EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,834		EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,835		EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,836		EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,837	}838);839840pub struct TransactionConverter;841842impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {843	fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {844		UncheckedExtrinsic::new_unsigned(845			pallet_ethereum::Call::<Runtime>::transact(transaction).into(),846		)847	}848}849850impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {851	fn convert_transaction(852		&self,853		transaction: pallet_ethereum::Transaction,854	) -> opaque::UncheckedExtrinsic {855		let extrinsic = UncheckedExtrinsic::new_unsigned(856			pallet_ethereum::Call::<Runtime>::transact(transaction).into(),857		);858		let encoded = extrinsic.encode();859		opaque::UncheckedExtrinsic::decode(&mut &encoded[..])860			.expect("Encoded extrinsic is always valid")861	}862}863864/// The address format for describing accounts.865pub type Address = sp_runtime::MultiAddress<AccountId, ()>;866/// Block header type as expected by this runtime.867pub type Header = generic::Header<BlockNumber, BlakeTwo256>;868/// Block type as expected by this runtime.869pub type Block = generic::Block<Header, UncheckedExtrinsic>;870/// A Block signed with a Justification871pub type SignedBlock = generic::SignedBlock<Block>;872/// BlockId type as expected by this runtime.873pub type BlockId = generic::BlockId<Block>;874/// The SignedExtension to the basic transaction logic.875pub type SignedExtra = (876	system::CheckSpecVersion<Runtime>,877	// system::CheckTxVersion<Runtime>,878	system::CheckGenesis<Runtime>,879	system::CheckEra<Runtime>,880	system::CheckNonce<Runtime>,881	system::CheckWeight<Runtime>,882	pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,883	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,884);885/// Unchecked extrinsic type as expected by this runtime.886pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;887/// Extrinsic type that has already been checked.888pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;889/// Executive: handles dispatch to the various modules.890pub type Executive = frame_executive::Executive<891	Runtime,892	Block,893	frame_system::ChainContext<Runtime>,894	Runtime,895	AllPallets,896>;897898impl_opaque_keys! {899	pub struct SessionKeys {900		pub aura: Aura,901	}902}903904impl_runtime_apis! {905	impl pallet_nft::NftApi<Block>906		for Runtime907	{908		fn eth_contract_code(account: H160) -> Option<Vec<u8>> {909			<pallet_nft::NftErcSupport<Runtime>>::get_code(&account)910		}911	}912913	impl sp_api::Core<Block> for Runtime {914		fn version() -> RuntimeVersion {915			VERSION916		}917918		fn execute_block(block: Block) {919			Executive::execute_block(block)920		}921922		fn initialize_block(header: &<Block as BlockT>::Header) {923			Executive::initialize_block(header)924		}925	}926927	impl sp_api::Metadata<Block> for Runtime {928		fn metadata() -> OpaqueMetadata {929			Runtime::metadata().into()930		}931	}932933	impl sp_block_builder::BlockBuilder<Block> for Runtime {934		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {935			Executive::apply_extrinsic(extrinsic)936		}937938		fn finalize_block() -> <Block as BlockT>::Header {939			Executive::finalize_block()940		}941942		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {943			data.create_extrinsics()944		}945946		fn check_inherents(947			block: Block,948			data: sp_inherents::InherentData,949		) -> sp_inherents::CheckInherentsResult {950			data.check_extrinsics(&block)951		}952953		// fn random_seed() -> <Block as BlockT>::Hash {954		//     RandomnessCollectiveFlip::random_seed().0955		// }956	}957958	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {959		fn validate_transaction(960			source: TransactionSource,961			tx: <Block as BlockT>::Extrinsic,962			hash: <Block as BlockT>::Hash,963		) -> TransactionValidity {964			Executive::validate_transaction(source, tx, hash)965		}966	}967968	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {969		fn offchain_worker(header: &<Block as BlockT>::Header) {970			Executive::offchain_worker(header)971		}972	}973974	impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {975		fn chain_id() -> u64 {976			<Runtime as pallet_evm::Config>::ChainId::get()977		}978979		fn account_basic(address: H160) -> EVMAccount {980			EVM::account_basic(&address)981		}982983		fn gas_price() -> U256 {984			<Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()985		}986987		fn account_code_at(address: H160) -> Vec<u8> {988			EVM::account_codes(address)989		}990991		fn author() -> H160 {992			<pallet_evm::Pallet<Runtime>>::find_author()993		}994995		fn storage_at(address: H160, index: U256) -> H256 {996			let mut tmp = [0u8; 32];997			index.to_big_endian(&mut tmp);998			EVM::account_storages(address, H256::from_slice(&tmp[..]))999		}10001001		fn call(1002			from: H160,1003			to: H160,1004			data: Vec<u8>,1005			value: U256,1006			gas_limit: U256,1007			gas_price: Option<U256>,1008			nonce: Option<U256>,1009			estimate: bool,1010		) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1011			let config = if estimate {1012				let mut config = <Runtime as pallet_evm::Config>::config().clone();1013				config.estimate = true;1014				Some(config)1015			} else {1016				None1017			};10181019			<Runtime as pallet_evm::Config>::Runner::call(1020				from,1021				to,1022				data,1023				value,1024				gas_limit.low_u64(),1025				gas_price,1026				nonce,1027				config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1028			).map_err(|err| err.into())1029		}10301031		fn create(1032			from: H160,1033			data: Vec<u8>,1034			value: U256,1035			gas_limit: U256,1036			gas_price: Option<U256>,1037			nonce: Option<U256>,1038			estimate: bool,1039		) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1040			let config = if estimate {1041				let mut config = <Runtime as pallet_evm::Config>::config().clone();1042				config.estimate = true;1043				Some(config)1044			} else {1045				None1046			};10471048			<Runtime as pallet_evm::Config>::Runner::create(1049				from,1050				data,1051				value,1052				gas_limit.low_u64(),1053				gas_price,1054				nonce,1055				config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1056			).map_err(|err| err.into())1057		}10581059		fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1060			Ethereum::current_transaction_statuses()1061		}10621063		fn current_block() -> Option<pallet_ethereum::Block> {1064			Ethereum::current_block()1065		}10661067		fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1068			Ethereum::current_receipts()1069		}10701071		fn current_all() -> (1072			Option<pallet_ethereum::Block>,1073			Option<Vec<pallet_ethereum::Receipt>>,1074			Option<Vec<TransactionStatus>>1075		) {1076			(1077				Ethereum::current_block(),1078				Ethereum::current_receipts(),1079				Ethereum::current_transaction_statuses()1080			)1081		}10821083		fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1084			xts.into_iter().filter_map(|xt| match xt.function {1085				Call::Ethereum(pallet_ethereum::Call::transact(t)) => Some(t),1086				_ => None1087			}).collect()1088		}1089	}10901091	impl sp_session::SessionKeys<Block> for Runtime {1092		fn decode_session_keys(1093			encoded: Vec<u8>,1094		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1095			SessionKeys::decode_into_raw_public_keys(&encoded)1096		}10971098		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1099			SessionKeys::generate(seed)1100		}1101	}11021103	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1104		fn slot_duration() -> sp_consensus_aura::SlotDuration {1105			sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1106		}11071108		fn authorities() -> Vec<AuraId> {1109			Aura::authorities()1110		}1111	}11121113	impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1114		fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {1115			ParachainSystem::collect_collation_info()1116		}1117	}11181119	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1120		fn account_nonce(account: AccountId) -> Index {1121			System::account_nonce(account)1122		}1123	}11241125	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1126		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1127			TransactionPayment::query_info(uxt, len)1128		}1129		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1130			TransactionPayment::query_fee_details(uxt, len)1131		}1132	}11331134	/*1135	impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>1136		for Runtime1137	{1138		fn call(1139			origin: AccountId,1140			dest: AccountId,1141			value: Balance,1142			gas_limit: u64,1143			input_data: Vec<u8>,1144		) -> pallet_contracts_primitives::ContractExecResult {1145			Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)1146		}11471148		fn instantiate(1149			origin: AccountId,1150			endowment: Balance,1151			gas_limit: u64,1152			code: pallet_contracts_primitives::Code<Hash>,1153			data: Vec<u8>,1154			salt: Vec<u8>,1155		) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>1156		{1157			Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)1158		}11591160		fn get_storage(1161			address: AccountId,1162			key: [u8; 32],1163		) -> pallet_contracts_primitives::GetStorageResult {1164			Contracts::get_storage(address, key)1165		}11661167		fn rent_projection(1168			address: AccountId,1169		) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {1170			Contracts::rent_projection(address)1171		}1172	}1173	*/11741175	#[cfg(feature = "runtime-benchmarks")]1176	impl frame_benchmarking::Benchmark<Block> for Runtime {1177		fn dispatch_benchmark(1178			config: frame_benchmarking::BenchmarkConfig1179		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1180			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};11811182			let whitelist: Vec<TrackedStorageKey> = vec![1183				// Alice account1184				hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),1185				// // Total Issuance1186				// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),1187				// // Execution Phase1188				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),1189				// // Event Count1190				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),1191				// // System Events1192				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),1193			];11941195			let mut batches = Vec::<BenchmarkBatch>::new();1196			let params = (&config, &whitelist);11971198			add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1199			add_benchmark!(params, batches, pallet_nft, Nft);1200			add_benchmark!(params, batches, pallet_inflation, Inflation);12011202			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1203			Ok(batches)1204		}1205	}1206}12071208struct CheckInherents;12091210impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1211	fn check_inherents(1212		block: &Block,1213		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1214	) -> sp_inherents::CheckInherentsResult {1215		let relay_chain_slot = relay_state_proof1216			.read_slot()1217			.expect("Could not read the relay chain slot from the proof");12181219		let inherent_data =1220			cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1221				relay_chain_slot,1222				sp_std::time::Duration::from_secs(6),1223			)1224			.create_inherent_data()1225			.expect("Could not create the timestamp inherent data");12261227		inherent_data.check_extrinsics(block)1228	}1229}12301231cumulus_pallet_parachain_system::register_validate_block!(1232	Runtime = Runtime,1233	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1234	CheckInherents = CheckInherents,1235);
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 = "1024"]11#![allow(clippy::from_over_into, clippy::identity_op)]12#![allow(clippy::fn_to_numeric_cast_with_truncation)]13// Make the WASM binary available.14#[cfg(feature = "std")]15include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1617use sp_api::impl_runtime_apis;18use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};19// #[cfg(any(feature = "std", test))]20// pub use sp_runtime::BuildStorage;2122use sp_runtime::{23	Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,24	traits::{25		AccountIdLookup, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify,26		AccountIdConversion,27	},28	transaction_validity::{TransactionSource, TransactionValidity},29	ApplyExtrinsicResult, MultiSignature,30};3132use sp_std::prelude::*;3334#[cfg(feature = "std")]35use sp_version::NativeVersion;36use sp_version::RuntimeVersion;37pub use pallet_transaction_payment::{38	Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,39};40// A few exports that help ease life for downstream crates.41pub use pallet_balances::Call as BalancesCall;42pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};43pub use frame_support::{44	construct_runtime, match_type,45	dispatch::DispatchResult,46	PalletId, parameter_types, StorageValue, ConsensusEngineId,47	traits::{48		Everything, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem,49		LockIdentifier, OnUnbalanced, Randomness, FindAuthor,50	},51	weights::{52		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},53		DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,54		WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,55	},56};57use nft_data_structs::*;58// use pallet_contracts::weights::WeightInfo;59// #[cfg(any(feature = "std", test))]60use frame_system::{61	self as system, EnsureRoot, EnsureSigned,62	limits::{BlockWeights, BlockLength},63};64use sp_arithmetic::{65	traits::{BaseArithmetic, Unsigned},66};67use smallvec::smallvec;68use codec::{Encode, Decode};69use pallet_evm::{Account as EVMAccount, FeeCalculator, OnMethodCall};70use fp_rpc::TransactionStatus;71use sp_core::crypto::Public;72use sp_runtime::{73	traits::{Dispatchable},74};7576// pub use pallet_timestamp::Call as TimestampCall;77pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;7879// Polkadot imports80use pallet_xcm::XcmPassthrough;81use polkadot_parachain::primitives::Sibling;82use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};83use xcm_builder::{84	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,85	EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,86	ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,87	SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,88	SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,89};90use xcm_executor::{Config, XcmExecutor};9192// mod chain_extension;93// use crate::chain_extension::{NFTExtension, Imbalance};9495/// An index to a block.96pub type BlockNumber = u32;9798/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.99pub type Signature = MultiSignature;100101/// Some way of identifying an account on the chain. We intentionally make it equivalent102/// to the public key of our transaction signing scheme.103pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;104105pub type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;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>;122123/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know124/// the specifics of the runtime. They can then be made to be agnostic over specific formats125/// of data like extrinsics, allowing for them to continue syncing the network through upgrades126/// to even the core data structures.127pub mod opaque {128	use super::*;129130	pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;131132	/// Opaque block type.133	pub type Block = generic::Block<Header, UncheckedExtrinsic>;134135	pub type SessionHandlers = ();136137	impl_opaque_keys! {138		pub struct SessionKeys {139			pub aura: Aura,140		}141	}142}143144/// This runtime version.145pub const VERSION: RuntimeVersion = RuntimeVersion {146	spec_name: create_runtime_str!("opal"),147	impl_name: create_runtime_str!("opal"),148	authoring_version: 1,149	spec_version: 910000,150	impl_version: 1,151	apis: RUNTIME_API_VERSIONS,152	transaction_version: 1,153};154155pub const MILLISECS_PER_BLOCK: u64 = 12000;156157pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;158159// These time units are defined in number of blocks.160pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);161pub const HOURS: BlockNumber = MINUTES * 60;162pub const DAYS: BlockNumber = HOURS * 24;163164parameter_types! {165	pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;166}167168#[derive(codec::Encode, codec::Decode)]169pub enum XCMPMessage<XAccountId, XBalance> {170	/// Transfer tokens to the given account from the Parachain account.171	TransferToken(XAccountId, XBalance),172}173174/// The version information used to identify this runtime when compiled natively.175#[cfg(feature = "std")]176pub fn native_version() -> NativeVersion {177	NativeVersion {178		runtime_version: VERSION,179		can_author_with: Default::default(),180	}181}182183type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;184185pub struct DealWithFees;186impl OnUnbalanced<NegativeImbalance> for DealWithFees {187	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {188		if let Some(fees) = fees_then_tips.next() {189			// for fees, 100% to treasury190			let mut split = fees.ration(100, 0);191			if let Some(tips) = fees_then_tips.next() {192				// for tips, if any, 100% to treasury193				tips.ration_merge_into(100, 0, &mut split);194			}195			Treasury::on_unbalanced(split.0);196			// Author::on_unbalanced(split.1);197		}198	}199}200201/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.202/// This is used to limit the maximal weight of a single extrinsic.203const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);204/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used205/// by  Operational  extrinsics.206const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);207/// We allow for 2 seconds of compute with a 6 second average block time.208const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;209210parameter_types! {211	pub const BlockHashCount: BlockNumber = 2400;212	pub RuntimeBlockLength: BlockLength =213		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);214	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);215	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;216	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()217		.base_block(BlockExecutionWeight::get())218		.for_class(DispatchClass::all(), |weights| {219			weights.base_extrinsic = ExtrinsicBaseWeight::get();220		})221		.for_class(DispatchClass::Normal, |weights| {222			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);223		})224		.for_class(DispatchClass::Operational, |weights| {225			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);226			// Operational transactions have some extra reserved space, so that they227			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.228			weights.reserved = Some(229				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT230			);231		})232		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)233		.build_or_panic();234	pub const Version: RuntimeVersion = VERSION;235	pub const SS58Prefix: u8 = 42;236}237238parameter_types! {239	pub const ChainId: u64 = 8888;240}241242pub struct FixedFee;243impl FeeCalculator for FixedFee {244	fn min_gas_price() -> U256 {245		1.into()246	}247}248249impl pallet_evm::Config for Runtime {250	type BlockGasLimit = BlockGasLimit;251	type FeeCalculator = FixedFee;252	type GasWeightMapping = ();253	type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;254	type CallOrigin = EnsureAddressTruncated;255	type WithdrawOrigin = EnsureAddressTruncated;256	type AddressMapping = HashedAddressMapping<Self::Hashing>;257	type Precompiles = ();258	type Currency = Balances;259	type Event = Event;260	type OnMethodCall = (261		pallet_evm_migration::OnMethodCall<Self>,262		pallet_nft::NftErcSupport<Self>,263		pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,264	);265	type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;266	type ChainId = ChainId;267	type Runner = pallet_evm::runner::stack::Runner<Self>;268	type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;269	type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;270	type FindAuthor = EthereumFindAuthor<Aura>;271}272273impl pallet_evm_migration::Config for Runtime {274	type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;275}276277pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);278impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {279	fn find_author<'a, I>(digests: I) -> Option<H160>280	where281		I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,282	{283		if let Some(author_index) = F::find_author(digests) {284			let authority_id = Aura::authorities()[author_index as usize].clone();285			return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));286		}287		None288	}289}290291parameter_types! {292	pub BlockGasLimit: U256 = U256::from(u32::max_value());293}294295impl pallet_ethereum::Config for Runtime {296	type Event = Event;297	type StateRoot = pallet_ethereum::IntermediateStateRoot;298	type EvmSubmitLog = pallet_evm::Pallet<Self>;299}300301impl pallet_randomness_collective_flip::Config for Runtime {}302303impl system::Config for Runtime {304	/// The data to be stored in an account.305	type AccountData = pallet_balances::AccountData<Balance>;306	/// The identifier used to distinguish between accounts.307	type AccountId = AccountId;308	/// The basic call filter to use in dispatchable.309	type BaseCallFilter = Everything;310	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).311	type BlockHashCount = BlockHashCount;312	/// The maximum length of a block (in bytes).313	type BlockLength = RuntimeBlockLength;314	/// The index type for blocks.315	type BlockNumber = BlockNumber;316	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.317	type BlockWeights = RuntimeBlockWeights;318	/// The aggregated dispatch type that is available for extrinsics.319	type Call = Call;320	/// The weight of database operations that the runtime can invoke.321	type DbWeight = RocksDbWeight;322	/// The ubiquitous event type.323	type Event = Event;324	/// The type for hashing blocks and tries.325	type Hash = Hash;326	/// The hashing algorithm used.327	type Hashing = BlakeTwo256;328	/// The header type.329	type Header = generic::Header<BlockNumber, BlakeTwo256>;330	/// The index type for storing how many extrinsics an account has signed.331	type Index = Index;332	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.333	type Lookup = AccountIdLookup<AccountId, ()>;334	/// What to do if an account is fully reaped from the system.335	type OnKilledAccount = ();336	/// What to do if a new account is created.337	type OnNewAccount = ();338	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;339	/// The ubiquitous origin type.340	type Origin = Origin;341	/// This type is being generated by `construct_runtime!`.342	type PalletInfo = PalletInfo;343	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.344	type SS58Prefix = SS58Prefix;345	/// Weight information for the extrinsics of this pallet.346	type SystemWeightInfo = system::weights::SubstrateWeight<Self>;347	/// Version of the runtime.348	type Version = Version;349}350351parameter_types! {352	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;353}354355impl pallet_timestamp::Config for Runtime {356	/// A timestamp: milliseconds since the unix epoch.357	type Moment = u64;358	type OnTimestampSet = ();359	type MinimumPeriod = MinimumPeriod;360	type WeightInfo = ();361}362363parameter_types! {364	// pub const ExistentialDeposit: u128 = 500;365	pub const ExistentialDeposit: u128 = 0;366	pub const MaxLocks: u32 = 50;367}368369impl pallet_balances::Config for Runtime {370	type MaxLocks = MaxLocks;371	type MaxReserves = ();372	type ReserveIdentifier = [u8; 8];373	/// The type for recording an account's balance.374	type Balance = Balance;375	/// The ubiquitous event type.376	type Event = Event;377	type DustRemoval = Treasury;378	type ExistentialDeposit = ExistentialDeposit;379	type AccountStore = System;380	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;381}382383pub const MICROUNIQUE: Balance = 1_000_000_000;384pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;385pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;386pub const UNIQUE: Balance = 100 * CENTIUNIQUE;387388pub const fn deposit(items: u32, bytes: u32) -> Balance {389	items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE390}391392/*393parameter_types! {394	pub TombstoneDeposit: Balance = deposit(395		1,396		sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,397	);398	pub DepositPerContract: Balance = TombstoneDeposit::get();399	pub const DepositPerStorageByte: Balance = deposit(0, 1);400	pub const DepositPerStorageItem: Balance = deposit(1, 0);401	pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);402	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;403	pub const SignedClaimHandicap: u32 = 2;404	pub const MaxDepth: u32 = 32;405	pub const MaxValueSize: u32 = 16 * 1024;406	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb407	// The lazy deletion runs inside on_initialize.408	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *409		RuntimeBlockWeights::get().max_block;410	// The weight needed for decoding the queue should be less or equal than a fifth411	// of the overall weight dedicated to the lazy deletion.412	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (413			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -414			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)415		)) / 5) as u32;416	pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();417}418419impl pallet_contracts::Config for Runtime {420	type Time = Timestamp;421	type Randomness = RandomnessCollectiveFlip;422	type Currency = Balances;423	type Event = Event;424	type RentPayment = ();425	type SignedClaimHandicap = SignedClaimHandicap;426	type TombstoneDeposit = TombstoneDeposit;427	type DepositPerContract = DepositPerContract;428	type DepositPerStorageByte = DepositPerStorageByte;429	type DepositPerStorageItem = DepositPerStorageItem;430	type RentFraction = RentFraction;431	type SurchargeReward = SurchargeReward;432	type WeightPrice = pallet_transaction_payment::Pallet<Self>;433	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;434	type ChainExtension = NFTExtension;435	type DeletionQueueDepth = DeletionQueueDepth;436	type DeletionWeightLimit = DeletionWeightLimit;437	type Schedule = Schedule;438	type CallStack = [pallet_contracts::Frame<Self>; 31];439}440*/441442parameter_types! {443	pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer444}445446/// Linear implementor of `WeightToFeePolynomial`447pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);448449impl<T> WeightToFeePolynomial for LinearFee<T>450where451	T: BaseArithmetic + From<u32> + Copy + Unsigned,452{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 = pallet_transaction_payment::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: PalletId = PalletId(*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	pub const MaxApprovals: u32 = 100;489}490491impl pallet_treasury::Config for Runtime {492	type PalletId = TreasuryModuleId;493	type Currency = Balances;494	type ApproveOrigin = EnsureRoot<AccountId>;495	type RejectOrigin = EnsureRoot<AccountId>;496	type Event = Event;497	type OnSlash = ();498	type ProposalBond = ProposalBond;499	type ProposalBondMinimum = ProposalBondMinimum;500	type SpendPeriod = SpendPeriod;501	type Burn = Burn;502	type BurnDestination = ();503	type SpendFunds = ();504	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;505	type MaxApprovals = MaxApprovals;506}507508impl pallet_sudo::Config for Runtime {509	type Event = Event;510	type Call = Call;511}512513parameter_types! {514	pub const MinVestedTransfer: Balance = 10 * UNIQUE;515}516517impl pallet_vesting::Config for Runtime {518	type Event = Event;519	type Currency = Balances;520	type BlockNumberToBalance = ConvertInto;521	type MinVestedTransfer = MinVestedTransfer;522	type WeightInfo = ();523}524525parameter_types! {526	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;527	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;528}529530impl cumulus_pallet_parachain_system::Config for Runtime {531	type Event = Event;532	type OnValidationData = ();533	type SelfParaId = parachain_info::Pallet<Self>;534	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<535	// 	MaxDownwardMessageWeight,536	// 	XcmExecutor<XcmConfig>,537	// 	Call,538	// >;539	type OutboundXcmpMessageSource = XcmpQueue;540	type DmpMessageHandler = DmpQueue;541	type ReservedDmpWeight = ReservedDmpWeight;542	type ReservedXcmpWeight = ReservedXcmpWeight;543	type XcmpMessageHandler = XcmpQueue;544}545546impl parachain_info::Config for Runtime {}547548impl cumulus_pallet_aura_ext::Config for Runtime {}549550parameter_types! {551	pub const RelayLocation: MultiLocation = MultiLocation::parent();552	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;553	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();554	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();555}556557/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used558/// when determining ownership of accounts for asset transacting and when attempting to use XCM559/// `Transact` in order to determine the dispatch Origin.560pub type LocationToAccountId = (561	// The parent (Relay-chain) origin converts to the default `AccountId`.562	ParentIsDefault<AccountId>,563	// Sibling parachain origins convert to AccountId via the `ParaId::into`.564	SiblingParachainConvertsVia<Sibling, AccountId>,565	// Straight up local `AccountId32` origins just alias directly to `AccountId`.566	AccountId32Aliases<RelayNetwork, AccountId>,567);568569/// Means for transacting assets on this chain.570pub type LocalAssetTransactor = CurrencyAdapter<571	// Use this currency:572	Balances,573	// Use this currency when it is a fungible asset matching the given location or name:574	IsConcrete<RelayLocation>,575	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:576	LocationToAccountId,577	// Our chain's account ID type (we can't get away without mentioning it explicitly):578	AccountId,579	// We don't track any teleports.580	(),581>;582583/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,584/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can585/// biases the kind of local `Origin` it will become.586pub type XcmOriginToTransactDispatchOrigin = (587	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location588	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for589	// foreign chains who want to have a local sovereign account on this chain which they control.590	SovereignSignedViaLocation<LocationToAccountId, Origin>,591	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when592	// recognised.593	RelayChainAsNative<RelayOrigin, Origin>,594	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when595	// recognised.596	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,597	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a598	// transaction from the Root origin.599	ParentAsSuperuser<Origin>,600	// Native signed account converter; this just converts an `AccountId32` origin into a normal601	// `Origin::Signed` origin of the same 32-byte value.602	SignedAccountId32AsNative<RelayNetwork, Origin>,603	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.604	XcmPassthrough<Origin>,605);606607parameter_types! {608	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.609	pub UnitWeightCost: Weight = 1_000_000;610	// 1200 UNIQUEs buy 1 second of weight.611	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);612}613614match_type! {615	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {616		MultiLocation { parents: 1, interior: Here } |617		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }618	};619}620621pub type Barrier = (622	TakeWeightCredit,623	AllowTopLevelPaidExecutionFrom<Everything>,624	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,625	// ^^^ Parent & its unit plurality gets free execution626);627628pub struct XcmConfig;629impl Config for XcmConfig {630	type Call = Call;631	type XcmSender = XcmRouter;632	// How to withdraw and deposit an asset.633	type AssetTransactor = LocalAssetTransactor;634	type OriginConverter = XcmOriginToTransactDispatchOrigin;635	type IsReserve = NativeAsset;636	type IsTeleporter = (); // Teleportation is disabled637	type LocationInverter = LocationInverter<Ancestry>;638	type Barrier = Barrier;639	type Weigher = FixedWeightBounds<UnitWeightCost, Call>;640	type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;641	type ResponseHandler = (); // Don't handle responses for now.642	type SubscriptionService = PolkadotXcm;643}644645// parameter_types! {646// 	pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;647// }648649/// No local origins on this chain are allowed to dispatch XCM sends/executions.650pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);651652/// The means for routing XCM messages which are not for local execution into the right message653/// queues.654pub type XcmRouter = (655	// Two routers - use UMP to communicate with the relay chain:656	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,657	// ..and XCMP to communicate with the sibling chains.658	XcmpQueue,659);660661impl pallet_evm_coder_substrate::Config for Runtime {662	type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;663}664665impl pallet_xcm::Config for Runtime {666	type Event = Event;667	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;668	type XcmRouter = XcmRouter;669	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;670	type XcmExecuteFilter = Everything;671	type XcmExecutor = XcmExecutor<XcmConfig>;672	type XcmTeleportFilter = Everything;673	type XcmReserveTransferFilter = ();674	type Weigher = FixedWeightBounds<UnitWeightCost, Call>;675	type LocationInverter = LocationInverter<Ancestry>;676}677678impl cumulus_pallet_xcm::Config for Runtime {679	type Event = Event;680	type XcmExecutor = XcmExecutor<XcmConfig>;681}682683impl cumulus_pallet_xcmp_queue::Config for Runtime {684	type Event = Event;685	type XcmExecutor = XcmExecutor<XcmConfig>;686	type ChannelInfo = ParachainSystem;687	type VersionWrapper = ();688}689690impl cumulus_pallet_dmp_queue::Config for Runtime {691	type Event = Event;692	type XcmExecutor = XcmExecutor<XcmConfig>;693	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;694}695696impl pallet_aura::Config for Runtime {697	type AuthorityId = AuraId;698	type DisabledValidators = ();699}700701parameter_types! {702	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();703	pub const CollectionCreationPrice: Balance = 100 * UNIQUE;704}705706impl pallet_common::Config for Runtime {707	type Event = Event;708	type EvmBackwardsAddressMapping = pallet_common::account::MapBackwardsAddressTruncated;709	type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;710	type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;711712	type Currency = Balances;713	type CollectionCreationPrice = CollectionCreationPrice;714	type TreasuryAccountId = TreasuryAccountId;715}716717impl pallet_fungible::Config for Runtime {718	type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;719}720impl pallet_refungible::Config for Runtime {721	type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;722}723impl pallet_nonfungible::Config for Runtime {724	type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;725}726727/// Used for the pallet nft in `./nft.rs`728impl pallet_nft::Config for Runtime {729	type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;730}731732parameter_types! {733	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied734}735736/// Used for the pallet inflation737impl pallet_inflation::Config for Runtime {738	type Currency = Balances;739	type TreasuryAccountId = TreasuryAccountId;740	type InflationBlockInterval = InflationBlockInterval;741}742743parameter_types! {744	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *745		RuntimeBlockWeights::get().max_block;746	pub const MaxScheduledPerBlock: u32 = 50;747}748749pub struct Sponsoring;750impl SponsoringResolve<AccountId, Call> for Sponsoring {751	fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>752	where753		Call: Dispatchable<Info = DispatchInfo>,754		AccountId: AsRef<[u8]>,755	{756		pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)757	}758}759760type SponsorshipHandler = (761	pallet_nft::NftSponsorshipHandler<Runtime>,762	//pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,763);764765impl pallet_scheduler::Config for Runtime {766	type Event = Event;767	type Origin = Origin;768	type PalletsOrigin = OriginCaller;769	type Call = Call;770	type MaximumWeight = MaximumSchedulerWeight;771	type ScheduleOrigin = EnsureSigned<AccountId>;772	type MaxScheduledPerBlock = MaxScheduledPerBlock;773	type SponsorshipHandler = SponsorshipHandler;774	type WeightInfo = ();775}776777impl pallet_nft_transaction_payment::Config for Runtime {778	type SponsorshipHandler = SponsorshipHandler;779}780781impl pallet_evm_transaction_payment::Config for Runtime {782	type SponsorshipHandler = (783		pallet_nft::NftEthSponsorshipHandler<Self>,784		pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,785	);786	type Currency = Balances;787}788789impl pallet_nft_charge_transaction::Config for Runtime {}790791// impl pallet_contract_helpers::Config for Runtime {792//	 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;793// }794795parameter_types! {796	// 0x842899ECF380553E8a4de75bF534cdf6fBF64049797	pub const HelpersContractAddress: H160 = H160([798		0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,799	]);800}801802impl pallet_evm_contract_helpers::Config for Runtime {803	type ContractAddress = HelpersContractAddress;804	type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;805}806807construct_runtime!(808	pub enum Runtime where809		Block = Block,810		NodeBlock = opaque::Block,811		UncheckedExtrinsic = UncheckedExtrinsic812	{813		ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,814		ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,815816		Aura: pallet_aura::{Pallet, Config<T>} = 22,817		AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,818819		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,820		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,821		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,822		TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,823		Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,824		Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,825		System: system::{Pallet, Call, Storage, Config, Event<T>} = 36,826		Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,827		// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,828829		// XCM helpers.830		XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,831		PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,832		CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,833		DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,834835		// Unique Pallets836		Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,837		Nft: pallet_nft::{Pallet, Call, Storage} = 61,838		Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 62,839		NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage} = 63,840		Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,841		// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,842		Common: pallet_common::{Pallet, Storage, Event<T>} = 66,843		Fungible: pallet_fungible::{Pallet, Storage} = 67,844		Refungible: pallet_refungible::{Pallet, Storage} = 68,845		Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,846847		// Frontier848		EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,849		Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, ValidateUnsigned} = 101,850851		EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,852		EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,853		EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,854		EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,855	}856);857858pub struct TransactionConverter;859860impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {861	fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {862		UncheckedExtrinsic::new_unsigned(863			pallet_ethereum::Call::<Runtime>::transact(transaction).into(),864		)865	}866}867868impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {869	fn convert_transaction(870		&self,871		transaction: pallet_ethereum::Transaction,872	) -> opaque::UncheckedExtrinsic {873		let extrinsic = UncheckedExtrinsic::new_unsigned(874			pallet_ethereum::Call::<Runtime>::transact(transaction).into(),875		);876		let encoded = extrinsic.encode();877		opaque::UncheckedExtrinsic::decode(&mut &encoded[..])878			.expect("Encoded extrinsic is always valid")879	}880}881882/// The address format for describing accounts.883pub type Address = sp_runtime::MultiAddress<AccountId, ()>;884/// Block header type as expected by this runtime.885pub type Header = generic::Header<BlockNumber, BlakeTwo256>;886/// Block type as expected by this runtime.887pub type Block = generic::Block<Header, UncheckedExtrinsic>;888/// A Block signed with a Justification889pub type SignedBlock = generic::SignedBlock<Block>;890/// BlockId type as expected by this runtime.891pub type BlockId = generic::BlockId<Block>;892/// The SignedExtension to the basic transaction logic.893pub type SignedExtra = (894	system::CheckSpecVersion<Runtime>,895	// system::CheckTxVersion<Runtime>,896	system::CheckGenesis<Runtime>,897	system::CheckEra<Runtime>,898	system::CheckNonce<Runtime>,899	system::CheckWeight<Runtime>,900	pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,901	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,902);903/// Unchecked extrinsic type as expected by this runtime.904pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;905/// Extrinsic type that has already been checked.906pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;907/// Executive: handles dispatch to the various modules.908pub type Executive = frame_executive::Executive<909	Runtime,910	Block,911	frame_system::ChainContext<Runtime>,912	Runtime,913	AllPallets,914>;915916impl_opaque_keys! {917	pub struct SessionKeys {918		pub aura: Aura,919	}920}921922macro_rules! dispatch_nft_runtime {923	($collection:ident.$method:ident($($name:ident),*)) => {{924		use pallet_nft::dispatch::Dispatched;925926		let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::new($collection).unwrap());927		let dispatch = collection.as_dyn();928929		dispatch.$method($($name),*)930	}};931}932933impl_runtime_apis! {934	impl up_rpc::NftApi<Block, CrossAccountId, AccountId>935		for Runtime936	{937		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId> {938			dispatch_nft_runtime!(collection.account_tokens(account))939		}940		fn token_exists(collection: CollectionId, token: TokenId) -> bool {941			dispatch_nft_runtime!(collection.token_exists(token))942		}943944		fn token_owner(collection: CollectionId, token: TokenId) -> CrossAccountId {945			dispatch_nft_runtime!(collection.token_owner(token))946		}947		fn const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {948			dispatch_nft_runtime!(collection.const_metadata(token))949		}950		fn variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {951			dispatch_nft_runtime!(collection.variable_metadata(token))952		}953954		fn collection_tokens(collection: CollectionId) -> u32 {955			dispatch_nft_runtime!(collection.collection_tokens())956		}957		fn account_balance(collection: CollectionId, account: CrossAccountId) -> u32 {958			dispatch_nft_runtime!(collection.account_balance(account))959		}960		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> u128 {961			dispatch_nft_runtime!(collection.balance(account, token))962		}963		fn allowance(964			collection: CollectionId,965			sender: CrossAccountId,966			spender: CrossAccountId,967			token: TokenId,968		) -> u128 {969			dispatch_nft_runtime!(collection.allowance(sender, spender, token))970		}971972		fn eth_contract_code(account: H160) -> Option<Vec<u8>> {973			<pallet_nft::NftErcSupport<Runtime>>::get_code(&account)974		}975	}976977	impl sp_api::Core<Block> for Runtime {978		fn version() -> RuntimeVersion {979			VERSION980		}981982		fn execute_block(block: Block) {983			Executive::execute_block(block)984		}985986		fn initialize_block(header: &<Block as BlockT>::Header) {987			Executive::initialize_block(header)988		}989	}990991	impl sp_api::Metadata<Block> for Runtime {992		fn metadata() -> OpaqueMetadata {993			Runtime::metadata().into()994		}995	}996997	impl sp_block_builder::BlockBuilder<Block> for Runtime {998		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {999			Executive::apply_extrinsic(extrinsic)1000		}10011002		fn finalize_block() -> <Block as BlockT>::Header {1003			Executive::finalize_block()1004		}10051006		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {1007			data.create_extrinsics()1008		}10091010		fn check_inherents(1011			block: Block,1012			data: sp_inherents::InherentData,1013		) -> sp_inherents::CheckInherentsResult {1014			data.check_extrinsics(&block)1015		}10161017		// fn random_seed() -> <Block as BlockT>::Hash {1018		//     RandomnessCollectiveFlip::random_seed().01019		// }1020	}10211022	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {1023		fn validate_transaction(1024			source: TransactionSource,1025			tx: <Block as BlockT>::Extrinsic,1026			hash: <Block as BlockT>::Hash,1027		) -> TransactionValidity {1028			Executive::validate_transaction(source, tx, hash)1029		}1030	}10311032	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {1033		fn offchain_worker(header: &<Block as BlockT>::Header) {1034			Executive::offchain_worker(header)1035		}1036	}10371038	impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {1039		fn chain_id() -> u64 {1040			<Runtime as pallet_evm::Config>::ChainId::get()1041		}10421043		fn account_basic(address: H160) -> EVMAccount {1044			EVM::account_basic(&address)1045		}10461047		fn gas_price() -> U256 {1048			<Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()1049		}10501051		fn account_code_at(address: H160) -> Vec<u8> {1052			EVM::account_codes(address)1053		}10541055		fn author() -> H160 {1056			<pallet_evm::Pallet<Runtime>>::find_author()1057		}10581059		fn storage_at(address: H160, index: U256) -> H256 {1060			let mut tmp = [0u8; 32];1061			index.to_big_endian(&mut tmp);1062			EVM::account_storages(address, H256::from_slice(&tmp[..]))1063		}10641065		fn call(1066			from: H160,1067			to: H160,1068			data: Vec<u8>,1069			value: U256,1070			gas_limit: U256,1071			gas_price: Option<U256>,1072			nonce: Option<U256>,1073			estimate: bool,1074		) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1075			let config = if estimate {1076				let mut config = <Runtime as pallet_evm::Config>::config().clone();1077				config.estimate = true;1078				Some(config)1079			} else {1080				None1081			};10821083			<Runtime as pallet_evm::Config>::Runner::call(1084				from,1085				to,1086				data,1087				value,1088				gas_limit.low_u64(),1089				gas_price,1090				nonce,1091				config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1092			).map_err(|err| err.into())1093		}10941095		fn create(1096			from: H160,1097			data: Vec<u8>,1098			value: U256,1099			gas_limit: U256,1100			gas_price: Option<U256>,1101			nonce: Option<U256>,1102			estimate: bool,1103		) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1104			let config = if estimate {1105				let mut config = <Runtime as pallet_evm::Config>::config().clone();1106				config.estimate = true;1107				Some(config)1108			} else {1109				None1110			};11111112			<Runtime as pallet_evm::Config>::Runner::create(1113				from,1114				data,1115				value,1116				gas_limit.low_u64(),1117				gas_price,1118				nonce,1119				config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1120			).map_err(|err| err.into())1121		}11221123		fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1124			Ethereum::current_transaction_statuses()1125		}11261127		fn current_block() -> Option<pallet_ethereum::Block> {1128			Ethereum::current_block()1129		}11301131		fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1132			Ethereum::current_receipts()1133		}11341135		fn current_all() -> (1136			Option<pallet_ethereum::Block>,1137			Option<Vec<pallet_ethereum::Receipt>>,1138			Option<Vec<TransactionStatus>>1139		) {1140			(1141				Ethereum::current_block(),1142				Ethereum::current_receipts(),1143				Ethereum::current_transaction_statuses()1144			)1145		}11461147		fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1148			xts.into_iter().filter_map(|xt| match xt.function {1149				Call::Ethereum(pallet_ethereum::Call::transact(t)) => Some(t),1150				_ => None1151			}).collect()1152		}1153	}11541155	impl sp_session::SessionKeys<Block> for Runtime {1156		fn decode_session_keys(1157			encoded: Vec<u8>,1158		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1159			SessionKeys::decode_into_raw_public_keys(&encoded)1160		}11611162		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1163			SessionKeys::generate(seed)1164		}1165	}11661167	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1168		fn slot_duration() -> sp_consensus_aura::SlotDuration {1169			sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1170		}11711172		fn authorities() -> Vec<AuraId> {1173			Aura::authorities()1174		}1175	}11761177	impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1178		fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {1179			ParachainSystem::collect_collation_info()1180		}1181	}11821183	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1184		fn account_nonce(account: AccountId) -> Index {1185			System::account_nonce(account)1186		}1187	}11881189	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1190		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1191			TransactionPayment::query_info(uxt, len)1192		}1193		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1194			TransactionPayment::query_fee_details(uxt, len)1195		}1196	}11971198	/*1199	impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>1200		for Runtime1201	{1202		fn call(1203			origin: AccountId,1204			dest: AccountId,1205			value: Balance,1206			gas_limit: u64,1207			input_data: Vec<u8>,1208		) -> pallet_contracts_primitives::ContractExecResult {1209			Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)1210		}12111212		fn instantiate(1213			origin: AccountId,1214			endowment: Balance,1215			gas_limit: u64,1216			code: pallet_contracts_primitives::Code<Hash>,1217			data: Vec<u8>,1218			salt: Vec<u8>,1219		) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>1220		{1221			Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)1222		}12231224		fn get_storage(1225			address: AccountId,1226			key: [u8; 32],1227		) -> pallet_contracts_primitives::GetStorageResult {1228			Contracts::get_storage(address, key)1229		}12301231		fn rent_projection(1232			address: AccountId,1233		) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {1234			Contracts::rent_projection(address)1235		}1236	}1237	*/12381239	#[cfg(feature = "runtime-benchmarks")]1240	impl frame_benchmarking::Benchmark<Block> for Runtime {1241		fn dispatch_benchmark(1242			config: frame_benchmarking::BenchmarkConfig1243		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1244			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};12451246			let whitelist: Vec<TrackedStorageKey> = vec![1247				// Alice account1248				hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),1249				// // Total Issuance1250				// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),1251				// // Execution Phase1252				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),1253				// // Event Count1254				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),1255				// // System Events1256				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),1257			];12581259			let mut batches = Vec::<BenchmarkBatch>::new();1260			let params = (&config, &whitelist);12611262			add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1263			add_benchmark!(params, batches, pallet_nft, Nft);1264			add_benchmark!(params, batches, pallet_inflation, Inflation);12651266			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1267			Ok(batches)1268		}1269	}1270}12711272struct CheckInherents;12731274impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1275	fn check_inherents(1276		block: &Block,1277		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1278	) -> sp_inherents::CheckInherentsResult {1279		let relay_chain_slot = relay_state_proof1280			.read_slot()1281			.expect("Could not read the relay chain slot from the proof");12821283		let inherent_data =1284			cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1285				relay_chain_slot,1286				sp_std::time::Duration::from_secs(6),1287			)1288			.create_inherent_data()1289			.expect("Could not create the timestamp inherent data");12901291		inherent_data.check_extrinsics(block)1292	}1293}12941295cumulus_pallet_parachain_system::register_validate_block!(1296	Runtime = Runtime,1297	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1298	CheckInherents = CheckInherents,1299);