From 7a2215a92f83638a595df1246ef1a0df5a03acd1 Mon Sep 17 00:00:00 2001 From: devwckd Date: Tue, 7 Jan 2025 15:57:17 -0300 Subject: [PATCH] feat: make root curator be able to manage allocators --- pallets/governance/src/lib.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pallets/governance/src/lib.rs b/pallets/governance/src/lib.rs index 65a6858..13bb029 100644 --- a/pallets/governance/src/lib.rs +++ b/pallets/governance/src/lib.rs @@ -184,14 +184,20 @@ pub mod pallet { #[pallet::call_index(2)] #[pallet::weight((::WeightInfo::add_allocator(), DispatchClass::Normal, Pays::Yes))] pub fn add_allocator(origin: OriginFor, key: AccountIdOf) -> DispatchResult { - ensure_root(origin)?; + if ensure_signed_or_root(origin.clone())?.is_some() { + roles::ensure_root_curator::(origin)?; + } + roles::manage_role::>(key, true, Error::::AlreadyAllocator) } #[pallet::call_index(3)] #[pallet::weight((::WeightInfo::remove_allocator(), DispatchClass::Normal, Pays::Yes))] pub fn remove_allocator(origin: OriginFor, key: AccountIdOf) -> DispatchResult { - ensure_root(origin)?; + if ensure_signed_or_root(origin.clone())?.is_some() { + roles::ensure_root_curator::(origin)?; + } + roles::manage_role::>(key, false, Error::::NotAllocator) }