hasPermission
Contract: JBOperatorStore
Interface: IJBOperatorStore
- Step by step
- Code
- Errors
Whether or not an operator has the permission to take a certain action pertaining to the specified domain.
Definition
function hasPermissions(
address _operator,
address _account,
uint256 _domain,
uint256[] calldata _permissionIndexes
) external view override returns (bool) { ... }
_operatoris the operator to check_accountis the account that has given out permission to the operator._domainis the domain that the operator has been given permissions to operate._permissionIndexesare the permission index to check for.- The view function can be accessed externally by anyone.
- The view function does not alter state on the blockchain.
- The function overrides a function definition from the
IJBOperatorStoreinterface. - The function returns a flag indicating whether the operator has the specified permission.
Body
-
Make sure the
_permissionIndexis one of the 255 indexes in auint256.if (_permissionIndex > 255) revert PERMISSION_INDEX_OUT_OF_BOUNDS(); -
Return true if the bit is flipped on for the specified permission index. Otherwise return false.
return (((permissionsOf[_operator][_account][_domain] >> _permissionIndex) & 1) == 1)Internal references:
/**
@notice
Whether or not an operator has the permission to take a certain action pertaining to the specified domain.
@param _operator The operator to check.
@param _account The account that has given out permissions to the operator.
@param _domain The domain that the operator has been given permissions to operate.
@param _permissionIndex The permission index to check for.
@return A flag indicating whether the operator has the specified permission.
*/
function hasPermission(
address _operator,
address _account,
uint256 _domain,
uint256 _permissionIndex
) external view override returns (bool) {
if (_permissionIndex > 255) revert PERMISSION_INDEX_OUT_OF_BOUNDS();
return (((permissionsOf[_operator][_account][_domain] >> _permissionIndex) & 1) == 1);
}
| String | Description |
|---|---|
PERMISSION_INDEX_OUT_OF_BOUNDS | Thrown if the provided index is more than whats supported in a uint256. |
| Category | Description | Reward |
|---|---|---|
| Optimization | Help make this operation more efficient. | 0.5ETH |
| Low severity | Identify a vulnerability in this operation that could lead to an inconvenience for a user of the protocol or for a protocol developer. | 1ETH |
| High severity | Identify a vulnerability in this operation that could lead to data corruption or loss of funds. | 5+ETH |