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.

7 changes: 7 additions & 0 deletions prdoc/pr_7224.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: Migrate pallet-examples-split to use umbrella crate
doc:
- audience: Runtime Dev
description: Part of https://github.com/paritytech/polkadot-sdk/issues/6504
Nathy-bajo marked this conversation as resolved.
Show resolved Hide resolved
crates:
- name: polkadot-sdk-frame
bump: minor
24 changes: 5 additions & 19 deletions substrate/frame/examples/split/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,18 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { workspace = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
frame = { workspace = true, features = ["experimental", "runtime"]}
Nathy-bajo marked this conversation as resolved.
Show resolved Hide resolved

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",

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
1 change: 0 additions & 1 deletion substrate/frame/examples/split/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
// 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]

Check failure on line 21 in substrate/frame/examples/split/src/events.rs

View workflow job for this annotation

GitHub Actions / cargo-check-all-crate-macos

cannot find attribute `pallet_section` in this scope
mod events {
#[pallet::event]

Check failure on line 23 in substrate/frame/examples/split/src/events.rs

View workflow job for this annotation

GitHub Actions / cargo-check-all-crate-macos

failed to resolve: use of undeclared crate or module `pallet`
#[pallet::generate_deposit(pub(super) fn deposit_event)]

Check failure on line 24 in substrate/frame/examples/split/src/events.rs

View workflow job for this annotation

GitHub Actions / cargo-check-all-crate-macos

failed to resolve: use of undeclared crate or module `pallet`
pub enum Event<T: Config> {
/// Event documentation should end with an array that provides descriptive names for event
/// parameters. [something, who]
SomethingStored { something: u32, who: T::AccountId },

Check failure on line 28 in substrate/frame/examples/split/src/events.rs

View workflow job for this annotation

GitHub Actions / cargo-check-all-crate-macos

associated type `AccountId` not found for `T`
}
}
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 @@ -26,7 +26,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

// Re-export pallet items so that they can be accessed from the crate namespace.
pub use pallet::*;

Check failure on line 29 in substrate/frame/examples/split/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo-check-all-crate-macos

unresolved import `pallet`

#[cfg(test)]
mod mock;
Expand All @@ -34,23 +34,21 @@
#[cfg(test)]
mod tests;

#[cfg(feature = "runtime-benchmarks")]

Check failure on line 37 in substrate/frame/examples/split/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo-check-all-crate-macos

unexpected `cfg` condition value: `runtime-benchmarks`
mod benchmarking;
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)]

Check failure on line 48 in substrate/frame/examples/split/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo-check-all-crate-macos

failed to resolve: could not find `__export_tokens_tt_events` in `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 @@ -230,10 +230,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};
/// Other error/result types for runtime
#[doc(no_inline)]
pub use sp_runtime::{
Expand Down
Loading