@@ -9,7 +9,7 @@ mod TokenBridge {
99 use super :: super :: err_msg :: AccessErrors :: {
1010 CALLER_MISSING_ROLE , ZERO_ADDRESS , ALREADY_INITIALIZED , ONLY_APP_GOVERNOR , ONLY_OPERATOR ,
1111 ONLY_TOKEN_ADMIN , ONLY_UPGRADE_GOVERNOR , ONLY_SECURITY_ADMIN , ONLY_SECURITY_AGENT ,
12- GOV_ADMIN_CANNOT_RENOUNCE ,
12+ GOV_ADMIN_CANNOT_RENOUNCE , SEC_ADMIN_CANNOT_RENOUNCE ,
1313 };
1414 use super :: super :: err_msg :: ERC20Errors as ERC20Errors ;
1515 use super :: super :: err_msg :: ReplaceErrors as ReplaceErrors ;
@@ -46,10 +46,8 @@ mod TokenBridge {
4646 OperatorAdded , OperatorRemoved , TokenAdminAdded , TokenAdminRemoved , UpgradeGovernorAdded ,
4747 UpgradeGovernorRemoved ,
4848 };
49- use super :: super :: erc20_interface :: {IERC20Dispatcher , IERC20DispatcherTrait };
50- use super :: super :: mintable_token_interface :: {
51- IMintableTokenDispatcher , IMintableTokenDispatcherTrait ,
52- };
49+ use src :: erc20_interface :: {IERC20Dispatcher , IERC20DispatcherTrait };
50+ use src :: mintable_token_interface :: {IMintableTokenDispatcher , IMintableTokenDispatcherTrait };
5351
5452 use super :: super :: replaceability_interface :: {
5553 ImplementationData , IReplaceable , IReplaceableDispatcher , IReplaceableDispatcherTrait ,
@@ -62,7 +60,7 @@ mod TokenBridge {
6260
6361 const WITHDRAW_MESSAGE : felt252 = 0 ;
6462 const CONTRACT_IDENTITY : felt252 = ' STARKGATE' ;
65- const CONTRACT_VERSION : felt252 = 2 ;
63+ const CONTRACT_VERSION : felt252 = ' 2.0.1 ' ;
6664
6765 const DEFAULT_DAILY_WITHDRAW_LIMIT_PCT : u8 = 5 ;
6866
@@ -452,6 +450,11 @@ mod TokenBridge {
452450 fn get_l1_token (self : @ ContractState , l2_token : ContractAddress ) -> EthAddress {
453451 self . l2_l1_token_map. read (l2_token )
454452 }
453+
454+ fn get_l1_bridge (self : @ ContractState ) -> EthAddress {
455+ self . l1_bridge. read ()
456+ }
457+
455458 fn get_l2_token (self : @ ContractState , l1_token : EthAddress ) -> ContractAddress {
456459 self . l1_l2_token_map. read (l1_token )
457460 }
@@ -827,6 +830,7 @@ mod TokenBridge {
827830 let event = Event :: SecurityAdminRemoved (
828831 SecurityAdminRemoved { removed_account : account , removed_by : get_caller_address () },
829832 );
833+ self . prevent_self_removal (: account , error : SEC_ADMIN_CANNOT_RENOUNCE );
830834 self . _revoke_role_and_emit (role : SECURITY_ADMIN , : account , : event );
831835 }
832836
@@ -858,6 +862,7 @@ mod TokenBridge {
858862 removed_account : account , removed_by : get_caller_address (),
859863 },
860864 );
865+ self . prevent_self_removal (: account , error : GOV_ADMIN_CANNOT_RENOUNCE );
861866 self . _revoke_role_and_emit (role : GOVERNANCE_ADMIN , : account , : event );
862867 }
863868
@@ -905,21 +910,20 @@ mod TokenBridge {
905910 self . _revoke_role_and_emit (role : UPGRADE_GOVERNOR , : account , : event );
906911 }
907912
908- // TODO - change the fn name to renounce_role when we can have modularity.
909- // TODO - change to GOVERNANCE_ADMIN_CANNOT_SELF_REMOVE when the 32 characters limitations
910- // is off.
911913 fn renounce (ref self : ContractState , role : RoleId ) {
912914 assert (role != GOVERNANCE_ADMIN , GOV_ADMIN_CANNOT_RENOUNCE );
915+ assert (role != SECURITY_ADMIN , SEC_ADMIN_CANNOT_RENOUNCE );
913916 self . renounce_role (: role , account : get_caller_address ())
914- // TODO add another event? Currently there are two events when a role is removed but
915- // only one if it was renounced.
916917 }
917918 }
918919
919920
920921 #[generate_trait]
921922 impl RolesInternal of _RolesInternal {
922- // TODO - change the fn name to _grant_role when we can have modularity.
923+ fn prevent_self_removal (self : @ ContractState , account : ContractAddress , error : felt252 ) {
924+ assert (account != get_caller_address (), error );
925+ }
926+
923927 fn _grant_role_and_emit (
924928 ref self : ContractState , role : RoleId , account : ContractAddress , event : Event ,
925929 ) {
@@ -930,7 +934,6 @@ mod TokenBridge {
930934 }
931935 }
932936
933- // TODO - change the fn name to _revoke_role when we can have modularity.
934937 fn _revoke_role_and_emit (
935938 ref self : ContractState , role : RoleId , account : ContractAddress , event : Event ,
936939 ) {
0 commit comments