@@ -10,6 +10,7 @@ import { IPAccountChecker } from "contracts/lib/registries/IPAccountChecker.sol"
1010import { IIPAccount } from "contracts/interfaces/IIPAccount.sol " ;
1111import { AccessPermission } from "contracts/lib/AccessPermission.sol " ;
1212import { Errors } from "contracts/lib/Errors.sol " ;
13+ import { Governable } from "contracts/governance/Governable.sol " ;
1314
1415/// @title AccessController
1516/// @dev This contract is used to control access permissions for different function calls in the protocol.
@@ -26,23 +27,28 @@ import { Errors } from "contracts/lib/Errors.sol";
2627/// - setPermission: Sets the permission for a specific function call.
2728/// - getPermission: Returns the permission level for a specific function call.
2829/// - checkPermission: Checks if a specific function call is allowed.
29- contract AccessController is IAccessController {
30+ contract AccessController is IAccessController , Governable {
3031 using IPAccountChecker for IIPAccountRegistry;
3132
3233 address public IP_ACCOUNT_REGISTRY;
3334 address public MODULE_REGISTRY;
3435
3536 mapping (address => mapping (address => mapping (address => mapping (bytes4 => uint8 )))) public permissions;
3637
37- // TODO: can only be called by protocol admin
38- function initialize (address ipAccountRegistry_ , address moduleRegistry_ ) external {
39- IP_ACCOUNT_REGISTRY = ipAccountRegistry_;
40- MODULE_REGISTRY = moduleRegistry_;
38+ constructor (address governance ) Governable (governance) {}
39+
40+ function initialize (address ipAccountRegistry , address moduleRegistry ) external onlyProtocolAdmin {
41+ IP_ACCOUNT_REGISTRY = ipAccountRegistry;
42+ MODULE_REGISTRY = moduleRegistry;
4143 }
4244
4345 /// @notice Sets the permission for all IPAccounts
44- function setGlobalPermission (address signer_ , address to_ , bytes4 func_ , uint8 permission_ ) external {
45- // TODO: access controller can only be called by protocol admin
46+ function setGlobalPermission (
47+ address signer_ ,
48+ address to_ ,
49+ bytes4 func_ ,
50+ uint8 permission_
51+ ) external onlyProtocolAdmin {
4652 if (signer_ == address (0 )) {
4753 revert Errors.AccessController__SignerIsZeroAddress ();
4854 }
@@ -65,7 +71,13 @@ contract AccessController is IAccessController {
6571 /// @param to_ The recipient of the transaction (support wildcard permission)
6672 /// @param func_ The function selector (support wildcard permission)
6773 /// @param permission_ The permission level (0 => ABSTAIN, 1 => ALLOW, 3 => DENY)
68- function setPermission (address ipAccount_ , address signer_ , address to_ , bytes4 func_ , uint8 permission_ ) external {
74+ function setPermission (
75+ address ipAccount_ ,
76+ address signer_ ,
77+ address to_ ,
78+ bytes4 func_ ,
79+ uint8 permission_
80+ ) external whenNotPaused {
6981 // IPAccount and signer does not support wildcard permission
7082 if (ipAccount_ == address (0 )) {
7183 revert Errors.AccessController__IPAccountIsZeroAddress ();
@@ -117,7 +129,7 @@ contract AccessController is IAccessController {
117129 address signer_ ,
118130 address to_ ,
119131 bytes4 func_
120- ) external view returns (bool ) {
132+ ) external view whenNotPaused returns (bool ) {
121133 // ipAccount_ can only call registered modules or set Permissions
122134 if (to_ != address (this ) && ! IModuleRegistry (MODULE_REGISTRY).isRegistered (to_)) {
123135 return false ;
0 commit comments