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, 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 up_data_structs::{CollectionId, TokenId, CollectionStats, Collection};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};888990pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;919293use pallet_xcm::XcmPassthrough;94use polkadot_parachain::primitives::Sibling;95use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};96use xcm_builder::{97 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,98 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,99 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,100 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,101 ParentIsPreset,102};103use xcm_executor::{Config, XcmExecutor, Assets};104use sp_std::{marker::PhantomData};105106use xcm::latest::{107 108 AssetId::{Concrete},109 Fungibility::Fungible as XcmFungible,110 MultiAsset,111 Error as XcmError,112};113use xcm_executor::traits::{MatchesFungible, WeightTrader};114115use sp_runtime::traits::CheckedConversion;116117use unique_runtime_common::{118 impl_common_runtime_apis,119 types::*,120 constants::*,121 dispatch::{CollectionDispatchT, CollectionDispatch},122};123124pub const RUNTIME_NAME: &str = "opal";125pub const TOKEN_SYMBOL: &str = "OPL";126127type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;128129impl RuntimeInstance for Runtime {130 type CrossAccountId = self::CrossAccountId;131 type TransactionConverter = self::TransactionConverter;132133 fn get_transaction_converter() -> TransactionConverter {134 TransactionConverter135 }136}137138139140pub type AccountIndex = u32;141142143pub type Balance = u128;144145146pub type Index = u32;147148149pub type Hash = sp_core::H256;150151152pub type DigestItem = generic::DigestItem;153154155156157158pub mod opaque {159 use sp_std::prelude::*;160 use sp_runtime::impl_opaque_keys;161 use super::Aura;162163 pub use unique_runtime_common::types::*;164165 impl_opaque_keys! {166 pub struct SessionKeys {167 pub aura: Aura,168 }169 }170}171172173pub const VERSION: RuntimeVersion = RuntimeVersion {174 spec_name: create_runtime_str!(RUNTIME_NAME),175 impl_name: create_runtime_str!(RUNTIME_NAME),176 authoring_version: 1,177 spec_version: 920000,178 impl_version: 0,179 apis: RUNTIME_API_VERSIONS,180 transaction_version: 1,181 state_version: 0,182};183184#[derive(codec::Encode, codec::Decode)]185pub enum XCMPMessage<XAccountId, XBalance> {186 187 TransferToken(XAccountId, XBalance),188}189190191#[cfg(feature = "std")]192pub fn native_version() -> NativeVersion {193 NativeVersion {194 runtime_version: VERSION,195 can_author_with: Default::default(),196 }197}198199type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;200201pub struct DealWithFees;202impl OnUnbalanced<NegativeImbalance> for DealWithFees {203 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {204 if let Some(fees) = fees_then_tips.next() {205 206 let mut split = fees.ration(100, 0);207 if let Some(tips) = fees_then_tips.next() {208 209 tips.ration_merge_into(100, 0, &mut split);210 }211 Treasury::on_unbalanced(split.0);212 213 }214 }215}216217parameter_types! {218 pub const BlockHashCount: BlockNumber = 2400;219 pub RuntimeBlockLength: BlockLength =220 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);221 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);222 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;223 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()224 .base_block(BlockExecutionWeight::get())225 .for_class(DispatchClass::all(), |weights| {226 weights.base_extrinsic = ExtrinsicBaseWeight::get();227 })228 .for_class(DispatchClass::Normal, |weights| {229 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);230 })231 .for_class(DispatchClass::Operational, |weights| {232 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);233 234 235 weights.reserved = Some(236 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT237 );238 })239 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)240 .build_or_panic();241 pub const Version: RuntimeVersion = VERSION;242 pub const SS58Prefix: u8 = 42;243}244245parameter_types! {246 pub const ChainId: u64 = 8882;247}248249pub struct FixedFee;250impl FeeCalculator for FixedFee {251 fn min_gas_price() -> U256 {252 MIN_GAS_PRICE.into()253 }254}255256257258259parameter_types! {260 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;261 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;262 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();263}264265266267268const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);269parameter_types! {270 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());271}272273pub enum FixedGasWeightMapping {}274impl GasWeightMapping for FixedGasWeightMapping {275 fn gas_to_weight(gas: u64) -> Weight {276 gas.saturating_mul(WeightPerGas::get())277 }278 fn weight_to_gas(weight: Weight) -> u64 {279 weight / WeightPerGas::get()280 }281}282283impl pallet_evm::account::Config for Runtime {284 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;285 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;286 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;287}288289impl pallet_evm::Config for Runtime {290 type BlockGasLimit = BlockGasLimit;291 type FeeCalculator = FixedFee;292 type GasWeightMapping = FixedGasWeightMapping;293 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;294 type CallOrigin = EnsureAddressTruncated;295 type WithdrawOrigin = EnsureAddressTruncated;296 type AddressMapping = HashedAddressMapping<Self::Hashing>;297 type PrecompilesType = ();298 type PrecompilesValue = ();299 type Currency = Balances;300 type Event = Event;301 type OnMethodCall = (302 pallet_evm_migration::OnMethodCall<Self>,303 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,304 CollectionDispatchT<Self>,305 );306 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;307 type ChainId = ChainId;308 type Runner = pallet_evm::runner::stack::Runner<Self>;309 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;310 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;311 type FindAuthor = EthereumFindAuthor<Aura>;312}313314impl pallet_evm_migration::Config for Runtime {315 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;316}317318pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);319impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {320 fn find_author<'a, I>(digests: I) -> Option<H160>321 where322 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,323 {324 if let Some(author_index) = F::find_author(digests) {325 let authority_id = Aura::authorities()[author_index as usize].clone();326 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));327 }328 None329 }330}331332impl pallet_ethereum::Config for Runtime {333 type Event = Event;334 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;335}336337impl pallet_randomness_collective_flip::Config for Runtime {}338339impl frame_system::Config for Runtime {340 341 type AccountData = pallet_balances::AccountData<Balance>;342 343 type AccountId = AccountId;344 345 type BaseCallFilter = Everything;346 347 type BlockHashCount = BlockHashCount;348 349 type BlockLength = RuntimeBlockLength;350 351 type BlockNumber = BlockNumber;352 353 type BlockWeights = RuntimeBlockWeights;354 355 type Call = Call;356 357 type DbWeight = RocksDbWeight;358 359 type Event = Event;360 361 type Hash = Hash;362 363 type Hashing = BlakeTwo256;364 365 type Header = generic::Header<BlockNumber, BlakeTwo256>;366 367 type Index = Index;368 369 type Lookup = AccountIdLookup<AccountId, ()>;370 371 type OnKilledAccount = ();372 373 type OnNewAccount = ();374 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;375 376 type Origin = Origin;377 378 type PalletInfo = PalletInfo;379 380 type SS58Prefix = SS58Prefix;381 382 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;383 384 type Version = Version;385 type MaxConsumers = ConstU32<16>;386}387388parameter_types! {389 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;390}391392impl pallet_timestamp::Config for Runtime {393 394 type Moment = u64;395 type OnTimestampSet = ();396 type MinimumPeriod = MinimumPeriod;397 type WeightInfo = ();398}399400parameter_types! {401 402 pub const ExistentialDeposit: u128 = 0;403 pub const MaxLocks: u32 = 50;404}405406impl pallet_balances::Config for Runtime {407 type MaxLocks = MaxLocks;408 type MaxReserves = ();409 type ReserveIdentifier = [u8; 8];410 411 type Balance = Balance;412 413 type Event = Event;414 type DustRemoval = Treasury;415 type ExistentialDeposit = ExistentialDeposit;416 type AccountStore = System;417 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;418}419420pub const fn deposit(items: u32, bytes: u32) -> Balance {421 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE422}423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474parameter_types! {475 476 477 pub const OperationalFeeMultiplier: u8 = 5;478}479480481pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);482483impl<T> WeightToFeePolynomial for LinearFee<T>484where485 T: BaseArithmetic + From<u32> + Copy + Unsigned,486{487 type Balance = T;488489 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {490 smallvec!(WeightToFeeCoefficient {491 492 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),493 coeff_frac: Perbill::zero(),494 negative: false,495 degree: 1,496 })497 }498}499500impl pallet_transaction_payment::Config for Runtime {501 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;502 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;503 type OperationalFeeMultiplier = OperationalFeeMultiplier;504 type WeightToFee = LinearFee<Balance>;505 type FeeMultiplierUpdate = ();506}507508parameter_types! {509 pub const ProposalBond: Permill = Permill::from_percent(5);510 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;511 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;512 pub const SpendPeriod: BlockNumber = 5 * MINUTES;513 pub const Burn: Permill = Permill::from_percent(0);514 pub const TipCountdown: BlockNumber = 1 * DAYS;515 pub const TipFindersFee: Percent = Percent::from_percent(20);516 pub const TipReportDepositBase: Balance = 1 * UNIQUE;517 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;518 pub const BountyDepositBase: Balance = 1 * UNIQUE;519 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;520 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");521 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;522 pub const MaximumReasonLength: u32 = 16384;523 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);524 pub const BountyValueMinimum: Balance = 5 * UNIQUE;525 pub const MaxApprovals: u32 = 100;526}527528impl pallet_treasury::Config for Runtime {529 type PalletId = TreasuryModuleId;530 type Currency = Balances;531 type ApproveOrigin = EnsureRoot<AccountId>;532 type RejectOrigin = EnsureRoot<AccountId>;533 type Event = Event;534 type OnSlash = ();535 type ProposalBond = ProposalBond;536 type ProposalBondMinimum = ProposalBondMinimum;537 type ProposalBondMaximum = ProposalBondMaximum;538 type SpendPeriod = SpendPeriod;539 type Burn = Burn;540 type BurnDestination = ();541 type SpendFunds = ();542 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;543 type MaxApprovals = MaxApprovals;544}545546impl pallet_sudo::Config for Runtime {547 type Event = Event;548 type Call = Call;549}550551pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);552553impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider554 for RelayChainBlockNumberProvider<T>555{556 type BlockNumber = BlockNumber;557558 fn current_block_number() -> Self::BlockNumber {559 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()560 .map(|d| d.relay_parent_number)561 .unwrap_or_default()562 }563}564565parameter_types! {566 pub const MinVestedTransfer: Balance = 10 * UNIQUE;567 pub const MaxVestingSchedules: u32 = 28;568}569570impl orml_vesting::Config for Runtime {571 type Event = Event;572 type Currency = pallet_balances::Pallet<Runtime>;573 type MinVestedTransfer = MinVestedTransfer;574 type VestedTransferOrigin = EnsureSigned<AccountId>;575 type WeightInfo = ();576 type MaxVestingSchedules = MaxVestingSchedules;577 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;578}579580parameter_types! {581 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;582 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;583}584585impl cumulus_pallet_parachain_system::Config for Runtime {586 type Event = Event;587 type SelfParaId = parachain_info::Pallet<Self>;588 type OnSystemEvent = ();589 590 591 592 593 594 type OutboundXcmpMessageSource = XcmpQueue;595 type DmpMessageHandler = DmpQueue;596 type ReservedDmpWeight = ReservedDmpWeight;597 type ReservedXcmpWeight = ReservedXcmpWeight;598 type XcmpMessageHandler = XcmpQueue;599}600601impl parachain_info::Config for Runtime {}602603impl cumulus_pallet_aura_ext::Config for Runtime {}604605parameter_types! {606 pub const RelayLocation: MultiLocation = MultiLocation::parent();607 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;608 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();609 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();610}611612613614615pub type LocationToAccountId = (616 617 ParentIsPreset<AccountId>,618 619 SiblingParachainConvertsVia<Sibling, AccountId>,620 621 AccountId32Aliases<RelayNetwork, AccountId>,622);623624pub struct OnlySelfCurrency;625impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {626 fn matches_fungible(a: &MultiAsset) -> Option<B> {627 match (&a.id, &a.fun) {628 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),629 _ => None,630 }631 }632}633634635pub type LocalAssetTransactor = CurrencyAdapter<636 637 Balances,638 639 OnlySelfCurrency,640 641 LocationToAccountId,642 643 AccountId,644 645 (),646>;647648649650651pub type XcmOriginToTransactDispatchOrigin = (652 653 654 655 SovereignSignedViaLocation<LocationToAccountId, Origin>,656 657 658 RelayChainAsNative<RelayOrigin, Origin>,659 660 661 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,662 663 664 ParentAsSuperuser<Origin>,665 666 667 SignedAccountId32AsNative<RelayNetwork, Origin>,668 669 XcmPassthrough<Origin>,670);671672parameter_types! {673 674 pub UnitWeightCost: Weight = 1_000_000;675 676 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);677 pub const MaxInstructions: u32 = 100;678 pub const MaxAuthorities: u32 = 100_000;679}680681match_types! {682 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {683 MultiLocation { parents: 1, interior: Here } |684 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }685 };686}687688pub type Barrier = (689 TakeWeightCredit,690 AllowTopLevelPaidExecutionFrom<Everything>,691 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,692 693);694695pub struct UsingOnlySelfCurrencyComponents<696 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,697 AssetId: Get<MultiLocation>,698 AccountId,699 Currency: CurrencyT<AccountId>,700 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,701>(702 Weight,703 Currency::Balance,704 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,705);706impl<707 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,708 AssetId: Get<MultiLocation>,709 AccountId,710 Currency: CurrencyT<AccountId>,711 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,712 > WeightTrader713 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>714{715 fn new() -> Self {716 Self(0, Zero::zero(), PhantomData)717 }718719 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {720 let amount = WeightToFee::calc(&weight);721 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;722723 724 let option1: xcm::v1::AssetId = Concrete(MultiLocation {725 parents: 1,726 interior: X1(Parachain(ParachainInfo::parachain_id().into())),727 });728 729 let option2: xcm::v1::AssetId = Concrete(MultiLocation {730 parents: 0,731 interior: Here,732 });733734 let required = if payment.fungible.contains_key(&option1) {735 (option1, u128_amount).into()736 } else if payment.fungible.contains_key(&option2) {737 (option2, u128_amount).into()738 } else {739 (Concrete(MultiLocation::default()), u128_amount).into()740 };741742 let unused = payment743 .checked_sub(required)744 .map_err(|_| XcmError::TooExpensive)?;745 self.0 = self.0.saturating_add(weight);746 self.1 = self.1.saturating_add(amount);747 Ok(unused)748 }749750 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {751 let weight = weight.min(self.0);752 let amount = WeightToFee::calc(&weight);753 self.0 -= weight;754 self.1 = self.1.saturating_sub(amount);755 let amount: u128 = amount.saturated_into();756 if amount > 0 {757 Some((AssetId::get(), amount).into())758 } else {759 None760 }761 }762}763impl<764 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,765 AssetId: Get<MultiLocation>,766 AccountId,767 Currency: CurrencyT<AccountId>,768 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,769 > Drop770 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>771{772 fn drop(&mut self) {773 OnUnbalanced::on_unbalanced(Currency::issue(self.1));774 }775}776777pub struct XcmConfig;778impl Config for XcmConfig {779 type Call = Call;780 type XcmSender = XcmRouter;781 782 type AssetTransactor = LocalAssetTransactor;783 type OriginConverter = XcmOriginToTransactDispatchOrigin;784 type IsReserve = NativeAsset;785 type IsTeleporter = (); 786 type LocationInverter = LocationInverter<Ancestry>;787 type Barrier = Barrier;788 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;789 type Trader = UsingOnlySelfCurrencyComponents<790 IdentityFee<Balance>,791 RelayLocation,792 AccountId,793 Balances,794 (),795 >;796 type ResponseHandler = (); 797 type SubscriptionService = PolkadotXcm;798799 type AssetTrap = PolkadotXcm;800 type AssetClaims = PolkadotXcm;801}802803804805806807808pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);809810811812pub type XcmRouter = (813 814 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,815 816 XcmpQueue,817);818819impl pallet_evm_coder_substrate::Config for Runtime {820 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;821 type GasWeightMapping = FixedGasWeightMapping;822}823824impl pallet_xcm::Config for Runtime {825 type Event = Event;826 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;827 type XcmRouter = XcmRouter;828 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;829 type XcmExecuteFilter = Everything;830 type XcmExecutor = XcmExecutor<XcmConfig>;831 type XcmTeleportFilter = Everything;832 type XcmReserveTransferFilter = Everything;833 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;834 type LocationInverter = LocationInverter<Ancestry>;835 type Origin = Origin;836 type Call = Call;837 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;838 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;839}840841impl cumulus_pallet_xcm::Config for Runtime {842 type Event = Event;843 type XcmExecutor = XcmExecutor<XcmConfig>;844}845846impl cumulus_pallet_xcmp_queue::Config for Runtime {847 type WeightInfo = ();848 type Event = Event;849 type XcmExecutor = XcmExecutor<XcmConfig>;850 type ChannelInfo = ParachainSystem;851 type VersionWrapper = ();852 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;853 type ControllerOrigin = EnsureRoot<AccountId>;854 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;855}856857impl cumulus_pallet_dmp_queue::Config for Runtime {858 type Event = Event;859 type XcmExecutor = XcmExecutor<XcmConfig>;860 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;861}862863impl pallet_aura::Config for Runtime {864 type AuthorityId = AuraId;865 type DisabledValidators = ();866 type MaxAuthorities = MaxAuthorities;867}868869parameter_types! {870 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();871 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;872}873874impl pallet_common::Config for Runtime {875 type Event = Event;876 type Currency = Balances;877 type CollectionCreationPrice = CollectionCreationPrice;878 type TreasuryAccountId = TreasuryAccountId;879 type CollectionDispatch = CollectionDispatchT<Self>;880881 type EvmTokenAddressMapping = EvmTokenAddressMapping;882 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;883}884885impl pallet_structure::Config for Runtime {886 type Event = Event;887 type Call = Call;888 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;889}890891impl pallet_fungible::Config for Runtime {892 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;893}894impl pallet_refungible::Config for Runtime {895 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;896}897impl pallet_nonfungible::Config for Runtime {898 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;899}900901impl pallet_unique::Config for Runtime {902 type Event = Event;903 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;904}905906parameter_types! {907 pub const InflationBlockInterval: BlockNumber = 100; 908}909910911impl pallet_inflation::Config for Runtime {912 type Currency = Balances;913 type TreasuryAccountId = TreasuryAccountId;914 type InflationBlockInterval = InflationBlockInterval;915 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;916}917918919920921922923924type EvmSponsorshipHandler = (925 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,926 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,927);928type SponsorshipHandler = (929 pallet_unique::UniqueSponsorshipHandler<Runtime>,930 931 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,932);933934935936937938939940941942943944945946impl pallet_evm_transaction_payment::Config for Runtime {947 type EvmSponsorshipHandler = EvmSponsorshipHandler;948 type Currency = Balances;949}950951impl pallet_charge_transaction::Config for Runtime {952 type SponsorshipHandler = SponsorshipHandler;953}954955956957958959parameter_types! {960 961 pub const HelpersContractAddress: H160 = H160([962 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,963 ]);964}965966impl pallet_evm_contract_helpers::Config for Runtime {967 type ContractAddress = HelpersContractAddress;968 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;969}970971construct_runtime!(972 pub enum Runtime where973 Block = Block,974 NodeBlock = opaque::Block,975 UncheckedExtrinsic = UncheckedExtrinsic976 {977 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,978 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,979980 Aura: pallet_aura::{Pallet, Config<T>} = 22,981 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,982983 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,984 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,985 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,986 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,987 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,988 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,989 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,990 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,991 992 993994 995 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,996 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,997 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,998 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,9991000 1001 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1002 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1003 1004 1005 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1006 1007 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1008 Fungible: pallet_fungible::{Pallet, Storage} = 67,1009 Refungible: pallet_refungible::{Pallet, Storage} = 68,1010 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,10111012 1013 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1014 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10151016 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1017 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1018 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1019 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1020 }1021);10221023pub struct TransactionConverter;10241025impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1026 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1027 UncheckedExtrinsic::new_unsigned(1028 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1029 )1030 }1031}10321033impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1034 fn convert_transaction(1035 &self,1036 transaction: pallet_ethereum::Transaction,1037 ) -> opaque::UncheckedExtrinsic {1038 let extrinsic = UncheckedExtrinsic::new_unsigned(1039 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1040 );1041 let encoded = extrinsic.encode();1042 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1043 .expect("Encoded extrinsic is always valid")1044 }1045}104610471048pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10491050pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10511052pub type Block = generic::Block<Header, UncheckedExtrinsic>;10531054pub type SignedBlock = generic::SignedBlock<Block>;10551056pub type BlockId = generic::BlockId<Block>;10571058pub type SignedExtra = (1059 frame_system::CheckSpecVersion<Runtime>,1060 1061 frame_system::CheckGenesis<Runtime>,1062 frame_system::CheckEra<Runtime>,1063 frame_system::CheckNonce<Runtime>,1064 frame_system::CheckWeight<Runtime>,1065 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1066 1067);10681069pub type UncheckedExtrinsic =1070 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10711072pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10731074pub type Executive = frame_executive::Executive<1075 Runtime,1076 Block,1077 frame_system::ChainContext<Runtime>,1078 Runtime,1079 AllPalletsReversedWithSystemFirst,1080>;10811082impl_opaque_keys! {1083 pub struct SessionKeys {1084 pub aura: Aura,1085 }1086}10871088impl fp_self_contained::SelfContainedCall for Call {1089 type SignedInfo = H160;10901091 fn is_self_contained(&self) -> bool {1092 match self {1093 Call::Ethereum(call) => call.is_self_contained(),1094 _ => false,1095 }1096 }10971098 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1099 match self {1100 Call::Ethereum(call) => call.check_self_contained(),1101 _ => None,1102 }1103 }11041105 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1106 match self {1107 Call::Ethereum(call) => call.validate_self_contained(info),1108 _ => None,1109 }1110 }11111112 fn pre_dispatch_self_contained(1113 &self,1114 info: &Self::SignedInfo,1115 ) -> Option<Result<(), TransactionValidityError>> {1116 match self {1117 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1118 _ => None,1119 }1120 }11211122 fn apply_self_contained(1123 self,1124 info: Self::SignedInfo,1125 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1126 match self {1127 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1128 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1129 )),1130 _ => None,1131 }1132 }1133}11341135macro_rules! dispatch_unique_runtime {1136 ($collection:ident.$method:ident($($name:ident),*)) => {{1137 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1138 let dispatch = collection.as_dyn();11391140 Ok(dispatch.$method($($name),*))1141 }};1142}11431144impl_common_runtime_apis!();11451146struct CheckInherents;11471148impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1149 fn check_inherents(1150 block: &Block,1151 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1152 ) -> sp_inherents::CheckInherentsResult {1153 let relay_chain_slot = relay_state_proof1154 .read_slot()1155 .expect("Could not read the relay chain slot from the proof");11561157 let inherent_data =1158 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1159 relay_chain_slot,1160 sp_std::time::Duration::from_secs(6),1161 )1162 .create_inherent_data()1163 .expect("Could not create the timestamp inherent data");11641165 inherent_data.check_extrinsics(block)1166 }1167}11681169cumulus_pallet_parachain_system::register_validate_block!(1170 Runtime = Runtime,1171 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1172 CheckInherents = CheckInherents,1173);