git.delta.rocks / unique-network / refs/commits / 07883ab68c21

difftreelog

CORE-195. Sponsoring

str-mv2021-11-02parent: #cadd585.patch.diff
in: master

13 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5090,10 +5090,10 @@
  "pallet-evm-transaction-payment",
  "pallet-inflation",
  "pallet-nft",
- "pallet-nft-charge-transaction",
  "pallet-nft-transaction-payment",
  "pallet-randomness-collective-flip",
  "pallet-sudo",
+ "pallet-template-charge-transaction",
  "pallet-timestamp",
  "pallet-transaction-payment",
  "pallet-transaction-payment-rpc-runtime-api",
@@ -6010,25 +6010,6 @@
  "sp-runtime",
  "sp-std",
  "up-sponsorship",
-]
-
-[[package]]
-name = "pallet-nft-charge-transaction"
-version = "3.0.0"
-dependencies = [
- "frame-benchmarking",
- "frame-support",
- "frame-system",
- "pallet-balances",
- "pallet-nft-transaction-payment",
- "pallet-transaction-payment",
- "parity-scale-codec",
- "scale-info",
- "serde",
- "sp-core",
- "sp-io",
- "sp-runtime",
- "sp-std",
 ]
 
 [[package]]
@@ -6271,6 +6252,26 @@
 ]
 
 [[package]]
+name = "pallet-template-charge-transaction"
+version = "3.0.0"
+source = "git+https://github.com/UniqueNetwork/pallet-sponsoring#e5d3354ab68face1b2ef709dc7f629803f56598d"
+dependencies = [
+ "frame-benchmarking",
+ "frame-support",
+ "frame-system",
+ "pallet-balances",
+ "pallet-transaction-payment",
+ "parity-scale-codec",
+ "scale-info",
+ "serde",
+ "sp-core",
+ "sp-io",
+ "sp-runtime",
+ "sp-std",
+ "up-sponsorship",
+]
+
+[[package]]
 name = "pallet-timestamp"
 version = "4.0.0-dev"
 source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.12#d76f39995315ec36980908e4b99709bd14927044"
@@ -11597,7 +11598,7 @@
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "1f559b464de2e2bdabcac6a210d12e9b5a5973c251e102c44c585c71d51bd78e"
 dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if 0.1.10",
  "rand 0.8.4",
  "static_assertions",
 ]
@@ -11717,6 +11718,7 @@
 [[package]]
 name = "up-sponsorship"
 version = "0.1.0"
+source = "git+https://github.com/UniqueNetwork/pallet-sponsoring#e5d3354ab68face1b2ef709dc7f629803f56598d"
 dependencies = [
  "impl-trait-for-tuples 0.2.1",
 ]
modifiedpallets/contract-helpers/Cargo.tomldiffbeforeafterboth
--- a/pallets/contract-helpers/Cargo.toml
+++ b/pallets/contract-helpers/Cargo.toml
@@ -9,11 +9,6 @@
 package = 'parity-scale-codec'
 version = '2.3.0'
 
-[dependencies.up-sponsorship]
-default-features = false
-path = '../../primitives/sponsorship'
-version = '0.1.0'
-
 [dependencies]
 scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
 frame-support = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
@@ -21,6 +16,7 @@
 pallet-contracts = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
 sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
 sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 
 
 [features]
 default = ["std"]
modifiedpallets/evm-contract-helpers/Cargo.tomldiffbeforeafterboth
--- a/pallets/evm-contract-helpers/Cargo.toml
+++ b/pallets/evm-contract-helpers/Cargo.toml
@@ -13,7 +13,7 @@
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
 pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }
 pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }
-up-sponsorship = { default-features = false, path = '../../primitives/sponsorship' }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 
 log = "0.4.14"
 
 [dependencies.codec]
modifiedpallets/evm-transaction-payment/Cargo.tomldiffbeforeafterboth
--- a/pallets/evm-transaction-payment/Cargo.toml
+++ b/pallets/evm-transaction-payment/Cargo.toml
@@ -14,7 +14,7 @@
 pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }
 fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }
 pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }
-up-sponsorship = { default-features = false, path = '../../primitives/sponsorship' }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 
 
 [dependencies.codec]
 default-features = false
deletedpallets/nft-charge-transaction/Cargo.tomldiffbeforeafterboth
--- a/pallets/nft-charge-transaction/Cargo.toml
+++ /dev/null
@@ -1,50 +0,0 @@
-[package]
-authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
-description = 'Unqiue pallet nft specific transaction payment'
-edition = '2018'
-homepage = 'https://substrate.io'
-license = 'Unlicense'
-name = 'pallet-nft-charge-transaction'
-repository = 'https://github.com/usetech-llc/nft_private/'
-version = '3.0.0'
-
-[package.metadata.docs.rs]
-targets = ['x86_64-unknown-linux-gnu']
-
-# alias "parity-scale-code" to "codec"
-[dependencies.codec]
-default-features = false
-features = ['derive']
-package = 'parity-scale-codec'
-version = '2.3.0'
-
-[dependencies]
-scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
-serde = { version = "1.0.130", default-features = false }
-frame-support = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
-frame-system = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
-pallet-balances = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
-pallet-transaction-payment = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
-sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
-frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
-sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
-sp-io = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
-sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
-
-pallet-nft-transaction-payment = { default-features = false, path = "../nft-transaction-payment" }
-
-[features]
-default = ['std']
-std = [
-    'codec/std',
-    'serde/std',
-    'frame-support/std',
-    'frame-system/std',
-    'pallet-balances/std',
-    'pallet-transaction-payment/std',
-    'pallet-nft-transaction-payment/std',
-    'sp-std/std',
-    'sp-runtime/std',
-    'frame-benchmarking/std',
-]
-runtime-benchmarks = ["frame-benchmarking"]
deletedpallets/nft-charge-transaction/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft-charge-transaction/src/lib.rs
+++ /dev/null
@@ -1,196 +0,0 @@
-//
-// This file is subject to the terms and conditions defined in
-// file 'LICENSE', which is part of this source code package.
-//
-
-#![cfg_attr(not(feature = "std"), no_std)]
-
-#[cfg(feature = "std")]
-pub use std::*;
-
-use scale_info::TypeInfo;
-#[cfg(feature = "std")]
-pub use serde::*;
-
-use codec::{Decode, Encode};
-use frame_support::traits::Get;
-use frame_support::{
-	decl_module, decl_storage,
-	weights::{DispatchInfo, PostDispatchInfo, DispatchClass},
-};
-use sp_runtime::{
-	traits::{
-		DispatchInfoOf, Dispatchable, PostDispatchInfoOf, Saturating, SaturatedConversion,
-		SignedExtension, Zero,
-	},
-	transaction_validity::{
-		TransactionPriority, TransactionValidity, TransactionValidityError, ValidTransaction,
-	},
-	FixedPointOperand, DispatchResult,
-};
-use pallet_transaction_payment::OnChargeTransaction;
-use sp_std::prelude::*;
-
-pub trait Config: frame_system::Config + pallet_nft_transaction_payment::Config + TypeInfo {}
-
-decl_storage! {
-	trait Store for Module<T: Config> as NftTransactionPayment
-	{}
-}
-
-decl_module! {
-
-	pub struct Module<T: Config> for enum Call
-	where
-		origin: T::Origin,
-	{}
-}
-
-type BalanceOf<T> = <<T as pallet_transaction_payment::Config>::OnChargeTransaction as pallet_transaction_payment::OnChargeTransaction<T>>::Balance;
-
-/// Require the transactor pay for themselves and maybe include a tip to gain additional priority
-/// in the queue.
-#[derive(Encode, Decode, Clone, Eq, PartialEq, scale_info::TypeInfo)]
-pub struct ChargeTransactionPayment<T: Config>(#[codec(compact)] BalanceOf<T>);
-
-impl<T: Config + Send + Sync> sp_std::fmt::Debug for ChargeTransactionPayment<T> {
-	#[cfg(feature = "std")]
-	fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
-		write!(f, "ChargeTransactionPayment<{:?}>", self.0)
-	}
-	#[cfg(not(feature = "std"))]
-	fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
-		Ok(())
-	}
-}
-
-impl<T: Config> ChargeTransactionPayment<T>
-where
-	T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
-	BalanceOf<T>: Send + Sync + From<u64> + FixedPointOperand,
-{
-	fn traditional_fee(
-		len: usize,
-		info: &DispatchInfoOf<T::Call>,
-		tip: BalanceOf<T>,
-	) -> BalanceOf<T>
-	where
-		T::Call: Dispatchable<Info = DispatchInfo>,
-	{
-		<pallet_transaction_payment::Pallet<T>>::compute_fee(len as u32, info, tip)
-	}
-
-	fn get_priority(
-		len: usize,
-		info: &DispatchInfoOf<T::Call>,
-		final_fee: BalanceOf<T>,
-	) -> TransactionPriority {
-		let weight_saturation = T::BlockWeights::get().max_block / info.weight.max(1);
-		let max_block_length = *T::BlockLength::get().max.get(DispatchClass::Normal);
-		let len_saturation = max_block_length as u64 / (len as u64).max(1);
-		let coefficient: BalanceOf<T> = weight_saturation
-			.min(len_saturation)
-			.saturated_into::<BalanceOf<T>>();
-		final_fee
-			.saturating_mul(coefficient)
-			.saturated_into::<TransactionPriority>()
-	}
-
-	#[allow(clippy::type_complexity)]
-    fn withdraw_fee(
-        &self,
-        who: &T::AccountId,
-        call: &T::Call,
-        info: &DispatchInfoOf<T::Call>,
-        len: usize,
-	) -> Result<
-		(
-			BalanceOf<T>,
-			<<T as pallet_transaction_payment::Config>::OnChargeTransaction as pallet_transaction_payment::OnChargeTransaction<T>>::LiquidityInfo,
-		),
-		TransactionValidityError,
-	>{
-		let tip = self.0;
-
-		let fee = Self::traditional_fee(len, info, tip);
-
-		// Only mess with balances if fee is not zero.
-		if fee.is_zero() {
-			return <<T as pallet_transaction_payment::Config>::OnChargeTransaction as pallet_transaction_payment::OnChargeTransaction<T>>::withdraw_fee(who, call, info, fee, tip)
-			.map(|i| (fee, i));
-		}
-
-		// Determine who is paying transaction fee based on ecnomic model
-		// Parse call to extract collection ID and access collection sponsor
-		let sponsor = <pallet_nft_transaction_payment::Module<T>>::withdraw_type(who, call);
-
-		let who_pays_fee = sponsor.unwrap_or_else(|| who.clone());
-
-		<<T as pallet_transaction_payment::Config>::OnChargeTransaction as pallet_transaction_payment::OnChargeTransaction<T>>::withdraw_fee(&who_pays_fee, call, info, fee, tip)
-			.map(|i| (fee, i))
-	}
-}
-
-impl<T: Config + Send + Sync> SignedExtension for ChargeTransactionPayment<T>
-where
-	BalanceOf<T>: Send + Sync + From<u64> + FixedPointOperand,
-	T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
-{
-	const IDENTIFIER: &'static str = "ChargeTransactionPayment";
-	type AccountId = T::AccountId;
-	type Call = T::Call;
-	type AdditionalSigned = ();
-	type Pre = (
-        // tip
-        BalanceOf<T>,
-        // who pays fee
-        Self::AccountId,
-		// imbalance resulting from withdrawing the fee
-		<<T as pallet_transaction_payment::Config>::OnChargeTransaction as pallet_transaction_payment::OnChargeTransaction<T>>::LiquidityInfo,
-    );
-	fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> {
-		Ok(())
-	}
-
-	fn validate(
-		&self,
-		who: &Self::AccountId,
-		call: &Self::Call,
-		info: &DispatchInfoOf<Self::Call>,
-		len: usize,
-	) -> TransactionValidity {
-		let (fee, _) = self.withdraw_fee(who, call, info, len)?;
-		Ok(ValidTransaction {
-			priority: Self::get_priority(len, info, fee),
-			..Default::default()
-		})
-	}
-
-	fn pre_dispatch(
-		self,
-		who: &Self::AccountId,
-		call: &Self::Call,
-		info: &DispatchInfoOf<Self::Call>,
-		len: usize,
-	) -> Result<Self::Pre, TransactionValidityError> {
-		let (_fee, imbalance) = self.withdraw_fee(who, call, info, len)?;
-		Ok((self.0, who.clone(), imbalance))
-	}
-
-	fn post_dispatch(
-		pre: Self::Pre,
-		info: &DispatchInfoOf<Self::Call>,
-		post_info: &PostDispatchInfoOf<Self::Call>,
-		len: usize,
-		_result: &DispatchResult,
-	) -> Result<(), TransactionValidityError> {
-		let (tip, who, imbalance) = pre;
-		let actual_fee = pallet_transaction_payment::Pallet::<T>::compute_actual_fee(
-			len as u32, info, post_info, tip,
-		);
-		<T as pallet_transaction_payment::Config>::OnChargeTransaction::correct_and_deposit_fee(
-			&who, info, post_info, actual_fee, tip, imbalance,
-		)?;
-		Ok(())
-	}
-}
modifiedpallets/nft-transaction-payment/Cargo.tomldiffbeforeafterboth
--- a/pallets/nft-transaction-payment/Cargo.toml
+++ b/pallets/nft-transaction-payment/Cargo.toml
@@ -30,7 +30,7 @@
 sp-io = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
 sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
 
-up-sponsorship = { default-features = false, path = "../../primitives/sponsorship", version = "0.1.0" }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 
 
 [features]
 default = ['std']
modifiedpallets/nft/Cargo.tomldiffbeforeafterboth
--- a/pallets/nft/Cargo.toml
+++ b/pallets/nft/Cargo.toml
@@ -122,18 +122,14 @@
 path = '../../primitives/nft'
 version = '0.9.0'
 
-[dependencies.up-sponsorship]
-default-features = false
-path = '../../primitives/sponsorship'
-version = '0.1.0'
-
-
 [dependencies]
 scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }
 ethereum = { version = "0.9", git = "https://github.com/purestake/ethereum", branch = "joshy-scale-info", default-features = false }
 rlp = { default-features = false, version = "0.5.0" }
 sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.12" }
 
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 
+
 evm-coder = { default-features = false, path = "../../crates/evm-coder" }
 pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }
 primitive-types = { version = "0.10.1", default-features = false, features = [
modifiedpallets/scheduler/Cargo.tomldiffbeforeafterboth
--- a/pallets/scheduler/Cargo.toml
+++ b/pallets/scheduler/Cargo.toml
@@ -20,7 +20,7 @@
 sp-io = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
 frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
 
-up-sponsorship = { default-features = false, path = "../../primitives/sponsorship", version = "0.1.0" }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 
 log = { version = "0.4.14", default-features = false }
 
 [dev-dependencies]
deletedprimitives/sponsorship/Cargo.tomldiffbeforeafterboth
--- a/primitives/sponsorship/Cargo.toml
+++ /dev/null
@@ -1,11 +0,0 @@
-[package]
-name = "up-sponsorship"
-version = "0.1.0"
-edition = "2018"
-
-[dependencies]
-impl-trait-for-tuples = "0.2.1"
-
-[features]
-default = ["std"]
-std = []
\ No newline at end of file
deletedprimitives/sponsorship/src/lib.rsdiffbeforeafterboth
--- a/primitives/sponsorship/src/lib.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-#![no_std]
-
-pub trait SponsorshipHandler<AccountId, Call> {
-	fn get_sponsor(who: &AccountId, call: &Call) -> Option<AccountId>;
-}
-
-impl<A, C> SponsorshipHandler<A, C> for () {
-	fn get_sponsor(_who: &A, _call: &C) -> Option<A> {
-		None
-	}
-}
-
-macro_rules! impl_tuples {
-	($($ident:ident)+) => {
-		impl<AccountId, Call, $($ident),+> SponsorshipHandler<AccountId, Call> for ($($ident,)+)
-		where
-			$(
-				$ident: SponsorshipHandler<AccountId, Call>
-			),+
-		{
-			fn get_sponsor(who: &AccountId, call: &Call) -> Option<AccountId> {
-				$(
-					if let Some(account) = $ident::get_sponsor(who, call) {
-						return Some(account);
-					}
-				)+
-				None
-			}
-		}
-	}
-}
-
-impl_tuples! {A}
-impl_tuples! {A B}
-impl_tuples! {A B C}
-impl_tuples! {A B C D}
-impl_tuples! {A B C D E}
-impl_tuples! {A B C D E F}
-impl_tuples! {A B C D E F G}
-impl_tuples! {A B C D E F G H}
-impl_tuples! {A B C D E F G H I}
-impl_tuples! {A B C D E F G H I J}
modifiedruntime/Cargo.tomldiffbeforeafterboth
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -363,7 +363,7 @@
 pallet-unq-scheduler = { path = '../pallets/scheduler', default-features = false, version = '3.0.0' }
 # 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' }
+pallet-nft-charge-transaction = {git = "https://github.com/UniqueNetwork/pallet-sponsoring", package = "pallet-template-charge-transaction", default-features = false, version = '3.0.0' }
 pallet-evm-migration = { path = '../pallets/evm-migration', default-features = false }
 pallet-evm-contract-helpers = { path = '../pallets/evm-contract-helpers', default-features = false }
 pallet-evm-transaction-payment = { path = '../pallets/evm-transaction-payment', default-features = false }
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, PostDispatchInfoOf},74	transaction_validity::TransactionValidityError,75};7677// pub use pallet_timestamp::Call as TimestampCall;78pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;7980// Polkadot imports81use pallet_xcm::XcmPassthrough;82use polkadot_parachain::primitives::Sibling;83use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};84use xcm_builder::{85	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,86	EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,87	ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,88	SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,89	SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,90};91use xcm_executor::{Config, XcmExecutor};9293// mod chain_extension;94// use crate::chain_extension::{NFTExtension, Imbalance};9596/// An index to a block.97pub type BlockNumber = u32;9899/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.100pub type Signature = MultiSignature;101102/// Some way of identifying an account on the chain. We intentionally make it equivalent103/// to the public key of our transaction signing scheme.104pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;105106/// The type for looking up accounts. We don't expect more than 4 billion of them, but you107/// never know...108pub type AccountIndex = u32;109110/// Balance of an account.111pub type Balance = u128;112113/// Index of a transaction in the chain.114pub type Index = u32;115116/// A hash of some data used by the chain.117pub type Hash = sp_core::H256;118119/// Digest item type.120pub type DigestItem = generic::DigestItem<Hash>;121122/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know123/// the specifics of the runtime. They can then be made to be agnostic over specific formats124/// of data like extrinsics, allowing for them to continue syncing the network through upgrades125/// to even the core data structures.126pub mod opaque {127	use super::*;128129	pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;130131	/// Opaque block type.132	pub type Block = generic::Block<Header, UncheckedExtrinsic>;133134	pub type SessionHandlers = ();135136	impl_opaque_keys! {137		pub struct SessionKeys {138			pub aura: Aura,139		}140	}141}142143/// This runtime version.144pub const VERSION: RuntimeVersion = RuntimeVersion {145	spec_name: create_runtime_str!("opal"),146	impl_name: create_runtime_str!("opal"),147	authoring_version: 1,148	spec_version: 912200,149	impl_version: 1,150	apis: RUNTIME_API_VERSIONS,151	transaction_version: 1,152};153154pub const MILLISECS_PER_BLOCK: u64 = 12000;155156pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;157158// These time units are defined in number of blocks.159pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);160pub const HOURS: BlockNumber = MINUTES * 60;161pub const DAYS: BlockNumber = HOURS * 24;162163parameter_types! {164	pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;165}166167#[derive(codec::Encode, codec::Decode)]168pub enum XCMPMessage<XAccountId, XBalance> {169	/// Transfer tokens to the given account from the Parachain account.170	TransferToken(XAccountId, XBalance),171}172173/// The version information used to identify this runtime when compiled natively.174#[cfg(feature = "std")]175pub fn native_version() -> NativeVersion {176	NativeVersion {177		runtime_version: VERSION,178		can_author_with: Default::default(),179	}180}181182type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;183184pub struct DealWithFees;185impl OnUnbalanced<NegativeImbalance> for DealWithFees {186	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {187		if let Some(fees) = fees_then_tips.next() {188			// for fees, 100% to treasury189			let mut split = fees.ration(100, 0);190			if let Some(tips) = fees_then_tips.next() {191				// for tips, if any, 100% to treasury192				tips.ration_merge_into(100, 0, &mut split);193			}194			Treasury::on_unbalanced(split.0);195			// Author::on_unbalanced(split.1);196		}197	}198}199200/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.201/// This is used to limit the maximal weight of a single extrinsic.202const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);203/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used204/// by  Operational  extrinsics.205const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);206/// We allow for 2 seconds of compute with a 6 second average block time.207const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;208209parameter_types! {210	pub const BlockHashCount: BlockNumber = 2400;211	pub RuntimeBlockLength: BlockLength =212		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);213	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);214	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;215	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()216		.base_block(BlockExecutionWeight::get())217		.for_class(DispatchClass::all(), |weights| {218			weights.base_extrinsic = ExtrinsicBaseWeight::get();219		})220		.for_class(DispatchClass::Normal, |weights| {221			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);222		})223		.for_class(DispatchClass::Operational, |weights| {224			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);225			// Operational transactions have some extra reserved space, so that they226			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.227			weights.reserved = Some(228				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT229			);230		})231		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)232		.build_or_panic();233	pub const Version: RuntimeVersion = VERSION;234	pub const SS58Prefix: u8 = 42;235}236237parameter_types! {238	pub const ChainId: u64 = 8888;239}240241pub struct FixedFee;242impl FeeCalculator for FixedFee {243	fn min_gas_price() -> U256 {244		1.into()245	}246}247248impl pallet_evm::Config for Runtime {249	type BlockGasLimit = BlockGasLimit;250	type FeeCalculator = FixedFee;251	type GasWeightMapping = ();252	type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;253	type CallOrigin = EnsureAddressTruncated;254	type WithdrawOrigin = EnsureAddressTruncated;255	type AddressMapping = HashedAddressMapping<Self::Hashing>;256	type Precompiles = ();257	type Currency = Balances;258	type Event = Event;259	type OnMethodCall = (260		pallet_evm_migration::OnMethodCall<Self>,261		pallet_nft::NftErcSupport<Self>,262		pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,263	);264	type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;265	type ChainId = ChainId;266	type Runner = pallet_evm::runner::stack::Runner<Self>;267	type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;268	type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;269	type FindAuthor = EthereumFindAuthor<Aura>;270}271272impl pallet_evm_migration::Config for Runtime {273	type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;274}275276pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);277impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {278	fn find_author<'a, I>(digests: I) -> Option<H160>279	where280		I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,281	{282		if let Some(author_index) = F::find_author(digests) {283			let authority_id = Aura::authorities()[author_index as usize].clone();284			return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));285		}286		None287	}288}289290parameter_types! {291	pub BlockGasLimit: U256 = U256::from(u32::max_value());292}293294impl pallet_ethereum::Config for Runtime {295	type Event = Event;296	type StateRoot = pallet_ethereum::IntermediateStateRoot;297	type EvmSubmitLog = pallet_evm::Pallet<Self>;298}299300impl pallet_randomness_collective_flip::Config for Runtime {}301302impl system::Config for Runtime {303	/// The data to be stored in an account.304	type AccountData = pallet_balances::AccountData<Balance>;305	/// The identifier used to distinguish between accounts.306	type AccountId = AccountId;307	/// The basic call filter to use in dispatchable.308	type BaseCallFilter = Everything;309	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).310	type BlockHashCount = BlockHashCount;311	/// The maximum length of a block (in bytes).312	type BlockLength = RuntimeBlockLength;313	/// The index type for blocks.314	type BlockNumber = BlockNumber;315	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.316	type BlockWeights = RuntimeBlockWeights;317	/// The aggregated dispatch type that is available for extrinsics.318	type Call = Call;319	/// The weight of database operations that the runtime can invoke.320	type DbWeight = RocksDbWeight;321	/// The ubiquitous event type.322	type Event = Event;323	/// The type for hashing blocks and tries.324	type Hash = Hash;325	/// The hashing algorithm used.326	type Hashing = BlakeTwo256;327	/// The header type.328	type Header = generic::Header<BlockNumber, BlakeTwo256>;329	/// The index type for storing how many extrinsics an account has signed.330	type Index = Index;331	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.332	type Lookup = AccountIdLookup<AccountId, ()>;333	/// What to do if an account is fully reaped from the system.334	type OnKilledAccount = ();335	/// What to do if a new account is created.336	type OnNewAccount = ();337	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;338	/// The ubiquitous origin type.339	type Origin = Origin;340	/// This type is being generated by `construct_runtime!`.341	type PalletInfo = PalletInfo;342	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.343	type SS58Prefix = SS58Prefix;344	/// Weight information for the extrinsics of this pallet.345	type SystemWeightInfo = system::weights::SubstrateWeight<Self>;346	/// Version of the runtime.347	type Version = Version;348}349350parameter_types! {351	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;352}353354impl pallet_timestamp::Config for Runtime {355	/// A timestamp: milliseconds since the unix epoch.356	type Moment = u64;357	type OnTimestampSet = ();358	type MinimumPeriod = MinimumPeriod;359	type WeightInfo = ();360}361362parameter_types! {363	// pub const ExistentialDeposit: u128 = 500;364	pub const ExistentialDeposit: u128 = 0;365	pub const MaxLocks: u32 = 50;366}367368impl pallet_balances::Config for Runtime {369	type MaxLocks = MaxLocks;370	type MaxReserves = ();371	type ReserveIdentifier = [u8; 8];372	/// The type for recording an account's balance.373	type Balance = Balance;374	/// The ubiquitous event type.375	type Event = Event;376	type DustRemoval = Treasury;377	type ExistentialDeposit = ExistentialDeposit;378	type AccountStore = System;379	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;380}381382pub const MICROUNIQUE: Balance = 1_000_000_000;383pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;384pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;385pub const UNIQUE: Balance = 100 * CENTIUNIQUE;386387pub const fn deposit(items: u32, bytes: u32) -> Balance {388	items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE389}390391/*392parameter_types! {393	pub TombstoneDeposit: Balance = deposit(394		1,395		sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,396	);397	pub DepositPerContract: Balance = TombstoneDeposit::get();398	pub const DepositPerStorageByte: Balance = deposit(0, 1);399	pub const DepositPerStorageItem: Balance = deposit(1, 0);400	pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);401	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;402	pub const SignedClaimHandicap: u32 = 2;403	pub const MaxDepth: u32 = 32;404	pub const MaxValueSize: u32 = 16 * 1024;405	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb406	// The lazy deletion runs inside on_initialize.407	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *408		RuntimeBlockWeights::get().max_block;409	// The weight needed for decoding the queue should be less or equal than a fifth410	// of the overall weight dedicated to the lazy deletion.411	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (412			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -413			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)414		)) / 5) as u32;415	pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();416}417418impl pallet_contracts::Config for Runtime {419	type Time = Timestamp;420	type Randomness = RandomnessCollectiveFlip;421	type Currency = Balances;422	type Event = Event;423	type RentPayment = ();424	type SignedClaimHandicap = SignedClaimHandicap;425	type TombstoneDeposit = TombstoneDeposit;426	type DepositPerContract = DepositPerContract;427	type DepositPerStorageByte = DepositPerStorageByte;428	type DepositPerStorageItem = DepositPerStorageItem;429	type RentFraction = RentFraction;430	type SurchargeReward = SurchargeReward;431	type WeightPrice = pallet_transaction_payment::Pallet<Self>;432	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;433	type ChainExtension = NFTExtension;434	type DeletionQueueDepth = DeletionQueueDepth;435	type DeletionWeightLimit = DeletionWeightLimit;436	type Schedule = Schedule;437	type CallStack = [pallet_contracts::Frame<Self>; 31];438}439*/440441parameter_types! {442	pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer443	/// This value increases the priority of `Operational` transactions by adding444	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.445	pub const OperationalFeeMultiplier: u8 = 5;446}447448/// Linear implementor of `WeightToFeePolynomial`449pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);450451impl<T> WeightToFeePolynomial for LinearFee<T>452where453	T: BaseArithmetic + From<u32> + Copy + Unsigned,454{455	type Balance = T;456457	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {458		smallvec!(WeightToFeeCoefficient {459			coeff_integer: 146_700u32.into(), // Targeting 0.1 Unique per NFT transfer460			coeff_frac: Perbill::zero(),461			negative: false,462			degree: 1,463		})464	}465}466467impl pallet_transaction_payment::Config for Runtime {468	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;469	type TransactionByteFee = TransactionByteFee;470	type OperationalFeeMultiplier = OperationalFeeMultiplier;471	type WeightToFee = LinearFee<Balance>;472	type FeeMultiplierUpdate = ();473}474475parameter_types! {476	pub const ProposalBond: Permill = Permill::from_percent(5);477	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;478	pub const SpendPeriod: BlockNumber = 5 * MINUTES;479	pub const Burn: Permill = Permill::from_percent(0);480	pub const TipCountdown: BlockNumber = 1 * DAYS;481	pub const TipFindersFee: Percent = Percent::from_percent(20);482	pub const TipReportDepositBase: Balance = 1 * UNIQUE;483	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;484	pub const BountyDepositBase: Balance = 1 * UNIQUE;485	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;486	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");487	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;488	pub const MaximumReasonLength: u32 = 16384;489	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);490	pub const BountyValueMinimum: Balance = 5 * UNIQUE;491	pub const MaxApprovals: u32 = 100;492}493494impl pallet_treasury::Config for Runtime {495	type PalletId = TreasuryModuleId;496	type Currency = Balances;497	type ApproveOrigin = EnsureRoot<AccountId>;498	type RejectOrigin = EnsureRoot<AccountId>;499	type Event = Event;500	type OnSlash = ();501	type ProposalBond = ProposalBond;502	type ProposalBondMinimum = ProposalBondMinimum;503	type SpendPeriod = SpendPeriod;504	type Burn = Burn;505	type BurnDestination = ();506	type SpendFunds = ();507	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;508	type MaxApprovals = MaxApprovals;509}510511impl pallet_sudo::Config for Runtime {512	type Event = Event;513	type Call = Call;514}515516parameter_types! {517	pub const MinVestedTransfer: Balance = 10 * UNIQUE;518}519520impl pallet_vesting::Config for Runtime {521	type Event = Event;522	type Currency = Balances;523	type BlockNumberToBalance = ConvertInto;524	type MinVestedTransfer = MinVestedTransfer;525	type WeightInfo = ();526	const MAX_VESTING_SCHEDULES: u32 = 28;527}528529parameter_types! {530	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;531	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;532}533534impl cumulus_pallet_parachain_system::Config for Runtime {535	type Event = Event;536	type OnValidationData = ();537	type SelfParaId = parachain_info::Pallet<Self>;538	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<539	// 	MaxDownwardMessageWeight,540	// 	XcmExecutor<XcmConfig>,541	// 	Call,542	// >;543	type OutboundXcmpMessageSource = XcmpQueue;544	type DmpMessageHandler = DmpQueue;545	type ReservedDmpWeight = ReservedDmpWeight;546	type ReservedXcmpWeight = ReservedXcmpWeight;547	type XcmpMessageHandler = XcmpQueue;548}549550impl parachain_info::Config for Runtime {}551552impl cumulus_pallet_aura_ext::Config for Runtime {}553554parameter_types! {555	pub const RelayLocation: MultiLocation = MultiLocation::parent();556	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;557	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();558	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();559}560561/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used562/// when determining ownership of accounts for asset transacting and when attempting to use XCM563/// `Transact` in order to determine the dispatch Origin.564pub type LocationToAccountId = (565	// The parent (Relay-chain) origin converts to the default `AccountId`.566	ParentIsDefault<AccountId>,567	// Sibling parachain origins convert to AccountId via the `ParaId::into`.568	SiblingParachainConvertsVia<Sibling, AccountId>,569	// Straight up local `AccountId32` origins just alias directly to `AccountId`.570	AccountId32Aliases<RelayNetwork, AccountId>,571);572573/// Means for transacting assets on this chain.574pub type LocalAssetTransactor = CurrencyAdapter<575	// Use this currency:576	Balances,577	// Use this currency when it is a fungible asset matching the given location or name:578	IsConcrete<RelayLocation>,579	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:580	LocationToAccountId,581	// Our chain's account ID type (we can't get away without mentioning it explicitly):582	AccountId,583	// We don't track any teleports.584	(),585>;586587/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,588/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can589/// biases the kind of local `Origin` it will become.590pub type XcmOriginToTransactDispatchOrigin = (591	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location592	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for593	// foreign chains who want to have a local sovereign account on this chain which they control.594	SovereignSignedViaLocation<LocationToAccountId, Origin>,595	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when596	// recognised.597	RelayChainAsNative<RelayOrigin, Origin>,598	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when599	// recognised.600	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,601	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a602	// transaction from the Root origin.603	ParentAsSuperuser<Origin>,604	// Native signed account converter; this just converts an `AccountId32` origin into a normal605	// `Origin::Signed` origin of the same 32-byte value.606	SignedAccountId32AsNative<RelayNetwork, Origin>,607	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.608	XcmPassthrough<Origin>,609);610611parameter_types! {612	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.613	pub UnitWeightCost: Weight = 1_000_000;614	// 1200 UNIQUEs buy 1 second of weight.615	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);616	pub const MaxInstructions: u32 = 100;617	pub const MaxAuthorities: u32 = 100_000;618}619620match_type! {621	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {622		MultiLocation { parents: 1, interior: Here } |623		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }624	};625}626627pub type Barrier = (628	TakeWeightCredit,629	AllowTopLevelPaidExecutionFrom<Everything>,630	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,631	// ^^^ Parent & its unit plurality gets free execution632);633634pub struct XcmConfig;635impl Config for XcmConfig {636	type Call = Call;637	type XcmSender = XcmRouter;638	// How to withdraw and deposit an asset.639	type AssetTransactor = LocalAssetTransactor;640	type OriginConverter = XcmOriginToTransactDispatchOrigin;641	type IsReserve = NativeAsset;642	type IsTeleporter = (); // Teleportation is disabled643	type LocationInverter = LocationInverter<Ancestry>;644	type Barrier = Barrier;645	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;646	type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;647	type ResponseHandler = (); // Don't handle responses for now.648	type SubscriptionService = PolkadotXcm;649650	type AssetTrap = PolkadotXcm;651	type AssetClaims = PolkadotXcm;652}653654// parameter_types! {655// 	pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;656// }657658/// No local origins on this chain are allowed to dispatch XCM sends/executions.659pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);660661/// The means for routing XCM messages which are not for local execution into the right message662/// queues.663pub type XcmRouter = (664	// Two routers - use UMP to communicate with the relay chain:665	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,666	// ..and XCMP to communicate with the sibling chains.667	XcmpQueue,668);669670impl pallet_evm_coder_substrate::Config for Runtime {671	type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;672}673674impl pallet_xcm::Config for Runtime {675	type Event = Event;676	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;677	type XcmRouter = XcmRouter;678	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;679	type XcmExecuteFilter = Everything;680	type XcmExecutor = XcmExecutor<XcmConfig>;681	type XcmTeleportFilter = Everything;682	type XcmReserveTransferFilter = Everything;683	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;684	type LocationInverter = LocationInverter<Ancestry>;685	type Origin = Origin;686	type Call = Call;687	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;688	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;689}690691impl cumulus_pallet_xcm::Config for Runtime {692	type Event = Event;693	type XcmExecutor = XcmExecutor<XcmConfig>;694}695696impl cumulus_pallet_xcmp_queue::Config for Runtime {697	type Event = Event;698	type XcmExecutor = XcmExecutor<XcmConfig>;699	type ChannelInfo = ParachainSystem;700	type VersionWrapper = ();701}702703impl cumulus_pallet_dmp_queue::Config for Runtime {704	type Event = Event;705	type XcmExecutor = XcmExecutor<XcmConfig>;706	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;707}708709impl pallet_aura::Config for Runtime {710	type AuthorityId = AuraId;711	type DisabledValidators = ();712	type MaxAuthorities = MaxAuthorities;713}714715parameter_types! {716	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();717	pub const CollectionCreationPrice: Balance = 100 * UNIQUE;718}719720/// Used for the pallet nft in `./nft.rs`721impl pallet_nft::Config for Runtime {722	type Event = Event;723	type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;724725	type EvmBackwardsAddressMapping = pallet_nft::MapBackwardsAddressTruncated;726	type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;727	type CrossAccountId = pallet_nft::BasicCrossAccountId<Self>;728729	type Currency = Balances;730	type CollectionCreationPrice = CollectionCreationPrice;731	type TreasuryAccountId = TreasuryAccountId;732}733734parameter_types! {735	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied736}737738/// Used for the pallet inflation739impl pallet_inflation::Config for Runtime {740	type Currency = Balances;741	type TreasuryAccountId = TreasuryAccountId;742	type InflationBlockInterval = InflationBlockInterval;743}744745parameter_types! {746	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *747		RuntimeBlockWeights::get().max_block;748	pub const MaxScheduledPerBlock: u32 = 50;749}750751pub struct Sponsoring;752impl SponsoringResolve<AccountId, Call> for Sponsoring {753	fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>754	where755		Call: Dispatchable<Info = DispatchInfo>,756		AccountId: AsRef<[u8]>,757	{758		pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)759	}760}761762type SponsorshipHandler = (763	pallet_nft::NftSponsorshipHandler<Runtime>,764	//pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,765);766767impl pallet_unq_scheduler::Config for Runtime {768	type Event = Event;769	type Origin = Origin;770	type PalletsOrigin = OriginCaller;771	type Call = Call;772	type MaximumWeight = MaximumSchedulerWeight;773	type ScheduleOrigin = EnsureSigned<AccountId>;774	type MaxScheduledPerBlock = MaxScheduledPerBlock;775	type SponsorshipHandler = SponsorshipHandler;776	type WeightInfo = ();777}778779impl pallet_nft_transaction_payment::Config for Runtime {780	type SponsorshipHandler = SponsorshipHandler;781}782783impl pallet_evm_transaction_payment::Config for Runtime {784	type SponsorshipHandler = (785		pallet_nft::NftEthSponsorshipHandler<Self>,786		pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,787	);788	type Currency = Balances;789}790791impl pallet_nft_charge_transaction::Config for Runtime {}792793// impl pallet_contract_helpers::Config for Runtime {794//	 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;795// }796797parameter_types! {798	// 0x842899ECF380553E8a4de75bF534cdf6fBF64049799	pub const HelpersContractAddress: H160 = H160([800		0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,801	]);802}803804impl pallet_evm_contract_helpers::Config for Runtime {805	type ContractAddress = HelpersContractAddress;806	type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;807}808809construct_runtime!(810	pub enum Runtime where811		Block = Block,812		NodeBlock = opaque::Block,813		UncheckedExtrinsic = UncheckedExtrinsic814	{815		ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,816		ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,817818		Aura: pallet_aura::{Pallet, Config<T>} = 22,819		AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,820821		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,822		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,823		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,824		TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,825		Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,826		Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,827		System: system::{Pallet, Call, Storage, Config, Event<T>} = 36,828		Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,829		// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,830831		// XCM helpers.832		XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,833		PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,834		CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,835		DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,836837		// Unique Pallets838		Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,839		Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>} = 61,840		Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,841		NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage} = 63,842		Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,843		// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,844845		// Frontier846		EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,847		Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,848849		EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,850		EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,851		EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,852		EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,853	}854);855856pub struct TransactionConverter;857858impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {859	fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {860		UncheckedExtrinsic::new_unsigned(861			pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),862		)863	}864}865866impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {867	fn convert_transaction(868		&self,869		transaction: pallet_ethereum::Transaction,870	) -> opaque::UncheckedExtrinsic {871		let extrinsic = UncheckedExtrinsic::new_unsigned(872			pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),873		);874		let encoded = extrinsic.encode();875		opaque::UncheckedExtrinsic::decode(&mut &encoded[..])876			.expect("Encoded extrinsic is always valid")877	}878}879880/// The address format for describing accounts.881pub type Address = sp_runtime::MultiAddress<AccountId, ()>;882/// Block header type as expected by this runtime.883pub type Header = generic::Header<BlockNumber, BlakeTwo256>;884/// Block type as expected by this runtime.885pub type Block = generic::Block<Header, UncheckedExtrinsic>;886/// A Block signed with a Justification887pub type SignedBlock = generic::SignedBlock<Block>;888/// BlockId type as expected by this runtime.889pub type BlockId = generic::BlockId<Block>;890/// The SignedExtension to the basic transaction logic.891pub type SignedExtra = (892	system::CheckSpecVersion<Runtime>,893	// system::CheckTxVersion<Runtime>,894	system::CheckGenesis<Runtime>,895	system::CheckEra<Runtime>,896	system::CheckNonce<Runtime>,897	system::CheckWeight<Runtime>,898	pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,899	//pallet_contract_helpers::ContractHelpersExtension<Runtime>,900);901/// Unchecked extrinsic type as expected by this runtime.902pub type UncheckedExtrinsic =903	fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;904/// Extrinsic type that has already been checked.905pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;906/// Executive: handles dispatch to the various modules.907pub type Executive = frame_executive::Executive<908	Runtime,909	Block,910	frame_system::ChainContext<Runtime>,911	Runtime,912	AllPallets,913>;914915impl_opaque_keys! {916	pub struct SessionKeys {917		pub aura: Aura,918	}919}920921impl fp_self_contained::SelfContainedCall for Call {922	type SignedInfo = H160;923924	fn is_self_contained(&self) -> bool {925		match self {926			Call::Ethereum(call) => call.is_self_contained(),927			_ => false,928		}929	}930931	fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {932		match self {933			Call::Ethereum(call) => call.check_self_contained(),934			_ => None,935		}936	}937938	fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {939		match self {940			Call::Ethereum(call) => call.validate_self_contained(info),941			_ => None,942		}943	}944945	fn pre_dispatch_self_contained(946		&self,947		info: &Self::SignedInfo,948	) -> Option<Result<(), TransactionValidityError>> {949		match self {950			Call::Ethereum(call) => call.pre_dispatch_self_contained(info),951			_ => None,952		}953	}954955	fn apply_self_contained(956		self,957		info: Self::SignedInfo,958	) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {959		match self {960			call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(961				Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),962			)),963			_ => None,964		}965	}966}967968impl_runtime_apis! {969	impl pallet_nft::NftApi<Block>970		for Runtime971	{972		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			OpaqueMetadata::new(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.0.function {1149				Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),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().to_vec()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);
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, PostDispatchInfoOf},74	transaction_validity::TransactionValidityError,75};7677// pub use pallet_timestamp::Call as TimestampCall;78pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;7980// Polkadot imports81use pallet_xcm::XcmPassthrough;82use polkadot_parachain::primitives::Sibling;83use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};84use xcm_builder::{85	AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,86	EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,87	ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,88	SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,89	SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,90};91use xcm_executor::{Config, XcmExecutor};9293// mod chain_extension;94// use crate::chain_extension::{NFTExtension, Imbalance};9596/// An index to a block.97pub type BlockNumber = u32;9899/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.100pub type Signature = MultiSignature;101102/// Some way of identifying an account on the chain. We intentionally make it equivalent103/// to the public key of our transaction signing scheme.104pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;105106/// The type for looking up accounts. We don't expect more than 4 billion of them, but you107/// never know...108pub type AccountIndex = u32;109110/// Balance of an account.111pub type Balance = u128;112113/// Index of a transaction in the chain.114pub type Index = u32;115116/// A hash of some data used by the chain.117pub type Hash = sp_core::H256;118119/// Digest item type.120pub type DigestItem = generic::DigestItem<Hash>;121122/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know123/// the specifics of the runtime. They can then be made to be agnostic over specific formats124/// of data like extrinsics, allowing for them to continue syncing the network through upgrades125/// to even the core data structures.126pub mod opaque {127	use super::*;128129	pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;130131	/// Opaque block type.132	pub type Block = generic::Block<Header, UncheckedExtrinsic>;133134	pub type SessionHandlers = ();135136	impl_opaque_keys! {137		pub struct SessionKeys {138			pub aura: Aura,139		}140	}141}142143/// This runtime version.144pub const VERSION: RuntimeVersion = RuntimeVersion {145	spec_name: create_runtime_str!("opal"),146	impl_name: create_runtime_str!("opal"),147	authoring_version: 1,148	spec_version: 912200,149	impl_version: 1,150	apis: RUNTIME_API_VERSIONS,151	transaction_version: 1,152};153154pub const MILLISECS_PER_BLOCK: u64 = 12000;155156pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;157158// These time units are defined in number of blocks.159pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);160pub const HOURS: BlockNumber = MINUTES * 60;161pub const DAYS: BlockNumber = HOURS * 24;162163parameter_types! {164	pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;165}166167#[derive(codec::Encode, codec::Decode)]168pub enum XCMPMessage<XAccountId, XBalance> {169	/// Transfer tokens to the given account from the Parachain account.170	TransferToken(XAccountId, XBalance),171}172173/// The version information used to identify this runtime when compiled natively.174#[cfg(feature = "std")]175pub fn native_version() -> NativeVersion {176	NativeVersion {177		runtime_version: VERSION,178		can_author_with: Default::default(),179	}180}181182type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;183184pub struct DealWithFees;185impl OnUnbalanced<NegativeImbalance> for DealWithFees {186	fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {187		if let Some(fees) = fees_then_tips.next() {188			// for fees, 100% to treasury189			let mut split = fees.ration(100, 0);190			if let Some(tips) = fees_then_tips.next() {191				// for tips, if any, 100% to treasury192				tips.ration_merge_into(100, 0, &mut split);193			}194			Treasury::on_unbalanced(split.0);195			// Author::on_unbalanced(split.1);196		}197	}198}199200/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.201/// This is used to limit the maximal weight of a single extrinsic.202const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);203/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used204/// by  Operational  extrinsics.205const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);206/// We allow for 2 seconds of compute with a 6 second average block time.207const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;208209parameter_types! {210	pub const BlockHashCount: BlockNumber = 2400;211	pub RuntimeBlockLength: BlockLength =212		BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);213	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);214	pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;215	pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()216		.base_block(BlockExecutionWeight::get())217		.for_class(DispatchClass::all(), |weights| {218			weights.base_extrinsic = ExtrinsicBaseWeight::get();219		})220		.for_class(DispatchClass::Normal, |weights| {221			weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);222		})223		.for_class(DispatchClass::Operational, |weights| {224			weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);225			// Operational transactions have some extra reserved space, so that they226			// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.227			weights.reserved = Some(228				MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT229			);230		})231		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)232		.build_or_panic();233	pub const Version: RuntimeVersion = VERSION;234	pub const SS58Prefix: u8 = 42;235}236237parameter_types! {238	pub const ChainId: u64 = 8888;239}240241pub struct FixedFee;242impl FeeCalculator for FixedFee {243	fn min_gas_price() -> U256 {244		1.into()245	}246}247248impl pallet_evm::Config for Runtime {249	type BlockGasLimit = BlockGasLimit;250	type FeeCalculator = FixedFee;251	type GasWeightMapping = ();252	type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;253	type CallOrigin = EnsureAddressTruncated;254	type WithdrawOrigin = EnsureAddressTruncated;255	type AddressMapping = HashedAddressMapping<Self::Hashing>;256	type Precompiles = ();257	type Currency = Balances;258	type Event = Event;259	type OnMethodCall = (260		pallet_evm_migration::OnMethodCall<Self>,261		pallet_nft::NftErcSupport<Self>,262		pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,263	);264	type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;265	type ChainId = ChainId;266	type Runner = pallet_evm::runner::stack::Runner<Self>;267	type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;268	type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;269	type FindAuthor = EthereumFindAuthor<Aura>;270}271272impl pallet_evm_migration::Config for Runtime {273	type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;274}275276pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);277impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {278	fn find_author<'a, I>(digests: I) -> Option<H160>279	where280		I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,281	{282		if let Some(author_index) = F::find_author(digests) {283			let authority_id = Aura::authorities()[author_index as usize].clone();284			return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));285		}286		None287	}288}289290parameter_types! {291	pub BlockGasLimit: U256 = U256::from(u32::max_value());292}293294impl pallet_ethereum::Config for Runtime {295	type Event = Event;296	type StateRoot = pallet_ethereum::IntermediateStateRoot;297	type EvmSubmitLog = pallet_evm::Pallet<Self>;298}299300impl pallet_randomness_collective_flip::Config for Runtime {}301302impl system::Config for Runtime {303	/// The data to be stored in an account.304	type AccountData = pallet_balances::AccountData<Balance>;305	/// The identifier used to distinguish between accounts.306	type AccountId = AccountId;307	/// The basic call filter to use in dispatchable.308	type BaseCallFilter = Everything;309	/// Maximum number of block number to block hash mappings to keep (oldest pruned first).310	type BlockHashCount = BlockHashCount;311	/// The maximum length of a block (in bytes).312	type BlockLength = RuntimeBlockLength;313	/// The index type for blocks.314	type BlockNumber = BlockNumber;315	/// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.316	type BlockWeights = RuntimeBlockWeights;317	/// The aggregated dispatch type that is available for extrinsics.318	type Call = Call;319	/// The weight of database operations that the runtime can invoke.320	type DbWeight = RocksDbWeight;321	/// The ubiquitous event type.322	type Event = Event;323	/// The type for hashing blocks and tries.324	type Hash = Hash;325	/// The hashing algorithm used.326	type Hashing = BlakeTwo256;327	/// The header type.328	type Header = generic::Header<BlockNumber, BlakeTwo256>;329	/// The index type for storing how many extrinsics an account has signed.330	type Index = Index;331	/// The lookup mechanism to get account ID from whatever is passed in dispatchers.332	type Lookup = AccountIdLookup<AccountId, ()>;333	/// What to do if an account is fully reaped from the system.334	type OnKilledAccount = ();335	/// What to do if a new account is created.336	type OnNewAccount = ();337	type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;338	/// The ubiquitous origin type.339	type Origin = Origin;340	/// This type is being generated by `construct_runtime!`.341	type PalletInfo = PalletInfo;342	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.343	type SS58Prefix = SS58Prefix;344	/// Weight information for the extrinsics of this pallet.345	type SystemWeightInfo = system::weights::SubstrateWeight<Self>;346	/// Version of the runtime.347	type Version = Version;348}349350parameter_types! {351	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;352}353354impl pallet_timestamp::Config for Runtime {355	/// A timestamp: milliseconds since the unix epoch.356	type Moment = u64;357	type OnTimestampSet = ();358	type MinimumPeriod = MinimumPeriod;359	type WeightInfo = ();360}361362parameter_types! {363	// pub const ExistentialDeposit: u128 = 500;364	pub const ExistentialDeposit: u128 = 0;365	pub const MaxLocks: u32 = 50;366}367368impl pallet_balances::Config for Runtime {369	type MaxLocks = MaxLocks;370	type MaxReserves = ();371	type ReserveIdentifier = [u8; 8];372	/// The type for recording an account's balance.373	type Balance = Balance;374	/// The ubiquitous event type.375	type Event = Event;376	type DustRemoval = Treasury;377	type ExistentialDeposit = ExistentialDeposit;378	type AccountStore = System;379	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;380}381382pub const MICROUNIQUE: Balance = 1_000_000_000;383pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;384pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;385pub const UNIQUE: Balance = 100 * CENTIUNIQUE;386387pub const fn deposit(items: u32, bytes: u32) -> Balance {388	items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE389}390391/*392parameter_types! {393	pub TombstoneDeposit: Balance = deposit(394		1,395		sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,396	);397	pub DepositPerContract: Balance = TombstoneDeposit::get();398	pub const DepositPerStorageByte: Balance = deposit(0, 1);399	pub const DepositPerStorageItem: Balance = deposit(1, 0);400	pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);401	pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;402	pub const SignedClaimHandicap: u32 = 2;403	pub const MaxDepth: u32 = 32;404	pub const MaxValueSize: u32 = 16 * 1024;405	pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb406	// The lazy deletion runs inside on_initialize.407	pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *408		RuntimeBlockWeights::get().max_block;409	// The weight needed for decoding the queue should be less or equal than a fifth410	// of the overall weight dedicated to the lazy deletion.411	pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (412			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -413			<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)414		)) / 5) as u32;415	pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();416}417418impl pallet_contracts::Config for Runtime {419	type Time = Timestamp;420	type Randomness = RandomnessCollectiveFlip;421	type Currency = Balances;422	type Event = Event;423	type RentPayment = ();424	type SignedClaimHandicap = SignedClaimHandicap;425	type TombstoneDeposit = TombstoneDeposit;426	type DepositPerContract = DepositPerContract;427	type DepositPerStorageByte = DepositPerStorageByte;428	type DepositPerStorageItem = DepositPerStorageItem;429	type RentFraction = RentFraction;430	type SurchargeReward = SurchargeReward;431	type WeightPrice = pallet_transaction_payment::Pallet<Self>;432	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;433	type ChainExtension = NFTExtension;434	type DeletionQueueDepth = DeletionQueueDepth;435	type DeletionWeightLimit = DeletionWeightLimit;436	type Schedule = Schedule;437	type CallStack = [pallet_contracts::Frame<Self>; 31];438}439*/440441parameter_types! {442	pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer443	/// This value increases the priority of `Operational` transactions by adding444	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.445	pub const OperationalFeeMultiplier: u8 = 5;446}447448/// Linear implementor of `WeightToFeePolynomial`449pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);450451impl<T> WeightToFeePolynomial for LinearFee<T>452where453	T: BaseArithmetic + From<u32> + Copy + Unsigned,454{455	type Balance = T;456457	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {458		smallvec!(WeightToFeeCoefficient {459			coeff_integer: 146_700u32.into(), // Targeting 0.1 Unique per NFT transfer460			coeff_frac: Perbill::zero(),461			negative: false,462			degree: 1,463		})464	}465}466467impl pallet_transaction_payment::Config for Runtime {468	type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;469	type TransactionByteFee = TransactionByteFee;470	type OperationalFeeMultiplier = OperationalFeeMultiplier;471	type WeightToFee = LinearFee<Balance>;472	type FeeMultiplierUpdate = ();473}474475parameter_types! {476	pub const ProposalBond: Permill = Permill::from_percent(5);477	pub const ProposalBondMinimum: Balance = 1 * UNIQUE;478	pub const SpendPeriod: BlockNumber = 5 * MINUTES;479	pub const Burn: Permill = Permill::from_percent(0);480	pub const TipCountdown: BlockNumber = 1 * DAYS;481	pub const TipFindersFee: Percent = Percent::from_percent(20);482	pub const TipReportDepositBase: Balance = 1 * UNIQUE;483	pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;484	pub const BountyDepositBase: Balance = 1 * UNIQUE;485	pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;486	pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");487	pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;488	pub const MaximumReasonLength: u32 = 16384;489	pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);490	pub const BountyValueMinimum: Balance = 5 * UNIQUE;491	pub const MaxApprovals: u32 = 100;492}493494impl pallet_treasury::Config for Runtime {495	type PalletId = TreasuryModuleId;496	type Currency = Balances;497	type ApproveOrigin = EnsureRoot<AccountId>;498	type RejectOrigin = EnsureRoot<AccountId>;499	type Event = Event;500	type OnSlash = ();501	type ProposalBond = ProposalBond;502	type ProposalBondMinimum = ProposalBondMinimum;503	type SpendPeriod = SpendPeriod;504	type Burn = Burn;505	type BurnDestination = ();506	type SpendFunds = ();507	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;508	type MaxApprovals = MaxApprovals;509}510511impl pallet_sudo::Config for Runtime {512	type Event = Event;513	type Call = Call;514}515516parameter_types! {517	pub const MinVestedTransfer: Balance = 10 * UNIQUE;518}519520impl pallet_vesting::Config for Runtime {521	type Event = Event;522	type Currency = Balances;523	type BlockNumberToBalance = ConvertInto;524	type MinVestedTransfer = MinVestedTransfer;525	type WeightInfo = ();526	const MAX_VESTING_SCHEDULES: u32 = 28;527}528529parameter_types! {530	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;531	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;532}533534impl cumulus_pallet_parachain_system::Config for Runtime {535	type Event = Event;536	type OnValidationData = ();537	type SelfParaId = parachain_info::Pallet<Self>;538	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<539	// 	MaxDownwardMessageWeight,540	// 	XcmExecutor<XcmConfig>,541	// 	Call,542	// >;543	type OutboundXcmpMessageSource = XcmpQueue;544	type DmpMessageHandler = DmpQueue;545	type ReservedDmpWeight = ReservedDmpWeight;546	type ReservedXcmpWeight = ReservedXcmpWeight;547	type XcmpMessageHandler = XcmpQueue;548}549550impl parachain_info::Config for Runtime {}551552impl cumulus_pallet_aura_ext::Config for Runtime {}553554parameter_types! {555	pub const RelayLocation: MultiLocation = MultiLocation::parent();556	pub const RelayNetwork: NetworkId = NetworkId::Polkadot;557	pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();558	pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();559}560561/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used562/// when determining ownership of accounts for asset transacting and when attempting to use XCM563/// `Transact` in order to determine the dispatch Origin.564pub type LocationToAccountId = (565	// The parent (Relay-chain) origin converts to the default `AccountId`.566	ParentIsDefault<AccountId>,567	// Sibling parachain origins convert to AccountId via the `ParaId::into`.568	SiblingParachainConvertsVia<Sibling, AccountId>,569	// Straight up local `AccountId32` origins just alias directly to `AccountId`.570	AccountId32Aliases<RelayNetwork, AccountId>,571);572573/// Means for transacting assets on this chain.574pub type LocalAssetTransactor = CurrencyAdapter<575	// Use this currency:576	Balances,577	// Use this currency when it is a fungible asset matching the given location or name:578	IsConcrete<RelayLocation>,579	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:580	LocationToAccountId,581	// Our chain's account ID type (we can't get away without mentioning it explicitly):582	AccountId,583	// We don't track any teleports.584	(),585>;586587/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,588/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can589/// biases the kind of local `Origin` it will become.590pub type XcmOriginToTransactDispatchOrigin = (591	// Sovereign account converter; this attempts to derive an `AccountId` from the origin location592	// using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for593	// foreign chains who want to have a local sovereign account on this chain which they control.594	SovereignSignedViaLocation<LocationToAccountId, Origin>,595	// Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when596	// recognised.597	RelayChainAsNative<RelayOrigin, Origin>,598	// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when599	// recognised.600	SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,601	// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a602	// transaction from the Root origin.603	ParentAsSuperuser<Origin>,604	// Native signed account converter; this just converts an `AccountId32` origin into a normal605	// `Origin::Signed` origin of the same 32-byte value.606	SignedAccountId32AsNative<RelayNetwork, Origin>,607	// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.608	XcmPassthrough<Origin>,609);610611parameter_types! {612	// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.613	pub UnitWeightCost: Weight = 1_000_000;614	// 1200 UNIQUEs buy 1 second of weight.615	pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);616	pub const MaxInstructions: u32 = 100;617	pub const MaxAuthorities: u32 = 100_000;618}619620match_type! {621	pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {622		MultiLocation { parents: 1, interior: Here } |623		MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }624	};625}626627pub type Barrier = (628	TakeWeightCredit,629	AllowTopLevelPaidExecutionFrom<Everything>,630	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,631	// ^^^ Parent & its unit plurality gets free execution632);633634pub struct XcmConfig;635impl Config for XcmConfig {636	type Call = Call;637	type XcmSender = XcmRouter;638	// How to withdraw and deposit an asset.639	type AssetTransactor = LocalAssetTransactor;640	type OriginConverter = XcmOriginToTransactDispatchOrigin;641	type IsReserve = NativeAsset;642	type IsTeleporter = (); // Teleportation is disabled643	type LocationInverter = LocationInverter<Ancestry>;644	type Barrier = Barrier;645	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;646	type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;647	type ResponseHandler = (); // Don't handle responses for now.648	type SubscriptionService = PolkadotXcm;649650	type AssetTrap = PolkadotXcm;651	type AssetClaims = PolkadotXcm;652}653654// parameter_types! {655// 	pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;656// }657658/// No local origins on this chain are allowed to dispatch XCM sends/executions.659pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);660661/// The means for routing XCM messages which are not for local execution into the right message662/// queues.663pub type XcmRouter = (664	// Two routers - use UMP to communicate with the relay chain:665	cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,666	// ..and XCMP to communicate with the sibling chains.667	XcmpQueue,668);669670impl pallet_evm_coder_substrate::Config for Runtime {671	type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;672}673674impl pallet_xcm::Config for Runtime {675	type Event = Event;676	type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;677	type XcmRouter = XcmRouter;678	type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;679	type XcmExecuteFilter = Everything;680	type XcmExecutor = XcmExecutor<XcmConfig>;681	type XcmTeleportFilter = Everything;682	type XcmReserveTransferFilter = Everything;683	type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;684	type LocationInverter = LocationInverter<Ancestry>;685	type Origin = Origin;686	type Call = Call;687	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;688	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;689}690691impl cumulus_pallet_xcm::Config for Runtime {692	type Event = Event;693	type XcmExecutor = XcmExecutor<XcmConfig>;694}695696impl cumulus_pallet_xcmp_queue::Config for Runtime {697	type Event = Event;698	type XcmExecutor = XcmExecutor<XcmConfig>;699	type ChannelInfo = ParachainSystem;700	type VersionWrapper = ();701}702703impl cumulus_pallet_dmp_queue::Config for Runtime {704	type Event = Event;705	type XcmExecutor = XcmExecutor<XcmConfig>;706	type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;707}708709impl pallet_aura::Config for Runtime {710	type AuthorityId = AuraId;711	type DisabledValidators = ();712	type MaxAuthorities = MaxAuthorities;713}714715parameter_types! {716	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();717	pub const CollectionCreationPrice: Balance = 100 * UNIQUE;718}719720/// Used for the pallet nft in `./nft.rs`721impl pallet_nft::Config for Runtime {722	type Event = Event;723	type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;724725	type EvmBackwardsAddressMapping = pallet_nft::MapBackwardsAddressTruncated;726	type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;727	type CrossAccountId = pallet_nft::BasicCrossAccountId<Self>;728729	type Currency = Balances;730	type CollectionCreationPrice = CollectionCreationPrice;731	type TreasuryAccountId = TreasuryAccountId;732}733734parameter_types! {735	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied736}737738/// Used for the pallet inflation739impl pallet_inflation::Config for Runtime {740	type Currency = Balances;741	type TreasuryAccountId = TreasuryAccountId;742	type InflationBlockInterval = InflationBlockInterval;743}744745parameter_types! {746	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *747		RuntimeBlockWeights::get().max_block;748	pub const MaxScheduledPerBlock: u32 = 50;749}750751pub struct Sponsoring;752impl SponsoringResolve<AccountId, Call> for Sponsoring {753	fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>754	where755		Call: Dispatchable<Info = DispatchInfo>,756		AccountId: AsRef<[u8]>,757	{758		pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)759	}760}761762type SponsorshipHandler = (763	pallet_nft::NftSponsorshipHandler<Runtime>,764	//pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,765);766767impl pallet_unq_scheduler::Config for Runtime {768	type Event = Event;769	type Origin = Origin;770	type PalletsOrigin = OriginCaller;771	type Call = Call;772	type MaximumWeight = MaximumSchedulerWeight;773	type ScheduleOrigin = EnsureSigned<AccountId>;774	type MaxScheduledPerBlock = MaxScheduledPerBlock;775	type SponsorshipHandler = SponsorshipHandler;776	type WeightInfo = ();777}778779impl pallet_nft_transaction_payment::Config for Runtime {780	type SponsorshipHandler = SponsorshipHandler;781}782783impl pallet_evm_transaction_payment::Config for Runtime {784	type SponsorshipHandler = (785		pallet_nft::NftEthSponsorshipHandler<Self>,786		pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,787	);788	type Currency = Balances;789}790791impl pallet_nft_charge_transaction::Config for Runtime {792	type SponsorshipHandler = pallet_nft::NftSponsorshipHandler<Runtime>;793}794795// impl pallet_contract_helpers::Config for Runtime {796//	 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;797// }798799parameter_types! {800	// 0x842899ECF380553E8a4de75bF534cdf6fBF64049801	pub const HelpersContractAddress: H160 = H160([802		0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,803	]);804}805806impl pallet_evm_contract_helpers::Config for Runtime {807	type ContractAddress = HelpersContractAddress;808	type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;809}810811construct_runtime!(812	pub enum Runtime where813		Block = Block,814		NodeBlock = opaque::Block,815		UncheckedExtrinsic = UncheckedExtrinsic816	{817		ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,818		ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,819820		Aura: pallet_aura::{Pallet, Config<T>} = 22,821		AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,822823		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,824		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,825		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,826		TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,827		Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,828		Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,829		System: system::{Pallet, Call, Storage, Config, Event<T>} = 36,830		Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,831		// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,832833		// XCM helpers.834		XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,835		PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,836		CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,837		DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,838839		// Unique Pallets840		Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,841		Nft: pallet_nft::{Pallet, Call, Config<T>, Storage, Event<T>} = 61,842		Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,843		NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage} = 63,844		Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,845		// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,846847		// Frontier848		EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,849		Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 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 =905	fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;906/// Extrinsic type that has already been checked.907pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;908/// Executive: handles dispatch to the various modules.909pub type Executive = frame_executive::Executive<910	Runtime,911	Block,912	frame_system::ChainContext<Runtime>,913	Runtime,914	AllPallets,915>;916917impl_opaque_keys! {918	pub struct SessionKeys {919		pub aura: Aura,920	}921}922923impl fp_self_contained::SelfContainedCall for Call {924	type SignedInfo = H160;925926	fn is_self_contained(&self) -> bool {927		match self {928			Call::Ethereum(call) => call.is_self_contained(),929			_ => false,930		}931	}932933	fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {934		match self {935			Call::Ethereum(call) => call.check_self_contained(),936			_ => None,937		}938	}939940	fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {941		match self {942			Call::Ethereum(call) => call.validate_self_contained(info),943			_ => None,944		}945	}946947	fn pre_dispatch_self_contained(948		&self,949		info: &Self::SignedInfo,950	) -> Option<Result<(), TransactionValidityError>> {951		match self {952			Call::Ethereum(call) => call.pre_dispatch_self_contained(info),953			_ => None,954		}955	}956957	fn apply_self_contained(958		self,959		info: Self::SignedInfo,960	) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {961		match self {962			call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(963				Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),964			)),965			_ => None,966		}967	}968}969970impl_runtime_apis! {971	impl pallet_nft::NftApi<Block>972		for Runtime973	{974		fn eth_contract_code(account: H160) -> Option<Vec<u8>> {975			<pallet_nft::NftErcSupport<Runtime>>::get_code(&account)976		}977	}978979	impl sp_api::Core<Block> for Runtime {980		fn version() -> RuntimeVersion {981			VERSION982		}983984		fn execute_block(block: Block) {985			Executive::execute_block(block)986		}987988		fn initialize_block(header: &<Block as BlockT>::Header) {989			Executive::initialize_block(header)990		}991	}992993	impl sp_api::Metadata<Block> for Runtime {994		fn metadata() -> OpaqueMetadata {995			OpaqueMetadata::new(Runtime::metadata().into())996		}997	}998999	impl sp_block_builder::BlockBuilder<Block> for Runtime {1000		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {1001			Executive::apply_extrinsic(extrinsic)1002		}10031004		fn finalize_block() -> <Block as BlockT>::Header {1005			Executive::finalize_block()1006		}10071008		fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {1009			data.create_extrinsics()1010		}10111012		fn check_inherents(1013			block: Block,1014			data: sp_inherents::InherentData,1015		) -> sp_inherents::CheckInherentsResult {1016			data.check_extrinsics(&block)1017		}10181019		// fn random_seed() -> <Block as BlockT>::Hash {1020		//     RandomnessCollectiveFlip::random_seed().01021		// }1022	}10231024	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {1025		fn validate_transaction(1026			source: TransactionSource,1027			tx: <Block as BlockT>::Extrinsic,1028			hash: <Block as BlockT>::Hash,1029		) -> TransactionValidity {1030			Executive::validate_transaction(source, tx, hash)1031		}1032	}10331034	impl sp_offchain::OffchainWorkerApi<Block> for Runtime {1035		fn offchain_worker(header: &<Block as BlockT>::Header) {1036			Executive::offchain_worker(header)1037		}1038	}10391040	impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {1041		fn chain_id() -> u64 {1042			<Runtime as pallet_evm::Config>::ChainId::get()1043		}10441045		fn account_basic(address: H160) -> EVMAccount {1046			EVM::account_basic(&address)1047		}10481049		fn gas_price() -> U256 {1050			<Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()1051		}10521053		fn account_code_at(address: H160) -> Vec<u8> {1054			EVM::account_codes(address)1055		}10561057		fn author() -> H160 {1058			<pallet_evm::Pallet<Runtime>>::find_author()1059		}10601061		fn storage_at(address: H160, index: U256) -> H256 {1062			let mut tmp = [0u8; 32];1063			index.to_big_endian(&mut tmp);1064			EVM::account_storages(address, H256::from_slice(&tmp[..]))1065		}10661067		fn call(1068			from: H160,1069			to: H160,1070			data: Vec<u8>,1071			value: U256,1072			gas_limit: U256,1073			gas_price: Option<U256>,1074			nonce: Option<U256>,1075			estimate: bool,1076		) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1077			let config = if estimate {1078				let mut config = <Runtime as pallet_evm::Config>::config().clone();1079				config.estimate = true;1080				Some(config)1081			} else {1082				None1083			};10841085			<Runtime as pallet_evm::Config>::Runner::call(1086				from,1087				to,1088				data,1089				value,1090				gas_limit.low_u64(),1091				gas_price,1092				nonce,1093				config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1094			).map_err(|err| err.into())1095		}10961097		fn create(1098			from: H160,1099			data: Vec<u8>,1100			value: U256,1101			gas_limit: U256,1102			gas_price: Option<U256>,1103			nonce: Option<U256>,1104			estimate: bool,1105		) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1106			let config = if estimate {1107				let mut config = <Runtime as pallet_evm::Config>::config().clone();1108				config.estimate = true;1109				Some(config)1110			} else {1111				None1112			};11131114			<Runtime as pallet_evm::Config>::Runner::create(1115				from,1116				data,1117				value,1118				gas_limit.low_u64(),1119				gas_price,1120				nonce,1121				config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1122			).map_err(|err| err.into())1123		}11241125		fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1126			Ethereum::current_transaction_statuses()1127		}11281129		fn current_block() -> Option<pallet_ethereum::Block> {1130			Ethereum::current_block()1131		}11321133		fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1134			Ethereum::current_receipts()1135		}11361137		fn current_all() -> (1138			Option<pallet_ethereum::Block>,1139			Option<Vec<pallet_ethereum::Receipt>>,1140			Option<Vec<TransactionStatus>>1141		) {1142			(1143				Ethereum::current_block(),1144				Ethereum::current_receipts(),1145				Ethereum::current_transaction_statuses()1146			)1147		}11481149		fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1150			xts.into_iter().filter_map(|xt| match xt.0.function {1151				Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),1152				_ => None1153			}).collect()1154		}1155	}11561157	impl sp_session::SessionKeys<Block> for Runtime {1158		fn decode_session_keys(1159			encoded: Vec<u8>,1160		) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1161			SessionKeys::decode_into_raw_public_keys(&encoded)1162		}11631164		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1165			SessionKeys::generate(seed)1166		}1167	}11681169	impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1170		fn slot_duration() -> sp_consensus_aura::SlotDuration {1171			sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1172		}11731174		fn authorities() -> Vec<AuraId> {1175			Aura::authorities().to_vec()1176		}1177	}11781179	impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1180		fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {1181			ParachainSystem::collect_collation_info()1182		}1183	}11841185	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1186		fn account_nonce(account: AccountId) -> Index {1187			System::account_nonce(account)1188		}1189	}11901191	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1192		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1193			TransactionPayment::query_info(uxt, len)1194		}1195		fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1196			TransactionPayment::query_fee_details(uxt, len)1197		}1198	}11991200	/*1201	impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>1202		for Runtime1203	{1204		fn call(1205			origin: AccountId,1206			dest: AccountId,1207			value: Balance,1208			gas_limit: u64,1209			input_data: Vec<u8>,1210		) -> pallet_contracts_primitives::ContractExecResult {1211			Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)1212		}12131214		fn instantiate(1215			origin: AccountId,1216			endowment: Balance,1217			gas_limit: u64,1218			code: pallet_contracts_primitives::Code<Hash>,1219			data: Vec<u8>,1220			salt: Vec<u8>,1221		) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>1222		{1223			Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)1224		}12251226		fn get_storage(1227			address: AccountId,1228			key: [u8; 32],1229		) -> pallet_contracts_primitives::GetStorageResult {1230			Contracts::get_storage(address, key)1231		}12321233		fn rent_projection(1234			address: AccountId,1235		) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {1236			Contracts::rent_projection(address)1237		}1238	}1239	*/12401241	#[cfg(feature = "runtime-benchmarks")]1242	impl frame_benchmarking::Benchmark<Block> for Runtime {1243		fn dispatch_benchmark(1244			config: frame_benchmarking::BenchmarkConfig1245		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1246			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};12471248			let whitelist: Vec<TrackedStorageKey> = vec![1249				// Alice account1250				hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),1251				// // Total Issuance1252				// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),1253				// // Execution Phase1254				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),1255				// // Event Count1256				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),1257				// // System Events1258				// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),1259			];12601261			let mut batches = Vec::<BenchmarkBatch>::new();1262			let params = (&config, &whitelist);12631264			add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1265			add_benchmark!(params, batches, pallet_nft, Nft);1266			add_benchmark!(params, batches, pallet_inflation, Inflation);12671268			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1269			Ok(batches)1270		}1271	}1272}12731274struct CheckInherents;12751276impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1277	fn check_inherents(1278		block: &Block,1279		relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1280	) -> sp_inherents::CheckInherentsResult {1281		let relay_chain_slot = relay_state_proof1282			.read_slot()1283			.expect("Could not read the relay chain slot from the proof");12841285		let inherent_data =1286			cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1287				relay_chain_slot,1288				sp_std::time::Duration::from_secs(6),1289			)1290			.create_inherent_data()1291			.expect("Could not create the timestamp inherent data");12921293		inherent_data.check_extrinsics(block)1294	}1295}12961297cumulus_pallet_parachain_system::register_validate_block!(1298	Runtime = Runtime,1299	BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1300	CheckInherents = CheckInherents,1301);