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 _, OnMethodCall,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, ConstU32, Imbalance,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 unique_runtime_common::{70 dispatch::{CollectionDispatchT, CollectionDispatch},71 weights::CommonWeights,72 sponsoring::UniqueSponsorshipHandler,73 eth_sponsoring::UniqueEthSponsorshipHandler,74};75use up_data_structs::*;767778use frame_system::{79 self as frame_system, EnsureRoot, EnsureSigned,80 limits::{BlockWeights, BlockLength},81};82use sp_arithmetic::{83 traits::{BaseArithmetic, Unsigned},84};85use smallvec::smallvec;86use codec::{Encode, Decode};87use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping, OnMethodCall};88use fp_rpc::TransactionStatus;89use sp_runtime::{90 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},91 transaction_validity::TransactionValidityError,92 SaturatedConversion,93};9495969798use pallet_xcm::XcmPassthrough;99use polkadot_parachain::primitives::Sibling;100use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};101use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};102use xcm_builder::{103 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,104 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,105 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,106 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,107 ParentIsPreset,108};109use xcm_executor::{Config, XcmExecutor, Assets};110use sp_std::{marker::PhantomData};111112use xcm::latest::{113 114 AssetId::{Concrete},115 Fungibility::Fungible as XcmFungible,116 MultiAsset,117 Error as XcmError,118};119use xcm_executor::traits::{MatchesFungible, WeightTrader};120121use sp_runtime::traits::CheckedConversion;122123use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};124125pub const RUNTIME_NAME: &str = "unique";126pub const TOKEN_SYMBOL: &str = "UNQ";127128type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;129130impl RuntimeInstance for Runtime {131 type CrossAccountId = self::CrossAccountId;132133 type TransactionConverter = self::TransactionConverter;134135 fn get_transaction_converter() -> TransactionConverter {136 TransactionConverter137 }138}139140141142143144pub mod opaque {145 use sp_std::prelude::*;146 use sp_runtime::impl_opaque_keys;147 use super::Aura;148149 pub use unique_runtime_common::types::*;150151 impl_opaque_keys! {152 pub struct SessionKeys {153 pub aura: Aura,154 }155 }156}157158159pub const VERSION: RuntimeVersion = RuntimeVersion {160 spec_name: create_runtime_str!(RUNTIME_NAME),161 impl_name: create_runtime_str!(RUNTIME_NAME),162 authoring_version: 1,163 spec_version: 920000,164 impl_version: 0,165 apis: RUNTIME_API_VERSIONS,166 transaction_version: 1,167 state_version: 0,168};169170#[derive(codec::Encode, codec::Decode)]171pub enum XCMPMessage<XAccountId, XBalance> {172 173 TransferToken(XAccountId, XBalance),174}175176177#[cfg(feature = "std")]178pub fn native_version() -> NativeVersion {179 NativeVersion {180 runtime_version: VERSION,181 can_author_with: Default::default(),182 }183}184185type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;186187pub struct DealWithFees;188impl OnUnbalanced<NegativeImbalance> for DealWithFees {189 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {190 if let Some(fees) = fees_then_tips.next() {191 192 let mut split = fees.ration(100, 0);193 if let Some(tips) = fees_then_tips.next() {194 195 tips.ration_merge_into(100, 0, &mut split);196 }197 Treasury::on_unbalanced(split.0);198 199 }200 }201}202203parameter_types! {204 pub const BlockHashCount: BlockNumber = 2400;205 pub RuntimeBlockLength: BlockLength =206 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);207 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);208 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;209 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()210 .base_block(BlockExecutionWeight::get())211 .for_class(DispatchClass::all(), |weights| {212 weights.base_extrinsic = ExtrinsicBaseWeight::get();213 })214 .for_class(DispatchClass::Normal, |weights| {215 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);216 })217 .for_class(DispatchClass::Operational, |weights| {218 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);219 220 221 weights.reserved = Some(222 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT223 );224 })225 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)226 .build_or_panic();227 pub const Version: RuntimeVersion = VERSION;228 pub const SS58Prefix: u16 = 7391;229}230231parameter_types! {232 pub const ChainId: u64 = 8880;233}234235pub struct FixedFee;236impl FeeCalculator for FixedFee {237 fn min_gas_price() -> U256 {238 MIN_GAS_PRICE.into()239 }240}241242243244245parameter_types! {246 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;247 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;248 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();249}250251252253254const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);255parameter_types! {256 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());257}258259pub enum FixedGasWeightMapping {}260impl GasWeightMapping for FixedGasWeightMapping {261 fn gas_to_weight(gas: u64) -> Weight {262 gas.saturating_mul(WeightPerGas::get())263 }264 fn weight_to_gas(weight: Weight) -> u64 {265 weight / WeightPerGas::get()266 }267}268269impl pallet_evm::Config for Runtime {270 type BlockGasLimit = BlockGasLimit;271 type FeeCalculator = FixedFee;272 type GasWeightMapping = FixedGasWeightMapping;273 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;274 type CallOrigin = EnsureAddressTruncated<Self>;275 type WithdrawOrigin = EnsureAddressTruncated<Self>;276 type AddressMapping = HashedAddressMapping<Self::Hashing>;277 type PrecompilesType = ();278 type PrecompilesValue = ();279 type Currency = Balances;280 type Event = Event;281 type OnMethodCall = (282 pallet_evm_migration::OnMethodCall<Self>,283 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,284 CollectionDispatchT<Self>,285 pallet_evm_collection::CollectionOnMethodCall<Self>,286 );287 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;288 type ChainId = ChainId;289 type Runner = pallet_evm::runner::stack::Runner<Self>;290 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;291 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;292 type FindAuthor = EthereumFindAuthor<Aura>;293}294295impl pallet_evm_migration::Config for Runtime {296 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;297}298299pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);300impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {301 fn find_author<'a, I>(digests: I) -> Option<H160>302 where303 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,304 {305 if let Some(author_index) = F::find_author(digests) {306 let authority_id = Aura::authorities()[author_index as usize].clone();307 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));308 }309 None310 }311}312313impl pallet_ethereum::Config for Runtime {314 type Event = Event;315 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;316}317318impl pallet_randomness_collective_flip::Config for Runtime {}319320impl frame_system::Config for Runtime {321 322 type AccountData = pallet_balances::AccountData<Balance>;323 324 type AccountId = AccountId;325 326 type BaseCallFilter = Everything;327 328 type BlockHashCount = BlockHashCount;329 330 type BlockLength = RuntimeBlockLength;331 332 type BlockNumber = BlockNumber;333 334 type BlockWeights = RuntimeBlockWeights;335 336 type Call = Call;337 338 type DbWeight = RocksDbWeight;339 340 type Event = Event;341 342 type Hash = Hash;343 344 type Hashing = BlakeTwo256;345 346 type Header = generic::Header<BlockNumber, BlakeTwo256>;347 348 type Index = Index;349 350 type Lookup = AccountIdLookup<AccountId, ()>;351 352 type OnKilledAccount = ();353 354 type OnNewAccount = ();355 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;356 357 type Origin = Origin;358 359 type PalletInfo = PalletInfo;360 361 type SS58Prefix = SS58Prefix;362 363 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;364 365 type Version = Version;366 type MaxConsumers = ConstU32<16>;367}368369parameter_types! {370 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;371}372373impl pallet_timestamp::Config for Runtime {374 375 type Moment = u64;376 type OnTimestampSet = ();377 type MinimumPeriod = MinimumPeriod;378 type WeightInfo = ();379}380381parameter_types! {382 383 pub const ExistentialDeposit: u128 = 0;384 pub const MaxLocks: u32 = 50;385}386387impl pallet_balances::Config for Runtime {388 type MaxLocks = MaxLocks;389 type MaxReserves = ();390 type ReserveIdentifier = [u8; 8];391 392 type Balance = Balance;393 394 type Event = Event;395 type DustRemoval = Treasury;396 type ExistentialDeposit = ExistentialDeposit;397 type AccountStore = System;398 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;399}400401pub const fn deposit(items: u32, bytes: u32) -> Balance {402 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE403}404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455parameter_types! {456 457 458 pub const OperationalFeeMultiplier: u8 = 5;459}460461462pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);463464impl<T> WeightToFeePolynomial for LinearFee<T>465where466 T: BaseArithmetic + From<u32> + Copy + Unsigned,467{468 type Balance = T;469470 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {471 smallvec!(WeightToFeeCoefficient {472 473 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),474 coeff_frac: Perbill::zero(),475 negative: false,476 degree: 1,477 })478 }479}480481impl pallet_transaction_payment::Config for Runtime {482 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;483 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;484 type OperationalFeeMultiplier = OperationalFeeMultiplier;485 type WeightToFee = LinearFee<Balance>;486 type FeeMultiplierUpdate = ();487}488489parameter_types! {490 pub const ProposalBond: Permill = Permill::from_percent(5);491 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;492 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;493 pub const SpendPeriod: BlockNumber = 5 * MINUTES;494 pub const Burn: Permill = Permill::from_percent(0);495 pub const TipCountdown: BlockNumber = 1 * DAYS;496 pub const TipFindersFee: Percent = Percent::from_percent(20);497 pub const TipReportDepositBase: Balance = 1 * UNIQUE;498 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;499 pub const BountyDepositBase: Balance = 1 * UNIQUE;500 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;501 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");502 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;503 pub const MaximumReasonLength: u32 = 16384;504 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);505 pub const BountyValueMinimum: Balance = 5 * UNIQUE;506 pub const MaxApprovals: u32 = 100;507}508509impl pallet_treasury::Config for Runtime {510 type PalletId = TreasuryModuleId;511 type Currency = Balances;512 type ApproveOrigin = EnsureRoot<AccountId>;513 type RejectOrigin = EnsureRoot<AccountId>;514 type Event = Event;515 type OnSlash = ();516 type ProposalBond = ProposalBond;517 type ProposalBondMinimum = ProposalBondMinimum;518 type ProposalBondMaximum = ProposalBondMaximum;519 type SpendPeriod = SpendPeriod;520 type Burn = Burn;521 type BurnDestination = ();522 type SpendFunds = ();523 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;524 type MaxApprovals = MaxApprovals;525}526527impl pallet_sudo::Config for Runtime {528 type Event = Event;529 type Call = Call;530}531532pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);533534impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider535 for RelayChainBlockNumberProvider<T>536{537 type BlockNumber = BlockNumber;538539 fn current_block_number() -> Self::BlockNumber {540 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()541 .map(|d| d.relay_parent_number)542 .unwrap_or_default()543 }544}545546parameter_types! {547 pub const MinVestedTransfer: Balance = 10 * UNIQUE;548 pub const MaxVestingSchedules: u32 = 28;549}550551impl orml_vesting::Config for Runtime {552 type Event = Event;553 type Currency = pallet_balances::Pallet<Runtime>;554 type MinVestedTransfer = MinVestedTransfer;555 type VestedTransferOrigin = EnsureSigned<AccountId>;556 type WeightInfo = ();557 type MaxVestingSchedules = MaxVestingSchedules;558 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;559}560561parameter_types! {562 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;563 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;564}565566impl cumulus_pallet_parachain_system::Config for Runtime {567 type Event = Event;568 type SelfParaId = parachain_info::Pallet<Self>;569 type OnSystemEvent = ();570 571 572 573 574 575 type OutboundXcmpMessageSource = XcmpQueue;576 type DmpMessageHandler = DmpQueue;577 type ReservedDmpWeight = ReservedDmpWeight;578 type ReservedXcmpWeight = ReservedXcmpWeight;579 type XcmpMessageHandler = XcmpQueue;580}581582impl parachain_info::Config for Runtime {}583584impl cumulus_pallet_aura_ext::Config for Runtime {}585586parameter_types! {587 pub const RelayLocation: MultiLocation = MultiLocation::parent();588 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;589 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();590 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();591}592593594595596pub type LocationToAccountId = (597 598 ParentIsPreset<AccountId>,599 600 SiblingParachainConvertsVia<Sibling, AccountId>,601 602 AccountId32Aliases<RelayNetwork, AccountId>,603);604605pub struct OnlySelfCurrency;606impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {607 fn matches_fungible(a: &MultiAsset) -> Option<B> {608 match (&a.id, &a.fun) {609 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),610 _ => None,611 }612 }613}614615616pub type LocalAssetTransactor = CurrencyAdapter<617 618 Balances,619 620 OnlySelfCurrency,621 622 LocationToAccountId,623 624 AccountId,625 626 (),627>;628629630631632pub type XcmOriginToTransactDispatchOrigin = (633 634 635 636 SovereignSignedViaLocation<LocationToAccountId, Origin>,637 638 639 RelayChainAsNative<RelayOrigin, Origin>,640 641 642 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,643 644 645 ParentAsSuperuser<Origin>,646 647 648 SignedAccountId32AsNative<RelayNetwork, Origin>,649 650 XcmPassthrough<Origin>,651);652653parameter_types! {654 655 pub UnitWeightCost: Weight = 1_000_000;656 657 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);658 pub const MaxInstructions: u32 = 100;659 pub const MaxAuthorities: u32 = 100_000;660}661662match_types! {663 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {664 MultiLocation { parents: 1, interior: Here } |665 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }666 };667}668669pub type Barrier = (670 TakeWeightCredit,671 AllowTopLevelPaidExecutionFrom<Everything>,672 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,673 674);675676pub struct UsingOnlySelfCurrencyComponents<677 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,678 AssetId: Get<MultiLocation>,679 AccountId,680 Currency: CurrencyT<AccountId>,681 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,682>(683 Weight,684 Currency::Balance,685 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,686);687impl<688 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,689 AssetId: Get<MultiLocation>,690 AccountId,691 Currency: CurrencyT<AccountId>,692 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,693 > WeightTrader694 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>695{696 fn new() -> Self {697 Self(0, Zero::zero(), PhantomData)698 }699700 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {701 let amount = WeightToFee::calc(&weight);702 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;703704 705 let option1: xcm::v1::AssetId = Concrete(MultiLocation {706 parents: 1,707 interior: X1(Parachain(ParachainInfo::parachain_id().into())),708 });709 710 let option2: xcm::v1::AssetId = Concrete(MultiLocation {711 parents: 0,712 interior: Here,713 });714715 let required = if payment.fungible.contains_key(&option1) {716 (option1, u128_amount).into()717 } else if payment.fungible.contains_key(&option2) {718 (option2, u128_amount).into()719 } else {720 (Concrete(MultiLocation::default()), u128_amount).into()721 };722723 let unused = payment724 .checked_sub(required)725 .map_err(|_| XcmError::TooExpensive)?;726 self.0 = self.0.saturating_add(weight);727 self.1 = self.1.saturating_add(amount);728 Ok(unused)729 }730731 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {732 let weight = weight.min(self.0);733 let amount = WeightToFee::calc(&weight);734 self.0 -= weight;735 self.1 = self.1.saturating_sub(amount);736 let amount: u128 = amount.saturated_into();737 if amount > 0 {738 Some((AssetId::get(), amount).into())739 } else {740 None741 }742 }743}744impl<745 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,746 AssetId: Get<MultiLocation>,747 AccountId,748 Currency: CurrencyT<AccountId>,749 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,750 > Drop751 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>752{753 fn drop(&mut self) {754 OnUnbalanced::on_unbalanced(Currency::issue(self.1));755 }756}757758pub struct XcmConfig;759impl Config for XcmConfig {760 type Call = Call;761 type XcmSender = XcmRouter;762 763 type AssetTransactor = LocalAssetTransactor;764 type OriginConverter = XcmOriginToTransactDispatchOrigin;765 type IsReserve = NativeAsset;766 type IsTeleporter = (); 767 type LocationInverter = LocationInverter<Ancestry>;768 type Barrier = Barrier;769 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;770 type Trader = UsingOnlySelfCurrencyComponents<771 IdentityFee<Balance>,772 RelayLocation,773 AccountId,774 Balances,775 (),776 >;777 type ResponseHandler = (); 778 type SubscriptionService = PolkadotXcm;779780 type AssetTrap = PolkadotXcm;781 type AssetClaims = PolkadotXcm;782}783784785786787788789pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);790791792793pub type XcmRouter = (794 795 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,796 797 XcmpQueue,798);799800impl pallet_evm_coder_substrate::Config for Runtime {801 type GasWeightMapping = FixedGasWeightMapping;802}803804impl pallet_xcm::Config for Runtime {805 type Event = Event;806 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;807 type XcmRouter = XcmRouter;808 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;809 type XcmExecuteFilter = Everything;810 type XcmExecutor = XcmExecutor<XcmConfig>;811 type XcmTeleportFilter = Everything;812 type XcmReserveTransferFilter = Everything;813 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;814 type LocationInverter = LocationInverter<Ancestry>;815 type Origin = Origin;816 type Call = Call;817 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;818 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;819}820821impl cumulus_pallet_xcm::Config for Runtime {822 type Event = Event;823 type XcmExecutor = XcmExecutor<XcmConfig>;824}825826impl cumulus_pallet_xcmp_queue::Config for Runtime {827 type WeightInfo = ();828 type Event = Event;829 type XcmExecutor = XcmExecutor<XcmConfig>;830 type ChannelInfo = ParachainSystem;831 type VersionWrapper = ();832 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;833 type ControllerOrigin = EnsureRoot<AccountId>;834 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;835}836837impl cumulus_pallet_dmp_queue::Config for Runtime {838 type Event = Event;839 type XcmExecutor = XcmExecutor<XcmConfig>;840 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;841}842843impl pallet_aura::Config for Runtime {844 type AuthorityId = AuraId;845 type DisabledValidators = ();846 type MaxAuthorities = MaxAuthorities;847}848849parameter_types! {850 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();851 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;852}853854impl pallet_common::Config for Runtime {855 type WeightInfo = pallet_common::weights::SubstrateWeight<Self>;856 type Event = Event;857 type Currency = Balances;858 type CollectionCreationPrice = CollectionCreationPrice;859 type TreasuryAccountId = TreasuryAccountId;860 type CollectionDispatch = CollectionDispatchT<Self>;861862 type EvmTokenAddressMapping = EvmTokenAddressMapping;863 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;864}865866impl pallet_structure::Config for Runtime {867 type Event = Event;868 type Call = Call;869 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;870}871872impl pallet_evm::account::Config for Runtime {873 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;874 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;875 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;876}877878impl pallet_fungible::Config for Runtime {879 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;880}881impl pallet_refungible::Config for Runtime {882 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;883}884impl pallet_nonfungible::Config for Runtime {885 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;886}887888impl pallet_proxy_rmrk_core::Config for Runtime {889 type Event = Event;890}891892impl pallet_proxy_rmrk_equip::Config for Runtime {893 type Event = Event;894}895896impl pallet_unique::Config for Runtime {897 type Event = Event;898 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;899 type CommonWeightInfo = CommonWeights<Self>;900}901902parameter_types! {903 pub const InflationBlockInterval: BlockNumber = 100; 904}905906907impl pallet_inflation::Config for Runtime {908 type Currency = Balances;909 type TreasuryAccountId = TreasuryAccountId;910 type InflationBlockInterval = InflationBlockInterval;911 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;912}913914915916917918919920type EvmSponsorshipHandler = (921 UniqueEthSponsorshipHandler<Runtime>,922 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,923);924type SponsorshipHandler = (925 UniqueSponsorshipHandler<Runtime>,926 927 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,928);929930931932933934935936937938939940941942impl pallet_evm_transaction_payment::Config for Runtime {943 type EvmSponsorshipHandler = EvmSponsorshipHandler;944 type Currency = Balances;945}946947impl pallet_charge_transaction::Config for Runtime {948 type SponsorshipHandler = SponsorshipHandler;949}950951952953954955parameter_types! {956 957 pub const HelpersContractAddress: H160 = H160([958 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,959 ]);960 961 962 pub const EvmCollectionAddress: H160 = H160([963 0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,964 ]);965}966967impl pallet_evm_contract_helpers::Config for Runtime {968 type ContractAddress = HelpersContractAddress;969 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;970}971972impl pallet_evm_collection::Config for Runtime {973 type ContractAddress = EvmCollectionAddress;974}975976construct_runtime!(977 pub enum Runtime where978 Block = Block,979 NodeBlock = opaque::Block,980 UncheckedExtrinsic = UncheckedExtrinsic981 {982 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,983 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,984985 Aura: pallet_aura::{Pallet, Config<T>} = 22,986 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,987988 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,989 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,990 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,991 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,992 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,993 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,994 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,995 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,996 997 998999 1000 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,1001 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,1002 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,1003 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10041005 1006 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1007 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1008 1009 1010 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1011 1012 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1013 Fungible: pallet_fungible::{Pallet, Storage} = 67,1014 Refungible: pallet_refungible::{Pallet, Storage} = 68,1015 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1016 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,1017 RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,1018 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,10191020 1021 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1022 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10231024 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1025 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1026 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1027 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1028 EvmCollection: pallet_evm_collection::{Pallet} = 154,1029 }1030);10311032pub struct TransactionConverter;10331034impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1035 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1036 UncheckedExtrinsic::new_unsigned(1037 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1038 )1039 }1040}10411042impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1043 fn convert_transaction(1044 &self,1045 transaction: pallet_ethereum::Transaction,1046 ) -> opaque::UncheckedExtrinsic {1047 let extrinsic = UncheckedExtrinsic::new_unsigned(1048 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1049 );1050 let encoded = extrinsic.encode();1051 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1052 .expect("Encoded extrinsic is always valid")1053 }1054}105510561057pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10581059pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10601061pub type Block = generic::Block<Header, UncheckedExtrinsic>;10621063pub type SignedBlock = generic::SignedBlock<Block>;10641065pub type BlockId = generic::BlockId<Block>;10661067pub type SignedExtra = (1068 frame_system::CheckSpecVersion<Runtime>,1069 1070 frame_system::CheckGenesis<Runtime>,1071 frame_system::CheckEra<Runtime>,1072 frame_system::CheckNonce<Runtime>,1073 frame_system::CheckWeight<Runtime>,1074 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1075 1076 pallet_ethereum::FakeTransactionFinalizer<Runtime>,1077);10781079pub type UncheckedExtrinsic =1080 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10811082pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10831084pub type Executive = frame_executive::Executive<1085 Runtime,1086 Block,1087 frame_system::ChainContext<Runtime>,1088 Runtime,1089 AllPalletsReversedWithSystemFirst,1090>;10911092impl_opaque_keys! {1093 pub struct SessionKeys {1094 pub aura: Aura,1095 }1096}10971098impl fp_self_contained::SelfContainedCall for Call {1099 type SignedInfo = H160;11001101 fn is_self_contained(&self) -> bool {1102 match self {1103 Call::Ethereum(call) => call.is_self_contained(),1104 _ => false,1105 }1106 }11071108 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1109 match self {1110 Call::Ethereum(call) => call.check_self_contained(),1111 _ => None,1112 }1113 }11141115 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1116 match self {1117 Call::Ethereum(call) => call.validate_self_contained(info),1118 _ => None,1119 }1120 }11211122 fn pre_dispatch_self_contained(1123 &self,1124 info: &Self::SignedInfo,1125 ) -> Option<Result<(), TransactionValidityError>> {1126 match self {1127 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1128 _ => None,1129 }1130 }11311132 fn apply_self_contained(1133 self,1134 info: Self::SignedInfo,1135 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1136 match self {1137 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1138 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1139 )),1140 _ => None,1141 }1142 }1143}11441145macro_rules! dispatch_unique_runtime {1146 ($collection:ident.$method:ident($($name:ident),*)) => {{1147 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1148 let dispatch = collection.as_dyn();11491150 Ok::<_, DispatchError>(dispatch.$method($($name),*))1151 }};1152}11531154impl_common_runtime_apis!();11551156struct CheckInherents;11571158impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1159 fn check_inherents(1160 block: &Block,1161 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1162 ) -> sp_inherents::CheckInherentsResult {1163 let relay_chain_slot = relay_state_proof1164 .read_slot()1165 .expect("Could not read the relay chain slot from the proof");11661167 let inherent_data =1168 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1169 relay_chain_slot,1170 sp_std::time::Duration::from_secs(6),1171 )1172 .create_inherent_data()1173 .expect("Could not create the timestamp inherent data");11741175 inherent_data.check_extrinsics(block)1176 }1177}11781179cumulus_pallet_parachain_system::register_validate_block!(1180 Runtime = Runtime,1181 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1182 CheckInherents = CheckInherents,1183);