difftreelog
fix cargo fmt
in: master
2 files changed
runtime/common/maintenance.rsdiffbeforeafterboth--- a/runtime/common/maintenance.rs
+++ b/runtime/common/maintenance.rs
@@ -21,7 +21,7 @@
use sp_runtime::{
traits::{DispatchInfoOf, SignedExtension},
- transaction_validity::{
+ transaction_validity::{
TransactionValidity, ValidTransaction, InvalidTransaction, TransactionValidityError,
},
};
@@ -68,22 +68,26 @@
| RuntimeCall::Structure(_)
| RuntimeCall::Unique(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
- #[cfg(feature = "scheduler")]
- RuntimeCall::Scheduler(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ #[cfg(feature = "scheduler")]
+ RuntimeCall::Scheduler(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
#[cfg(feature = "rmrk")]
RuntimeCall::RmrkCore(_) | RuntimeCall::RmrkEquip(_) => {
Err(TransactionValidityError::Invalid(InvalidTransaction::Call))
}
- #[cfg(feature = "app-promotion")]
- RuntimeCall::AppPromotion(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ #[cfg(feature = "app-promotion")]
+ RuntimeCall::AppPromotion(_) => {
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call))
+ }
- #[cfg(feature = "foreign-assets")]
- RuntimeCall::ForeignAssets(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ #[cfg(feature = "foreign-assets")]
+ RuntimeCall::ForeignAssets(_) => {
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call))
+ }
- #[cfg(feature = "pallet-test-utils")]
- RuntimeCall::TestUtils(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ #[cfg(feature = "pallet-test-utils")]
+ RuntimeCall::TestUtils(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
_ => Ok(ValidTransaction::default()),
}
runtime/common/mod.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617pub mod config;18pub mod construct_runtime;19pub mod dispatch;20pub mod ethereum;21pub mod instance;22pub mod runtime_apis;23pub mod maintenance;2425#[cfg(feature = "scheduler")]26pub mod scheduler;2728pub mod sponsoring;29pub mod weights;3031#[cfg(test)]32pub mod tests;3334use sp_core::H160;35use frame_support::traits::{Currency, OnUnbalanced, Imbalance};36use sp_runtime::{37 generic,38 traits::{BlakeTwo256, BlockNumberProvider},39 impl_opaque_keys,40};41use sp_std::vec::Vec;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;4546use crate::{47 Runtime, RuntimeCall, Balances, Treasury, Aura, Signature, AllPalletsWithSystem,48 InherentDataExt,49};50use up_common::types::{AccountId, BlockNumber};5152#[macro_export]53macro_rules! unsupported {54 () => {55 pallet_common::unsupported!($crate::Runtime)56 };57}5859/// The address format for describing accounts.60pub type Address = sp_runtime::MultiAddress<AccountId, ()>;61/// Block header type as expected by this runtime.62pub type Header = generic::Header<BlockNumber, BlakeTwo256>;63/// Block type as expected by this runtime.64pub type Block = generic::Block<Header, UncheckedExtrinsic>;65/// A Block signed with a Justification66pub type SignedBlock = generic::SignedBlock<Block>;67/// BlockId type as expected by this runtime.68pub type BlockId = generic::BlockId<Block>;6970impl_opaque_keys! {71 pub struct SessionKeys {72 pub aura: Aura,73 }74}7576/// The version information used to identify this runtime when compiled natively.77#[cfg(feature = "std")]78pub fn native_version() -> NativeVersion {79 NativeVersion {80 runtime_version: crate::VERSION,81 can_author_with: Default::default(),82 }83}8485pub type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;8687pub type SignedExtra = (88 frame_system::CheckSpecVersion<Runtime>,89 frame_system::CheckTxVersion<Runtime>,90 frame_system::CheckGenesis<Runtime>,91 frame_system::CheckEra<Runtime>,92 frame_system::CheckNonce<Runtime>,93 frame_system::CheckWeight<Runtime>,94 maintenance::CheckMaintenance,95 ChargeTransactionPayment,96 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,97 pallet_ethereum::FakeTransactionFinalizer<Runtime>,98);99100/// Unchecked extrinsic type as expected by this runtime.101pub type UncheckedExtrinsic =102 fp_self_contained::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;103104/// Extrinsic type that has already been checked.105pub type CheckedExtrinsic =106 fp_self_contained::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra, H160>;107108/// Executive: handles dispatch to the various modules.109pub type Executive = frame_executive::Executive<110 Runtime,111 Block,112 frame_system::ChainContext<Runtime>,113 Runtime,114 AllPalletsWithSystem,115>;116117type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;118119pub struct DealWithFees;120impl OnUnbalanced<NegativeImbalance> for DealWithFees {121 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {122 if let Some(fees) = fees_then_tips.next() {123 // for fees, 100% to treasury124 let mut split = fees.ration(100, 0);125 if let Some(tips) = fees_then_tips.next() {126 // for tips, if any, 100% to treasury127 tips.ration_merge_into(100, 0, &mut split);128 }129 Treasury::on_unbalanced(split.0);130 // Author::on_unbalanced(split.1);131 }132 }133}134135pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);136137impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider138 for RelayChainBlockNumberProvider<T>139{140 type BlockNumber = BlockNumber;141142 fn current_block_number() -> Self::BlockNumber {143 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()144 .map(|d| d.relay_parent_number)145 .unwrap_or_default()146 }147}148149pub(crate) struct CheckInherents;150151impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {152 fn check_inherents(153 block: &Block,154 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,155 ) -> sp_inherents::CheckInherentsResult {156 let relay_chain_slot = relay_state_proof157 .read_slot()158 .expect("Could not read the relay chain slot from the proof");159160 let inherent_data =161 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(162 relay_chain_slot,163 sp_std::time::Duration::from_secs(6),164 )165 .create_inherent_data()166 .expect("Could not create the timestamp inherent data");167168 inherent_data.check_extrinsics(block)169 }170}171172#[derive(codec::Encode, codec::Decode)]173pub enum XCMPMessage<XAccountId, XBalance> {174 /// Transfer tokens to the given account from the Parachain account.175 TransferToken(XAccountId, XBalance),176}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617pub mod config;18pub mod construct_runtime;19pub mod dispatch;20pub mod ethereum;21pub mod instance;22pub mod maintenance;23pub mod runtime_apis;2425#[cfg(feature = "scheduler")]26pub mod scheduler;2728pub mod sponsoring;29pub mod weights;3031#[cfg(test)]32pub mod tests;3334use sp_core::H160;35use frame_support::traits::{Currency, OnUnbalanced, Imbalance};36use sp_runtime::{37 generic,38 traits::{BlakeTwo256, BlockNumberProvider},39 impl_opaque_keys,40};41use sp_std::vec::Vec;4243#[cfg(feature = "std")]44use sp_version::NativeVersion;4546use crate::{47 Runtime, RuntimeCall, Balances, Treasury, Aura, Signature, AllPalletsWithSystem,48 InherentDataExt,49};50use up_common::types::{AccountId, BlockNumber};5152#[macro_export]53macro_rules! unsupported {54 () => {55 pallet_common::unsupported!($crate::Runtime)56 };57}5859/// The address format for describing accounts.60pub type Address = sp_runtime::MultiAddress<AccountId, ()>;61/// Block header type as expected by this runtime.62pub type Header = generic::Header<BlockNumber, BlakeTwo256>;63/// Block type as expected by this runtime.64pub type Block = generic::Block<Header, UncheckedExtrinsic>;65/// A Block signed with a Justification66pub type SignedBlock = generic::SignedBlock<Block>;67/// BlockId type as expected by this runtime.68pub type BlockId = generic::BlockId<Block>;6970impl_opaque_keys! {71 pub struct SessionKeys {72 pub aura: Aura,73 }74}7576/// The version information used to identify this runtime when compiled natively.77#[cfg(feature = "std")]78pub fn native_version() -> NativeVersion {79 NativeVersion {80 runtime_version: crate::VERSION,81 can_author_with: Default::default(),82 }83}8485pub type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;8687pub type SignedExtra = (88 frame_system::CheckSpecVersion<Runtime>,89 frame_system::CheckTxVersion<Runtime>,90 frame_system::CheckGenesis<Runtime>,91 frame_system::CheckEra<Runtime>,92 frame_system::CheckNonce<Runtime>,93 frame_system::CheckWeight<Runtime>,94 maintenance::CheckMaintenance,95 ChargeTransactionPayment,96 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,97 pallet_ethereum::FakeTransactionFinalizer<Runtime>,98);99100/// Unchecked extrinsic type as expected by this runtime.101pub type UncheckedExtrinsic =102 fp_self_contained::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;103104/// Extrinsic type that has already been checked.105pub type CheckedExtrinsic =106 fp_self_contained::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra, H160>;107108/// Executive: handles dispatch to the various modules.109pub type Executive = frame_executive::Executive<110 Runtime,111 Block,112 frame_system::ChainContext<Runtime>,113 Runtime,114 AllPalletsWithSystem,115>;116117type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;118119pub struct DealWithFees;120impl OnUnbalanced<NegativeImbalance> for DealWithFees {121 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {122 if let Some(fees) = fees_then_tips.next() {123 // for fees, 100% to treasury124 let mut split = fees.ration(100, 0);125 if let Some(tips) = fees_then_tips.next() {126 // for tips, if any, 100% to treasury127 tips.ration_merge_into(100, 0, &mut split);128 }129 Treasury::on_unbalanced(split.0);130 // Author::on_unbalanced(split.1);131 }132 }133}134135pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);136137impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider138 for RelayChainBlockNumberProvider<T>139{140 type BlockNumber = BlockNumber;141142 fn current_block_number() -> Self::BlockNumber {143 cumulus_pallet_parachain_system::Pallet::<T>::validation_data()144 .map(|d| d.relay_parent_number)145 .unwrap_or_default()146 }147}148149pub(crate) struct CheckInherents;150151impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {152 fn check_inherents(153 block: &Block,154 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,155 ) -> sp_inherents::CheckInherentsResult {156 let relay_chain_slot = relay_state_proof157 .read_slot()158 .expect("Could not read the relay chain slot from the proof");159160 let inherent_data =161 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(162 relay_chain_slot,163 sp_std::time::Duration::from_secs(6),164 )165 .create_inherent_data()166 .expect("Could not create the timestamp inherent data");167168 inherent_data.check_extrinsics(block)169 }170}171172#[derive(codec::Encode, codec::Decode)]173pub enum XCMPMessage<XAccountId, XBalance> {174 /// Transfer tokens to the given account from the Parachain account.175 TransferToken(XAccountId, XBalance),176}