Fraction ProtocolgenericFacetsaccessControlFacet

AccessControlFacetStorage

Library that contains storage and functionality associated with AccessControlFacet.

AlreadyInitialized

error AlreadyInitialized()

Thrown when attempting to re-initialize.

RestrictedDefaultRole

error RestrictedDefaultRole(bytes32 role)

Thrown when attempting to handle (grant or revoke) a default role (either OPEN_ROLE or ADMIN_ROLE).

UnauthorizedRoleHandling

error UnauthorizedRoleHandling(address account, bytes32 role)

Thrown when an account attempts to handle (grant or revoke) a role it is not permitted to manage.

AccountMissingRole

error AccountMissingRole(address account, bytes32 role)

Thrown when an account attempts an action without the required role.

InvalidZeroAddressForAdmin

error InvalidZeroAddressForAdmin()

Thrown when attempting to assign the zero address as the admin.

InvalidCampaignIdZero

error InvalidCampaignIdZero()

Thrown when a campaignId of 0 is provided, which is invalid for campaign-scoped role checks.

ZeroAccountsToGrant

error ZeroAccountsToGrant()

Thrown when no accounts provided for role granting.

ZeroAccountsToRevoke

error ZeroAccountsToRevoke()

Thrown when no accounts provided for role revocation.

CannotHandleAdminRole

error CannotHandleAdminRole()

Thrown when an attempt is made to handle ADMIN_ROLE.

STORAGE_SLOT

bytes32 STORAGE_SLOT

================================================== STORAGE =================================================

Unique identifier for the storage slot where the Layout struct is stored. Derived from the ERC7201 formula. STORAGE_SLOT: 0xf38f18dbf28c638dc6bd2b4f1f6d9a444471db909c2346c79451042d2b750100

ADMIN_ROLE

bytes32 ADMIN_ROLE

OPEN_ROLE

bytes32 OPEN_ROLE

Layout

struct Layout {
  bool isInitialized;
  mapping(address => struct EnumerableSet.Bytes32Set) userRoles;
  mapping(bytes32 => struct EnumerableSet.AddressSet) usersWithRole;
  mapping(uint256 => mapping(address => struct EnumerableSet.Bytes32Set)) userRolesForId;
  mapping(uint256 => mapping(bytes32 => struct EnumerableSet.AddressSet)) usersWithRoleForId;
  mapping(address => struct EnumerableSet.Bytes32Set) userHandledRoles;
}

onlyRoleHandler

modifier onlyRoleHandler(bytes32 role)

Restricts function execution to designated role handlers for a specified role.

Checks that the specified role is not OPEN_ROLE or ADMIN_ROLE, and verifies whether the caller is authorized to handle the specified role. If the caller is neither a designated role handler nor the Admin, the function reverts.

Parameters

NameTypeDescription
rolebytes32The identifier of the role for which the caller must be a designated handler.

onlyRole

modifier onlyRole(bytes32 role)

Rrestricts function execution to accounts with the specified role.

Checks whether the caller has the specified role, else it reverts. If the specified role is the OPEN_ROLE then function proceeds with the execution.

Parameters

NameTypeDescription
rolebytes32The identifier of the role that the caller must hold to proceed.

layout

function layout() internal pure returns (struct AccessControlFacetStorage.Layout l)

Retrieves a reference to the Layout struct stored at a specified storage slot

initAccessControlFacet

function initAccessControlFacet(struct AccessControlFacetStorage.Layout l, address account) internal

Initializes the AccessControlFacetStorage by setting the Admin of the tmi-fractions platform.

admin cannot be address(0).

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
accountaddressThe address to be the designated Admin of the platform, responsible for managing permissions.

hasRole

function hasRole(struct AccessControlFacetStorage.Layout l, bytes32 role, address account) internal view returns (bool)

Checks whether a specific account holds a specified role within the tmi-fractions platform.

This function verifies role-based permissions within a platform-scoped context.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
rolebytes32The role identifier to check.
accountaddressThe address to verify for the specified role.

Return Values

NameTypeDescription
[0]booltrue if account holds role; false otherwise.

hasRoleForId

function hasRoleForId(struct AccessControlFacetStorage.Layout l, uint256 campaignId, bytes32 role, address account) internal view returns (bool)

Checks whether a specific account holds a specified role within a given campaign.

This function verifies role-based permissions within a campaign-scoped context.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted campaign.
rolebytes32The role identifier to check.
accountaddressThe address to verify for the specified role in the given campaign.

Return Values

NameTypeDescription
[0]booltrue if account holds role within campaignId; false otherwise.

getRolesOf

function getRolesOf(struct AccessControlFacetStorage.Layout l, address account) internal view returns (bytes32[])

Returns all the roles that a specified account holds within a platform-scoped context.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
accountaddressThe address to query for platform-scoped roles.

Return Values

NameTypeDescription
[0]bytes32[]An array of all the platform-scoped roles that account holds.

getAccountsWithRole

function getAccountsWithRole(struct AccessControlFacetStorage.Layout l, bytes32 role) internal view returns (address[])

Returns all the accounts that hold the specified role within a platform-scoped context.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
rolebytes32The role to check for.

Return Values

NameTypeDescription
[0]address[]An array of all the accounts that hold the specified role.

getRolesOfAccountForId

function getRolesOfAccountForId(struct AccessControlFacetStorage.Layout l, uint256 campaignId, address account) internal view returns (bytes32[])

Returns all the roles that a specified account holds within a campaign-scoped context.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted campaign.
accountaddressThe address to query for the targeted campaign-scoped roles.

Return Values

NameTypeDescription
[0]bytes32[]An array of all the roles held by account within campaignId.

getAccountsWithRoleForId

function getAccountsWithRoleForId(struct AccessControlFacetStorage.Layout l, uint256 campaignId, bytes32 role) internal view returns (address[])

Returns all the accounts that hold a specified role within a given campaign.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted campaign.
rolebytes32The role to check for.

Return Values

NameTypeDescription
[0]address[]An array of all the accounts that hold the specified role within campaignId.

getHandledRolesOf

function getHandledRolesOf(struct AccessControlFacetStorage.Layout l, address account) internal view returns (bytes32[])

Returns all the roles that a specified account is a role handler for.

A role handler manages its role both in a platform-scoped and campaign-scoped context.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
accountaddressThe account to check.

Return Values

NameTypeDescription
[0]bytes32[]An array of all the roles that account is a role handler for.

grantRole

function grantRole(struct AccessControlFacetStorage.Layout l, bytes32 role, address account) internal

Grants role to account within a platform-scoped context.

Only callable by the Admin or a handler of role.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
rolebytes32The identifier of the role to grant.
accountaddressThe address to which role is granted.

grantRoleForId

function grantRoleForId(struct AccessControlFacetStorage.Layout l, uint256 campaignId, bytes32 role, address account) internal

Grants role to account within a campaign-scoped context.

Only callable by the Admin or a handler of role.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted campaign.
rolebytes32The identifier of the role to grant.
accountaddressThe address to which role is granted.

grantRoleMultiple

function grantRoleMultiple(struct AccessControlFacetStorage.Layout l, bytes32 role, address[] accounts) internal

Grants role to multiple accounts within a platform-scoped context.

Only callable by the Admin or a handler of role.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
rolebytes32The identifier of the role to grant.
accountsaddress[]An array of addresses to which role is granted.

grantRoleMultipleForId

function grantRoleMultipleForId(struct AccessControlFacetStorage.Layout l, uint256 campaignId, bytes32 role, address[] accounts) internal

Grants role to multiple accounts within a campaign-scoped context.

Only callable by the Admin or a handler of role.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted campaign.
rolebytes32The identifier of the role to grant.
accountsaddress[]An array of addresses to which role is granted.

revokeRole

function revokeRole(struct AccessControlFacetStorage.Layout l, bytes32 role, address account) internal

Revokes role from account within a platform-scoped context.

Only callable by the Admin or a handler of role.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
rolebytes32The identifier of the role to revoke.
accountaddressThe address from which role is revoked.

revokeRoleForId

function revokeRoleForId(struct AccessControlFacetStorage.Layout l, uint256 campaignId, bytes32 role, address account) internal

Revokes role from account within a campaign-scoped context.

Only callable by the Admin or a handler of role.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted campaign.
rolebytes32The identifier of the role to revoke.
accountaddressThe address from which role is revoked.

revokeRoleMultiple

function revokeRoleMultiple(struct AccessControlFacetStorage.Layout l, bytes32 role, address[] accounts) internal

Revokes role from multiple accounts within a platform-scoped context.

Only callable by the Admin or a handler of role.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
rolebytes32The identifier of the role to revoke.
accountsaddress[]An array of addresses from which role is revoked.

revokeRoleMultipleForId

function revokeRoleMultipleForId(struct AccessControlFacetStorage.Layout l, uint256 campaignId, bytes32 role, address[] accounts) internal

Revokes role from multiple accounts within a campaign-scoped context.

Only callable by the Admin or a handler of role.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted campaign.
rolebytes32The identifier of the role to revoke.
accountsaddress[]An array of addresses from which role is revoked.

addRoleHandler

function addRoleHandler(struct AccessControlFacetStorage.Layout l, bytes32 role, address account) internal

Delegates the handling of role to the specified account, allowing account to manage the granting and revocation of this role.

_Only callable by the Admin.

Designated role handlers can manage the associated roles both at the platform level (platform-scoped context) and within individual campaigns (campaign-scoped context)._

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
rolebytes32The identifier of the role to delegate handling for.
accountaddressThe address to be designated as a role handler for role.

removeRoleHandler

function removeRoleHandler(struct AccessControlFacetStorage.Layout l, bytes32 role, address account) internal

Revokes role handling privileges from the specified account, preventing account from managing the granting and revocation of this role.

Only callable by the Admin.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
rolebytes32The identifier of the role to revoke handling for.
accountaddressThe address to be removed as a role handler for role.

changeAdmin

function changeAdmin(struct AccessControlFacetStorage.Layout l, address account) internal

Replaces the current Admin with a new Admin.

Only callable by the (current) Admin. In this version, only one Admin is supported per platform.

Parameters

NameTypeDescription
lstruct AccessControlFacetStorage.LayoutA reference to the Layout struct in storage.
accountaddressThe address of the new Admin.