Skip to content

Commit

Permalink
Listing/unlisting reserved to Root
Browse files Browse the repository at this point in the history
  • Loading branch information
ndkazu committed Jan 1, 2025
1 parent b639990 commit 757d7a4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
15 changes: 8 additions & 7 deletions substrate/frame/opf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -113,10 +119,6 @@ pub mod pallet {
pub type WhiteListedProjectAccounts<T: Config> =
StorageValue<_, BoundedVec<ProjectInfo<T>, T::MaxProjects>, ValueQuery>;

/// Whitelisted Projects registration counter
#[pallet::storage]
pub type WhiteListedProjectCounter<T: Config> = StorageValue<_, u32, ValueQuery>;

/// Returns (positive_funds,negative_funds) of Whitelisted Project accounts
#[pallet::storage]
pub type ProjectFunds<T: Config> = StorageMap<
Expand Down Expand Up @@ -238,21 +240,20 @@ 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::<T>::SubmittedProjectId`]: Project already submitted under this project_id
/// - [`Error::<T>::MaximumProjectsNumber`]: Maximum number of project subscriptions reached
///
/// ## Events
/// Emits [`Event::<T>::Projectlisted`].
#[pallet::call_index(0)]
#[transactional]
pub fn register_project(origin: OriginFor<T>, project_id: ProjectId<T>) -> DispatchResult {
let _caller = ensure_signed(origin)?;
let _caller = ensure_root(origin)?;
let when = T::BlockNumberProvider::current_block_number();
ProjectInfo::<T>::new(project_id.clone());
Self::deposit_event(Event::Projectlisted { when, project_id });
Expand Down
6 changes: 4 additions & 2 deletions substrate/frame/opf/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ pub fn run_to_block(n: BlockNumberFor<Test>) {
fn project_registration_works(){
new_test_ext().execute_with(|| {



assert_ok!(Opf::register_project(RawOrigin::Root.into(), BOB));
let project_list = WhiteListedProjectAccounts::<Test>::get().to_vec();
assert_eq!(project_list.len(),1);

})
}
2 changes: 1 addition & 1 deletion substrate/frame/opf/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub struct VoteInfo<T: Config> {
// If no conviction, user's funds are released at the end of the voting round
impl<T: Config> VoteInfo<T> {
pub fn funds_unlock(&mut self) {
let conviction_coeff = <u8 as From<Conviction>>::from(self.conviction);
//let conviction_coeff = <u8 as From<Conviction>>::from(self.conviction);
let funds_unlock_block = self.round.round_ending_block;
self.funds_unlock_block = funds_unlock_block;
}
Expand Down

0 comments on commit 757d7a4

Please sign in to comment.