1234567891011121314151617pub mod config;18pub mod construct_runtime;19pub mod dispatch;20pub mod ethereum;21pub mod instance;22pub mod maintenance;23pub mod runtime_apis;24pub mod xcm;2526#[cfg(feature = "scheduler")]27pub mod scheduler;2829pub mod sponsoring;30pub mod weights;3132#[cfg(test)]33pub mod tests;3435use sp_core::H160;36use frame_support::traits::{Currency, OnUnbalanced, Imbalance};37use sp_runtime::{38 generic,39 traits::{BlakeTwo256, BlockNumberProvider},40 impl_opaque_keys,41};42use sp_std::vec::Vec;4344#[cfg(feature = "std")]45use sp_version::NativeVersion;4647use crate::{48 Runtime, RuntimeCall, Balances, Treasury, Aura, Signature, AllPalletsWithSystem,49 InherentDataExt,50};51use up_common::types::{AccountId, BlockNumber};5253#[macro_export]54macro_rules! unsupported {55 () => {56 pallet_common::unsupported!($crate::Runtime)57 };58}596061pub type Address = sp_runtime::MultiAddress<AccountId, ()>;6263pub type Header = generic::Header<BlockNumber, BlakeTwo256>;6465pub type Block = generic::Block<Header, UncheckedExtrinsic>;6667pub type SignedBlock = generic::SignedBlock<Block>;6869pub type BlockId = generic::BlockId<Block>;7071impl_opaque_keys! {72 pub struct SessionKeys {73 pub aura: Aura,74 }75}767778#[cfg(feature = "std")]79pub fn native_version() -> NativeVersion {80 NativeVersion {81 runtime_version: crate::VERSION,82 can_author_with: Default::default(),83 }84}8586pub type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;8788pub type SignedExtra = (89 frame_system::CheckSpecVersion<Runtime>,90 frame_system::CheckTxVersion<Runtime>,91 frame_system::CheckGenesis<Runtime>,92 frame_system::CheckEra<Runtime>,93 frame_system::CheckNonce<Runtime>,94 frame_system::CheckWeight<Runtime>,95 maintenance::CheckMaintenance,96 ChargeTransactionPayment,97 98 pallet_ethereum::FakeTransactionFinalizer<Runtime>,99);100101102pub type UncheckedExtrinsic =103 fp_self_contained::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;104105106pub type CheckedExtrinsic =107 fp_self_contained::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra, H160>;108109110pub type Executive = frame_executive::Executive<111 Runtime,112 Block,113 frame_system::ChainContext<Runtime>,114 Runtime,115 AllPalletsWithSystem,116>;117118type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;119120pub struct DealWithFees;121impl OnUnbalanced<NegativeImbalance> for DealWithFees {122 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {123 if let Some(fees) = fees_then_tips.next() {124 125 let mut split = fees.ration(100, 0);126 if let Some(tips) = fees_then_tips.next() {127 128 tips.ration_merge_into(100, 0, &mut split);129 }130 Treasury::on_unbalanced(split.0);131 132 }133 }134}135136pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);137138impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider139 for RelayChainBlockNumberProvider<T>140{141 type BlockNumber = BlockNumber;142143 fn current_block_number() -> Self::BlockNumber {144 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()145 .map(|d| d.relay_parent_number)146 .unwrap_or_default()147 }148 #[cfg(feature = "runtime-benchmarks")]149 fn set_block_number(block: Self::BlockNumber) {150 cumulus_pallet_parachain_system::RelaychainBlockNumberProvider::<T>::set_block_number(block)151 }152}153154pub(crate) struct CheckInherents;155156impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {157 fn check_inherents(158 block: &Block,159 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,160 ) -> sp_inherents::CheckInherentsResult {161 let relay_chain_slot = relay_state_proof162 .read_slot()163 .expect("Could not read the relay chain slot from the proof");164165 let inherent_data =166 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(167 relay_chain_slot,168 sp_std::time::Duration::from_secs(6),169 )170 .create_inherent_data()171 .expect("Could not create the timestamp inherent data");172173 inherent_data.check_extrinsics(block)174 }175}176177#[derive(codec::Encode, codec::Decode)]178pub enum XCMPMessage<XAccountId, XBalance> {179 180 TransferToken(XAccountId, XBalance),181}