diff --git a/Cargo.lock b/Cargo.lock index 3c55a14256c5..1cfadfd4afbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15877,17 +15877,12 @@ name = "pallet-tx-pause" version = "9.0.0" dependencies = [ "docify", - "frame-benchmarking 28.0.0", - "frame-support 28.0.0", - "frame-system 28.0.0", "pallet-balances 28.0.0", "pallet-proxy 28.0.0", "pallet-utility 28.0.0", "parity-scale-codec", + "polkadot-sdk-frame 0.1.0", "scale-info", - "sp-core 28.0.0", - "sp-io 30.0.0", - "sp-runtime 31.0.1", ] [[package]] diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index b3e340cbcbff..3be103cd511c 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -204,7 +204,8 @@ pub mod prelude { #[doc(no_inline)] pub use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; pub use frame_support::traits::{ - Contains, EstimateNextSessionRotation, IsSubType, OnRuntimeUpgrade, OneSessionHandler, + Contains, EstimateNextSessionRotation, Everything, InsideBoth, InstanceFilter, IsSubType, + OnRuntimeUpgrade, OneSessionHandler, VariantCount, VariantCountOf, }; /// Pallet prelude of `frame-system`. @@ -222,6 +223,8 @@ pub mod prelude { /// All hashing related things pub use super::hashing::*; + pub use crate::transaction::*; + /// All arithmetic types and traits used for safe math. pub use super::arithmetic::*; @@ -545,6 +548,22 @@ pub mod hashing { pub use sp_runtime::traits::{BlakeTwo256, Hash, Keccak256}; } +// Systems involved in transaction execution in the runtime. +/// +/// This is already part of the [`prelude`]. +pub mod transaction { + pub use frame_support::traits::{CallMetadata, GetCallMetadata}; + pub use sp_runtime::{ + generic::ExtensionVersion, + impl_tx_ext_default, + traits::{ + AsTransactionAuthorizedOrigin, DispatchTransaction, TransactionExtension, + ValidateResult, + }, + transaction_validity::{InvalidTransaction, ValidTransaction}, + }; +} + /// Access to all of the dependencies of this crate. In case the prelude re-exports are not enough, /// this module can be used. /// diff --git a/substrate/frame/tx-pause/Cargo.toml b/substrate/frame/tx-pause/Cargo.toml index 6298645fb2b3..d8048fa122d9 100644 --- a/substrate/frame/tx-pause/Cargo.toml +++ b/substrate/frame/tx-pause/Cargo.toml @@ -17,51 +17,36 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { features = ["derive"], workspace = true } docify = { workspace = true } -frame-benchmarking = { optional = true, workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"] } +scale-info = { features = ["derive"], workspace = true } pallet-balances = { optional = true, workspace = true } pallet-proxy = { optional = true, workspace = true } pallet-utility = { optional = true, workspace = true } -scale-info = { features = ["derive"], workspace = true } -sp-runtime = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } pallet-proxy = { workspace = true, default-features = true } pallet-utility = { workspace = true, default-features = true } -sp-core = { workspace = true, default-features = true } -sp-io = { workspace = true, default-features = true } [features] default = ["std"] std = [ "codec/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", + "frame/std", "pallet-balances?/std", "pallet-proxy?/std", "pallet-utility?/std", "scale-info/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", ] runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", "pallet-utility/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", + "frame/try-runtime", "pallet-balances?/try-runtime", "pallet-proxy?/try-runtime", "pallet-utility?/try-runtime", - "sp-runtime/try-runtime", ] diff --git a/substrate/frame/tx-pause/src/benchmarking.rs b/substrate/frame/tx-pause/src/benchmarking.rs index 95ae250eff7b..a8bf0e350165 100644 --- a/substrate/frame/tx-pause/src/benchmarking.rs +++ b/substrate/frame/tx-pause/src/benchmarking.rs @@ -19,7 +19,7 @@ use super::{Pallet as TxPause, *}; use alloc::vec; -use frame_benchmarking::v2::*; +use frame::benchmarking::prelude::*; #[benchmarks] mod benchmarks { diff --git a/substrate/frame/tx-pause/src/lib.rs b/substrate/frame/tx-pause/src/lib.rs index 962bfd744a65..3d3bca526ed5 100644 --- a/substrate/frame/tx-pause/src/lib.rs +++ b/substrate/frame/tx-pause/src/lib.rs @@ -78,15 +78,10 @@ pub mod weights; extern crate alloc; use alloc::vec::Vec; -use frame_support::{ - dispatch::GetDispatchInfo, - pallet_prelude::*, - traits::{CallMetadata, Contains, GetCallMetadata, IsSubType, IsType}, - DefaultNoBound, +use frame::{ + prelude::*, + traits::{TransactionPause, TransactionPauseError}, }; -use frame_system::pallet_prelude::*; -use sp_runtime::{traits::Dispatchable, DispatchResult}; - pub use pallet::*; pub use weights::*; @@ -101,7 +96,7 @@ pub type PalletCallNameOf = BoundedVec::MaxNameLen>; /// to partially or fully specify an item a variant of a [`Config::RuntimeCall`]. pub type RuntimeCallNameOf = (PalletNameOf, PalletCallNameOf); -#[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; @@ -294,7 +289,7 @@ where } } -impl frame_support::traits::TransactionPause for Pallet { +impl TransactionPause for Pallet { type CallIdentifier = RuntimeCallNameOf; fn is_paused(full_name: Self::CallIdentifier) -> bool { @@ -305,20 +300,16 @@ impl frame_support::traits::TransactionPause for Pallet { Self::ensure_can_pause(&full_name).is_ok() } - fn pause( - full_name: Self::CallIdentifier, - ) -> Result<(), frame_support::traits::TransactionPauseError> { + fn pause(full_name: Self::CallIdentifier) -> Result<(), TransactionPauseError> { Self::do_pause(full_name).map_err(Into::into) } - fn unpause( - full_name: Self::CallIdentifier, - ) -> Result<(), frame_support::traits::TransactionPauseError> { + fn unpause(full_name: Self::CallIdentifier) -> Result<(), TransactionPauseError> { Self::do_unpause(full_name).map_err(Into::into) } } -impl From> for frame_support::traits::TransactionPauseError { +impl From> for TransactionPauseError { fn from(err: Error) -> Self { match err { Error::::NotFound => Self::NotFound, diff --git a/substrate/frame/tx-pause/src/mock.rs b/substrate/frame/tx-pause/src/mock.rs index fd9b3b552ccd..a747a3dc8bdb 100644 --- a/substrate/frame/tx-pause/src/mock.rs +++ b/substrate/frame/tx-pause/src/mock.rs @@ -21,13 +21,7 @@ use super::*; use crate as pallet_tx_pause; - -use frame_support::{ - derive_impl, parameter_types, - traits::{ConstU64, Everything, InsideBoth, InstanceFilter}, -}; -use frame_system::EnsureSignedBy; -use sp_runtime::{traits::BlakeTwo256, BuildStorage}; +use frame::testing_prelude::*; #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Test { @@ -112,7 +106,7 @@ parameter_types! { pub const MaxNameLen: u32 = 50; } -frame_support::ord_parameter_types! { +ord_parameter_types! { pub const PauseOrigin: u64 = 1; pub const UnpauseOrigin: u64 = 2; } @@ -140,7 +134,7 @@ impl Config for Test { type Block = frame_system::mocking::MockBlock; -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, @@ -151,7 +145,7 @@ frame_support::construct_runtime!( } ); -pub fn new_test_ext() -> sp_io::TestExternalities { +pub fn new_test_ext() -> TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { @@ -165,7 +159,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { .assimilate_storage(&mut t) .unwrap(); - let mut ext = sp_io::TestExternalities::new(t); + let mut ext = TestExternalities::new(t); ext.execute_with(|| { System::set_block_number(1); }); diff --git a/substrate/frame/tx-pause/src/tests.rs b/substrate/frame/tx-pause/src/tests.rs index 823abf9d9c43..05a211be253a 100644 --- a/substrate/frame/tx-pause/src/tests.rs +++ b/substrate/frame/tx-pause/src/tests.rs @@ -19,10 +19,7 @@ use super::*; use crate::mock::{RuntimeCall, *}; - -use frame_support::{assert_err, assert_noop, assert_ok}; -use sp_runtime::DispatchError; - +use frame::testing_prelude::*; // GENERAL SUCCESS/POSITIVE TESTS --------------------- #[docify::export] diff --git a/substrate/frame/tx-pause/src/weights.rs b/substrate/frame/tx-pause/src/weights.rs index 67e1390e9c7d..5f6d26e5166d 100644 --- a/substrate/frame/tx-pause/src/weights.rs +++ b/substrate/frame/tx-pause/src/weights.rs @@ -46,7 +46,7 @@ #![allow(unused_imports)] #![allow(missing_docs)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame::weights_prelude::*; use core::marker::PhantomData; /// Weight functions needed for `pallet_tx_pause`.