@@ -165,6 +165,7 @@ pub enum ProxyType {
165165 SwapHotkey ,
166166 SubnetLeaseBeneficiary , // Used to operate the leased subnet
167167 RootClaim ,
168+ Validate ,
168169}
169170
170171impl TryFrom < u8 > for ProxyType {
@@ -190,6 +191,7 @@ impl TryFrom<u8> for ProxyType {
190191 15 => Ok ( Self :: SwapHotkey ) ,
191192 16 => Ok ( Self :: SubnetLeaseBeneficiary ) ,
192193 17 => Ok ( Self :: RootClaim ) ,
194+ 18 => Ok ( Self :: Validate ) ,
193195 _ => Err ( ( ) ) ,
194196 }
195197 }
@@ -216,6 +218,7 @@ impl From<ProxyType> for u8 {
216218 ProxyType :: SwapHotkey => 15 ,
217219 ProxyType :: SubnetLeaseBeneficiary => 16 ,
218220 ProxyType :: RootClaim => 17 ,
221+ ProxyType :: Validate => 18 ,
219222 }
220223 }
221224}
@@ -453,4 +456,34 @@ mod tests {
453456 fn netuid_has_u16_bin_repr ( ) {
454457 assert_eq ! ( NetUid ( 5 ) . encode( ) , 5u16 . encode( ) ) ;
455458 }
459+
460+ #[ test]
461+ fn proxy_type_ids_remain_stable_and_validate_roundtrips ( ) {
462+ let expected_ids = [
463+ ( ProxyType :: Any , 0u8 ) ,
464+ ( ProxyType :: Owner , 1u8 ) ,
465+ ( ProxyType :: NonCritical , 2u8 ) ,
466+ ( ProxyType :: NonTransfer , 3u8 ) ,
467+ ( ProxyType :: Senate , 4u8 ) ,
468+ ( ProxyType :: NonFungible , 5u8 ) ,
469+ ( ProxyType :: Triumvirate , 6u8 ) ,
470+ ( ProxyType :: Governance , 7u8 ) ,
471+ ( ProxyType :: Staking , 8u8 ) ,
472+ ( ProxyType :: Registration , 9u8 ) ,
473+ ( ProxyType :: Transfer , 10u8 ) ,
474+ ( ProxyType :: SmallTransfer , 11u8 ) ,
475+ ( ProxyType :: RootWeights , 12u8 ) ,
476+ ( ProxyType :: ChildKeys , 13u8 ) ,
477+ ( ProxyType :: SudoUncheckedSetCode , 14u8 ) ,
478+ ( ProxyType :: SwapHotkey , 15u8 ) ,
479+ ( ProxyType :: SubnetLeaseBeneficiary , 16u8 ) ,
480+ ( ProxyType :: RootClaim , 17u8 ) ,
481+ ( ProxyType :: Validate , 18u8 ) ,
482+ ] ;
483+
484+ for ( proxy_type, id) in expected_ids {
485+ assert_eq ! ( <u8 as From <ProxyType >>:: from( proxy_type) , id) ;
486+ assert_eq ! ( ProxyType :: try_from( id) , Ok ( proxy_type) ) ;
487+ }
488+ }
456489}
0 commit comments