12345678910111213141516171819#![cfg_attr(not(feature = "std"), no_std)]2021#![recursion_limit = "1024"]22#![allow(clippy::from_over_into, clippy::identity_op)]23#![allow(clippy::fn_to_numeric_cast_with_truncation)]2425#[cfg(feature = "std")]26include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));2728use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;31323334use sp_runtime::{35 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37 transaction_validity::{TransactionSource, TransactionValidity},38 ApplyExtrinsicResult, RuntimeAppPublic,39};4041use sp_std::prelude::*;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;45use sp_version::RuntimeVersion;46pub use pallet_transaction_payment::{47 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,48};4950pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,53};54pub use frame_support::{55 construct_runtime, match_types,56 dispatch::DispatchResult,57 PalletId, parameter_types, StorageValue, ConsensusEngineId,58 traits::{59 tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Everything,60 Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem, LockIdentifier,61 OnUnbalanced, Randomness, FindAuthor,62 },63 weights::{64 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},65 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,67 },68};69use up_data_structs::*;707172use frame_system::{73 self as frame_system, EnsureRoot, EnsureSigned,74 limits::{BlockWeights, BlockLength},75};76use sp_arithmetic::{77 traits::{BaseArithmetic, Unsigned},78};79use smallvec::smallvec;80use codec::{Encode, Decode};81use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};82use fp_rpc::TransactionStatus;83use sp_runtime::{84 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},85 transaction_validity::TransactionValidityError,86 SaturatedConversion,87};8889909192use pallet_xcm::XcmPassthrough;93use polkadot_parachain::primitives::Sibling;94use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};95use xcm_builder::{96 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,97 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,98 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,99 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,100 ParentIsPreset,101};102use xcm_executor::{Config, XcmExecutor, Assets};103use sp_std::{marker::PhantomData};104105use xcm::latest::{106 107 AssetId::{Concrete},108 Fungibility::Fungible as XcmFungible,109 MultiAsset,110 Error as XcmError,111};112use xcm_executor::traits::{MatchesFungible, WeightTrader};113114use sp_runtime::traits::CheckedConversion;115116use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};117118pub const RUNTIME_NAME: &str = "unique";119pub const TOKEN_SYMBOL: &str = "UNQ";120121type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;122123impl RuntimeInstance for Runtime {124 type CrossAccountId = self::CrossAccountId;125126 type TransactionConverter = self::TransactionConverter;127128 fn get_transaction_converter() -> TransactionConverter {129 TransactionConverter130 }131}132133134135136137pub mod opaque {138 use sp_std::prelude::*;139 use sp_runtime::impl_opaque_keys;140 use super::Aura;141142 pub use unique_runtime_common::types::*;143144 impl_opaque_keys! {145 pub struct SessionKeys {146 pub aura: Aura,147 }148 }149}150151152pub const VERSION: RuntimeVersion = RuntimeVersion {153 spec_name: create_runtime_str!(RUNTIME_NAME),154 impl_name: create_runtime_str!(RUNTIME_NAME),155 authoring_version: 1,156 spec_version: 918010,157 impl_version: 0,158 apis: RUNTIME_API_VERSIONS,159 transaction_version: 1,160 state_version: 0,161};162163#[derive(codec::Encode, codec::Decode)]164pub enum XCMPMessage<XAccountId, XBalance> {165 166 TransferToken(XAccountId, XBalance),167}168169170#[cfg(feature = "std")]171pub fn native_version() -> NativeVersion {172 NativeVersion {173 runtime_version: VERSION,174 can_author_with: Default::default(),175 }176}177178type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;179180pub struct DealWithFees;181impl OnUnbalanced<NegativeImbalance> for DealWithFees {182 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {183 if let Some(fees) = fees_then_tips.next() {184 185 let mut split = fees.ration(100, 0);186 if let Some(tips) = fees_then_tips.next() {187 188 tips.ration_merge_into(100, 0, &mut split);189 }190 Treasury::on_unbalanced(split.0);191 192 }193 }194}195196parameter_types! {197 pub const BlockHashCount: BlockNumber = 2400;198 pub RuntimeBlockLength: BlockLength =199 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);200 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);201 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;202 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()203 .base_block(BlockExecutionWeight::get())204 .for_class(DispatchClass::all(), |weights| {205 weights.base_extrinsic = ExtrinsicBaseWeight::get();206 })207 .for_class(DispatchClass::Normal, |weights| {208 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);209 })210 .for_class(DispatchClass::Operational, |weights| {211 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);212 213 214 weights.reserved = Some(215 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT216 );217 })218 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)219 .build_or_panic();220 pub const Version: RuntimeVersion = VERSION;221 pub const SS58Prefix: u16 = 7391;222}223224parameter_types! {225 pub const ChainId: u64 = 8880;226}227228pub struct FixedFee;229impl FeeCalculator for FixedFee {230 fn min_gas_price() -> U256 {231 MIN_GAS_PRICE.into()232 }233}234235236237238parameter_types! {239 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;240 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;241 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();242}243244245246247const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);248parameter_types! {249 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());250}251252pub enum FixedGasWeightMapping {}253impl GasWeightMapping for FixedGasWeightMapping {254 fn gas_to_weight(gas: u64) -> Weight {255 gas.saturating_mul(WeightPerGas::get())256 }257 fn weight_to_gas(weight: Weight) -> u64 {258 weight / WeightPerGas::get()259 }260}261262impl pallet_evm::Config for Runtime {263 type BlockGasLimit = BlockGasLimit;264 type FeeCalculator = FixedFee;265 type GasWeightMapping = FixedGasWeightMapping;266 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;267 type CallOrigin = EnsureAddressTruncated;268 type WithdrawOrigin = EnsureAddressTruncated;269 type AddressMapping = HashedAddressMapping<Self::Hashing>;270 type PrecompilesType = ();271 type PrecompilesValue = ();272 type Currency = Balances;273 type Event = Event;274 type OnMethodCall = (275 pallet_evm_migration::OnMethodCall<Self>,276 pallet_unique::UniqueErcSupport<Self>,277 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,278 );279 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;280 type ChainId = ChainId;281 type Runner = pallet_evm::runner::stack::Runner<Self>;282 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;283 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;284 type FindAuthor = EthereumFindAuthor<Aura>;285}286287impl pallet_evm_migration::Config for Runtime {288 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;289}290291pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);292impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {293 fn find_author<'a, I>(digests: I) -> Option<H160>294 where295 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,296 {297 if let Some(author_index) = F::find_author(digests) {298 let authority_id = Aura::authorities()[author_index as usize].clone();299 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));300 }301 None302 }303}304305impl pallet_ethereum::Config for Runtime {306 type Event = Event;307 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;308}309310impl pallet_randomness_collective_flip::Config for Runtime {}311312impl frame_system::Config for Runtime {313 314 type AccountData = pallet_balances::AccountData<Balance>;315 316 type AccountId = AccountId;317 318 type BaseCallFilter = Everything;319 320 type BlockHashCount = BlockHashCount;321 322 type BlockLength = RuntimeBlockLength;323 324 type BlockNumber = BlockNumber;325 326 type BlockWeights = RuntimeBlockWeights;327 328 type Call = Call;329 330 type DbWeight = RocksDbWeight;331 332 type Event = Event;333 334 type Hash = Hash;335 336 type Hashing = BlakeTwo256;337 338 type Header = generic::Header<BlockNumber, BlakeTwo256>;339 340 type Index = Index;341 342 type Lookup = AccountIdLookup<AccountId, ()>;343 344 type OnKilledAccount = ();345 346 type OnNewAccount = ();347 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;348 349 type Origin = Origin;350 351 type PalletInfo = PalletInfo;352 353 type SS58Prefix = SS58Prefix;354 355 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;356 357 type Version = Version;358 type MaxConsumers = ConstU32<16>;359}360361parameter_types! {362 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;363}364365impl pallet_timestamp::Config for Runtime {366 367 type Moment = u64;368 type OnTimestampSet = ();369 type MinimumPeriod = MinimumPeriod;370 type WeightInfo = ();371}372373parameter_types! {374 375 pub const ExistentialDeposit: u128 = 0;376 pub const MaxLocks: u32 = 50;377}378379impl pallet_balances::Config for Runtime {380 type MaxLocks = MaxLocks;381 type MaxReserves = ();382 type ReserveIdentifier = [u8; 8];383 384 type Balance = Balance;385 386 type Event = Event;387 type DustRemoval = Treasury;388 type ExistentialDeposit = ExistentialDeposit;389 type AccountStore = System;390 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;391}392393pub const fn deposit(items: u32, bytes: u32) -> Balance {394 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE395}396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447parameter_types! {448 449 450 pub const OperationalFeeMultiplier: u8 = 5;451}452453454pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);455456impl<T> WeightToFeePolynomial for LinearFee<T>457where458 T: BaseArithmetic + From<u32> + Copy + Unsigned,459{460 type Balance = T;461462 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {463 smallvec!(WeightToFeeCoefficient {464 465 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),466 coeff_frac: Perbill::zero(),467 negative: false,468 degree: 1,469 })470 }471}472473impl pallet_transaction_payment::Config for Runtime {474 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;475 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;476 type OperationalFeeMultiplier = OperationalFeeMultiplier;477 type WeightToFee = LinearFee<Balance>;478 type FeeMultiplierUpdate = ();479}480481parameter_types! {482 pub const ProposalBond: Permill = Permill::from_percent(5);483 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;484 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;485 pub const SpendPeriod: BlockNumber = 5 * MINUTES;486 pub const Burn: Permill = Permill::from_percent(0);487 pub const TipCountdown: BlockNumber = 1 * DAYS;488 pub const TipFindersFee: Percent = Percent::from_percent(20);489 pub const TipReportDepositBase: Balance = 1 * UNIQUE;490 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;491 pub const BountyDepositBase: Balance = 1 * UNIQUE;492 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;493 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");494 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;495 pub const MaximumReasonLength: u32 = 16384;496 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);497 pub const BountyValueMinimum: Balance = 5 * UNIQUE;498 pub const MaxApprovals: u32 = 100;499}500501impl pallet_treasury::Config for Runtime {502 type PalletId = TreasuryModuleId;503 type Currency = Balances;504 type ApproveOrigin = EnsureRoot<AccountId>;505 type RejectOrigin = EnsureRoot<AccountId>;506 type Event = Event;507 type OnSlash = ();508 type ProposalBond = ProposalBond;509 type ProposalBondMinimum = ProposalBondMinimum;510 type ProposalBondMaximum = ProposalBondMaximum;511 type SpendPeriod = SpendPeriod;512 type Burn = Burn;513 type BurnDestination = ();514 type SpendFunds = ();515 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;516 type MaxApprovals = MaxApprovals;517}518519impl pallet_sudo::Config for Runtime {520 type Event = Event;521 type Call = Call;522}523524pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);525526impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider527 for RelayChainBlockNumberProvider<T>528{529 type BlockNumber = BlockNumber;530531 fn current_block_number() -> Self::BlockNumber {532 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()533 .map(|d| d.relay_parent_number)534 .unwrap_or_default()535 }536}537538parameter_types! {539 pub const MinVestedTransfer: Balance = 10 * UNIQUE;540 pub const MaxVestingSchedules: u32 = 28;541}542543impl orml_vesting::Config for Runtime {544 type Event = Event;545 type Currency = pallet_balances::Pallet<Runtime>;546 type MinVestedTransfer = MinVestedTransfer;547 type VestedTransferOrigin = EnsureSigned<AccountId>;548 type WeightInfo = ();549 type MaxVestingSchedules = MaxVestingSchedules;550 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;551}552553parameter_types! {554 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;555 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;556}557558impl cumulus_pallet_parachain_system::Config for Runtime {559 type Event = Event;560 type SelfParaId = parachain_info::Pallet<Self>;561 type OnSystemEvent = ();562 563 564 565 566 567 type OutboundXcmpMessageSource = XcmpQueue;568 type DmpMessageHandler = DmpQueue;569 type ReservedDmpWeight = ReservedDmpWeight;570 type ReservedXcmpWeight = ReservedXcmpWeight;571 type XcmpMessageHandler = XcmpQueue;572}573574impl parachain_info::Config for Runtime {}575576impl cumulus_pallet_aura_ext::Config for Runtime {}577578parameter_types! {579 pub const RelayLocation: MultiLocation = MultiLocation::parent();580 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;581 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();582 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();583}584585586587588pub type LocationToAccountId = (589 590 ParentIsPreset<AccountId>,591 592 SiblingParachainConvertsVia<Sibling, AccountId>,593 594 AccountId32Aliases<RelayNetwork, AccountId>,595);596597pub struct OnlySelfCurrency;598impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {599 fn matches_fungible(a: &MultiAsset) -> Option<B> {600 match (&a.id, &a.fun) {601 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),602 _ => None,603 }604 }605}606607608pub type LocalAssetTransactor = CurrencyAdapter<609 610 Balances,611 612 OnlySelfCurrency,613 614 LocationToAccountId,615 616 AccountId,617 618 (),619>;620621622623624pub type XcmOriginToTransactDispatchOrigin = (625 626 627 628 SovereignSignedViaLocation<LocationToAccountId, Origin>,629 630 631 RelayChainAsNative<RelayOrigin, Origin>,632 633 634 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,635 636 637 ParentAsSuperuser<Origin>,638 639 640 SignedAccountId32AsNative<RelayNetwork, Origin>,641 642 XcmPassthrough<Origin>,643);644645parameter_types! {646 647 pub UnitWeightCost: Weight = 1_000_000;648 649 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);650 pub const MaxInstructions: u32 = 100;651 pub const MaxAuthorities: u32 = 100_000;652}653654match_types! {655 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {656 MultiLocation { parents: 1, interior: Here } |657 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }658 };659}660661pub type Barrier = (662 TakeWeightCredit,663 AllowTopLevelPaidExecutionFrom<Everything>,664 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,665 666);667668pub struct UsingOnlySelfCurrencyComponents<669 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,670 AssetId: Get<MultiLocation>,671 AccountId,672 Currency: CurrencyT<AccountId>,673 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,674>(675 Weight,676 Currency::Balance,677 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,678);679impl<680 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,681 AssetId: Get<MultiLocation>,682 AccountId,683 Currency: CurrencyT<AccountId>,684 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,685 > WeightTrader686 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>687{688 fn new() -> Self {689 Self(0, Zero::zero(), PhantomData)690 }691692 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {693 let amount = WeightToFee::calc(&weight);694 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;695696 697 let option1: xcm::v1::AssetId = Concrete(MultiLocation {698 parents: 1,699 interior: X1(Parachain(ParachainInfo::parachain_id().into())),700 });701 702 let option2: xcm::v1::AssetId = Concrete(MultiLocation {703 parents: 0,704 interior: Here,705 });706707 let required = if payment.fungible.contains_key(&option1) {708 (option1, u128_amount).into()709 } else if payment.fungible.contains_key(&option2) {710 (option2, u128_amount).into()711 } else {712 (Concrete(MultiLocation::default()), u128_amount).into()713 };714715 let unused = payment716 .checked_sub(required)717 .map_err(|_| XcmError::TooExpensive)?;718 self.0 = self.0.saturating_add(weight);719 self.1 = self.1.saturating_add(amount);720 Ok(unused)721 }722723 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {724 let weight = weight.min(self.0);725 let amount = WeightToFee::calc(&weight);726 self.0 -= weight;727 self.1 = self.1.saturating_sub(amount);728 let amount: u128 = amount.saturated_into();729 if amount > 0 {730 Some((AssetId::get(), amount).into())731 } else {732 None733 }734 }735}736impl<737 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,738 AssetId: Get<MultiLocation>,739 AccountId,740 Currency: CurrencyT<AccountId>,741 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,742 > Drop743 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>744{745 fn drop(&mut self) {746 OnUnbalanced::on_unbalanced(Currency::issue(self.1));747 }748}749750pub struct XcmConfig;751impl Config for XcmConfig {752 type Call = Call;753 type XcmSender = XcmRouter;754 755 type AssetTransactor = LocalAssetTransactor;756 type OriginConverter = XcmOriginToTransactDispatchOrigin;757 type IsReserve = NativeAsset;758 type IsTeleporter = (); 759 type LocationInverter = LocationInverter<Ancestry>;760 type Barrier = Barrier;761 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;762 type Trader = UsingOnlySelfCurrencyComponents<763 IdentityFee<Balance>,764 RelayLocation,765 AccountId,766 Balances,767 (),768 >;769 type ResponseHandler = (); 770 type SubscriptionService = PolkadotXcm;771772 type AssetTrap = PolkadotXcm;773 type AssetClaims = PolkadotXcm;774}775776777778779780781pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);782783784785pub type XcmRouter = (786 787 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,788 789 XcmpQueue,790);791792impl pallet_evm_coder_substrate::Config for Runtime {793 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;794 type GasWeightMapping = FixedGasWeightMapping;795}796797impl pallet_xcm::Config for Runtime {798 type Event = Event;799 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;800 type XcmRouter = XcmRouter;801 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;802 type XcmExecuteFilter = Everything;803 type XcmExecutor = XcmExecutor<XcmConfig>;804 type XcmTeleportFilter = Everything;805 type XcmReserveTransferFilter = Everything;806 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;807 type LocationInverter = LocationInverter<Ancestry>;808 type Origin = Origin;809 type Call = Call;810 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;811 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;812}813814impl cumulus_pallet_xcm::Config for Runtime {815 type Event = Event;816 type XcmExecutor = XcmExecutor<XcmConfig>;817}818819impl cumulus_pallet_xcmp_queue::Config for Runtime {820 type WeightInfo = ();821 type Event = Event;822 type XcmExecutor = XcmExecutor<XcmConfig>;823 type ChannelInfo = ParachainSystem;824 type VersionWrapper = ();825 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;826 type ControllerOrigin = EnsureRoot<AccountId>;827 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;828}829830impl cumulus_pallet_dmp_queue::Config for Runtime {831 type Event = Event;832 type XcmExecutor = XcmExecutor<XcmConfig>;833 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;834}835836impl pallet_aura::Config for Runtime {837 type AuthorityId = AuraId;838 type DisabledValidators = ();839 type MaxAuthorities = MaxAuthorities;840}841842parameter_types! {843 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();844 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;845}846847impl pallet_common::Config for Runtime {848 type Event = Event;849 type Currency = Balances;850 type CollectionCreationPrice = CollectionCreationPrice;851 type TreasuryAccountId = TreasuryAccountId;852}853854impl pallet_evm::account::Config for Runtime {855 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;856 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;857 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;858}859860impl pallet_fungible::Config for Runtime {861 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;862}863impl pallet_refungible::Config for Runtime {864 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;865}866impl pallet_nonfungible::Config for Runtime {867 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;868}869870impl pallet_unique::Config for Runtime {871 type Event = Event;872 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;873}874875parameter_types! {876 pub const InflationBlockInterval: BlockNumber = 100; 877}878879880impl pallet_inflation::Config for Runtime {881 type Currency = Balances;882 type TreasuryAccountId = TreasuryAccountId;883 type InflationBlockInterval = InflationBlockInterval;884 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;885}886887888889890891892893type EvmSponsorshipHandler = (894 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,895 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,896);897type SponsorshipHandler = (898 pallet_unique::UniqueSponsorshipHandler<Runtime>,899 900 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,901);902903904905906907908909910911912913914915impl pallet_evm_transaction_payment::Config for Runtime {916 type EvmSponsorshipHandler = EvmSponsorshipHandler;917 type Currency = Balances;918}919920impl pallet_charge_transaction::Config for Runtime {921 type SponsorshipHandler = SponsorshipHandler;922}923924925926927928parameter_types! {929 930 pub const HelpersContractAddress: H160 = H160([931 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,932 ]);933}934935impl pallet_evm_contract_helpers::Config for Runtime {936 type ContractAddress = HelpersContractAddress;937 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;938}939940construct_runtime!(941 pub enum Runtime where942 Block = Block,943 NodeBlock = opaque::Block,944 UncheckedExtrinsic = UncheckedExtrinsic945 {946 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,947 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,948949 Aura: pallet_aura::{Pallet, Config<T>} = 22,950 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,951952 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,953 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,954 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,955 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,956 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,957 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,958 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,959 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,960 961 962963 964 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,965 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,966 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,967 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,968969 970 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,971 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,972 973 974 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,975 976 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,977 Fungible: pallet_fungible::{Pallet, Storage} = 67,978 Refungible: pallet_refungible::{Pallet, Storage} = 68,979 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,980981 982 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,983 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,984985 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,986 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,987 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,988 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,989 }990);991992pub struct TransactionConverter;993994impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {995 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {996 UncheckedExtrinsic::new_unsigned(997 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),998 )999 }1000}10011002impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1003 fn convert_transaction(1004 &self,1005 transaction: pallet_ethereum::Transaction,1006 ) -> opaque::UncheckedExtrinsic {1007 let extrinsic = UncheckedExtrinsic::new_unsigned(1008 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1009 );1010 let encoded = extrinsic.encode();1011 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1012 .expect("Encoded extrinsic is always valid")1013 }1014}101510161017pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10181019pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10201021pub type Block = generic::Block<Header, UncheckedExtrinsic>;10221023pub type SignedBlock = generic::SignedBlock<Block>;10241025pub type BlockId = generic::BlockId<Block>;10261027pub type SignedExtra = (1028 frame_system::CheckSpecVersion<Runtime>,1029 1030 frame_system::CheckGenesis<Runtime>,1031 frame_system::CheckEra<Runtime>,1032 frame_system::CheckNonce<Runtime>,1033 frame_system::CheckWeight<Runtime>,1034 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1035 1036);10371038pub type UncheckedExtrinsic =1039 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10401041pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10421043pub type Executive = frame_executive::Executive<1044 Runtime,1045 Block,1046 frame_system::ChainContext<Runtime>,1047 Runtime,1048 AllPalletsReversedWithSystemFirst,1049>;10501051impl_opaque_keys! {1052 pub struct SessionKeys {1053 pub aura: Aura,1054 }1055}10561057impl fp_self_contained::SelfContainedCall for Call {1058 type SignedInfo = H160;10591060 fn is_self_contained(&self) -> bool {1061 match self {1062 Call::Ethereum(call) => call.is_self_contained(),1063 _ => false,1064 }1065 }10661067 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1068 match self {1069 Call::Ethereum(call) => call.check_self_contained(),1070 _ => None,1071 }1072 }10731074 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1075 match self {1076 Call::Ethereum(call) => call.validate_self_contained(info),1077 _ => None,1078 }1079 }10801081 fn pre_dispatch_self_contained(1082 &self,1083 info: &Self::SignedInfo,1084 ) -> Option<Result<(), TransactionValidityError>> {1085 match self {1086 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1087 _ => None,1088 }1089 }10901091 fn apply_self_contained(1092 self,1093 info: Self::SignedInfo,1094 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1095 match self {1096 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1097 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1098 )),1099 _ => None,1100 }1101 }1102}11031104macro_rules! dispatch_unique_runtime {1105 ($collection:ident.$method:ident($($name:ident),*)) => {{1106 use pallet_unique::dispatch::Dispatched;11071108 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1109 let dispatch = collection.as_dyn();11101111 Ok(dispatch.$method($($name),*))1112 }};1113}11141115impl_common_runtime_apis!();11161117struct CheckInherents;11181119impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1120 fn check_inherents(1121 block: &Block,1122 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1123 ) -> sp_inherents::CheckInherentsResult {1124 let relay_chain_slot = relay_state_proof1125 .read_slot()1126 .expect("Could not read the relay chain slot from the proof");11271128 let inherent_data =1129 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1130 relay_chain_slot,1131 sp_std::time::Duration::from_secs(6),1132 )1133 .create_inherent_data()1134 .expect("Could not create the timestamp inherent data");11351136 inherent_data.check_extrinsics(block)1137 }1138}11391140cumulus_pallet_parachain_system::register_validate_block!(1141 Runtime = Runtime,1142 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1143 CheckInherents = CheckInherents,1144);