From 757d7a44332061fbad3e668411e8f8e81330ca37 Mon Sep 17 00:00:00 2001 From: ndkazu Date: Wed, 1 Jan 2025 23:13:37 +0900 Subject: [PATCH] Listing/unlisting reserved to Root --- substrate/frame/opf/src/lib.rs | 15 ++++++++------- substrate/frame/opf/src/tests.rs | 6 ++++-- substrate/frame/opf/src/types.rs | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/substrate/frame/opf/src/lib.rs b/substrate/frame/opf/src/lib.rs index 7d20b8f2ed1d..7b6c9ce8aac7 100644 --- a/substrate/frame/opf/src/lib.rs +++ b/substrate/frame/opf/src/lib.rs @@ -23,6 +23,12 @@ mod types; pub use pallet_scheduler as Schedule; pub use types::*; +#[cfg(test)] +mod mock; + +#[cfg(test)] +mod tests; + #[frame_support::pallet(dev_mode)] pub mod pallet { use super::*; @@ -113,10 +119,6 @@ pub mod pallet { pub type WhiteListedProjectAccounts = StorageValue<_, BoundedVec, T::MaxProjects>, ValueQuery>; - /// Whitelisted Projects registration counter - #[pallet::storage] - pub type WhiteListedProjectCounter = StorageValue<_, u32, ValueQuery>; - /// Returns (positive_funds,negative_funds) of Whitelisted Project accounts #[pallet::storage] pub type ProjectFunds = StorageMap< @@ -238,13 +240,12 @@ pub mod pallet { /// /// ## Details /// - /// From this extrinsic any user can register project. + /// From this extrinsic only Root can register project. /// /// ### Parameters /// - `project_id`: The account that will receive the reward. /// /// ### Errors - /// - [`Error::::SubmittedProjectId`]: Project already submitted under this project_id /// - [`Error::::MaximumProjectsNumber`]: Maximum number of project subscriptions reached /// /// ## Events @@ -252,7 +253,7 @@ pub mod pallet { #[pallet::call_index(0)] #[transactional] pub fn register_project(origin: OriginFor, project_id: ProjectId) -> DispatchResult { - let _caller = ensure_signed(origin)?; + let _caller = ensure_root(origin)?; let when = T::BlockNumberProvider::current_block_number(); ProjectInfo::::new(project_id.clone()); Self::deposit_event(Event::Projectlisted { when, project_id }); diff --git a/substrate/frame/opf/src/tests.rs b/substrate/frame/opf/src/tests.rs index 03b20b10ab83..74b2472a978d 100644 --- a/substrate/frame/opf/src/tests.rs +++ b/substrate/frame/opf/src/tests.rs @@ -49,7 +49,9 @@ pub fn run_to_block(n: BlockNumberFor) { fn project_registration_works(){ new_test_ext().execute_with(|| { - - + assert_ok!(Opf::register_project(RawOrigin::Root.into(), BOB)); + let project_list = WhiteListedProjectAccounts::::get().to_vec(); + assert_eq!(project_list.len(),1); + }) } \ No newline at end of file diff --git a/substrate/frame/opf/src/types.rs b/substrate/frame/opf/src/types.rs index 3f96af2939d7..f3667600a622 100644 --- a/substrate/frame/opf/src/types.rs +++ b/substrate/frame/opf/src/types.rs @@ -158,7 +158,7 @@ pub struct VoteInfo { // If no conviction, user's funds are released at the end of the voting round impl VoteInfo { pub fn funds_unlock(&mut self) { - let conviction_coeff = >::from(self.conviction); + //let conviction_coeff = >::from(self.conviction); let funds_unlock_block = self.round.round_ending_block; self.funds_unlock_block = funds_unlock_block; }