SelfSelect.sol
SelfSelect.sol is an electoral law that enables accounts to self-assign or self-revoke a specific role. It provides a mechanism for accounts to manage their own role assignments.
Overview
This law provides a mechanism to:
Allow accounts to assign themselves a specific role
Enable accounts to revoke their own role
Track self-assigned accounts
Enforce maximum role holder limits
Configuration
When adopting a SelfSelect instance, two parameters must be provided:
maxRoleHolders(uint256): Maximum number of accounts that can be assigned the roleroleID(uint256): The role ID that can be self-assigned/revoked
Usage
Proposing an Action
When calling the law, one parameter must be provided:
assign(bool):true: Self-assign the rolefalse: Self-revoke the role
Execution Flow
Account Validation
Verifies the caller's address
Checks current role status
Validates maximum role holders limit
Role Assignment
If
assignis true:Checks if account already has the role
Verifies maximum role holders limit
Assigns role if conditions are met
If
assignis false:Verifies account has the role
Revokes role if conditions are met
State Management
Updates self-assigned accounts list
Maintains sorted list of accounts
Records state changes
Technical Specifications
State Variables
Functions
initializeLaw
initializeLawInitializes law with configuration parameters
Sets up maximum role holders and role ID
Initializes empty self-assigned lists
handleRequest
handleRequestProcesses the self-assignment request
Validates caller's role status
Prepares role assignment/revocation call
Returns execution data
_changeState
_changeStateUpdates self-assigned accounts list
Maintains sorted list of accounts
Handles both assignments and revocations
getData
getDataReturns the current state of the law
Includes all configuration and self-assigned accounts
Error Conditions
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 caller address
Current Deployments
421614
Arbitrum Sepolia
0x1C1dbed377bafA71CA935B40102Ea7A2C1D6ec8d
11155420
Optimism Sepolia
0x1C1dbed377bafA71CA935B40102Ea7A2C1D6ec8d
11155111
Ethereum Sepolia
0x1C1dbed377bafA71CA935B40102Ea7A2C1D6ec8d
Last updated