跳到主要内容

OperatorStore

Git Source

Mainnet: 0xab47304D987390E27Ce3BC0fA4Fe31E3A98B0db2

Inherits: IOperatorStore

Addresses can give permissions to any other address to take specific actions throughout the Juicebox ecosystem on their behalf. These addresses are called operators.

Permissions are stored as a uint256, with each boolean bit representing whether or not an oporator has the permission identified by that bit's index in the 256 bit uint256. Indexes must be between 0 and 255. The directory of permissions, along with how they uniquely mapp to indexes, are managed externally. This contract doesn't know or care about specific permissions and their indexes.

State Variables

permissionsOf

The permissions that an operator has to operate on a specific domain.

An account can give an operator permissions that only pertain to a specific domain. There is no domain with an ID of 0 -- accounts can use the 0 domain to give an operator permissions to operator on their personal behalf.

mapping(address => mapping(address => mapping(uint256 => uint256))) public override permissionsOf;

Functions

hasPermission

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

function hasPermission(address _operator, address _account, uint256 _domain, uint256 _permissionIndex)
external
view
override
returns (bool);

Parameters

NameTypeDescription
_operatoraddressThe operator to check.
_accountaddressThe account that has given out permission to the operator.
_domainuint256The domain that the operator has been given permissions to operate.
_permissionIndexuint256the permission to check for.

Returns

NameTypeDescription
<none>boolWhether the operator has the specified permission.

hasPermissions

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

function hasPermissions(address _operator, address _account, uint256 _domain, uint256[] calldata _permissionIndexes)
external
view
override
returns (bool);

Parameters

NameTypeDescription
_operatoraddressThe operator to check.
_accountaddressThe account that has given out permissions to the operator.
_domainuint256The domain that the operator has been given permissions to operate.
_permissionIndexesuint256[]An array of permission indexes to check for.

Returns

NameTypeDescription
<none>boolWhether the operator has all specified permissions.

setOperator

Sets permissions for an operator.

function setOperator(address _operator, uint256 _domain, uint256[] calldata _permissionIndexes) external override;

Parameters

NameTypeDescription
_operatoraddressThe operator to give permission to.
_domainuint256The domain that the operator is being given permissions to operate.
_permissionIndexesuint256[]An array of indexes of permissions to set.

setOperators

Sets permissions for many operators.

function setOperators(
address[] calldata _operators,
uint256[] calldata _domains,
uint256[][] calldata _permissionIndexes
) external override;

Parameters

NameTypeDescription
_operatorsaddress[]The operators to give permission to.
_domainsuint256[]The domains that can be operated. Set to 0 to allow operation of account level actions.
_permissionIndexesuint256[][]The level of power each operator should have.

_packedPermissions

Converts an array of permission indexes to a packed int.

function _packedPermissions(uint256[] calldata _indexes) private pure returns (uint256 packed);

Parameters

NameTypeDescription
_indexesuint256[]The indexes of the permissions to pack.

Returns

NameTypeDescription
packeduint256The packed result.