RoleByRoles
RoleByRoles is an electoral mandate that assigns or revokes a role based on whether an account holds any of a set of prerequisite roles. It is useful for composing “grouped” roles — for example, granting a general contributor role to anyone who holds any of several specific contributor roles.
Overview
Section titled “Overview”This mandate checks a single account against a list of prerequisite roles and synchronizes a target role accordingly:
- If the account holds any of the prerequisite roles and does not yet have the target role → assigns the target role.
- If the account holds none of the prerequisite roles but does have the target role → revokes the target role.
- If no change is needed (already in sync) → returns empty execution data without reverting.
Configuration
Section titled “Configuration”When adopting a RoleByRoles instance, two parameters must be provided:
newRoleId(uint256): The role ID to assign or revoke based on prerequisites.roleIdsNeeded(uint256[]): Array of prerequisite role IDs. Holding any one of these is sufficient to qualify for the target role.
Proposing an Action
Section titled “Proposing an Action”When calling the mandate, one parameter must be provided:
account(address): The account to check and potentially assign/revoke the role for.
Execution Flow
Section titled “Execution Flow”-
Prerequisite Check
- Checks if the account holds any of the roles in
roleIdsNeeded. - Checks if the account already holds
newRoleId.
- Checks if the account holds any of the roles in
-
Role Assignment Logic
- If account has a prerequisite role and does not have the target role → assigns the target role.
- If account has no prerequisite roles but has the target role → revokes the target role.
- If no change is needed → returns empty execution data (no revert).
Technical Specifications
Section titled “Technical Specifications”Functions
Section titled “Functions”initializeMandate
Section titled “initializeMandate”function initializeMandate(...) public override- Stores configuration (target role ID and prerequisite role IDs).
- Sets input parameters to
(address Account).
handleRequest
Section titled “handleRequest”function handleRequest(...) public view virtual override returns (...)- Decodes the target account from calldata.
- Checks prerequisite role ownership against the Powers contract.
- Returns an
assignRoleorrevokeRolecall, or empty arrays if no change is needed.
Error Conditions
Section titled “Error Conditions”This mandate has no explicit reverts for no-op cases. If the account’s role status is already in sync, it returns empty execution data and the action completes without any state change.
Current Deployments
Section titled “Current Deployments”| Chain ID | Chain Name | Address |
|---|---|---|
| 421614 | Arbitrum Sepolia | 0xa797799EE0C6FA7d9b76eF52e993288a04982267 |
| 11155420 | Optimism Sepolia | 0xa797799EE0C6FA7d9b76eF52e993288a04982267 |
| 11155111 | Ethereum Sepolia | 0xa797799EE0C6FA7d9b76eF52e993288a04982267 |