Skip to main content

hasPermissions

Contract: JBOperatorStore​‌

Interface: IJBOperatorStore

Whether or not an operator has the permission to take certain actions pertaining to the specified domain.

Definition

function hasPermissions(
address _operator,
address _account,
uint256 _domain,
uint256[] calldata _permissionIndexes
) external view override returns (bool) { ... }
  • _operator is the operator to check
  • _account is the account that has given out permission to the operator.
  • _domain is the domain that the operator has been given permissions to operate.
  • _permissionIndexes is an array of permission indexes 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 IJBOperatorStore interface.
  • The function returns a flag indicating whether the operator has all specified permissions.

Body

  1. Loop through the provided _permissionIndexes.

    for (uint256 _i; _i < _permissionIndexes.length; ) { ... }
    1. Get a reference to the _permissionIndex being iterated on.

      uint256 _permissionIndex = _permissionIndexes[_i];
    2. Make sure the _permissionIndex is one of the 255 indexes in a uint256.

      if (_permissionIndex > 255) revert PERMISSION_INDEX_OUT_OF_BOUNDS();
    3. If the bit at the specified permission index of the packed permissions of the operator for the specified account and within the specified domain is off, return false because all provided permissions are not on.

      if (((permissionsOf[_operator][_account][_domain] >> _permissionIndex) & 1) == 0)
      return false;

      Internal references:

    4. Increment the loop counter.

      unchecked {
      ++_i;
      }
  2. After the loop, return true since the loop checked all specified permissions without returning false.

    return true;