_packedPermissions
Contract: JBOperatorStore
- Step by step
- Code
- Errors
- Bug bounty
Converts an array of permission indexes to a packed uint256.
Definition
function _packedPermissions(uint256[] calldata _indexes) private pure returns (uint256 packed) {...}
- _indexesare the indexes of the permissions to pack.
- The view function is private to the contract.
- The view function does not modify or reference state variables outside the function.
- The function returns the packed value.
Body
- 
Loop through the provided indexes. for (uint256 _i; _i < _indexes.length; ) { ... }- 
Get a reference to the permission index being iterated on. uint256 _index = _indexes[_i];
- 
Make sure the permission index is one of the 255 indexes in a uint256.if (_index > 255) revert PERMISSION_INDEX_OUT_OF_BOUNDS();
- 
Flip the bit at the specified index of the packed value being returned to indicate a truthy permission. // Turn the bit at the index on.
 packed |= 1 << _index;
- 
Increment the loop counter. unchecked {
 ++_i;
 }
 
- 
/**
  @notice
  Converts an array of permission indexes to a packed `uint256`.
  @param _indexes The indexes of the permissions to pack.
  @return packed The packed value.
*/
function _packedPermissions(uint256[] calldata _indexes) private pure returns (uint256 packed) {
  for (uint256 _i; _i < _indexes.length; ) {
    uint256 _index = _indexes[_i];
    if (_index > 255) revert PERMISSION_INDEX_OUT_OF_BOUNDS();
    // Turn the bit at the index on.
    packed |= 1 << _index;
    unchecked {
    ++_i;
    }
  }
}
| 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 |