AccessControlFacet

Git Source

Inherits: IAccessControl, AccessControlBase, Facet

Functions

AccessControl_init

function AccessControl_init(address roleAdmin) external onlyInitializing;

setFunctionAccess

Sets the function access for a given role.

function setFunctionAccess(bytes4 functionSig, uint8 role, bool enabled) external onlyAuthorized;

Parameters

NameTypeDescription

functionSig

bytes4

The function signature to set access for.

role

uint8

The role to set access for.

enabled

bool

Whether the role should be able to call the function.

setUserRole

Sets the role for a given user.

function setUserRole(address user, uint8 role, bool enabled) external onlyAuthorized;

Parameters

NameTypeDescription

user

address

The user to set the role for.

role

uint8

The role to set.

enabled

bool

Whether the user should have the role.

canCall

Checks whether a given user can call a given function.

function canCall(address user, bytes4 functionSig) external view returns (bool);

Parameters

NameTypeDescription

user

address

The user to check.

functionSig

bytes4

The function signature to check.

Returns

NameTypeDescription

<none>

bool

Whether the user can call the function.

userRoles

Gets the roles for a given user.

function userRoles(address user) external view returns (bytes32);

Parameters

NameTypeDescription

user

address

The user to get the roles for.

Returns

NameTypeDescription

<none>

bytes32

The roles the user has encoded in 256 bits.

functionRoles

Gets the roles that can call a given function.

function functionRoles(bytes4 functionSig) external view returns (bytes32);

Parameters

NameTypeDescription

functionSig

bytes4

The function signature to get the roles for.

Returns

NameTypeDescription

<none>

bytes32

The roles that can call the function encoded in 256 bits.

hasRole

Checks whether a given user has a given role.

function hasRole(address user, uint8 role) external view returns (bool);

Parameters

NameTypeDescription

user

address

The user to check.

role

uint8

The role to check.

Returns

NameTypeDescription

<none>

bool

Whether the user has the role.

roleHasAccess

Checks whether a given role can call a given function.

function roleHasAccess(uint8 role, bytes4 functionSig) external view returns (bool);

Parameters

NameTypeDescription

role

uint8

The role to check.

functionSig

bytes4

The function signature to check.

Returns

NameTypeDescription

<none>

bool

Whether the role can call the function.