Access Control Revoke Batch Module
Revoke roles from multiple accounts efficiently
- Provides an
internalfunctionrevokeRoleBatchfor batch role revocation. - Operates on shared diamond storage, ensuring state consistency across facets.
- Emits
RoleRevokedevents for each account processed. - Reverts with
AccessControlUnauthorizedAccountif the caller lacks administrative rights for the role.
This module provides internal functions for use in your custom facets. Import it to access shared logic and storage.
Overview
This module provides an internal function to revoke a specified role from multiple accounts in a single transaction. By batching these operations, it reduces gas costs and simplifies the process for administrators managing access control within a diamond. Changes are immediately reflected across all facets interacting with the shared access control storage.
Storage
AccessControlStorage
storage struct for the AccessControl. storage-location: erc8042:compose.accesscontrol
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("compose.accesscontrol")) |
Functions
getStorage
Returns the storage for the AccessControl.
Returns:
| Property | Type | Description |
|---|---|---|
_s | AccessControlStorage | The storage for the AccessControl. |
revokeRoleBatch
function to revoke a role from multiple accounts in a single transaction. Emits a {RoleRevoked} event for each account the role is revoked from. Reverts with AccessControlUnauthorizedAccount If the caller is not the admin of the role.
Parameters:
| Property | Type | Description |
|---|---|---|
_role | bytes32 | The role to revoke. |
_accounts | address[] | The accounts to revoke the role from. |
Events
Errors
Best Practices
- Ensure the caller of
revokeRolesFromAccountswithin your facet has the necessary permissions (e.g., admin role) to revoke the specified role, as enforced by the diamond's access control mechanism. - Verify that the
AccessControlRevokeBatchModmodule is correctly initialized and accessible via its address. - Handle the
AccessControlUnauthorizedAccounterror if the caller lacks the required administrative privileges for the role.
Integration Notes
This module interacts with diamond storage at the STORAGE_POSITION slot, identified by keccak256(\"compose.accesscontrol\"). It reads and writes to the AccessControlStorage struct. The revokeRoleBatch function modifies role assignments within this shared storage. Any facet that subsequently reads from this storage will see the updated role assignments immediately, ensuring consistency across the diamond.