From ff6b281bc6beeca213da78c2bb3d04b779be1378 Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Sun, 24 Nov 2024 09:57:32 -0800 Subject: [PATCH 1/9] add frame --- Cargo.lock | 7 +----- substrate/frame/tx-pause/Cargo.toml | 23 ++++---------------- substrate/frame/tx-pause/src/benchmarking.rs | 3 ++- substrate/frame/tx-pause/src/lib.rs | 15 ++++++++----- substrate/frame/tx-pause/src/mock.rs | 11 ++++++---- substrate/frame/tx-pause/src/tests.rs | 5 +++-- substrate/frame/tx-pause/src/weights.rs | 3 ++- 7 files changed, 28 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 182d8f6bacad..ee8b54b95197 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15677,17 +15677,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/tx-pause/Cargo.toml b/substrate/frame/tx-pause/Cargo.toml index 03c700ec053c..59b413bf270b 100644 --- a/substrate/frame/tx-pause/Cargo.toml +++ b/substrate/frame/tx-pause/Cargo.toml @@ -17,18 +17,13 @@ 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 } -sp-runtime = { workspace = true } pallet-balances = { optional = true, workspace = true } pallet-utility = { optional = true, workspace = true } pallet-proxy = { optional = true, workspace = true } [dev-dependencies] -sp-core = { workspace = true, default-features = true } -sp-io = { workspace = true, default-features = true } pallet-balances = { workspace = true, default-features = true } pallet-utility = { workspace = true, default-features = true } pallet-proxy = { workspace = true, default-features = true } @@ -37,31 +32,21 @@ pallet-proxy = { workspace = true, default-features = true } 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..22cd15ffc5c1 100644 --- a/substrate/frame/tx-pause/src/benchmarking.rs +++ b/substrate/frame/tx-pause/src/benchmarking.rs @@ -19,7 +19,8 @@ use super::{Pallet as TxPause, *}; use alloc::vec; -use frame_benchmarking::v2::*; +use frame::benchmarking::prelude::*; +// use frame_benchmarking::v2::*; #[benchmarks] mod benchmarks { diff --git a/substrate/frame/tx-pause/src/lib.rs b/substrate/frame/tx-pause/src/lib.rs index 962bfd744a65..37fbfad993c5 100644 --- a/substrate/frame/tx-pause/src/lib.rs +++ b/substrate/frame/tx-pause/src/lib.rs @@ -78,6 +78,7 @@ pub mod weights; extern crate alloc; use alloc::vec::Vec; +/* use frame_support::{ dispatch::GetDispatchInfo, pallet_prelude::*, @@ -86,7 +87,8 @@ use frame_support::{ }; use frame_system::pallet_prelude::*; use sp_runtime::{traits::Dispatchable, DispatchResult}; - +*/ +use frame::{prelude::*, traits::{CallMetadata, Contains, Dispatchable, GetCallMetadata, IsSubType, IsType, TransactionPause,TransactionPauseError}, deps::{frame_support::{dispatch::GetDispatchInfo, DefaultNoBound}}}; pub use pallet::*; pub use weights::*; @@ -101,7 +103,8 @@ 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_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; @@ -294,7 +297,7 @@ where } } -impl frame_support::traits::TransactionPause for Pallet { +impl TransactionPause for Pallet { type CallIdentifier = RuntimeCallNameOf; fn is_paused(full_name: Self::CallIdentifier) -> bool { @@ -307,18 +310,18 @@ impl frame_support::traits::TransactionPause for Pallet { fn pause( full_name: Self::CallIdentifier, - ) -> Result<(), frame_support::traits::TransactionPauseError> { + ) -> Result<(), TransactionPauseError> { Self::do_pause(full_name).map_err(Into::into) } fn unpause( full_name: Self::CallIdentifier, - ) -> Result<(), frame_support::traits::TransactionPauseError> { + ) -> 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 84ce45e83528..172f4d8ac9ba 100644 --- a/substrate/frame/tx-pause/src/mock.rs +++ b/substrate/frame/tx-pause/src/mock.rs @@ -22,12 +22,15 @@ 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::{prelude::frame_system, testing_prelude::TestExternalities, traits::{BlakeTwo256, ConstU64, Everything, InsideBoth, InstanceFilter}, runtime::{prelude::{derive_impl, parameter_types, EnsureSignedBy, construct_runtime, ord_parameter_types}, testing_prelude::BuildStorage}}; #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Test { @@ -111,7 +114,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; } @@ -139,7 +142,7 @@ impl Config for Test { type Block = frame_system::mocking::MockBlock; -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, @@ -150,7 +153,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:: { @@ -164,7 +167,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..31b156853b8a 100644 --- a/substrate/frame/tx-pause/src/tests.rs +++ b/substrate/frame/tx-pause/src/tests.rs @@ -19,10 +19,11 @@ use super::*; use crate::mock::{RuntimeCall, *}; - +/* use frame_support::{assert_err, assert_noop, assert_ok}; use sp_runtime::DispatchError; - +*/ +use frame::{testing_prelude::{assert_err, assert_noop, assert_ok}, deps::sp_runtime::{DispatchError}}; // 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..bd42e8891130 100644 --- a/substrate/frame/tx-pause/src/weights.rs +++ b/substrate/frame/tx-pause/src/weights.rs @@ -46,7 +46,8 @@ #![allow(unused_imports)] #![allow(missing_docs)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +// use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame::weights_prelude::*; use core::marker::PhantomData; /// Weight functions needed for `pallet_tx_pause`. From f53c6d0eef9aa039b0cac18da3a5b8b5ccb6818a Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Sun, 24 Nov 2024 11:56:53 -0800 Subject: [PATCH 2/9] cargo +nightly fmt, add prdoc --- prdoc/pr_6630.prdoc | 14 +++++++++++ substrate/frame/tx-pause/src/benchmarking.rs | 1 - substrate/frame/tx-pause/src/lib.rs | 25 +++++++------------- substrate/frame/tx-pause/src/mock.rs | 19 ++++++++------- substrate/frame/tx-pause/src/tests.rs | 9 ++++--- 5 files changed, 37 insertions(+), 31 deletions(-) create mode 100644 prdoc/pr_6630.prdoc diff --git a/prdoc/pr_6630.prdoc b/prdoc/pr_6630.prdoc new file mode 100644 index 000000000000..b020746975f3 --- /dev/null +++ b/prdoc/pr_6630.prdoc @@ -0,0 +1,14 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: migrate pallet-tx-pause to umbrella crate + +doc: + - audience: Runtime Dev + description: | + This pull request adapts the frame umbrella crate into pallet-tx-pause + by importing existing systems into the pallet. + +crates: + - name: pallet-tx-pause + bump: minor diff --git a/substrate/frame/tx-pause/src/benchmarking.rs b/substrate/frame/tx-pause/src/benchmarking.rs index 22cd15ffc5c1..a8bf0e350165 100644 --- a/substrate/frame/tx-pause/src/benchmarking.rs +++ b/substrate/frame/tx-pause/src/benchmarking.rs @@ -20,7 +20,6 @@ use super::{Pallet as TxPause, *}; use alloc::vec; use frame::benchmarking::prelude::*; -// use frame_benchmarking::v2::*; #[benchmarks] mod benchmarks { diff --git a/substrate/frame/tx-pause/src/lib.rs b/substrate/frame/tx-pause/src/lib.rs index 37fbfad993c5..1d580824be24 100644 --- a/substrate/frame/tx-pause/src/lib.rs +++ b/substrate/frame/tx-pause/src/lib.rs @@ -78,17 +78,14 @@ 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::{ + deps::frame_support::{dispatch::GetDispatchInfo, DefaultNoBound}, + prelude::*, + traits::{ + CallMetadata, Contains, Dispatchable, GetCallMetadata, IsSubType, IsType, TransactionPause, + TransactionPauseError, + }, }; -use frame_system::pallet_prelude::*; -use sp_runtime::{traits::Dispatchable, DispatchResult}; -*/ -use frame::{prelude::*, traits::{CallMetadata, Contains, Dispatchable, GetCallMetadata, IsSubType, IsType, TransactionPause,TransactionPauseError}, deps::{frame_support::{dispatch::GetDispatchInfo, DefaultNoBound}}}; pub use pallet::*; pub use weights::*; @@ -308,15 +305,11 @@ impl TransactionPause for Pallet { Self::ensure_can_pause(&full_name).is_ok() } - fn pause( - full_name: Self::CallIdentifier, - ) -> Result<(), 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<(), TransactionPauseError> { + fn unpause(full_name: Self::CallIdentifier) -> Result<(), TransactionPauseError> { Self::do_unpause(full_name).map_err(Into::into) } } diff --git a/substrate/frame/tx-pause/src/mock.rs b/substrate/frame/tx-pause/src/mock.rs index 172f4d8ac9ba..45fd319d84e6 100644 --- a/substrate/frame/tx-pause/src/mock.rs +++ b/substrate/frame/tx-pause/src/mock.rs @@ -21,16 +21,17 @@ use super::*; use crate as pallet_tx_pause; - -/* -use frame_support::{ - derive_impl, parameter_types, - traits::{ConstU64, Everything, InsideBoth, InstanceFilter}, +use frame::{ + prelude::frame_system, + runtime::{ + prelude::{ + construct_runtime, derive_impl, ord_parameter_types, parameter_types, EnsureSignedBy, + }, + testing_prelude::BuildStorage, + }, + testing_prelude::TestExternalities, + traits::{BlakeTwo256, ConstU64, Everything, InsideBoth, InstanceFilter}, }; -use frame_system::EnsureSignedBy; -use sp_runtime::{traits::BlakeTwo256, BuildStorage}; -*/ -use frame::{prelude::frame_system, testing_prelude::TestExternalities, traits::{BlakeTwo256, ConstU64, Everything, InsideBoth, InstanceFilter}, runtime::{prelude::{derive_impl, parameter_types, EnsureSignedBy, construct_runtime, ord_parameter_types}, testing_prelude::BuildStorage}}; #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Test { diff --git a/substrate/frame/tx-pause/src/tests.rs b/substrate/frame/tx-pause/src/tests.rs index 31b156853b8a..6b5f30bb691c 100644 --- a/substrate/frame/tx-pause/src/tests.rs +++ b/substrate/frame/tx-pause/src/tests.rs @@ -19,11 +19,10 @@ use super::*; use crate::mock::{RuntimeCall, *}; -/* -use frame_support::{assert_err, assert_noop, assert_ok}; -use sp_runtime::DispatchError; -*/ -use frame::{testing_prelude::{assert_err, assert_noop, assert_ok}, deps::sp_runtime::{DispatchError}}; +use frame::{ + deps::sp_runtime::DispatchError, + testing_prelude::{assert_err, assert_noop, assert_ok}, +}; // GENERAL SUCCESS/POSITIVE TESTS --------------------- #[docify::export] From 76cffe8956b9a3e3723706e49cc5a5c7995d6667 Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Thu, 5 Dec 2024 16:01:06 -0800 Subject: [PATCH 3/9] prelude to the max --- substrate/frame/tx-pause/src/lib.rs | 4 ++++ substrate/frame/tx-pause/src/mock.rs | 11 ++--------- substrate/frame/tx-pause/src/tests.rs | 5 +---- substrate/frame/tx-pause/src/weights.rs | 1 - 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/substrate/frame/tx-pause/src/lib.rs b/substrate/frame/tx-pause/src/lib.rs index 1d580824be24..c5d1e41e6247 100644 --- a/substrate/frame/tx-pause/src/lib.rs +++ b/substrate/frame/tx-pause/src/lib.rs @@ -79,12 +79,16 @@ extern crate alloc; use alloc::vec::Vec; use frame::{ + /* deps::frame_support::{dispatch::GetDispatchInfo, DefaultNoBound}, prelude::*, traits::{ CallMetadata, Contains, Dispatchable, GetCallMetadata, IsSubType, IsType, TransactionPause, TransactionPauseError, }, + */ + runtime::prelude::*, + traits::{CallMetadata, GetCallMetadata, TransactionPause, TransactionPauseError}, }; pub use pallet::*; pub use weights::*; diff --git a/substrate/frame/tx-pause/src/mock.rs b/substrate/frame/tx-pause/src/mock.rs index 9a288985908c..5fe0cc60ec07 100644 --- a/substrate/frame/tx-pause/src/mock.rs +++ b/substrate/frame/tx-pause/src/mock.rs @@ -22,15 +22,8 @@ use super::*; use crate as pallet_tx_pause; use frame::{ - prelude::frame_system, - runtime::{ - prelude::{ - construct_runtime, derive_impl, ord_parameter_types, parameter_types, EnsureSignedBy, - }, - testing_prelude::BuildStorage, - }, - testing_prelude::TestExternalities, - traits::{BlakeTwo256, ConstU64, Everything, InsideBoth, InstanceFilter}, + testing_prelude::*, + traits::{Everything, InsideBoth, InstanceFilter}, }; #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] diff --git a/substrate/frame/tx-pause/src/tests.rs b/substrate/frame/tx-pause/src/tests.rs index 6b5f30bb691c..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::{ - deps::sp_runtime::DispatchError, - testing_prelude::{assert_err, assert_noop, assert_ok}, -}; +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 bd42e8891130..5f6d26e5166d 100644 --- a/substrate/frame/tx-pause/src/weights.rs +++ b/substrate/frame/tx-pause/src/weights.rs @@ -46,7 +46,6 @@ #![allow(unused_imports)] #![allow(missing_docs)] -// use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use frame::weights_prelude::*; use core::marker::PhantomData; From d8930cad62c86eff9d09ad357a5e0f4ed43c757d Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Thu, 5 Dec 2024 16:07:47 -0800 Subject: [PATCH 4/9] remove commenting --- substrate/frame/tx-pause/src/lib.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/substrate/frame/tx-pause/src/lib.rs b/substrate/frame/tx-pause/src/lib.rs index c5d1e41e6247..989981f99cf4 100644 --- a/substrate/frame/tx-pause/src/lib.rs +++ b/substrate/frame/tx-pause/src/lib.rs @@ -79,14 +79,6 @@ extern crate alloc; use alloc::vec::Vec; use frame::{ - /* - deps::frame_support::{dispatch::GetDispatchInfo, DefaultNoBound}, - prelude::*, - traits::{ - CallMetadata, Contains, Dispatchable, GetCallMetadata, IsSubType, IsType, TransactionPause, - TransactionPauseError, - }, - */ runtime::prelude::*, traits::{CallMetadata, GetCallMetadata, TransactionPause, TransactionPauseError}, }; @@ -104,7 +96,6 @@ 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::*; From 8e73cba910bf7dbbab4da9bb248bf9af3cdf3301 Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Wed, 11 Dec 2024 20:29:08 -0800 Subject: [PATCH 5/9] remove prdoc --- prdoc/pr_6630.prdoc | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 prdoc/pr_6630.prdoc diff --git a/prdoc/pr_6630.prdoc b/prdoc/pr_6630.prdoc deleted file mode 100644 index b020746975f3..000000000000 --- a/prdoc/pr_6630.prdoc +++ /dev/null @@ -1,14 +0,0 @@ -# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 -# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json - -title: migrate pallet-tx-pause to umbrella crate - -doc: - - audience: Runtime Dev - description: | - This pull request adapts the frame umbrella crate into pallet-tx-pause - by importing existing systems into the pallet. - -crates: - - name: pallet-tx-pause - bump: minor From 12aa5ae8e271bc9149b5289331401bd7e2e28c10 Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Sun, 29 Dec 2024 23:28:01 +0100 Subject: [PATCH 6/9] utility mod --- substrate/frame/src/lib.rs | 29 ++++++++++++++++++++++++++++ substrate/frame/tx-pause/src/lib.rs | 5 +---- substrate/frame/tx-pause/src/mock.rs | 5 +---- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 03d815e349df..58acc4ecb135 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -216,6 +216,10 @@ pub mod prelude { /// All hashing related things pub use super::hashing::*; + pub use crate::transaction::*; + + pub use super::utility::*; + /// Runtime traits #[doc(no_inline)] pub use sp_runtime::traits::{ @@ -532,6 +536,31 @@ 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, TransactionPause, TransactionPauseError, + }; + pub use sp_runtime::{ + generic::ExtensionVersion, + impl_tx_ext_default, + traits::{ + AsTransactionAuthorizedOrigin, DispatchTransaction, TransactionExtension, + ValidateResult, + }, + transaction_validity::{InvalidTransaction, ValidTransaction}, + }; +} + +/// Utility traits not tied to any direct operation in the runtime. +pub mod utility { + pub use frame_support::traits::{ + Everything, InsideBoth, InstanceFilter, VariantCount, VariantCountOf, + }; +} + /// 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/src/lib.rs b/substrate/frame/tx-pause/src/lib.rs index 989981f99cf4..ed5068aa3a91 100644 --- a/substrate/frame/tx-pause/src/lib.rs +++ b/substrate/frame/tx-pause/src/lib.rs @@ -78,10 +78,7 @@ pub mod weights; extern crate alloc; use alloc::vec::Vec; -use frame::{ - runtime::prelude::*, - traits::{CallMetadata, GetCallMetadata, TransactionPause, TransactionPauseError}, -}; +use frame::runtime::prelude::*; pub use pallet::*; pub use weights::*; diff --git a/substrate/frame/tx-pause/src/mock.rs b/substrate/frame/tx-pause/src/mock.rs index 5fe0cc60ec07..a747a3dc8bdb 100644 --- a/substrate/frame/tx-pause/src/mock.rs +++ b/substrate/frame/tx-pause/src/mock.rs @@ -21,10 +21,7 @@ use super::*; use crate as pallet_tx_pause; -use frame::{ - testing_prelude::*, - traits::{Everything, InsideBoth, InstanceFilter}, -}; +use frame::testing_prelude::*; #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Test { From 9126cd6b4f4d4b46b781b428d41d1246e5529167 Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Mon, 30 Dec 2024 00:01:36 +0100 Subject: [PATCH 7/9] TransactionPause and error not used widely --- substrate/frame/src/lib.rs | 2 +- substrate/frame/tx-pause/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 58acc4ecb135..039246b895fb 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -541,7 +541,7 @@ pub mod hashing { /// This is already part of the [`prelude`]. pub mod transaction { pub use frame_support::traits::{ - CallMetadata, GetCallMetadata, TransactionPause, TransactionPauseError, + CallMetadata, GetCallMetadata, }; pub use sp_runtime::{ generic::ExtensionVersion, diff --git a/substrate/frame/tx-pause/src/lib.rs b/substrate/frame/tx-pause/src/lib.rs index ed5068aa3a91..52d5dc681b9d 100644 --- a/substrate/frame/tx-pause/src/lib.rs +++ b/substrate/frame/tx-pause/src/lib.rs @@ -78,7 +78,7 @@ pub mod weights; extern crate alloc; use alloc::vec::Vec; -use frame::runtime::prelude::*; +use frame::{prelude::*, traits::{TransactionPause, TransactionPauseError}}; pub use pallet::*; pub use weights::*; From 30a8b1efeaa42bdcc0d778b8bcdd321577fd21f6 Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Sat, 4 Jan 2025 04:34:31 +0100 Subject: [PATCH 8/9] no utility prelude --- substrate/frame/src/lib.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 039246b895fb..fc0a2cc61c76 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -203,7 +203,10 @@ pub mod prelude { /// Dispatch types from `frame-support`, other fundamental traits #[doc(no_inline)] pub use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; - pub use frame_support::traits::{Contains, IsSubType, OnRuntimeUpgrade}; + pub use frame_support::traits::{ + Contains, Everything, InsideBoth, InstanceFilter, IsSubType, OnRuntimeUpgrade, + VariantCount, VariantCountOf, + }; /// Pallet prelude of `frame-system`. #[doc(no_inline)] @@ -218,8 +221,6 @@ pub mod prelude { pub use crate::transaction::*; - pub use super::utility::*; - /// Runtime traits #[doc(no_inline)] pub use sp_runtime::traits::{ @@ -540,9 +541,7 @@ pub mod hashing { /// /// This is already part of the [`prelude`]. pub mod transaction { - pub use frame_support::traits::{ - CallMetadata, GetCallMetadata, - }; + pub use frame_support::traits::{CallMetadata, GetCallMetadata}; pub use sp_runtime::{ generic::ExtensionVersion, impl_tx_ext_default, @@ -554,13 +553,6 @@ pub mod transaction { }; } -/// Utility traits not tied to any direct operation in the runtime. -pub mod utility { - pub use frame_support::traits::{ - Everything, InsideBoth, InstanceFilter, VariantCount, VariantCountOf, - }; -} - /// Access to all of the dependencies of this crate. In case the prelude re-exports are not enough, /// this module can be used. /// From a8d89544573deba3f2d2df42e65603b7106f3a87 Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Sat, 4 Jan 2025 05:10:15 +0100 Subject: [PATCH 9/9] match to main --- substrate/frame/src/lib.rs | 4 ++-- substrate/frame/tx-pause/src/lib.rs | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 127d1ed30449..3be103cd511c 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -204,8 +204,8 @@ pub mod prelude { #[doc(no_inline)] pub use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; pub use frame_support::traits::{ - Contains, EstimateNextSessionRotation, Everything, InsideBoth, InstanceFilter, IsSubType, OnRuntimeUpgrade, - VariantCount, VariantCountOf, OneSessionHandler, + Contains, EstimateNextSessionRotation, Everything, InsideBoth, InstanceFilter, IsSubType, + OnRuntimeUpgrade, OneSessionHandler, VariantCount, VariantCountOf, }; /// Pallet prelude of `frame-system`. diff --git a/substrate/frame/tx-pause/src/lib.rs b/substrate/frame/tx-pause/src/lib.rs index 52d5dc681b9d..3d3bca526ed5 100644 --- a/substrate/frame/tx-pause/src/lib.rs +++ b/substrate/frame/tx-pause/src/lib.rs @@ -78,7 +78,10 @@ pub mod weights; extern crate alloc; use alloc::vec::Vec; -use frame::{prelude::*, traits::{TransactionPause, TransactionPauseError}}; +use frame::{ + prelude::*, + traits::{TransactionPause, TransactionPauseError}, +}; pub use pallet::*; pub use weights::*;