Skip to content

Commit

Permalink
frame-whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
bennethxyz committed Nov 17, 2024
1 parent 4df9433 commit aaf788a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 36 deletions.
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 @@ -17,46 +17,28 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { features = ["derive", "max-encoded-len"], workspace = true }
scale-info = { features = ["derive"], workspace = true }
frame-benchmarking = { optional = true, workspace = true }
frame-support = { workspace = true }
frame-system = { 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: 3 additions & 1 deletion substrate/frame/whitelist/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
#![cfg(feature = "runtime-benchmarks")]

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

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

Expand Down
10 changes: 8 additions & 2 deletions substrate/frame/whitelist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,28 @@ extern crate alloc;

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

pub use pallet::*;

#[frame_support::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
8 changes: 5 additions & 3 deletions substrate/frame/whitelist/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@

use crate as pallet_whitelist;

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

*/
use frame::{testing_prelude::*, pallet_macros::derive_impl};
type Block = frame_system::mocking::MockBlock<Test>;

construct_runtime!(
Expand Down Expand Up @@ -65,9 +67,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
}
3 changes: 3 additions & 0 deletions substrate/frame/whitelist/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@

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

#[test]
fn test_whitelist_call_and_remove() {
Expand Down
3 changes: 2 additions & 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.

0 comments on commit aaf788a

Please sign in to comment.