AccessControlFacet
This facet is a core component of any tmi-fractions platform, allowing for role-based access control mechanisms for both the platform and its individual campaigns.
_Roles are referred to by their bytes32 identifier.
IMPORTANT:
The Admin of the tmi-fractions platform is not the owner of the FractionalisationDiamond.sol (i.e., diamond proxy)
and does not possess the same privileges.
NOTE:
- Only the Admin can grant and revoke all roles except for
ADMIN_ROLEandOPEN_ROLEto/from users, and designate or dismiss users as role handlers (seeaddRoleHandler()&removeRoleHandler()). - Designated role handlers can only grant and revoke roles they are assigned to manage from/to users.
OPEN_ROLEis the default role; all accounts inherently have this role.- By default, the Admin is a handler of all roles except for
ADMIN_ROLEandOPEN_ROLE. - This version supports only one Admin per tmi-fractions platform._
RestrictedAdminRole
Thrown when attempting to change forwarder.
InvalidZeroAddressForForwarder
Thrown when attempting to assign the zero address as the forwarder.
initAccessControlFacet
Initializes the AccessControlFacetStorage by setting the Admin of the tmi-fractions platform.
admin cannot be address(0).
Emits a {AccessControlInitialized} event.
Parameters
| Name | Type | Description |
|---|---|---|
| account | address | The address to be the designated Admin of the platform, responsible for managing permissions. |
hasRole
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
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role identifier to check. |
| account | address | The address to verify for the specified role. |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | true if account holds role; false otherwise. |
hasRoleForId
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
| Name | Type | Description |
|---|---|---|
| campaignId | uint256 | The unique identifier of the targeted campaign. |
| role | bytes32 | The role identifier to check. |
| account | address | The address to verify for the specified role in the given campaign. |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | true if account holds role within campaignId; false otherwise. |
getRolesOf
Returns all the roles that a specified account holds within a platform-scoped context.
Parameters
| Name | Type | Description |
|---|---|---|
| account | address | The address to query for platform-scoped roles. |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes32[] | An array of all the platform-scoped roles that account holds. |
getAccountsWithRole
Returns all the accounts that hold the specified role within a platform-scoped context.
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The role to check for. |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | address[] | An array of all the accounts that hold the specified role. |
getRolesOfAccountForId
Returns all the roles that a specified account holds within a campaign-scoped context.
Parameters
| Name | Type | Description |
|---|---|---|
| campaignId | uint256 | The unique identifier of the targeted campaign. |
| account | address | The address to query for the targeted campaign-scoped roles. |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes32[] | An array of all the roles held by account within campaignId. |
getAccountsWithRoleForId
Returns all the accounts that hold a specified role within a given campaign.
Parameters
| Name | Type | Description |
|---|---|---|
| campaignId | uint256 | The unique identifier of the targeted campaign. |
| role | bytes32 | The role to check for. |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | address[] | An array of all the accounts that hold the specified role within campaignId. |
getHandledRolesOf
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
| Name | Type | Description |
|---|---|---|
| account | address | The account to check. |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes32[] | An array of all the roles that account is a role handler for. |
grantRole
Grants role to account within a platform-scoped context.
Only callable by the Admin or a handler of role.
Emits a {RoleGranted} event.
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The identifier of the role to grant. |
| account | address | The address to which role is granted. |
grantRoleForId
Grants role to account within a campaign-scoped context.
Only callable by the Admin or a handler of role.
Emits a {RoleGrantedForId} event.
Parameters
| Name | Type | Description |
|---|---|---|
| campaignId | uint256 | The unique identifier of the targeted campaign. |
| role | bytes32 | The identifier of the role to grant. |
| account | address | The address to which role is granted. |
grantRoleMultiple
Grants role to multiple accounts within a platform-scoped context.
Only callable by the Admin or a handler of role.
Emits a {RoleMultipleGranted} event.
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The identifier of the role to grant. |
| accounts | address[] | An array of addresses to which role is granted. |
grantRoleMultipleForId
Grants role to multiple accounts within a campaign-scoped context.
Only callable by the Admin or a handler of role.
Emits a {RoleMultipleGrantedForId} event.
Parameters
| Name | Type | Description |
|---|---|---|
| campaignId | uint256 | The unique identifier of the targeted campaign. |
| role | bytes32 | The identifier of the role to grant. |
| accounts | address[] | An array of addresses to which role is granted. |
revokeRole
Revokes role from account within a platform-scoped context.
Only callable by the Admin or a handler of role.
Emits a {RoleRevoked} event.
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The identifier of the role to revoke. |
| account | address | The address from which role is revoked. |
revokeRoleForId
Revokes role from account within a campaign-scoped context.
Only callable by the Admin or a handler of role.
Emits a {RoleRevokedForId} event.
Parameters
| Name | Type | Description |
|---|---|---|
| campaignId | uint256 | The unique identifier of the targeted campaign. |
| role | bytes32 | The identifier of the role to revoke. |
| account | address | The address from which role is revoked. |
revokeRoleMultiple
Revokes role from multiple accounts within a platform-scoped context.
Only callable by the Admin or a handler of role.
Emits a {RoleMultipleRevoked} event.
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The identifier of the role to revoke. |
| accounts | address[] | An array of addresses from which role is revoked. |
revokeRoleMultipleForId
Revokes role from multiple accounts within a campaign-scoped context.
Only callable by the Admin or a handler of role.
Emits a {RoleMultipleRevokedForId} event.
Parameters
| Name | Type | Description |
|---|---|---|
| campaignId | uint256 | The unique identifier of the targeted campaign. |
| role | bytes32 | The identifier of the role to revoke. |
| accounts | address[] | An array of addresses from which role is revoked. |
addRoleHandler
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).
Emits a {RoleHandlerAdded} event._
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The identifier of the role to delegate handling for. |
| account | address | The address to be designated as a role handler for role. |
removeRoleHandler
Revokes role handling privileges from the specified account, preventing account from managing
the granting and revocation of this role.
Only callable by the Admin. Emits a {RoleHandlerRemoved} event.
Parameters
| Name | Type | Description |
|---|---|---|
| role | bytes32 | The identifier of the role to revoke handling for. |
| account | address | The address to be removed as a role handler for role. |
changeAdmin
Replaces the current Admin with a new Admin.
Only callable by the (current) Admin. In this version, only one Admin is supported per platform. Emits an {AdminChanged} event.
Parameters
| Name | Type | Description |
|---|---|---|
| account | address | The address of the new Admin. |
updateTrustedForwarder
Updates the trusted forwarder.
Only callable by the Admin. Emits an {TrustedForwarderUpdated} event.
Parameters
| Name | Type | Description |
|---|---|---|
| newForwarder | address | The address of the new forwarder. |

