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-whitelist to umbrella crate #6514

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 1 addition & 7 deletions Cargo.lock

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

26 changes: 4 additions & 22 deletions substrate/frame/whitelist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,29 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { features = ["derive", "max-encoded-len"], workspace = true }
frame-benchmarking = { optional = true, workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
sp-api = { workspace = true }
sp-runtime = { workspace = true }
frame = { workspace = true, features = ["experimental", "runtime"] }

[dev-dependencies]
pallet-balances = { workspace = true, default-features = true }
pallet-preimage = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }

[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"frame/std",
"pallet-balances/std",
"pallet-preimage/std",
"scale-info/std",
"sp-api/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
]
runtime-benchmarks = [
"frame-benchmarking",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"frame/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame/try-runtime",
"pallet-balances/try-runtime",
"pallet-preimage/try-runtime",
"sp-runtime/try-runtime",
]
4 changes: 1 addition & 3 deletions substrate/frame/whitelist/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
#![cfg(feature = "runtime-benchmarks")]

use super::*;
use frame_benchmarking::v2::*;
use frame_support::traits::EnsureOrigin;

#[cfg(test)]
use crate::Pallet as Whitelist;
use frame::benchmarking::prelude::*;

#[benchmarks]
mod benchmarks {
Expand Down
13 changes: 4 additions & 9 deletions substrate/frame/whitelist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,17 @@ extern crate alloc;

use alloc::boxed::Box;
use codec::{DecodeLimit, Encode, FullCodec};
use frame_support::{
dispatch::{GetDispatchInfo, PostDispatchInfo},
ensure,
use frame::{
prelude::*,
traits::{QueryPreimage, StorePreimage},
weights::Weight,
};
use scale_info::TypeInfo;
use sp_runtime::traits::{Dispatchable, Hash};

pub use pallet::*;

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

#[pallet::config]
pub trait Config: frame_system::Config {
Expand Down Expand Up @@ -172,7 +167,7 @@ pub mod pallet {
.map_err(|_| Error::<T>::UnavailablePreImage)?;

let call = <T as Config>::RuntimeCall::decode_all_with_depth_limit(
sp_api::MAX_EXTRINSIC_DEPTH,
frame::deps::sp_api::MAX_EXTRINSIC_DEPTH,
&mut &call[..],
)
.map_err(|_| Error::<T>::UndecodableCall)?;
Expand Down
11 changes: 4 additions & 7 deletions substrate/frame/whitelist/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@

use crate as pallet_whitelist;

use frame_support::{construct_runtime, derive_impl};
use frame_system::EnsureRoot;
use sp_runtime::BuildStorage;

type Block = frame_system::mocking::MockBlock<Test>;
use frame::testing_prelude::*;
type Block = MockBlock<Test>;

construct_runtime!(
pub enum Test
Expand Down Expand Up @@ -65,9 +62,9 @@ impl pallet_whitelist::Config for Test {
type WeightInfo = ();
}

pub fn new_test_ext() -> sp_io::TestExternalities {
pub fn new_test_ext() -> TestExternalities {
let t = RuntimeGenesisConfig::default().build_storage().unwrap();
let mut ext = sp_io::TestExternalities::new(t);
let mut ext = TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
}
7 changes: 2 additions & 5 deletions substrate/frame/whitelist/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@

use crate::mock::*;
use codec::Encode;
use frame_support::{
assert_noop, assert_ok,
dispatch::GetDispatchInfo,
use frame::{
testing_prelude::*,
traits::{QueryPreimage, StorePreimage},
weights::Weight,
};
use sp_runtime::{traits::Hash, DispatchError};

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

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

Loading