@@ -44,6 +44,7 @@ pub mod pallet {
4444 const STORAGE_VERSION : StorageVersion = StorageVersion :: new ( 5 ) ;
4545
4646 use pallet_permission0_api:: { CuratorPermissions , Permission0Api , Permission0CuratorApi } ;
47+ use polkadot_sdk:: sp_core:: ConstBool ;
4748 use proposal:: GlobalParamsData ;
4849 use weights:: WeightInfo ;
4950
@@ -101,6 +102,14 @@ pub mod pallet {
101102 pub type TreasuryEmissionFee < T : Config > =
102103 StorageValue < _ , Percent , ValueQuery , T :: DefaultTreasuryEmissionFee > ;
103104
105+ /// Determines if new agents can be registered on the chain.
106+ #[ pallet:: storage]
107+ pub type AgentsFrozen < T : Config > = StorageValue < _ , bool , ValueQuery , ConstBool < false > > ;
108+
109+ /// Determines if new namespaces can be created on the chain.
110+ #[ pallet:: storage]
111+ pub type NamespacesFrozen < T : Config > = StorageValue < _ , bool , ValueQuery , ConstBool < false > > ;
112+
104113 #[ pallet:: config]
105114 pub trait Config :
106115 polkadot_sdk:: frame_system:: Config + pallet_torus0:: Config + pallet_emission0:: Config
@@ -378,6 +387,44 @@ pub mod pallet {
378387
379388 Ok ( ( ) )
380389 }
390+
391+ #[ pallet:: call_index( 19 ) ]
392+ #[ pallet:: weight( ( <T as Config >:: WeightInfo :: toggle_agent_freezing( ) , DispatchClass :: Normal , Pays :: No ) ) ]
393+ pub fn toggle_agent_freezing ( origin : OriginFor < T > ) -> DispatchResult {
394+ let curator = <T as pallet:: Config >:: Permission0 :: ensure_curator_permission (
395+ origin,
396+ CuratorPermissions :: AGENT_FREEZING_TOGGLING ,
397+ ) ?;
398+
399+ let new_state = !crate :: AgentsFrozen :: < T > :: get ( ) ;
400+ AgentsFrozen :: < T > :: set ( new_state) ;
401+
402+ crate :: Pallet :: < T > :: deposit_event ( crate :: Event :: AgentFreezingToggled {
403+ curator,
404+ new_state,
405+ } ) ;
406+
407+ Ok ( ( ) )
408+ }
409+
410+ #[ pallet:: call_index( 20 ) ]
411+ #[ pallet:: weight( ( <T as Config >:: WeightInfo :: toggle_namespace_freezing( ) , DispatchClass :: Normal , Pays :: No ) ) ]
412+ pub fn toggle_namespace_freezing ( origin : OriginFor < T > ) -> DispatchResult {
413+ let curator = <T as pallet:: Config >:: Permission0 :: ensure_curator_permission (
414+ origin,
415+ CuratorPermissions :: NAMESPACE_FREEZING_TOGGLING ,
416+ ) ?;
417+
418+ let new_state = !crate :: NamespacesFrozen :: < T > :: get ( ) ;
419+ NamespacesFrozen :: < T > :: set ( new_state) ;
420+
421+ crate :: Pallet :: < T > :: deposit_event ( crate :: Event :: NamespaceFreezingToggled {
422+ curator,
423+ new_state,
424+ } ) ;
425+
426+ Ok ( ( ) )
427+ }
381428 }
382429
383430 #[ pallet:: event]
@@ -413,6 +460,16 @@ pub mod pallet {
413460 agent : T :: AccountId ,
414461 penalty : Percent ,
415462 } ,
463+ /// The agent freezing feature was toggled by a curator.
464+ AgentFreezingToggled {
465+ curator : T :: AccountId ,
466+ new_state : bool ,
467+ } ,
468+ /// The namespace freezing feature was toggled by a curator.
469+ NamespaceFreezingToggled {
470+ curator : T :: AccountId ,
471+ new_state : bool ,
472+ } ,
416473 }
417474
418475 #[ pallet:: error]
@@ -529,6 +586,14 @@ impl<T: Config> pallet_governance_api::GovernanceApi<T::AccountId> for Pallet<T>
529586 Allocators :: < T > :: insert ( key, ( ) ) ;
530587 }
531588
589+ fn can_create_namespace ( key : & T :: AccountId ) -> bool {
590+ !NamespacesFrozen :: < T > :: get ( ) || Self :: is_whitelisted ( key)
591+ }
592+
593+ fn can_register_agent ( key : & T :: AccountId ) -> bool {
594+ !AgentsFrozen :: < T > :: get ( ) || Self :: is_whitelisted ( key)
595+ }
596+
532597 #[ cfg( feature = "runtime-benchmarks" ) ]
533598 fn force_set_whitelisted ( key : & T :: AccountId ) {
534599 Whitelist :: < T > :: insert ( key, ( ) ) ;
0 commit comments