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-dev-mode & pallet-example-kitchensink to umbrella crate #6907

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions Cargo.lock

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

18 changes: 3 additions & 15 deletions substrate/frame/examples/dev-mode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,19 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { workspace = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame = { workspace = true, features = ["experimental", "runtime"] }
pallet-balances = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }

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

[features]
default = ["std"]
std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"frame/std",
"log/std",
"pallet-balances/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame/try-runtime",
"pallet-balances/try-runtime",
"sp-runtime/try-runtime",
]
7 changes: 2 additions & 5 deletions substrate/frame/examples/dev-mode/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
extern crate alloc;

use alloc::{vec, vec::Vec};
use frame_support::dispatch::DispatchResult;
use frame_system::ensure_signed;
use frame::prelude::*;

// Re-export pallet items so that they can be accessed from the crate namespace.
pub use pallet::*;
Expand All @@ -44,11 +43,9 @@ mod tests;
type BalanceOf<T> = <T as pallet_balances::Config>::Balance;

/// Enable `dev_mode` for this pallet.
#[frame_support::pallet(dev_mode)]
#[frame::pallet(dev_mode)]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;

#[pallet::config]
pub trait Config: pallet_balances::Config + frame_system::Config {
Expand Down
9 changes: 2 additions & 7 deletions substrate/frame/examples/dev-mode/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,14 @@
//! Tests for pallet-dev-mode.

use crate::*;
use frame_support::{assert_ok, derive_impl};
use sp_core::H256;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
use frame::testing_prelude::*;
// Reexport crate as its pallet name for construct_runtime.
use crate as pallet_dev_mode;

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

// For testing the pallet, we construct a mock runtime.
frame_support::construct_runtime!(
construct_runtime!(
pub enum Test
{
System: frame_system,
Expand Down
24 changes: 4 additions & 20 deletions substrate/frame/examples/kitchensink/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ codec = { workspace = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }

frame-support = { features = ["experimental"], workspace = true }
frame-system = { workspace = true }

sp-io = { workspace = true }
sp-runtime = { workspace = true }

frame-benchmarking = { optional = true, workspace = true }
frame = { workspace = true, features = ["experimental", "runtime"] }

pallet-balances = { workspace = true }

Expand All @@ -37,26 +31,16 @@ sp-core = { workspace = true }
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"frame/std",
"log/std",
"pallet-balances/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",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame/try-runtime",
"pallet-balances/try-runtime",
"sp-runtime/try-runtime",
]
3 changes: 1 addition & 2 deletions substrate/frame/examples/kitchensink/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ use super::*;
#[allow(unused)]
use crate::Pallet as Kitchensink;

use frame_benchmarking::v2::*;
use frame_system::RawOrigin;
use frame::benchmarking::prelude::*;

// To actually run this benchmark on pallet-example-kitchensink, we need to put this pallet into the
// runtime and compile it with `runtime-benchmarks` feature. The detail procedures are
Expand Down
11 changes: 5 additions & 6 deletions substrate/frame/examples/kitchensink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ mod tests;
mod benchmarking;

#[cfg(feature = "try-runtime")]
use sp_runtime::TryRuntimeError;
use frame::try_runtime::TryRuntimeError;

pub mod weights;
pub use weights::*;

extern crate alloc;
pub use frame::prelude::*;

#[frame_support::pallet]
#[frame::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;

/// The config trait of the pallet. You can basically do anything with the config trait that you
/// can do with a normal rust trait: import items consisting of types, constants and functions.
Expand Down Expand Up @@ -76,7 +75,7 @@ pub mod pallet {
type WeightInfo: WeightInfo;

/// This is a normal Rust type, nothing specific to FRAME here.
type Currency: frame_support::traits::fungible::Inspect<Self::AccountId>;
type Currency: frame::traits::fungible::Inspect<Self::AccountId>;

/// Similarly, let the runtime decide this.
fn some_function() -> u32;
Expand Down Expand Up @@ -104,7 +103,7 @@ pub mod pallet {
}
}

const STORAGE_VERSION: frame_support::traits::StorageVersion = StorageVersion::new(1);
const STORAGE_VERSION: frame::traits::StorageVersion = StorageVersion::new(1);

/// The pallet struct. There's nothing special to FRAME about this; it can implement functions
/// in an impl blocks, traits and so on.
Expand Down
9 changes: 4 additions & 5 deletions substrate/frame/examples/kitchensink/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
//! Tests for pallet-example-kitchensink.

use crate::*;
use frame_support::{assert_ok, derive_impl, parameter_types, traits::VariantCountOf};
use sp_runtime::BuildStorage;
use frame::testing_prelude::*;
// Reexport crate as its pallet name for construct_runtime.
use crate as pallet_example_kitchensink;

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

// For testing the pallet, we construct a mock runtime.
frame_support::construct_runtime!(
construct_runtime!(
pub enum Test
{
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Expand All @@ -48,7 +47,7 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
type WeightInfo = ();
type FreezeIdentifier = RuntimeFreezeReason;
type MaxFreezes = VariantCountOf<RuntimeFreezeReason>;
type MaxFreezes = frame::traits::VariantCountOf<RuntimeFreezeReason>;
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
}
Expand All @@ -73,7 +72,7 @@ impl Config for Test {

// This function basically just builds a genesis storage key/value store according to
// our desired mockup.
pub fn new_test_ext() -> sp_io::TestExternalities {
pub fn new_test_ext() -> TestExternalities {
let t = RuntimeGenesisConfig {
// We use default for brevity, but you can configure as desired if needed.
system: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/examples/kitchensink/src/weights.rs

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