Skip to content

Commit e7ba9a2

Browse files
bennethxyzbennethxyzre-gius
authored
Migrate pallet-tx-pause to umbrella crate (#6630)
Part of #6504 polkadot address: 15rM9idTv1izwNFqPabfcT4jkqHDsEvHSa5fASAUZwZcS4Yw --------- Co-authored-by: bennethxyz <[email protected]> Co-authored-by: Giuseppe Re <[email protected]>
1 parent 21fbd6b commit e7ba9a2

File tree

8 files changed

+43
-61
lines changed

8 files changed

+43
-61
lines changed

Cargo.lock

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

substrate/frame/src/lib.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,12 @@ pub mod prelude {
203203
#[doc(no_inline)]
204204
pub use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo};
205205
pub use frame_support::{
206+
defensive, defensive_assert,
206207
traits::{
207208
Contains, Defensive, DefensiveSaturating, EitherOf, EstimateNextSessionRotation,
208-
Everything, IsSubType, MapSuccess, NoOpPoll, OnRuntimeUpgrade, OneSessionHandler,
209-
RankedMembers, RankedMembersSwapHandler, VariantCount, VariantCountOf,
209+
Everything, InsideBoth, InstanceFilter, IsSubType, MapSuccess, NoOpPoll,
210+
OnRuntimeUpgrade, OneSessionHandler, RankedMembers, RankedMembersSwapHandler,
211+
VariantCount, VariantCountOf,
210212
},
211213
PalletId,
212214
};
@@ -226,6 +228,8 @@ pub mod prelude {
226228
/// All hashing related things.
227229
pub use super::hashing::*;
228230

231+
pub use crate::transaction::*;
232+
229233
/// All account related things.
230234
pub use super::account::*;
231235

@@ -584,6 +588,22 @@ pub mod hashing {
584588
pub use sp_runtime::traits::{BlakeTwo256, Hash, Keccak256};
585589
}
586590

591+
// Systems involved in transaction execution in the runtime.
592+
///
593+
/// This is already part of the [`prelude`].
594+
pub mod transaction {
595+
pub use frame_support::traits::{CallMetadata, GetCallMetadata};
596+
pub use sp_runtime::{
597+
generic::ExtensionVersion,
598+
impl_tx_ext_default,
599+
traits::{
600+
AsTransactionAuthorizedOrigin, DispatchTransaction, TransactionExtension,
601+
ValidateResult,
602+
},
603+
transaction_validity::{InvalidTransaction, ValidTransaction},
604+
};
605+
}
606+
587607
/// All account management related traits.
588608
///
589609
/// This is already part of the [`prelude`].

substrate/frame/tx-pause/Cargo.toml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,51 +17,36 @@ targets = ["x86_64-unknown-linux-gnu"]
1717
[dependencies]
1818
codec = { features = ["derive"], workspace = true }
1919
docify = { workspace = true }
20-
frame-benchmarking = { optional = true, workspace = true }
21-
frame-support = { workspace = true }
22-
frame-system = { workspace = true }
20+
frame = { workspace = true, features = ["runtime"] }
2321
pallet-balances = { optional = true, workspace = true }
2422
pallet-proxy = { optional = true, workspace = true }
2523
pallet-utility = { optional = true, workspace = true }
2624
scale-info = { features = ["derive"], workspace = true }
27-
sp-runtime = { workspace = true }
2825

2926
[dev-dependencies]
3027
pallet-balances = { workspace = true, default-features = true }
3128
pallet-proxy = { workspace = true, default-features = true }
3229
pallet-utility = { workspace = true, default-features = true }
33-
sp-core = { workspace = true, default-features = true }
34-
sp-io = { workspace = true, default-features = true }
3530

3631
[features]
3732
default = ["std"]
3833
std = [
3934
"codec/std",
40-
"frame-benchmarking/std",
41-
"frame-support/std",
42-
"frame-system/std",
35+
"frame/std",
4336
"pallet-balances?/std",
4437
"pallet-proxy?/std",
4538
"pallet-utility?/std",
4639
"scale-info/std",
47-
"sp-core/std",
48-
"sp-io/std",
49-
"sp-runtime/std",
5040
]
5141
runtime-benchmarks = [
52-
"frame-benchmarking/runtime-benchmarks",
53-
"frame-support/runtime-benchmarks",
54-
"frame-system/runtime-benchmarks",
42+
"frame/runtime-benchmarks",
5543
"pallet-balances/runtime-benchmarks",
5644
"pallet-proxy/runtime-benchmarks",
5745
"pallet-utility/runtime-benchmarks",
58-
"sp-runtime/runtime-benchmarks",
5946
]
6047
try-runtime = [
61-
"frame-support/try-runtime",
62-
"frame-system/try-runtime",
48+
"frame/try-runtime",
6349
"pallet-balances?/try-runtime",
6450
"pallet-proxy?/try-runtime",
6551
"pallet-utility?/try-runtime",
66-
"sp-runtime/try-runtime",
6752
]

substrate/frame/tx-pause/src/benchmarking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
use super::{Pallet as TxPause, *};
2121
use alloc::vec;
22-
use frame_benchmarking::v2::*;
22+
use frame::benchmarking::prelude::*;
2323

2424
#[benchmarks]
2525
mod benchmarks {

substrate/frame/tx-pause/src/lib.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,10 @@ pub mod weights;
7878
extern crate alloc;
7979

8080
use alloc::vec::Vec;
81-
use frame_support::{
82-
dispatch::GetDispatchInfo,
83-
pallet_prelude::*,
84-
traits::{CallMetadata, Contains, GetCallMetadata, IsSubType, IsType},
85-
DefaultNoBound,
81+
use frame::{
82+
prelude::*,
83+
traits::{TransactionPause, TransactionPauseError},
8684
};
87-
use frame_system::pallet_prelude::*;
88-
use sp_runtime::{traits::Dispatchable, DispatchResult};
89-
9085
pub use pallet::*;
9186
pub use weights::*;
9287

@@ -101,7 +96,7 @@ pub type PalletCallNameOf<T> = BoundedVec<u8, <T as Config>::MaxNameLen>;
10196
/// to partially or fully specify an item a variant of a [`Config::RuntimeCall`].
10297
pub type RuntimeCallNameOf<T> = (PalletNameOf<T>, PalletCallNameOf<T>);
10398

104-
#[frame_support::pallet]
99+
#[frame::pallet]
105100
pub mod pallet {
106101
use super::*;
107102

@@ -294,7 +289,7 @@ where
294289
}
295290
}
296291

297-
impl<T: Config> frame_support::traits::TransactionPause for Pallet<T> {
292+
impl<T: Config> TransactionPause for Pallet<T> {
298293
type CallIdentifier = RuntimeCallNameOf<T>;
299294

300295
fn is_paused(full_name: Self::CallIdentifier) -> bool {
@@ -305,20 +300,16 @@ impl<T: Config> frame_support::traits::TransactionPause for Pallet<T> {
305300
Self::ensure_can_pause(&full_name).is_ok()
306301
}
307302

308-
fn pause(
309-
full_name: Self::CallIdentifier,
310-
) -> Result<(), frame_support::traits::TransactionPauseError> {
303+
fn pause(full_name: Self::CallIdentifier) -> Result<(), TransactionPauseError> {
311304
Self::do_pause(full_name).map_err(Into::into)
312305
}
313306

314-
fn unpause(
315-
full_name: Self::CallIdentifier,
316-
) -> Result<(), frame_support::traits::TransactionPauseError> {
307+
fn unpause(full_name: Self::CallIdentifier) -> Result<(), TransactionPauseError> {
317308
Self::do_unpause(full_name).map_err(Into::into)
318309
}
319310
}
320311

321-
impl<T: Config> From<Error<T>> for frame_support::traits::TransactionPauseError {
312+
impl<T: Config> From<Error<T>> for TransactionPauseError {
322313
fn from(err: Error<T>) -> Self {
323314
match err {
324315
Error::<T>::NotFound => Self::NotFound,

substrate/frame/tx-pause/src/mock.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@
2121

2222
use super::*;
2323
use crate as pallet_tx_pause;
24-
25-
use frame_support::{
26-
derive_impl, parameter_types,
27-
traits::{ConstU64, Everything, InsideBoth, InstanceFilter},
28-
};
29-
use frame_system::EnsureSignedBy;
30-
use sp_runtime::{traits::BlakeTwo256, BuildStorage};
24+
use frame::testing_prelude::*;
3125

3226
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
3327
impl frame_system::Config for Test {
@@ -113,7 +107,7 @@ parameter_types! {
113107
pub const MaxNameLen: u32 = 50;
114108
}
115109

116-
frame_support::ord_parameter_types! {
110+
ord_parameter_types! {
117111
pub const PauseOrigin: u64 = 1;
118112
pub const UnpauseOrigin: u64 = 2;
119113
}
@@ -141,7 +135,7 @@ impl Config for Test {
141135

142136
type Block = frame_system::mocking::MockBlock<Test>;
143137

144-
frame_support::construct_runtime!(
138+
construct_runtime!(
145139
pub enum Test
146140
{
147141
System: frame_system,
@@ -152,7 +146,7 @@ frame_support::construct_runtime!(
152146
}
153147
);
154148

155-
pub fn new_test_ext() -> sp_io::TestExternalities {
149+
pub fn new_test_ext() -> TestExternalities {
156150
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
157151

158152
pallet_balances::GenesisConfig::<Test> {
@@ -167,7 +161,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
167161
.assimilate_storage(&mut t)
168162
.unwrap();
169163

170-
let mut ext = sp_io::TestExternalities::new(t);
164+
let mut ext = TestExternalities::new(t);
171165
ext.execute_with(|| {
172166
System::set_block_number(1);
173167
});

substrate/frame/tx-pause/src/tests.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919

2020
use super::*;
2121
use crate::mock::{RuntimeCall, *};
22-
23-
use frame_support::{assert_err, assert_noop, assert_ok};
24-
use sp_runtime::DispatchError;
25-
22+
use frame::testing_prelude::*;
2623
// GENERAL SUCCESS/POSITIVE TESTS ---------------------
2724

2825
#[docify::export]

substrate/frame/tx-pause/src/weights.rs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)