Skip to content

ElectionRegistry_Tally

ElectionRegistry_Tally is an integration mandate that concludes an election, calculates the winners, and updates the role assignments accordingly.

This mandate is the final step in the PowerLabs election lifecycle. Once an election period has ended, this mandate can be called to:

  1. Verify that the election is officially closed.
  2. Retrieve the ranked list of nominees from the ElectionRegistry contract based on votes cast.
  3. Revoke the role from all current holders (effectively clearing the slate).
  4. Assign the role to the top N candidates from the election, where N is the configured maximum.

When adopting an ElectionRegistry_Tally instance, the following parameters are required:

  1. electionContract (address): The address of the ElectionRegistry helper contract.
  2. RoleId (uint256): The role ID to be updated based on the election results.
  3. MaxRoleHolders (uint256): The maximum number of winners to elect (the top candidates).

When calling the mandate, one parameter must be provided:

  1. Title (string): The title of the election. The unique election ID is derived from this title and the Powers contract address.
  1. Verification

    • Computes the unique electionId.
    • Calls isElectionOpen(electionId) on the ElectionRegistry contract. Reverts with "Election is still open" if it returns true.
  2. Tallying

    • Retrieves the nominee ranking from the ElectionRegistry.
    • Selects the top candidates up to MaxRoleHolders.
  3. Role Updates

    • Generates revokeRole calls for all existing role holders.
    • Generates assignRole calls for the newly elected candidates.
    • Returns the batch of updates for execution.
function initializeMandate(...) public override
  • Initializes the tally configuration.
  • Sets input parameters to (string Title).
function handleRequest(...) public view override returns (...)
  • Performs the validation, tallying, and state transition logic.
Chain IDChain NameAddress