@@ -4,9 +4,10 @@ pub(crate) mod RolesComponent {
44 APP_GOVERNOR , APP_ROLE_ADMIN , AppGovernorAdded , AppGovernorRemoved , AppRoleAdminAdded ,
55 AppRoleAdminRemoved , GOVERNANCE_ADMIN , GovernanceAdminAdded , GovernanceAdminRemoved , IRoles ,
66 OPERATOR , OperatorAdded , OperatorRemoved , RoleId , SECURITY_ADMIN , SECURITY_AGENT ,
7- SecurityAdminAdded , SecurityAdminRemoved , SecurityAgentAdded , SecurityAgentRemoved ,
8- TOKEN_ADMIN , TokenAdminAdded , TokenAdminRemoved , UPGRADE_AGENT , UPGRADE_GOVERNOR ,
9- UpgradeAgentAdded , UpgradeAgentRemoved , UpgradeGovernorAdded , UpgradeGovernorRemoved ,
7+ SECURITY_GOVERNOR , SecurityAdminAdded , SecurityAdminRemoved , SecurityAgentAdded ,
8+ SecurityAgentRemoved , SecurityGovernorAdded , SecurityGovernorRemoved , TOKEN_ADMIN ,
9+ TokenAdminAdded , TokenAdminRemoved , UPGRADE_AGENT , UPGRADE_GOVERNOR , UpgradeAgentAdded ,
10+ UpgradeAgentRemoved , UpgradeGovernorAdded , UpgradeGovernorRemoved ,
1011 };
1112 use core :: num :: traits :: Zero ;
1213 use starknet :: storage :: StorageMapReadAccess ;
@@ -36,6 +37,8 @@ pub(crate) mod RolesComponent {
3637 SecurityAdminRemoved : SecurityAdminRemoved ,
3738 SecurityAgentAdded : SecurityAgentAdded ,
3839 SecurityAgentRemoved : SecurityAgentRemoved ,
40+ SecurityGovernorAdded : SecurityGovernorAdded ,
41+ SecurityGovernorRemoved : SecurityGovernorRemoved ,
3942 TokenAdminAdded : TokenAdminAdded ,
4043 TokenAdminRemoved : TokenAdminRemoved ,
4144 UpgradeGovernorAdded : UpgradeGovernorAdded ,
@@ -97,6 +100,13 @@ pub(crate) mod RolesComponent {
97100 access_comp . has_role (role : SECURITY_AGENT , : account )
98101 }
99102
103+ fn is_security_governor (
104+ self : @ ComponentState <TContractState >, account : ContractAddress ,
105+ ) -> bool {
106+ let access_comp = get_dep_component! (self , Access );
107+ access_comp . has_role (role : SECURITY_GOVERNOR , : account )
108+ }
109+
100110 fn is_token_admin (self : @ ComponentState <TContractState >, account : ContractAddress ) -> bool {
101111 let access_comp = get_dep_component! (self , Access );
102112 access_comp . has_role (role : TOKEN_ADMIN , : account )
@@ -186,6 +196,25 @@ pub(crate) mod RolesComponent {
186196 self . _revoke_role_and_emit (role : SECURITY_AGENT , : account , : event );
187197 }
188198
199+ fn register_security_governor (
200+ ref self : ComponentState <TContractState >, account : ContractAddress ,
201+ ) {
202+ let event = Event :: SecurityGovernorAdded (
203+ SecurityGovernorAdded { added_account : account , added_by : get_caller_address () },
204+ );
205+ self . _grant_role_and_emit (role : SECURITY_GOVERNOR , : account , : event );
206+ }
207+
208+ fn remove_security_governor (
209+ ref self : ComponentState <TContractState >, account : ContractAddress ,
210+ ) {
211+ let event = Event :: SecurityGovernorRemoved (
212+ SecurityGovernorRemoved {
213+ removed_account : account , removed_by : get_caller_address (),
214+ },
215+ );
216+ self . _revoke_role_and_emit (role : SECURITY_GOVERNOR , : account , : event );
217+ }
189218
190219 fn register_governance_admin (
191220 ref self : ComponentState <TContractState >, account : ContractAddress ,
@@ -382,6 +411,7 @@ pub(crate) mod RolesComponent {
382411 access_comp . _grant_role (role : SECURITY_ADMIN , account : governance_admin );
383412 access_comp . set_role_admin (role : SECURITY_ADMIN , admin_role : SECURITY_ADMIN );
384413 access_comp . set_role_admin (role : SECURITY_AGENT , admin_role : SECURITY_ADMIN );
414+ access_comp . set_role_admin (role : SECURITY_GOVERNOR , admin_role : SECURITY_ADMIN );
385415 }
386416
387417 fn only_app_governor (self : @ ComponentState <TContractState >) {
@@ -432,5 +462,13 @@ pub(crate) mod RolesComponent {
432462 AccessErrors :: ONLY_SECURITY_AGENT ,
433463 );
434464 }
465+
466+ fn only_security_governor (self : @ ComponentState <TContractState >) {
467+ assert! (
468+ self . is_security_governor (get_caller_address ()),
469+ " {}" ,
470+ AccessErrors :: ONLY_SECURITY_GOVERNOR ,
471+ );
472+ }
435473 }
436474}
0 commit comments