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::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};70use up_data_structs::{CollectionId, TokenId, CollectionStats, Collection};717273use frame_system::{74 self as frame_system, EnsureRoot, EnsureSigned,75 limits::{BlockWeights, BlockLength},76};77use sp_arithmetic::{78 traits::{BaseArithmetic, Unsigned},79};80use smallvec::smallvec;81use codec::{Encode, Decode};82use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};83use fp_rpc::TransactionStatus;84use sp_runtime::{85 traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf, Saturating},86 transaction_validity::TransactionValidityError,87 SaturatedConversion,88};899091pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;929394use pallet_xcm::XcmPassthrough;95use polkadot_parachain::primitives::Sibling;96use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};97use xcm_builder::{98 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,99 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, ParentAsSuperuser,100 RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,101 SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,102 ParentIsPreset,103};104use xcm_executor::{Config, XcmExecutor, Assets};105use sp_std::{marker::PhantomData};106107use xcm::latest::{108 109 AssetId::{Concrete},110 Fungibility::Fungible as XcmFungible,111 MultiAsset,112 Error as XcmError,113};114use xcm_executor::traits::{MatchesFungible, WeightTrader};115116use sp_runtime::traits::CheckedConversion;117118use unique_runtime_common::{119 impl_common_runtime_apis,120 types::*,121 constants::*,122 dispatch::{CollectionDispatchT, CollectionDispatch},123};124125pub const RUNTIME_NAME: &str = "opal";126pub const TOKEN_SYMBOL: &str = "OPL";127128type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;129130impl RuntimeInstance for Runtime {131 type CrossAccountId = self::CrossAccountId;132 type TransactionConverter = self::TransactionConverter;133134 fn get_transaction_converter() -> TransactionConverter {135 TransactionConverter136 }137}138139140141pub type AccountIndex = u32;142143144pub type Balance = u128;145146147pub type Index = u32;148149150pub type Hash = sp_core::H256;151152153pub type DigestItem = generic::DigestItem;154155156157158159pub mod opaque {160 use sp_std::prelude::*;161 use sp_runtime::impl_opaque_keys;162 use super::Aura;163164 pub use unique_runtime_common::types::*;165166 impl_opaque_keys! {167 pub struct SessionKeys {168 pub aura: Aura,169 }170 }171}172173174pub const VERSION: RuntimeVersion = RuntimeVersion {175 spec_name: create_runtime_str!(RUNTIME_NAME),176 impl_name: create_runtime_str!(RUNTIME_NAME),177 authoring_version: 1,178 spec_version: 920000,179 impl_version: 0,180 apis: RUNTIME_API_VERSIONS,181 transaction_version: 1,182 state_version: 0,183};184185#[derive(codec::Encode, codec::Decode)]186pub enum XCMPMessage<XAccountId, XBalance> {187 188 TransferToken(XAccountId, XBalance),189}190191192#[cfg(feature = "std")]193pub fn native_version() -> NativeVersion {194 NativeVersion {195 runtime_version: VERSION,196 can_author_with: Default::default(),197 }198}199200type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;201202pub struct DealWithFees;203impl OnUnbalanced<NegativeImbalance> for DealWithFees {204 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {205 if let Some(fees) = fees_then_tips.next() {206 207 let mut split = fees.ration(100, 0);208 if let Some(tips) = fees_then_tips.next() {209 210 tips.ration_merge_into(100, 0, &mut split);211 }212 Treasury::on_unbalanced(split.0);213 214 }215 }216}217218parameter_types! {219 pub const BlockHashCount: BlockNumber = 2400;220 pub RuntimeBlockLength: BlockLength =221 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);222 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);223 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;224 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()225 .base_block(BlockExecutionWeight::get())226 .for_class(DispatchClass::all(), |weights| {227 weights.base_extrinsic = ExtrinsicBaseWeight::get();228 })229 .for_class(DispatchClass::Normal, |weights| {230 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);231 })232 .for_class(DispatchClass::Operational, |weights| {233 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);234 235 236 weights.reserved = Some(237 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT238 );239 })240 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)241 .build_or_panic();242 pub const Version: RuntimeVersion = VERSION;243 pub const SS58Prefix: u8 = 42;244}245246parameter_types! {247 pub const ChainId: u64 = 8882;248}249250pub struct FixedFee;251impl FeeCalculator for FixedFee {252 fn min_gas_price() -> U256 {253 MIN_GAS_PRICE.into()254 }255}256257258259260parameter_types! {261 pub const WritesPerSecond: u64 = WEIGHT_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;262 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;263 pub const WeightPerGas: u64 = WEIGHT_PER_SECOND / GasPerSecond::get();264}265266267268269const EVM_DISPATCH_RATIO: Perbill = Perbill::from_percent(50);270parameter_types! {271 pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * EVM_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WeightPerGas::get());272}273274pub enum FixedGasWeightMapping {}275impl GasWeightMapping for FixedGasWeightMapping {276 fn gas_to_weight(gas: u64) -> Weight {277 gas.saturating_mul(WeightPerGas::get())278 }279 fn weight_to_gas(weight: Weight) -> u64 {280 weight / WeightPerGas::get()281 }282}283284impl pallet_evm::account::Config for Runtime {285 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;286 type EvmAddressMapping = pallet_evm::HashedAddressMapping<Self::Hashing>;287 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;288}289290impl pallet_evm::Config for Runtime {291 type BlockGasLimit = BlockGasLimit;292 type FeeCalculator = FixedFee;293 type GasWeightMapping = FixedGasWeightMapping;294 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;295 type CallOrigin = EnsureAddressTruncated;296 type WithdrawOrigin = EnsureAddressTruncated;297 type AddressMapping = HashedAddressMapping<Self::Hashing>;298 type PrecompilesType = ();299 type PrecompilesValue = ();300 type Currency = Balances;301 type Event = Event;302 type OnMethodCall = (303 pallet_evm_migration::OnMethodCall<Self>,304 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,305 CollectionDispatchT<Self>,306 );307 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;308 type ChainId = ChainId;309 type Runner = pallet_evm::runner::stack::Runner<Self>;310 type OnChargeTransaction = pallet_evm::EVMCurrencyAdapter<Balances, DealWithFees>;311 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;312 type FindAuthor = EthereumFindAuthor<Aura>;313}314315impl pallet_evm_migration::Config for Runtime {316 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;317}318319pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);320impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {321 fn find_author<'a, I>(digests: I) -> Option<H160>322 where323 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,324 {325 if let Some(author_index) = F::find_author(digests) {326 let authority_id = Aura::authorities()[author_index as usize].clone();327 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));328 }329 None330 }331}332333impl pallet_ethereum::Config for Runtime {334 type Event = Event;335 type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;336}337338impl pallet_randomness_collective_flip::Config for Runtime {}339340impl frame_system::Config for Runtime {341 342 type AccountData = pallet_balances::AccountData<Balance>;343 344 type AccountId = AccountId;345 346 type BaseCallFilter = Everything;347 348 type BlockHashCount = BlockHashCount;349 350 type BlockLength = RuntimeBlockLength;351 352 type BlockNumber = BlockNumber;353 354 type BlockWeights = RuntimeBlockWeights;355 356 type Call = Call;357 358 type DbWeight = RocksDbWeight;359 360 type Event = Event;361 362 type Hash = Hash;363 364 type Hashing = BlakeTwo256;365 366 type Header = generic::Header<BlockNumber, BlakeTwo256>;367 368 type Index = Index;369 370 type Lookup = AccountIdLookup<AccountId, ()>;371 372 type OnKilledAccount = ();373 374 type OnNewAccount = ();375 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;376 377 type Origin = Origin;378 379 type PalletInfo = PalletInfo;380 381 type SS58Prefix = SS58Prefix;382 383 type SystemWeightInfo = frame_system::weights::SubstrateWeight<Self>;384 385 type Version = Version;386 type MaxConsumers = ConstU32<16>;387}388389parameter_types! {390 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;391}392393impl pallet_timestamp::Config for Runtime {394 395 type Moment = u64;396 type OnTimestampSet = ();397 type MinimumPeriod = MinimumPeriod;398 type WeightInfo = ();399}400401parameter_types! {402 403 pub const ExistentialDeposit: u128 = 0;404 pub const MaxLocks: u32 = 50;405}406407impl pallet_balances::Config for Runtime {408 type MaxLocks = MaxLocks;409 type MaxReserves = ();410 type ReserveIdentifier = [u8; 8];411 412 type Balance = Balance;413 414 type Event = Event;415 type DustRemoval = Treasury;416 type ExistentialDeposit = ExistentialDeposit;417 type AccountStore = System;418 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;419}420421pub const fn deposit(items: u32, bytes: u32) -> Balance {422 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE423}424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475parameter_types! {476 477 478 pub const OperationalFeeMultiplier: u8 = 5;479}480481482pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);483484impl<T> WeightToFeePolynomial for LinearFee<T>485where486 T: BaseArithmetic + From<u32> + Copy + Unsigned,487{488 type Balance = T;489490 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {491 smallvec!(WeightToFeeCoefficient {492 493 coeff_integer: WEIGHT_TO_FEE_COEFF.into(),494 coeff_frac: Perbill::zero(),495 negative: false,496 degree: 1,497 })498 }499}500501impl pallet_transaction_payment::Config for Runtime {502 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;503 type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;504 type OperationalFeeMultiplier = OperationalFeeMultiplier;505 type WeightToFee = LinearFee<Balance>;506 type FeeMultiplierUpdate = ();507}508509parameter_types! {510 pub const ProposalBond: Permill = Permill::from_percent(5);511 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;512 pub const ProposalBondMaximum: Balance = 1000 * UNIQUE;513 pub const SpendPeriod: BlockNumber = 5 * MINUTES;514 pub const Burn: Permill = Permill::from_percent(0);515 pub const TipCountdown: BlockNumber = 1 * DAYS;516 pub const TipFindersFee: Percent = Percent::from_percent(20);517 pub const TipReportDepositBase: Balance = 1 * UNIQUE;518 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;519 pub const BountyDepositBase: Balance = 1 * UNIQUE;520 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;521 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");522 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;523 pub const MaximumReasonLength: u32 = 16384;524 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);525 pub const BountyValueMinimum: Balance = 5 * UNIQUE;526 pub const MaxApprovals: u32 = 100;527}528529impl pallet_treasury::Config for Runtime {530 type PalletId = TreasuryModuleId;531 type Currency = Balances;532 type ApproveOrigin = EnsureRoot<AccountId>;533 type RejectOrigin = EnsureRoot<AccountId>;534 type Event = Event;535 type OnSlash = ();536 type ProposalBond = ProposalBond;537 type ProposalBondMinimum = ProposalBondMinimum;538 type ProposalBondMaximum = ProposalBondMaximum;539 type SpendPeriod = SpendPeriod;540 type Burn = Burn;541 type BurnDestination = ();542 type SpendFunds = ();543 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;544 type MaxApprovals = MaxApprovals;545}546547impl pallet_sudo::Config for Runtime {548 type Event = Event;549 type Call = Call;550}551552pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);553554impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider555 for RelayChainBlockNumberProvider<T>556{557 type BlockNumber = BlockNumber;558559 fn current_block_number() -> Self::BlockNumber {560 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()561 .map(|d| d.relay_parent_number)562 .unwrap_or_default()563 }564}565566parameter_types! {567 pub const MinVestedTransfer: Balance = 10 * UNIQUE;568 pub const MaxVestingSchedules: u32 = 28;569}570571impl orml_vesting::Config for Runtime {572 type Event = Event;573 type Currency = pallet_balances::Pallet<Runtime>;574 type MinVestedTransfer = MinVestedTransfer;575 type VestedTransferOrigin = EnsureSigned<AccountId>;576 type WeightInfo = ();577 type MaxVestingSchedules = MaxVestingSchedules;578 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;579}580581parameter_types! {582 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;583 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;584}585586impl cumulus_pallet_parachain_system::Config for Runtime {587 type Event = Event;588 type SelfParaId = parachain_info::Pallet<Self>;589 type OnSystemEvent = ();590 591 592 593 594 595 type OutboundXcmpMessageSource = XcmpQueue;596 type DmpMessageHandler = DmpQueue;597 type ReservedDmpWeight = ReservedDmpWeight;598 type ReservedXcmpWeight = ReservedXcmpWeight;599 type XcmpMessageHandler = XcmpQueue;600}601602impl parachain_info::Config for Runtime {}603604impl cumulus_pallet_aura_ext::Config for Runtime {}605606parameter_types! {607 pub const RelayLocation: MultiLocation = MultiLocation::parent();608 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;609 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();610 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();611}612613614615616pub type LocationToAccountId = (617 618 ParentIsPreset<AccountId>,619 620 SiblingParachainConvertsVia<Sibling, AccountId>,621 622 AccountId32Aliases<RelayNetwork, AccountId>,623);624625pub struct OnlySelfCurrency;626impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {627 fn matches_fungible(a: &MultiAsset) -> Option<B> {628 match (&a.id, &a.fun) {629 (Concrete(_), XcmFungible(ref amount)) => CheckedConversion::checked_from(*amount),630 _ => None,631 }632 }633}634635636pub type LocalAssetTransactor = CurrencyAdapter<637 638 Balances,639 640 OnlySelfCurrency,641 642 LocationToAccountId,643 644 AccountId,645 646 (),647>;648649650651652pub type XcmOriginToTransactDispatchOrigin = (653 654 655 656 SovereignSignedViaLocation<LocationToAccountId, Origin>,657 658 659 RelayChainAsNative<RelayOrigin, Origin>,660 661 662 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,663 664 665 ParentAsSuperuser<Origin>,666 667 668 SignedAccountId32AsNative<RelayNetwork, Origin>,669 670 XcmPassthrough<Origin>,671);672673parameter_types! {674 675 pub UnitWeightCost: Weight = 1_000_000;676 677 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);678 pub const MaxInstructions: u32 = 100;679 pub const MaxAuthorities: u32 = 100_000;680}681682match_types! {683 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {684 MultiLocation { parents: 1, interior: Here } |685 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }686 };687}688689pub type Barrier = (690 TakeWeightCredit,691 AllowTopLevelPaidExecutionFrom<Everything>,692 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,693 694);695696pub struct UsingOnlySelfCurrencyComponents<697 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,698 AssetId: Get<MultiLocation>,699 AccountId,700 Currency: CurrencyT<AccountId>,701 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,702>(703 Weight,704 Currency::Balance,705 PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,706);707impl<708 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,709 AssetId: Get<MultiLocation>,710 AccountId,711 Currency: CurrencyT<AccountId>,712 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,713 > WeightTrader714 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>715{716 fn new() -> Self {717 Self(0, Zero::zero(), PhantomData)718 }719720 fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {721 let amount = WeightToFee::calc(&weight);722 let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;723724 725 let option1: xcm::v1::AssetId = Concrete(MultiLocation {726 parents: 1,727 interior: X1(Parachain(ParachainInfo::parachain_id().into())),728 });729 730 let option2: xcm::v1::AssetId = Concrete(MultiLocation {731 parents: 0,732 interior: Here,733 });734735 let required = if payment.fungible.contains_key(&option1) {736 (option1, u128_amount).into()737 } else if payment.fungible.contains_key(&option2) {738 (option2, u128_amount).into()739 } else {740 (Concrete(MultiLocation::default()), u128_amount).into()741 };742743 let unused = payment744 .checked_sub(required)745 .map_err(|_| XcmError::TooExpensive)?;746 self.0 = self.0.saturating_add(weight);747 self.1 = self.1.saturating_add(amount);748 Ok(unused)749 }750751 fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {752 let weight = weight.min(self.0);753 let amount = WeightToFee::calc(&weight);754 self.0 -= weight;755 self.1 = self.1.saturating_sub(amount);756 let amount: u128 = amount.saturated_into();757 if amount > 0 {758 Some((AssetId::get(), amount).into())759 } else {760 None761 }762 }763}764impl<765 WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,766 AssetId: Get<MultiLocation>,767 AccountId,768 Currency: CurrencyT<AccountId>,769 OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,770 > Drop771 for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>772{773 fn drop(&mut self) {774 OnUnbalanced::on_unbalanced(Currency::issue(self.1));775 }776}777778pub struct XcmConfig;779impl Config for XcmConfig {780 type Call = Call;781 type XcmSender = XcmRouter;782 783 type AssetTransactor = LocalAssetTransactor;784 type OriginConverter = XcmOriginToTransactDispatchOrigin;785 type IsReserve = NativeAsset;786 type IsTeleporter = (); 787 type LocationInverter = LocationInverter<Ancestry>;788 type Barrier = Barrier;789 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;790 type Trader = UsingOnlySelfCurrencyComponents<791 IdentityFee<Balance>,792 RelayLocation,793 AccountId,794 Balances,795 (),796 >;797 type ResponseHandler = (); 798 type SubscriptionService = PolkadotXcm;799800 type AssetTrap = PolkadotXcm;801 type AssetClaims = PolkadotXcm;802}803804805806807808809pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);810811812813pub type XcmRouter = (814 815 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,816 817 XcmpQueue,818);819820impl pallet_evm_coder_substrate::Config for Runtime {821 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;822 type GasWeightMapping = FixedGasWeightMapping;823}824825impl pallet_xcm::Config for Runtime {826 type Event = Event;827 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;828 type XcmRouter = XcmRouter;829 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;830 type XcmExecuteFilter = Everything;831 type XcmExecutor = XcmExecutor<XcmConfig>;832 type XcmTeleportFilter = Everything;833 type XcmReserveTransferFilter = Everything;834 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;835 type LocationInverter = LocationInverter<Ancestry>;836 type Origin = Origin;837 type Call = Call;838 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;839 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;840}841842impl cumulus_pallet_xcm::Config for Runtime {843 type Event = Event;844 type XcmExecutor = XcmExecutor<XcmConfig>;845}846847impl cumulus_pallet_xcmp_queue::Config for Runtime {848 type WeightInfo = ();849 type Event = Event;850 type XcmExecutor = XcmExecutor<XcmConfig>;851 type ChannelInfo = ParachainSystem;852 type VersionWrapper = ();853 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;854 type ControllerOrigin = EnsureRoot<AccountId>;855 type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;856}857858impl cumulus_pallet_dmp_queue::Config for Runtime {859 type Event = Event;860 type XcmExecutor = XcmExecutor<XcmConfig>;861 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;862}863864impl pallet_aura::Config for Runtime {865 type AuthorityId = AuraId;866 type DisabledValidators = ();867 type MaxAuthorities = MaxAuthorities;868}869870parameter_types! {871 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();872 pub const CollectionCreationPrice: Balance = 2 * UNIQUE;873}874875impl pallet_common::Config for Runtime {876 type Event = Event;877 type Currency = Balances;878 type CollectionCreationPrice = CollectionCreationPrice;879 type TreasuryAccountId = TreasuryAccountId;880 type CollectionDispatch = CollectionDispatchT<Self>;881882 type EvmTokenAddressMapping = EvmTokenAddressMapping;883 type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;884}885886impl pallet_structure::Config for Runtime {887 type Event = Event;888 type Call = Call;889 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;890}891892impl pallet_fungible::Config for Runtime {893 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;894}895impl pallet_refungible::Config for Runtime {896 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;897}898impl pallet_nonfungible::Config for Runtime {899 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;900}901902impl pallet_unique::Config for Runtime {903 type Event = Event;904 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;905}906907parameter_types! {908 pub const InflationBlockInterval: BlockNumber = 100; 909}910911912impl pallet_inflation::Config for Runtime {913 type Currency = Balances;914 type TreasuryAccountId = TreasuryAccountId;915 type InflationBlockInterval = InflationBlockInterval;916 type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;917}918919920921922923924925type EvmSponsorshipHandler = (926 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,927 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,928);929type SponsorshipHandler = (930 pallet_unique::UniqueSponsorshipHandler<Runtime>,931 932 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,933);934935936937938939940941942943944945946947impl pallet_evm_transaction_payment::Config for Runtime {948 type EvmSponsorshipHandler = EvmSponsorshipHandler;949 type Currency = Balances;950}951952impl pallet_charge_transaction::Config for Runtime {953 type SponsorshipHandler = SponsorshipHandler;954}955956957958959960parameter_types! {961 962 pub const HelpersContractAddress: H160 = H160([963 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,964 ]);965}966967impl pallet_evm_contract_helpers::Config for Runtime {968 type ContractAddress = HelpersContractAddress;969 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;970}971972construct_runtime!(973 pub enum Runtime where974 Block = Block,975 NodeBlock = opaque::Block,976 UncheckedExtrinsic = UncheckedExtrinsic977 {978 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,979 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,980981 Aura: pallet_aura::{Pallet, Config<T>} = 22,982 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,983984 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,985 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,986 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,987 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,988 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,989 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,990 System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,991 Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,992 993 994995 996 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,997 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,998 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,999 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,10001001 1002 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,1003 Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,1004 1005 1006 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,1007 1008 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,1009 Fungible: pallet_fungible::{Pallet, Storage} = 67,1010 Refungible: pallet_refungible::{Pallet, Storage} = 68,1011 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,1012 Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,10131014 1015 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,1016 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,10171018 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,1019 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,1020 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,1021 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,1022 }1023);10241025pub struct TransactionConverter;10261027impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {1028 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {1029 UncheckedExtrinsic::new_unsigned(1030 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1031 )1032 }1033}10341035impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {1036 fn convert_transaction(1037 &self,1038 transaction: pallet_ethereum::Transaction,1039 ) -> opaque::UncheckedExtrinsic {1040 let extrinsic = UncheckedExtrinsic::new_unsigned(1041 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),1042 );1043 let encoded = extrinsic.encode();1044 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])1045 .expect("Encoded extrinsic is always valid")1046 }1047}104810491050pub type Address = sp_runtime::MultiAddress<AccountId, ()>;10511052pub type Header = generic::Header<BlockNumber, BlakeTwo256>;10531054pub type Block = generic::Block<Header, UncheckedExtrinsic>;10551056pub type SignedBlock = generic::SignedBlock<Block>;10571058pub type BlockId = generic::BlockId<Block>;10591060pub type SignedExtra = (1061 frame_system::CheckSpecVersion<Runtime>,1062 1063 frame_system::CheckGenesis<Runtime>,1064 frame_system::CheckEra<Runtime>,1065 frame_system::CheckNonce<Runtime>,1066 frame_system::CheckWeight<Runtime>,1067 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1068 1069);10701071pub type UncheckedExtrinsic =1072 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;10731074pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;10751076pub type Executive = frame_executive::Executive<1077 Runtime,1078 Block,1079 frame_system::ChainContext<Runtime>,1080 Runtime,1081 AllPalletsReversedWithSystemFirst,1082>;10831084impl_opaque_keys! {1085 pub struct SessionKeys {1086 pub aura: Aura,1087 }1088}10891090impl fp_self_contained::SelfContainedCall for Call {1091 type SignedInfo = H160;10921093 fn is_self_contained(&self) -> bool {1094 match self {1095 Call::Ethereum(call) => call.is_self_contained(),1096 _ => false,1097 }1098 }10991100 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {1101 match self {1102 Call::Ethereum(call) => call.check_self_contained(),1103 _ => None,1104 }1105 }11061107 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {1108 match self {1109 Call::Ethereum(call) => call.validate_self_contained(info),1110 _ => None,1111 }1112 }11131114 fn pre_dispatch_self_contained(1115 &self,1116 info: &Self::SignedInfo,1117 ) -> Option<Result<(), TransactionValidityError>> {1118 match self {1119 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),1120 _ => None,1121 }1122 }11231124 fn apply_self_contained(1125 self,1126 info: Self::SignedInfo,1127 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {1128 match self {1129 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(1130 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),1131 )),1132 _ => None,1133 }1134 }1135}11361137macro_rules! dispatch_unique_runtime {1138 ($collection:ident.$method:ident($($name:ident),*)) => {{1139 let collection = <Runtime as pallet_common::Config>::CollectionDispatch::dispatch(<pallet_common::CollectionHandle<Runtime>>::try_get($collection)?);1140 let dispatch = collection.as_dyn();11411142 Ok(dispatch.$method($($name),*))1143 }};1144}11451146impl_common_runtime_apis!();11471148struct CheckInherents;11491150impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1151 fn check_inherents(1152 block: &Block,1153 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1154 ) -> sp_inherents::CheckInherentsResult {1155 let relay_chain_slot = relay_state_proof1156 .read_slot()1157 .expect("Could not read the relay chain slot from the proof");11581159 let inherent_data =1160 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1161 relay_chain_slot,1162 sp_std::time::Duration::from_secs(6),1163 )1164 .create_inherent_data()1165 .expect("Could not create the timestamp inherent data");11661167 inherent_data.check_extrinsics(block)1168 }1169}11701171cumulus_pallet_parachain_system::register_validate_block!(1172 Runtime = Runtime,1173 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1174 CheckInherents = CheckInherents,1175);