From 70b0b4b3cddbdb1fd74cf2e3f8dbe025ba57879e Mon Sep 17 00:00:00 2001 From: runcomet Date: Tue, 19 Nov 2024 07:06:00 -0800 Subject: [PATCH 1/5] frame::prelude --- Cargo.lock | 4 +--- substrate/frame/alliance/Cargo.toml | 20 ++++---------------- substrate/frame/alliance/src/lib.rs | 8 ++++++-- substrate/frame/alliance/src/migration.rs | 3 ++- substrate/frame/alliance/src/types.rs | 5 +++-- substrate/frame/alliance/src/weights.rs | 3 ++- 6 files changed, 18 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 119a8b3afed2..d1b8c5e22a3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10601,14 +10601,12 @@ name = "pallet-alliance" version = "27.0.0" dependencies = [ "array-bytes", - "frame-benchmarking", - "frame-support", - "frame-system", "log", "pallet-balances", "pallet-collective", "pallet-identity", "parity-scale-codec", + "polkadot-sdk-frame", "scale-info", "sp-core 28.0.0", "sp-crypto-hashing 0.1.0", diff --git a/substrate/frame/alliance/Cargo.toml b/substrate/frame/alliance/Cargo.toml index 451b86b35dde..732a97bb8d54 100644 --- a/substrate/frame/alliance/Cargo.toml +++ b/substrate/frame/alliance/Cargo.toml @@ -27,9 +27,7 @@ sp-crypto-hashing = { optional = true, workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -frame-benchmarking = { optional = true, workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"] } pallet-identity = { workspace = true } pallet-collective = { optional = true, workspace = true } @@ -44,35 +42,25 @@ pallet-collective = { workspace = true, default-features = true } default = ["std"] std = [ "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", + "frame/std", "log/std", "pallet-balances/std", "pallet-collective?/std", "pallet-identity/std", "scale-info/std", - "sp-core/std", "sp-crypto-hashing?/std", - "sp-io/std", - "sp-runtime/std", ] runtime-benchmarks = [ "array-bytes", - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-identity/runtime-benchmarks", "sp-crypto-hashing", - "sp-runtime/runtime-benchmarks", ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", + "frame/try-runtime", "pallet-balances/try-runtime", "pallet-collective?/try-runtime", "pallet-identity/try-runtime", - "sp-runtime/try-runtime", ] diff --git a/substrate/frame/alliance/src/lib.rs b/substrate/frame/alliance/src/lib.rs index be65f49e6e4e..9c956adb3a60 100644 --- a/substrate/frame/alliance/src/lib.rs +++ b/substrate/frame/alliance/src/lib.rs @@ -98,6 +98,8 @@ extern crate alloc; use alloc::{boxed::Box, vec, vec::Vec}; use codec::{Decode, Encode, MaxEncodedLen}; +use frame::{prelude::*, traits::{Dispatchable, Saturating, StaticLookup, Zero}, deps::sp_runtime::DispatchError, derive::DefaultNoBound}; +/* use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; use sp_runtime::{ @@ -114,6 +116,7 @@ use frame_support::{ }, weights::Weight, }; +*/ use scale_info::TypeInfo; pub use pallet::*; @@ -215,7 +218,8 @@ type UnscrupulousItemOf = type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; -#[frame_support::pallet] +// #[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; @@ -399,7 +403,7 @@ pub mod pallet { } #[pallet::genesis_config] - #[derive(frame_support::DefaultNoBound)] + #[derive(frame::derive::DefaultNoBound)] pub struct GenesisConfig, I: 'static = ()> { pub fellows: Vec, pub allies: Vec, diff --git a/substrate/frame/alliance/src/migration.rs b/substrate/frame/alliance/src/migration.rs index b4ecc1819447..7f66310f5871 100644 --- a/substrate/frame/alliance/src/migration.rs +++ b/substrate/frame/alliance/src/migration.rs @@ -16,7 +16,8 @@ // limitations under the License. use crate::{Config, Pallet, Weight, LOG_TARGET}; -use frame_support::{pallet_prelude::*, storage::migration, traits::OnRuntimeUpgrade}; +//use frame_support::{pallet_prelude::*, storage::migration, traits::OnRuntimeUpgrade}; +use frame::{prelude::*, traits::OnRuntimeUpgrade, deps::frame_support::storage::migration}; use log; /// The in-code storage version. diff --git a/substrate/frame/alliance/src/types.rs b/substrate/frame/alliance/src/types.rs index 75b949c19b32..103234c4cf20 100644 --- a/substrate/frame/alliance/src/types.rs +++ b/substrate/frame/alliance/src/types.rs @@ -17,9 +17,10 @@ use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; -use frame_support::{traits::ConstU32, BoundedVec}; +// use frame_support::{traits::ConstU32, BoundedVec}; use scale_info::TypeInfo; -use sp_runtime::RuntimeDebug; +// use sp_runtime::RuntimeDebug; +use frame::{runtime::prelude::ConstU32, derive::RuntimeDebug, deps::frame_support::BoundedVec}; /// A Multihash instance that only supports the basic functionality and no hashing. #[derive( diff --git a/substrate/frame/alliance/src/weights.rs b/substrate/frame/alliance/src/weights.rs index 0184ac91107c..87034066ad34 100644 --- a/substrate/frame/alliance/src/weights.rs +++ b/substrate/frame/alliance/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_alliance`. From 8c9c6cf4d098ca9ec703c533fa716ecc50adb2cd Mon Sep 17 00:00:00 2001 From: runcomet Date: Tue, 19 Nov 2024 14:15:02 -0800 Subject: [PATCH 2/5] comp imports --- Cargo.lock | 3 ++- substrate/frame/alliance/Cargo.toml | 1 + substrate/frame/alliance/src/benchmarking.rs | 8 +++++--- substrate/frame/alliance/src/lib.rs | 9 ++++++++- substrate/frame/alliance/src/migration.rs | 4 +++- substrate/frame/alliance/src/mock.rs | 19 +++++++++++++++++-- substrate/frame/alliance/src/tests.rs | 4 +++- substrate/frame/alliance/src/types.rs | 2 +- 8 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad9d0f898f5b..b504ab366491 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11612,7 +11612,8 @@ dependencies = [ "pallet-collective 28.0.0", "pallet-identity 29.0.0", "parity-scale-codec", - "polkadot-sdk-frame", + "polkadot-sdk-frame 0.1.0", + "pretty_assertions", "scale-info", "sp-core 28.0.0", "sp-crypto-hashing 0.1.0", diff --git a/substrate/frame/alliance/Cargo.toml b/substrate/frame/alliance/Cargo.toml index 732a97bb8d54..9c58ca9fccbb 100644 --- a/substrate/frame/alliance/Cargo.toml +++ b/substrate/frame/alliance/Cargo.toml @@ -37,6 +37,7 @@ array-bytes = { workspace = true, default-features = true } sp-crypto-hashing = { workspace = true } pallet-balances = { workspace = true, default-features = true } pallet-collective = { workspace = true, default-features = true } +pretty_assertions = { workspace = true } [features] default = ["std"] diff --git a/substrate/frame/alliance/src/benchmarking.rs b/substrate/frame/alliance/src/benchmarking.rs index 09e2045555b6..c7a8312f648e 100644 --- a/substrate/frame/alliance/src/benchmarking.rs +++ b/substrate/frame/alliance/src/benchmarking.rs @@ -20,13 +20,15 @@ #![cfg(feature = "runtime-benchmarks")] use core::{cmp, mem::size_of}; +/* use sp_runtime::traits::{Bounded, Hash, StaticLookup}; use frame_benchmarking::{account, v2::*, BenchmarkError}; use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System, RawOrigin as SystemOrigin}; - +*/ use super::{Call as AllianceCall, Pallet as Alliance, *}; +use frame::{benchmarking::prelude::*, deps::{frame_system::{Pallet as System, RawOrigin as SystemOrigin}, frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}}}; const SEED: u32 = 0; @@ -193,7 +195,7 @@ mod benchmarks { // Whitelist voter account from further DB operations. let voter_key = frame_system::Account::::hashed_key_for(&voter); - frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into()); + add_to_whitelist(voter_key.into()); #[extrinsic_call] _(SystemOrigin::Signed(voter), last_hash, index, approve); @@ -264,7 +266,7 @@ mod benchmarks { // Whitelist voter account from further DB operations. let voter_key = frame_system::Account::::hashed_key_for(&voter); - frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into()); + add_to_whitelist(voter_key.into()); #[extrinsic_call] close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage); diff --git a/substrate/frame/alliance/src/lib.rs b/substrate/frame/alliance/src/lib.rs index 9c956adb3a60..4b57cd29cbeb 100644 --- a/substrate/frame/alliance/src/lib.rs +++ b/substrate/frame/alliance/src/lib.rs @@ -98,7 +98,14 @@ extern crate alloc; use alloc::{boxed::Box, vec, vec::Vec}; use codec::{Decode, Encode, MaxEncodedLen}; -use frame::{prelude::*, traits::{Dispatchable, Saturating, StaticLookup, Zero}, deps::sp_runtime::DispatchError, derive::DefaultNoBound}; +use frame::{ + deps::sp_runtime::DispatchError, + prelude::*, + traits::{ + ChangeMembers, Currency, Dispatchable, InitializeMembers, OnUnbalanced, ReservableCurrency, + Saturating, StaticLookup, Zero, + }, +}; /* use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; diff --git a/substrate/frame/alliance/src/migration.rs b/substrate/frame/alliance/src/migration.rs index 7f66310f5871..c0113ba88fa7 100644 --- a/substrate/frame/alliance/src/migration.rs +++ b/substrate/frame/alliance/src/migration.rs @@ -17,7 +17,7 @@ use crate::{Config, Pallet, Weight, LOG_TARGET}; //use frame_support::{pallet_prelude::*, storage::migration, traits::OnRuntimeUpgrade}; -use frame::{prelude::*, traits::OnRuntimeUpgrade, deps::frame_support::storage::migration}; +use frame::{deps::frame_support::storage::migration, prelude::*, traits::OnRuntimeUpgrade}; use log; /// The in-code storage version. @@ -163,6 +163,8 @@ pub(crate) mod v1_to_v2 { #[cfg(test)] mod test { use super::*; + use frame::testing_prelude::assert_ok; + use pretty_assertions::assert_eq; use crate::{mock::*, MemberRole, Members}; #[test] diff --git a/substrate/frame/alliance/src/mock.rs b/substrate/frame/alliance/src/mock.rs index 625cabf3457f..5013e105dfbd 100644 --- a/substrate/frame/alliance/src/mock.rs +++ b/substrate/frame/alliance/src/mock.rs @@ -16,7 +16,7 @@ // limitations under the License. //! Test utilities - +/* pub use sp_core::H256; use sp_runtime::traits::Hash; pub use sp_runtime::{ @@ -29,6 +29,21 @@ pub use frame_support::{ traits::EitherOfDiverse, BoundedVec, }; use frame_system::{EnsureRoot, EnsureSignedBy}; +*/ +use frame::{ + deps::{ + frame_support::{traits::EitherOfDiverse, BoundedVec}, + sp_runtime::traits::{IdentifyAccount, Lazy, Verify}, + }, + runtime::{ + prelude::{ + construct_runtime, derive_impl, ord_parameter_types, parameter_types, EnsureRoot, + EnsureSignedBy, + }, + testing_prelude::BuildStorage, + }, + testing_prelude::{assert_noop, assert_ok}, +}; use pallet_identity::{ legacy::{IdentityField, IdentityInfo}, Data, IdentityOf, Judgement, SuperOf, @@ -237,7 +252,7 @@ impl Config for Test { type Block = frame_system::mocking::MockBlock; -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, diff --git a/substrate/frame/alliance/src/tests.rs b/substrate/frame/alliance/src/tests.rs index 2397ebfe7db4..3d412f51fd8a 100644 --- a/substrate/frame/alliance/src/tests.rs +++ b/substrate/frame/alliance/src/tests.rs @@ -17,12 +17,14 @@ //! Tests for the alliance pallet. +/* use frame_support::{assert_noop, assert_ok}; use frame_system::{EventRecord, Phase}; use sp_runtime::traits::BadOrigin; - +*/ use super::*; use crate::{self as alliance, mock::*}; +use frame::{testing_prelude::{assert_noop, assert_ok}, deps::{sp_runtime::DispatchError::BadOrigin, frame_system::{EventRecord, Phase}}}; type AllianceMotionEvent = pallet_collective::Event; diff --git a/substrate/frame/alliance/src/types.rs b/substrate/frame/alliance/src/types.rs index 103234c4cf20..04e4e78b6130 100644 --- a/substrate/frame/alliance/src/types.rs +++ b/substrate/frame/alliance/src/types.rs @@ -20,7 +20,7 @@ use codec::{Decode, Encode, MaxEncodedLen}; // use frame_support::{traits::ConstU32, BoundedVec}; use scale_info::TypeInfo; // use sp_runtime::RuntimeDebug; -use frame::{runtime::prelude::ConstU32, derive::RuntimeDebug, deps::frame_support::BoundedVec}; +use frame::{deps::frame_support::BoundedVec, derive::RuntimeDebug, runtime::prelude::ConstU32}; /// A Multihash instance that only supports the basic functionality and no hashing. #[derive( From f100e33450a8b836ffe6ec97dff26c0946184bb4 Mon Sep 17 00:00:00 2001 From: runcomet Date: Fri, 22 Nov 2024 19:24:40 -0800 Subject: [PATCH 3/5] cargo fmt --- substrate/frame/alliance/src/benchmarking.rs | 17 ++++++++--------- substrate/frame/alliance/src/lib.rs | 18 ------------------ substrate/frame/alliance/src/migration.rs | 3 +-- substrate/frame/alliance/src/mock.rs | 14 -------------- substrate/frame/alliance/src/tests.rs | 13 +++++++------ substrate/frame/alliance/src/types.rs | 4 +--- substrate/frame/alliance/src/weights.rs | 1 - 7 files changed, 17 insertions(+), 53 deletions(-) diff --git a/substrate/frame/alliance/src/benchmarking.rs b/substrate/frame/alliance/src/benchmarking.rs index c7a8312f648e..94cee5a7c811 100644 --- a/substrate/frame/alliance/src/benchmarking.rs +++ b/substrate/frame/alliance/src/benchmarking.rs @@ -19,16 +19,15 @@ #![cfg(feature = "runtime-benchmarks")] -use core::{cmp, mem::size_of}; -/* -use sp_runtime::traits::{Bounded, Hash, StaticLookup}; - -use frame_benchmarking::{account, v2::*, BenchmarkError}; -use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; -use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System, RawOrigin as SystemOrigin}; -*/ use super::{Call as AllianceCall, Pallet as Alliance, *}; -use frame::{benchmarking::prelude::*, deps::{frame_system::{Pallet as System, RawOrigin as SystemOrigin}, frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}}}; +use core::{cmp, mem::size_of}; +use frame::{ + benchmarking::prelude::*, + deps::{ + frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}, + frame_system::{Pallet as System, RawOrigin as SystemOrigin}, + }, +}; const SEED: u32 = 0; diff --git a/substrate/frame/alliance/src/lib.rs b/substrate/frame/alliance/src/lib.rs index 4b57cd29cbeb..9c280bcd97b9 100644 --- a/substrate/frame/alliance/src/lib.rs +++ b/substrate/frame/alliance/src/lib.rs @@ -106,24 +106,6 @@ use frame::{ Saturating, StaticLookup, Zero, }, }; -/* -use frame_support::pallet_prelude::*; -use frame_system::pallet_prelude::*; -use sp_runtime::{ - traits::{Dispatchable, Saturating, StaticLookup, Zero}, - DispatchError, RuntimeDebug, -}; - -use frame_support::{ - dispatch::{DispatchResult, DispatchResultWithPostInfo, GetDispatchInfo, PostDispatchInfo}, - ensure, - traits::{ - ChangeMembers, Currency, Get, InitializeMembers, IsSubType, OnUnbalanced, - ReservableCurrency, - }, - weights::Weight, -}; -*/ use scale_info::TypeInfo; pub use pallet::*; diff --git a/substrate/frame/alliance/src/migration.rs b/substrate/frame/alliance/src/migration.rs index c0113ba88fa7..c75574be7143 100644 --- a/substrate/frame/alliance/src/migration.rs +++ b/substrate/frame/alliance/src/migration.rs @@ -16,7 +16,6 @@ // limitations under the License. use crate::{Config, Pallet, Weight, LOG_TARGET}; -//use frame_support::{pallet_prelude::*, storage::migration, traits::OnRuntimeUpgrade}; use frame::{deps::frame_support::storage::migration, prelude::*, traits::OnRuntimeUpgrade}; use log; @@ -163,9 +162,9 @@ pub(crate) mod v1_to_v2 { #[cfg(test)] mod test { use super::*; + use crate::{mock::*, MemberRole, Members}; use frame::testing_prelude::assert_ok; use pretty_assertions::assert_eq; - use crate::{mock::*, MemberRole, Members}; #[test] fn migration_v1_to_v2_works() { diff --git a/substrate/frame/alliance/src/mock.rs b/substrate/frame/alliance/src/mock.rs index 5013e105dfbd..685a87247e79 100644 --- a/substrate/frame/alliance/src/mock.rs +++ b/substrate/frame/alliance/src/mock.rs @@ -16,20 +16,6 @@ // limitations under the License. //! Test utilities -/* -pub use sp_core::H256; -use sp_runtime::traits::Hash; -pub use sp_runtime::{ - traits::{BlakeTwo256, IdentifyAccount, Lazy, Verify}, - BuildStorage, -}; - -pub use frame_support::{ - assert_noop, assert_ok, derive_impl, ord_parameter_types, parameter_types, - traits::EitherOfDiverse, BoundedVec, -}; -use frame_system::{EnsureRoot, EnsureSignedBy}; -*/ use frame::{ deps::{ frame_support::{traits::EitherOfDiverse, BoundedVec}, diff --git a/substrate/frame/alliance/src/tests.rs b/substrate/frame/alliance/src/tests.rs index 3d412f51fd8a..6827476a5838 100644 --- a/substrate/frame/alliance/src/tests.rs +++ b/substrate/frame/alliance/src/tests.rs @@ -17,14 +17,15 @@ //! Tests for the alliance pallet. -/* -use frame_support::{assert_noop, assert_ok}; -use frame_system::{EventRecord, Phase}; -use sp_runtime::traits::BadOrigin; -*/ use super::*; use crate::{self as alliance, mock::*}; -use frame::{testing_prelude::{assert_noop, assert_ok}, deps::{sp_runtime::DispatchError::BadOrigin, frame_system::{EventRecord, Phase}}}; +use frame::{ + deps::{ + frame_system::{EventRecord, Phase}, + sp_runtime::DispatchError::BadOrigin, + }, + testing_prelude::{assert_noop, assert_ok}, +}; type AllianceMotionEvent = pallet_collective::Event; diff --git a/substrate/frame/alliance/src/types.rs b/substrate/frame/alliance/src/types.rs index 04e4e78b6130..15c1917cae18 100644 --- a/substrate/frame/alliance/src/types.rs +++ b/substrate/frame/alliance/src/types.rs @@ -17,10 +17,8 @@ use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; -// use frame_support::{traits::ConstU32, BoundedVec}; -use scale_info::TypeInfo; -// use sp_runtime::RuntimeDebug; use frame::{deps::frame_support::BoundedVec, derive::RuntimeDebug, runtime::prelude::ConstU32}; +use scale_info::TypeInfo; /// A Multihash instance that only supports the basic functionality and no hashing. #[derive( diff --git a/substrate/frame/alliance/src/weights.rs b/substrate/frame/alliance/src/weights.rs index cd4b4cd9fee3..b06a0913a5b9 100644 --- a/substrate/frame/alliance/src/weights.rs +++ b/substrate/frame/alliance/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 a152e9ec11ac4ac43ae2027a4022133a610217a9 Mon Sep 17 00:00:00 2001 From: runcomet Date: Fri, 29 Nov 2024 07:15:15 -0800 Subject: [PATCH 4/5] add BoundedVec to frame::runtime::prelude --- prdoc/pr_6541.prdoc | 15 +++++++++++++++ substrate/frame/alliance/src/lib.rs | 1 - substrate/frame/alliance/src/migration.rs | 5 ++++- substrate/frame/alliance/src/mock.rs | 9 +++------ substrate/frame/alliance/src/types.rs | 5 ++++- substrate/frame/src/lib.rs | 3 +++ 6 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 prdoc/pr_6541.prdoc diff --git a/prdoc/pr_6541.prdoc b/prdoc/pr_6541.prdoc new file mode 100644 index 000000000000..cae7a88f93c0 --- /dev/null +++ b/prdoc/pr_6541.prdoc @@ -0,0 +1,15 @@ +# 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-alliance to umbrella crate. + +doc: + - audience: Runtime Dev + description: | + Imports frame umbrella crate systems into pallet-alliance. + +crates: + - name: pallet-alliance + bump: minor + - name: polkadot-sdk-frame + bump: minor diff --git a/substrate/frame/alliance/src/lib.rs b/substrate/frame/alliance/src/lib.rs index 9c280bcd97b9..8458b5096e95 100644 --- a/substrate/frame/alliance/src/lib.rs +++ b/substrate/frame/alliance/src/lib.rs @@ -207,7 +207,6 @@ type UnscrupulousItemOf = type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; -// #[frame_support::pallet] #[frame::pallet] pub mod pallet { use super::*; diff --git a/substrate/frame/alliance/src/migration.rs b/substrate/frame/alliance/src/migration.rs index c75574be7143..012792dcbd28 100644 --- a/substrate/frame/alliance/src/migration.rs +++ b/substrate/frame/alliance/src/migration.rs @@ -16,7 +16,10 @@ // limitations under the License. use crate::{Config, Pallet, Weight, LOG_TARGET}; -use frame::{deps::frame_support::storage::migration, prelude::*, traits::OnRuntimeUpgrade}; +use frame::{ + deps::frame_support::{pallet_prelude::*, storage::migration}, + traits::OnRuntimeUpgrade, +}; use log; /// The in-code storage version. diff --git a/substrate/frame/alliance/src/mock.rs b/substrate/frame/alliance/src/mock.rs index 685a87247e79..f44dfec2c0de 100644 --- a/substrate/frame/alliance/src/mock.rs +++ b/substrate/frame/alliance/src/mock.rs @@ -17,18 +17,15 @@ //! Test utilities use frame::{ - deps::{ - frame_support::{traits::EitherOfDiverse, BoundedVec}, - sp_runtime::traits::{IdentifyAccount, Lazy, Verify}, - }, runtime::{ prelude::{ - construct_runtime, derive_impl, ord_parameter_types, parameter_types, EnsureRoot, - EnsureSignedBy, + construct_runtime, derive_impl, ord_parameter_types, parameter_types, BoundedVec, + EnsureRoot, EnsureSignedBy, }, testing_prelude::BuildStorage, }, testing_prelude::{assert_noop, assert_ok}, + traits::{EitherOfDiverse, IdentifyAccount, Lazy, Verify}, }; use pallet_identity::{ legacy::{IdentityField, IdentityInfo}, diff --git a/substrate/frame/alliance/src/types.rs b/substrate/frame/alliance/src/types.rs index 15c1917cae18..b1d048088385 100644 --- a/substrate/frame/alliance/src/types.rs +++ b/substrate/frame/alliance/src/types.rs @@ -17,7 +17,10 @@ use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; -use frame::{deps::frame_support::BoundedVec, derive::RuntimeDebug, runtime::prelude::ConstU32}; +use frame::{ + derive::RuntimeDebug, + runtime::prelude::{BoundedVec, ConstU32}, +}; use scale_info::TypeInfo; /// A Multihash instance that only supports the basic functionality and no hashing. diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 03d815e349df..1a46818d556e 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -342,6 +342,9 @@ pub mod runtime { /// Consider using the new version of this [`frame_construct_runtime`]. pub use frame_support::construct_runtime; + /// Related to runtime contruction. + pub use frame_support::BoundedVec; + /// Macro to amalgamate the runtime into `struct Runtime`. /// /// This is the newer version of [`construct_runtime`]. From b90040baa752b7dc9d72b7ff65f7e12697833f24 Mon Sep 17 00:00:00 2001 From: runcomet Date: Fri, 29 Nov 2024 10:51:48 -0800 Subject: [PATCH 5/5] remove primitives --- Cargo.lock | 3 --- prdoc/pr_6541.prdoc | 4 +++- substrate/frame/alliance/Cargo.toml | 7 ------- substrate/frame/alliance/src/mock.rs | 11 ++++++----- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 544a8e3544a3..ee73e19ca435 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11646,10 +11646,7 @@ dependencies = [ "polkadot-sdk-frame 0.1.0", "pretty_assertions", "scale-info", - "sp-core 28.0.0", "sp-crypto-hashing 0.1.0", - "sp-io 30.0.0", - "sp-runtime 31.0.1", ] [[package]] diff --git a/prdoc/pr_6541.prdoc b/prdoc/pr_6541.prdoc index cae7a88f93c0..d443f0d6e75b 100644 --- a/prdoc/pr_6541.prdoc +++ b/prdoc/pr_6541.prdoc @@ -6,7 +6,9 @@ title: migrate pallet-alliance to umbrella crate. doc: - audience: Runtime Dev description: | - Imports frame umbrella crate systems into pallet-alliance. + Imports frame umbrella crate systems into pallet-alliance and + exports BoundedVec as part of runtime::prelude of the + polkadot-sdk-frame crate. crates: - name: pallet-alliance diff --git a/substrate/frame/alliance/Cargo.toml b/substrate/frame/alliance/Cargo.toml index 9c58ca9fccbb..0963927f54da 100644 --- a/substrate/frame/alliance/Cargo.toml +++ b/substrate/frame/alliance/Cargo.toml @@ -18,17 +18,10 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = { optional = true, workspace = true, default-features = true } log = { workspace = true } - codec = { features = ["derive"], workspace = true } scale-info = { features = ["derive"], workspace = true } - -sp-core = { workspace = true } sp-crypto-hashing = { optional = true, workspace = true } -sp-io = { workspace = true } -sp-runtime = { workspace = true } - frame = { workspace = true, features = ["experimental", "runtime"] } - pallet-identity = { workspace = true } pallet-collective = { optional = true, workspace = true } diff --git a/substrate/frame/alliance/src/mock.rs b/substrate/frame/alliance/src/mock.rs index f44dfec2c0de..534b92a18c0c 100644 --- a/substrate/frame/alliance/src/mock.rs +++ b/substrate/frame/alliance/src/mock.rs @@ -17,6 +17,7 @@ //! Test utilities use frame::{ + arithmetic::Perbill, runtime::{ prelude::{ construct_runtime, derive_impl, ord_parameter_types, parameter_types, BoundedVec, @@ -24,7 +25,7 @@ use frame::{ }, testing_prelude::BuildStorage, }, - testing_prelude::{assert_noop, assert_ok}, + testing_prelude::{assert_noop, assert_ok, TestExternalities}, traits::{EitherOfDiverse, IdentifyAccount, Lazy, Verify}, }; use pallet_identity::{ @@ -61,7 +62,7 @@ parameter_types! { pub const MotionDuration: BlockNumber = MOTION_DURATION_IN_BLOCKS; pub const MaxProposals: u32 = 100; pub const MaxMembers: u32 = 100; - pub MaxProposalWeight: Weight = sp_runtime::Perbill::from_percent(50) * BlockWeights::get().max_block; + pub MaxProposalWeight: Weight = Perbill::from_percent(50) * BlockWeights::get().max_block; } type AllianceCollective = pallet_collective::Instance1; impl pallet_collective::Config for Test { @@ -266,7 +267,7 @@ pub(super) fn test_identity_info_deposit() -> : byte_deposit * test_identity_info().encoded_size() as u64 + basic_deposit } -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:: { @@ -293,7 +294,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(|| { assert_ok!(Identity::add_registrar(RuntimeOrigin::signed(1), 1)); @@ -370,7 +371,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { } #[cfg(feature = "runtime-benchmarks")] -pub fn new_bench_ext() -> sp_io::TestExternalities { +pub fn new_bench_ext() -> TestExternalities { RuntimeGenesisConfig::default().build_storage().unwrap().into() }