Description
PermissionedProxy is a minimal access-control contract. It defines a single admin, an operator allowlist, and a selector allowlist controlling which functions can be forwarded via proxy(). Meant to be inherited by other contracts.
Constructor
constructor(address _admin, address _operator)
- Description - Sets the initial admin and enables the initial operator by setting
operators[_operator] = true. Contracts that inherit PermissionedProxy pass both addresses through from their own constructors.@param _admin- The initial admin address.@param _operator- The initial operator address.
- Reverts
- With
"zero"if_admin == address(0). - With
"zero"if_operator == address(0).
- With
- Emits - none
Variables
admin
- Description - The address that manages the contract's roles and allowlist: transferring admin ownership, adding or removing operators, and enabling or disabling selectors. The admin role does not include
proxy(), which checks theoperatorsmapping only, so the admin can forward calls only if it is also enabled as an operator. - Type -
address - Visibility - internal
- Used By
onlyAdmin
- Updated By
- The constructor, which sets the initial admin.
acceptAdminOwnership()
pendingAdmin
- Description - The first step in a two-step process to transfer admin ownership. The current admin sets a pendingAdmin, then the pendingAdmin must call
acceptAdminOwnership()to complete the transfer. - Type -
address - Used By
- Updated By
- Read By
pendingAdmin()
operators
- Description - A mapping of addresses to operator status. Each address in the mapping that maps to true is enabled as an operator.
- Type -
mapping(address => bool) - Visibility - public
- Used By
onlyOperator
- Updated By
- The constructor, which enables the initial operator.
setOperator(address _operator, bool value)
- Read By
operators(address)- returnstrueif the address is an enabled operator.
permissionedCalls
- Description - A mapping of function selectors to true/false values. If the mapping of a function selector is true, then the proxied call is allowed for that function. Selectors must be explicitly enabled before they can be forwarded via
proxy(). - Type -
mapping(bytes4 => bool) - Visibility - public
- Used By
- Updated By
- Read By
permissionedCalls(bytes4)- returnstrueif the selector may be forwarded.
Modifiers
onlyAdmin
- Description - Restricts function execution to the
adminaddress. - Reverts
- With
"PD"ifmsg.sender != admin.
- With
onlyOperator
- Description - Restricts function execution to addresses with
operators[msg.sender] == true. - Reverts
- With
"PD"ifoperators[msg.sender] != true.
- With
Functions
Admin Actions
transferAdminOwnerShip(address _newAdmin)
- Description - Sets the pending admin to a new address. First step of a two-step admin transfer process. The pending admin must then call
acceptAdminOwnership()to complete the transfer.@param _newAdmin- The address to set as the pending admin.
- Visibility Specifier - external
- State Mutability Specifier - nonpayable
- Access Control -
onlyAdmin - Emits - none
- Reverts
- With
"PD"ifmsg.sender != admin.
- With
acceptAdminOwnership()
- Description - Completes the two-step admin transfer. Can only be called by the current
pendingAdmin. Setsadminto the caller and clearspendingAdmin. - Visibility Specifier - external
- State Mutability Specifier - nonpayable
- Reverts
- With
"PD"ifmsg.sender != pendingAdmin.
- With
- Emits
setOperator(address _operator, bool value)
- Description - Adds or removes an address from the operator allowlist.
@param _operator- Address to update.@param value-trueto enable as an operator,falseto disable as an operator.
- Visibility Specifier - external
- State Mutability Specifier - nonpayable
- Access Control -
onlyAdmin - Reverts
- With
"zero"if_operator == address(0).
- With
- Emits
setPermissionedCall(bytes4 sig, bool value)
- Description - Marks a function selector as allowed (
true) or disallowed (false) forproxy()forwarding.@param sig- The function selector to modify.@param value-trueto allow proxied calls for this selector,falseto disallow.
- Visibility Specifier - external
- State Mutability Specifier - nonpayable
- Access Control -
onlyAdmin - Emits
Operator Actions
proxy(address vault, bytes memory data)
- Description - Forwards a call to the
vaultwith the passeddata. The function selector must be explicitly enabled in thepermissionedCallsallowlist. ETH is also forwarded.@param vault- The address of the vault contract to call.@param data- ABI-encoded calldata indicating the selector of the function to call on the vault.
- Visibility Specifier - external
- State Mutability Specifier - payable
- Access Control -
onlyOperator - Reverts
- With
"PD"ifmsg.senderis not an enabled operator. The admin is not exempt. - With
"SEL"ifdata.length < 4. - With
"PD"if the selector is not enabled in the allowlist. - With
"failed"if the forwarded call returnssuccess == false.
- With
- Emits - none
Events
-
AdminUpdated(address indexed admin)- emitted when the admin address is updated viaacceptAdminOwnership(). -
OperatorUpdated(address indexed operator)- emitted when an operator address is added or removed. -
AddedPermissionedCall(bytes4 indexed sig)- emitted when a function selector’s allowlist status is updated.