Skip to content

Peer Select

PeerSelect is an electoral mandate that allows an authorized caller to select exactly N nominees from a candidate list, fully replacing the current set of role holders with the new selection. It is designed as a one-time-use mandate: after execution, it revokes itself.

This mandate allows an authorized caller to:

  1. View the current list of nominees from a Nominees contract.
  2. Submit a boolean selection array — one entry per nominee.
  3. Revoke the role from all current holders.
  4. Assign the role to the selected nominees.
  5. Revoke the mandate itself, preventing it from being executed again.

This is a full reset mechanism, not a toggle. Every execution replaces the entire set of role holders with the chosen nominees.

When adopting a PeerSelect instance, the following parameters are required:

  1. numberToSelect (uint8): The exact number of nominees that must be selected. The caller must select precisely this many — no more, no fewer.
  2. roleId (uint256): The role ID to be assigned to the selected nominees (and revoked from all current holders).
  3. NomineesContract (address): The address of the Nominees helper contract providing the list of candidates.

When calling the mandate, one parameter must be provided:

  1. selection (bool[]): An array of booleans, one per nominee in the NomineesContract list.
    • true: Select this nominee for the role.
    • false: Do not select this nominee.

The array length must exactly match the current number of nominees, and exactly numberToSelect entries must be true.

  1. Validation

    • Verifies that the selection array length matches the nominee list length.
    • Verifies there are at least numberToSelect nominees available.
    • Verifies that the number of true entries equals exactly numberToSelect.
  2. Role Reset

    • Revokes the role from every current role holder.
  3. Role Assignment

    • Assigns the role to each selected nominee.
  4. Self-Revocation

    • Revokes the mandate itself (revokeMandate), making it impossible to execute again. This ensures PeerSelect is a one-time selection event.
function initializeMandate(...) public override
  • Initializes configuration.
  • Dynamically generates the input parameter list from the current nominee addresses at the time of initialization (one bool per nominee).
function handleRequest(...) public view virtual override returns (...)
  • Validates the selection array.
  • Builds revocation calls for all current role holders.
  • Builds assignment calls for selected nominees.
  • Appends a final revokeMandate call targeting itself.
  • "Invalid selection length." — The selection array length does not match the current nominee count.
  • "Not enough nominees to fill the seats." — Fewer nominees exist than numberToSelect requires.
  • "Must select exactly numberToSelect options." — The number of true entries in the selection does not equal numberToSelect.
Chain IDChain NameAddress