Skip to content
Lattice

Governor

Git Source

Inherits: IGovernor

Title: Governor

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/Governor.sol)

Diamond-compatible stateless facet that delegates all governance logic to GovernorLib. No state is held here — all state lives in ERC-7201 namespaced storage accessed through the library.

Consumers targeting a Diamond proxy should deploy this as a facet and call GovernorLib.__Governor_init (wrapped in pre/postInitializer) from the diamond's initializer. For standalone deployment use GovernorStandalone.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: OpenZeppelin v5.1.0

Functions

name

The human-readable name of this governor.

function name() external view virtual override returns (string memory);

Returns

NameTypeDescription
<none>string

version

The version string ("1").

function version() external pure virtual override returns (string memory);

Returns

NameTypeDescription
<none>string

token

The IVotes token used for voting power.

function token() external view virtual override returns (address);

Returns

NameTypeDescription
<none>address

clock

The current clock value (block.timestamp in uint48).

function clock() external view virtual override returns (uint48);

Returns

NameTypeDescription
<none>uint48

CLOCK_MODE

Machine-readable clock mode string.

function CLOCK_MODE() external view virtual override returns (string memory);

Returns

NameTypeDescription
<none>string

COUNTING_MODE

Machine-readable counting mode string.

function COUNTING_MODE() external pure virtual override returns (string memory);

Returns

NameTypeDescription
<none>string

votingDelay

Delay (in clock units) between proposal creation and the start of voting.

function votingDelay() external view virtual override returns (uint256);

Returns

NameTypeDescription
<none>uint256

votingPeriod

Duration (in clock units) of the voting period.

function votingPeriod() external view virtual override returns (uint256);

Returns

NameTypeDescription
<none>uint256

proposalThreshold

Minimum voting power required to create a proposal.

function proposalThreshold() external view virtual override returns (uint256);

Returns

NameTypeDescription
<none>uint256

quorum

The quorum required at a given timepoint (in token units).

function quorum(uint256 timepoint) external view virtual override returns (uint256);

Parameters

NameTypeDescription
timepointuint256

Returns

NameTypeDescription
<none>uint256

quorumNumerator

The current quorum numerator (out of quorumDenominator).

function quorumNumerator() external view virtual override returns (uint256);

Returns

NameTypeDescription
<none>uint256

quorumNumerator

The quorum numerator at a given timepoint (historical or current).

function quorumNumerator(uint256 timepoint) external view virtual override returns (uint256);

Parameters

NameTypeDescription
timepointuint256

Returns

NameTypeDescription
<none>uint256

quorumDenominator

The quorum denominator (100 for percentage-based quorum).

function quorumDenominator() external pure virtual override returns (uint256);

Returns

NameTypeDescription
<none>uint256

timelock

The configured TimelockController address (address(0) if none).

function timelock() external view virtual override returns (address);

Returns

NameTypeDescription
<none>address

state

Returns the current state of a proposal.

function state(uint256 proposalId) external view virtual override returns (ProposalState);

Parameters

NameTypeDescription
proposalIduint256

Returns

NameTypeDescription
<none>ProposalState

proposalSnapshot

The clock value at which voting starts for a proposal.

function proposalSnapshot(uint256 proposalId) external view virtual override returns (uint256);

Parameters

NameTypeDescription
proposalIduint256

Returns

NameTypeDescription
<none>uint256

proposalDeadline

The clock value at which voting ends for a proposal.

function proposalDeadline(uint256 proposalId) external view virtual override returns (uint256);

Parameters

NameTypeDescription
proposalIduint256

Returns

NameTypeDescription
<none>uint256

proposalProposer

The address that created a proposal.

function proposalProposer(uint256 proposalId) external view virtual override returns (address);

Parameters

NameTypeDescription
proposalIduint256

Returns

NameTypeDescription
<none>address

proposalEta

The timelock ETA (in seconds) for a queued proposal (0 if not queued).

function proposalEta(uint256 proposalId) external view virtual override returns (uint256);

Parameters

NameTypeDescription
proposalIduint256

Returns

NameTypeDescription
<none>uint256

proposalVotes

Returns the vote totals for a proposal.

function proposalVotes(uint256 proposalId)
        external
        view
        virtual
        override
        returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);

Parameters

NameTypeDescription
proposalIduint256

Returns

NameTypeDescription
againstVotesuint256
forVotesuint256
abstainVotesuint256

hasVoted

Returns whether an account has voted on a proposal.

function hasVoted(uint256 proposalId, address account) external view virtual override returns (bool);

Parameters

NameTypeDescription
proposalIduint256
accountaddress

Returns

NameTypeDescription
<none>bool

getVotes

Returns the voting power of an account at a past timepoint.

function getVotes(address account, uint256 timepoint) external view virtual override returns (uint256);

Parameters

NameTypeDescription
accountaddress
timepointuint256

Returns

NameTypeDescription
<none>uint256

hashProposal

Computes the proposal ID for a given set of actions and description.

function hashProposal(
        address[] memory targets,
        uint256[] memory values,
        bytes[] memory calldatas,
        bytes32 descriptionHash
    ) external pure virtual override returns (uint256);

Parameters

NameTypeDescription
targetsaddress[]
valuesuint256[]
calldatasbytes[]
descriptionHashbytes32

Returns

NameTypeDescription
<none>uint256

propose

Create a new proposal.

function propose(
        address[] memory targets,
        uint256[] memory values,
        bytes[] memory calldatas,
        string memory description
    ) external virtual override returns (uint256);

Parameters

NameTypeDescription
targetsaddress[]
valuesuint256[]
calldatasbytes[]
descriptionstring

Returns

NameTypeDescription
<none>uint256

queue

Queue a succeeded proposal in the timelock.

function queue(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
        external
        virtual
        override
        returns (uint256);

Parameters

NameTypeDescription
targetsaddress[]
valuesuint256[]
calldatasbytes[]
descriptionHashbytes32

Returns

NameTypeDescription
<none>uint256

execute

Execute a succeeded (or queued+ready) proposal. A queued proposal past its grace period is Expired and can no longer be executed.

function execute(
        address[] memory targets,
        uint256[] memory values,
        bytes[] memory calldatas,
        bytes32 descriptionHash
    ) external payable virtual override returns (uint256);

Parameters

NameTypeDescription
targetsaddress[]
valuesuint256[]
calldatasbytes[]
descriptionHashbytes32

Returns

NameTypeDescription
<none>uint256

cancel

Cancel a proposal before voting starts (proposer only, Pending state only).

function cancel(
        address[] memory targets,
        uint256[] memory values,
        bytes[] memory calldatas,
        bytes32 descriptionHash
    ) external virtual override returns (uint256);

Parameters

NameTypeDescription
targetsaddress[]
valuesuint256[]
calldatasbytes[]
descriptionHashbytes32

Returns

NameTypeDescription
<none>uint256

castVote

Cast a vote on an active proposal.

function castVote(uint256 proposalId, uint8 support) external virtual override returns (uint256);

Parameters

NameTypeDescription
proposalIduint256
supportuint8

Returns

NameTypeDescription
<none>uint256

castVoteWithReason

Cast a vote with a reason string.

function castVoteWithReason(uint256 proposalId, uint8 support, string calldata reason)
        external
        virtual
        override
        returns (uint256);

Parameters

NameTypeDescription
proposalIduint256
supportuint8
reasonstring

Returns

NameTypeDescription
<none>uint256

castVoteBySig

Cast a vote via an EIP-712 signature.

function castVoteBySig(uint256 proposalId, uint8 support, address voter, bytes memory signature)
        external
        virtual
        override
        returns (uint256);

Parameters

NameTypeDescription
proposalIduint256
supportuint8
voteraddress
signaturebytes

Returns

NameTypeDescription
<none>uint256

castVoteWithReasonAndParams

Cast a vote with a reason string and extra params.

function castVoteWithReasonAndParams(
        uint256 proposalId,
        uint8 support,
        string calldata reason,
        bytes calldata params
    ) external virtual override returns (uint256);

Parameters

NameTypeDescription
proposalIduint256
supportuint8
reasonstring
paramsbytes

Returns

NameTypeDescription
<none>uint256

setVotingDelay

Update the voting delay. Must be called via governance (address(this)).

function setVotingDelay(uint48 newVotingDelay) external virtual override;

Parameters

NameTypeDescription
newVotingDelayuint48

setVotingPeriod

Update the voting period. Must be called via governance (address(this)).

function setVotingPeriod(uint32 newVotingPeriod) external virtual override;

Parameters

NameTypeDescription
newVotingPerioduint32

setProposalThreshold

Update the proposal threshold. Must be called via governance (address(this)).

function setProposalThreshold(uint256 newProposalThreshold) external virtual override;

Parameters

NameTypeDescription
newProposalThresholduint256

updateQuorumNumerator

Update the quorum numerator. Must be called via governance (address(this)).

function updateQuorumNumerator(uint256 newQuorumNumerator) external virtual override;

Parameters

NameTypeDescription
newQuorumNumeratoruint256

updateTimelock

Update the timelock address. Must be called via governance (address(this)).

function updateTimelock(address newTimelock) external virtual override;

Parameters

NameTypeDescription
newTimelockaddress

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches forge inspect Governor methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: CLOCK_MODE() 0x4bf5d7e9 COUNTING_MODE() 0xdd4e2ba5 cancel(address[],uint256[],bytes[],bytes32) 0x452115d6 castVote(uint256,uint8) 0x56781388 castVoteBySig(uint256,uint8,address,bytes) 0x8ff262e3 castVoteWithReason(uint256,uint8,string) 0x7b3c71d3 castVoteWithReasonAndParams(uint256,uint8,string,bytes) 0x5f398a14 clock() 0x91ddadf4 execute(address[],uint256[],bytes[],bytes32) 0x2656227d getVotes(address,uint256) 0xeb9019d4 hasVoted(uint256,address) 0x43859632 hashProposal(address[],uint256[],bytes[],bytes32) 0xc59057e4 name() 0x06fdde03 proposalDeadline(uint256) 0xc01f9e37 proposalEta(uint256) 0xab58fb8e proposalProposer(uint256) 0x143489d0 proposalSnapshot(uint256) 0x2d63f693 proposalThreshold() 0xb58131b0 proposalVotes(uint256) 0x544ffc9c propose(address[],uint256[],bytes[],string) 0x7d5e81e2 queue(address[],uint256[],bytes[],bytes32) 0x160cbed7 quorum(uint256) 0xf8ce560a quorumDenominator() 0x97c3d334 quorumNumerator() 0xa7713a70 quorumNumerator(uint256) 0x60c4247f setProposalThreshold(uint256) 0xece40cc1 setVotingDelay(uint48) 0x79051887 setVotingPeriod(uint32) 0xe540d01d state(uint256) 0x3e4f49e6 timelock() 0xd33219b4 token() 0xfc0c546a updateQuorumNumerator(uint256) 0x06f3f9e6 updateTimelock(address) 0xa890c910 version() 0x54fd4d50 votingDelay() 0x3932abb1 votingPeriod() 0x02a251a3

function exportSelectors() external pure virtual returns (bytes memory selectors);

Returns

NameTypeDescription
selectorsbytes