RenounceRole.sol
SelfResign.sol is an electoral law that allows accounts to voluntarily resign from a specific role. It provides a mechanism for role holders to self-revoke their role assignment.
Overview
This law provides a mechanism to:
Allow role holders to voluntarily resign
Process self-resignation requests
Track resignation history
Maintain role holder statistics
Enforce resignation rules
Configuration
When adopting a SelfResign instance, two parameters must be provided:
roleID(uint256): The role ID that can be resigned fromminHoldTime(uint256): Minimum time a role must be held before resignation
Usage
Proposing an Action
When calling the law, one parameter must be provided:
resign(bool):true: Process resignation requestfalse: Cancel resignation request
Execution Flow
Role Validation
Verifies the caller has the role
Checks minimum hold time requirement
Validates resignation eligibility
Resignation Processing
If
resignis true:Revokes role from caller
Updates role holder statistics
Records resignation
If
resignis false:Cancels pending resignation
Updates resignation status
State Management
Updates role holder list
Maintains resignation history
Records role statistics
Technical Specifications
State Variables
Functions
initializeLaw
initializeLawInitializes law with configuration parameters
Sets up role ID and hold time requirements
Initializes empty role holder tracking
handleRequest
handleRequestProcesses the resignation request
Validates role holder status
Prepares role revocation
Returns execution data
_changeState
_changeStateUpdates role holder list
Maintains resignation history
Records role statistics
getData
getDataReturns the current state of the law
Includes all configuration and role data
Error Conditions
Role Errors
"Not a role holder"
"Invalid role"
"Role not held long enough"
Resignation Errors
"No pending resignation"
"Resignation not allowed"
"Invalid resignation"
Validation Errors
Invalid role ID
Invalid hold time
Zero address caller
Invalid resignation status
Current Deployments
Last updated