ZKPassportSelect.sol
AttestedSelect.sol is an electoral law that enables role assignment based on attestations. It allows accounts to be assigned roles only after receiving a required number of attestations from other accounts with specific attestation roles.
Overview
This law provides a mechanism to:
Assign roles based on attestations
Track attestations for each account
Enforce minimum attestation requirements
Manage attestation roles
Enforce maximum role holder limits
Configuration
When adopting an AttestedSelect instance, four parameters must be provided:
maxRoleHolders(uint256): Maximum number of accounts that can be assigned the roleroleID(uint256): The role ID that can be assigned through attestationsattestorRoleID(uint256): The role ID required to provide attestationsminAttestations(uint256): Minimum number of attestations required for role assignment
Usage
Proposing an Action
When calling the law, two parameters must be provided:
target(address): The account to attest for/againstattest(bool):true: Provide a positive attestationfalse: Provide a negative attestation
Execution Flow
Attestation Validation
Verifies the attestor has the required role
Checks if attestor has already attested
Validates attestation status
Target Validation
Verifies the target address
Checks target's current role status
Validates maximum role holders limit
Attestation Processing
If
attestis true:Records positive attestation
Checks if minimum attestations reached
Assigns role if conditions are met
If
attestis false:Records negative attestation
Removes existing attestations if any
State Management
Updates attestation counts
Maintains list of attested accounts
Records attestation history
Technical Specifications
State Variables
Functions
initializeLaw
initializeLawInitializes law with configuration parameters
Sets up role IDs and attestation requirements
Initializes empty attestation tracking
handleRequest
handleRequestProcesses the attestation request
Validates attestor and target status
Prepares role assignment if conditions met
Returns execution data
_changeState
_changeStateUpdates attestation counts
Maintains attested accounts list
Records attestation history
getData
getDataReturns the current state of the law
Includes all configuration and attestation data
Error Conditions
Attestation Errors
"Not an attestor"
"Already attested"
"Invalid attestation"
Role Assignment Errors
"Account already has role"
"Max role holders reached"
"Insufficient attestations"
Validation Errors
Invalid role ID
Invalid target address
Zero address target
Invalid attestation count
Current Deployments
Last updated