Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate pallet-examples-split to use umbrella crate #7224

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
6 changes: 1 addition & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions prdoc/pr_7224.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
title: '[pallet-examples-split] Migrate to using frame umbrella crate'

doc:
- audience: Runtime Dev
description: This PR migrates the pallet-examples-split to use the frame umbrella crate. This
is part of the ongoing effort to migrate all pallets to use the frame umbrella crate.
The effort is tracked [here](https://github.com/paritytech/polkadot-sdk/issues/6504).

crates:
- name: pallet-examples-split
bump: minor
- name: polkadot-sdk-frame
bump: minor
26 changes: 8 additions & 18 deletions substrate/frame/examples/split/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,22 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { workspace = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
frame = { workspace = true, features = ["runtime"]}

frame-support = { workspace = true }
frame-system = { workspace = true }

sp-io = { workspace = true }

frame-benchmarking = { optional = true, workspace = true }

[dev-dependencies]
sp-core = { workspace = true }

[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"log/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"frame/std",
]

runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"frame/runtime-benchmarks",
]

try-runtime = [
"frame/try-runtime",
]
try-runtime = ["frame-support/try-runtime", "frame-system/try-runtime"]
3 changes: 1 addition & 2 deletions substrate/frame/examples/split/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ use super::*;

#[allow(unused)]
use crate::Pallet as Template;
use frame_benchmarking::v2::*;
use frame_system::RawOrigin;
use frame::benchmarking::prelude::*;

#[benchmarks]
mod benchmarks {
Expand Down
3 changes: 1 addition & 2 deletions substrate/frame/examples/split/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use frame_support::pallet_macros::*;

/// A [`pallet_section`] that defines the events for a pallet.
/// This can later be imported into the pallet using [`import_section`].
#[pallet_section]
#[frame::pallet_section]
mod events {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
Expand Down
6 changes: 2 additions & 4 deletions substrate/frame/examples/split/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ mod events;
pub mod weights;
pub use weights::*;

use frame_support::pallet_macros::*;
use frame::prelude::*;

/// Imports a [`pallet_section`] defined at [`events::events`].
/// This brings the events defined in that section into the pallet's namespace.
#[import_section(events::events)]
#[frame_support::pallet]
#[frame::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;

#[pallet::pallet]
pub struct Pallet<T>(_);
Expand Down
8 changes: 4 additions & 4 deletions substrate/frame/examples/split/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
// limitations under the License.

use crate as pallet_template;
use frame_support::{derive_impl, sp_runtime::BuildStorage};
use frame::testing_prelude::*;

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

// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
construct_runtime!(
pub enum Test
{
System: frame_system,
Expand All @@ -42,6 +42,6 @@ impl pallet_template::Config for Test {
}

// Build genesis storage according to the mock runtime.
pub fn new_test_ext() -> sp_io::TestExternalities {
pub fn new_test_ext() -> TestState {
frame_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
}
2 changes: 1 addition & 1 deletion substrate/frame/examples/split/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// limitations under the License.

use crate::{mock::*, Error, Event, Something};
use frame_support::{assert_noop, assert_ok};
use frame::testing_prelude::*;

#[test]
fn it_works_for_default_value() {
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/examples/split/src/weights.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions substrate/frame/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ pub mod prelude {

/// Runtime traits
#[doc(no_inline)]
pub use sp_runtime::traits::{
pub use sp_runtime::{traits::{
BlockNumberProvider, Bounded, Convert, DispatchInfoOf, Dispatchable, ReduceBy,
ReplaceWithDefault, SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput,
};
}, BuildStorage};

/// Bounded storage related types.
pub use sp_runtime::{BoundedSlice, BoundedVec};
Expand Down
Loading