NStrikesRevokesRoles.sol
NStrikesRevokesRoles.sol is an electoral law that revokes roles from all current holders when the number of flagged actions exceeds a configured threshold. It provides a mechanism for automatic role revocation based on behavioral violations.
Overview
This law provides a mechanism to:
Monitor flagged actions for a specific role
Count violations against role holders
Automatically revoke roles when threshold is exceeded
Reset flagged actions after revocation
Enforce behavioral standards
Configuration
When adopting an NStrikesRevokesRoles instance, three parameters must be provided:
roleId(uint256): The role ID to monitor for violationsnumberOfStrikes(uint256): The threshold number of strikes before revocationflagActionsAddress(address): The address of the FlagActions contract
Usage
Proposing an Action
When calling the law, no parameters are required. The law automatically checks the current number of flagged actions and revokes roles if the threshold is exceeded.
Execution Flow
Strike Count Validation
Queries the FlagActions contract for flagged actions
Counts violations for the specific role ID
Compares count against configured threshold
Role Holder Retrieval
Gets all current holders of the monitored role
Prepares revocation calls for each holder
Role Revocation
If threshold is exceeded:
Creates revocation calls for all role holders
Executes role revocation in batch
If threshold not met:
Returns empty execution data
State Management
Records revocation actions
Updates role holder lists
Tracks violation counts
Technical Specifications
State Variables
Functions
initializeLaw
initializeLawInitializes law with configuration parameters
Sets up role monitoring and strike threshold
Configures FlagActions contract address
handleRequest
handleRequestProcesses the revocation request
Checks flagged actions count
Prepares role revocation calls if threshold exceeded
Returns execution data
shouldRevokeRole
shouldRevokeRoleChecks if the role should be revoked based on current strikes
Returns true if threshold is exceeded
Error Conditions
Threshold Errors
"Not enough strikes to revoke roles"
Insufficient flagged actions
Configuration Errors
Invalid role ID
Invalid FlagActions contract address
Invalid strike threshold
Validation Errors
Zero address FlagActions contract
Invalid role configuration
Current Deployments
421614
Arbitrum Sepolia
0xa797799EE0C6FA7d9b76eF52e993288a04982267
11155420
Optimism Sepolia
0xa797799EE0C6FA7d9b76eF52e993288a04982267
11155111
Ethereum Sepolia
0xa797799EE0C6FA7d9b76eF52e993288a04982267
Last updated