1
1
use super :: * ;
2
2
use crate :: {
3
3
Error ,
4
- system:: { ensure_root, ensure_signed_or_root, pallet_prelude:: BlockNumberFor } ,
4
+ system:: { ensure_root, ensure_signed , ensure_signed_or_root, pallet_prelude:: BlockNumberFor } ,
5
5
} ;
6
6
use safe_math:: * ;
7
7
use sp_core:: Get ;
@@ -23,6 +23,15 @@ impl<T: Config> Pallet<T> {
23
23
}
24
24
}
25
25
26
+ pub fn ensure_subnet_owner ( o : T :: RuntimeOrigin , netuid : u16 ) -> Result < ( ) , DispatchError > {
27
+ let coldkey = ensure_signed ( o) ;
28
+ match coldkey {
29
+ Ok ( who) if SubnetOwner :: < T > :: get ( netuid) == who => Ok ( ( ) ) ,
30
+ Ok ( _) => Err ( DispatchError :: BadOrigin ) ,
31
+ Err ( x) => Err ( x. into ( ) ) ,
32
+ }
33
+ }
34
+
26
35
// ========================
27
36
// ==== Global Setters ====
28
37
// ========================
@@ -743,4 +752,20 @@ impl<T: Config> Pallet<T> {
743
752
DissolveNetworkScheduleDuration :: < T > :: set ( duration) ;
744
753
Self :: deposit_event ( Event :: DissolveNetworkScheduleDurationSet ( duration) ) ;
745
754
}
755
+
756
+ /// Set the owner hotkey for a subnet.
757
+ ///
758
+ /// # Arguments
759
+ ///
760
+ /// * `netuid` - The unique identifier for the subnet.
761
+ /// * `hotkey` - The new hotkey for the subnet owner.
762
+ ///
763
+ /// # Effects
764
+ ///
765
+ /// * Update the SubnetOwnerHotkey storage.
766
+ /// * Emits a SubnetOwnerHotkeySet event.
767
+ pub fn set_subnet_owner_hotkey ( netuid : u16 , hotkey : & T :: AccountId ) {
768
+ SubnetOwnerHotkey :: < T > :: insert ( netuid, hotkey. clone ( ) ) ;
769
+ Self :: deposit_event ( Event :: SubnetOwnerHotkeySet ( netuid, hotkey. clone ( ) ) ) ;
770
+ }
746
771
}
0 commit comments