ElectionSelect.sol
DelegateSelect.sol is an electoral law that enables delegation-based role assignment. It allows accounts to delegate their role assignment rights to other accounts, who can then assign or revoke roles on their behalf.
Overview
This law provides a mechanism to:
Delegate role assignment rights to other accounts
Assign roles through delegation
Revoke roles through delegation
Track delegated assignments and revocations
Enforce maximum role holder limits
Configuration
When adopting a DelegateSelect instance, three parameters must be provided:
maxRoleHolders(uint256): Maximum number of accounts that can be assigned the roleroleID(uint256): The role ID that can be assigned/revoked through delegationdelegateRoleID(uint256): The role ID required to act as a delegate
Usage
Proposing an Action
When calling the law, three parameters must be provided:
target(address): The account to assign/revoke the role fromassign(bool):true: Assign the role to the targetfalse: Revoke the role from the target
delegator(address): The account whose delegation rights are being used
Execution Flow
Delegation Validation
Verifies the delegate has the required role
Checks if delegator has delegated their rights
Validates delegation status
Target Validation
Verifies the target address
Checks target's current role status
Validates maximum role holders limit
Role Assignment
If
assignis true:Checks if target already has the role
Verifies maximum role holders limit
Assigns role if conditions are met
If
assignis false:Verifies target has the role
Revokes role if conditions are met
State Management
Updates delegated assignments list
Maintains sorted list of accounts
Records delegation usage
Technical Specifications
State Variables
Functions
initializeLaw
initializeLawInitializes law with configuration parameters
Sets up maximum role holders and role IDs
Initializes empty delegated assignment lists
handleRequest
handleRequestProcesses the delegation-based assignment request
Validates delegation and target status
Prepares role assignment/revocation call
Returns execution data
_changeState
_changeStateUpdates delegated assignments list
Maintains sorted list of accounts
Handles both assignments and revocations
getData
getDataReturns the current state of the law
Includes all configuration and delegated assignments
Error Conditions
Delegation Errors
"Not a delegate"
"No delegation rights"
"Invalid delegator"
Role Assignment Errors
"Account already has role"
"Max role holders reached"
Role Revocation Errors
"Account does not have role"
Validation Errors
Invalid role ID
Invalid target address
Zero address target
Invalid delegation
Current Deployments
421614
Arbitrum Sepolia
0x4cba41C3D34A6177659126517b9806ACeFA0F83C
11155420
Optimism Sepolia
0x4cba41C3D34A6177659126517b9806ACeFA0F83C
11155111
Ethereum Sepolia
0x4cba41C3D34A6177659126517b9806ACeFA0F83C
Last updated