Votes
Inherits: IVotes
Title: Votes
Author: Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/utils/Votes.sol)
Stateless Diamond facet implementing ERC-5805 delegation + ERC-6372 clock.
All logic lives in VotesLib. This contract is a pure delegator.
delegate and delegateBySig read the delegator's ERC20Lib balance at delegation time as its voting
units. This facet never moves those units when tokens move, so an ERC-20 token recipe cuts ERC20Votes,
whose transfer, mint and burn paths do.
Differences from OpenZeppelin v5.6.1:
- The clock is
block.timestampandCLOCK_MODE()returnsmode=timestamp; OpenZeppelin defaults to the block number. - Voting units are the ERC20Lib balance, not an overridable
_getVotingUnits, and this facet does not move them when tokens move; OpenZeppelin's token extension does that in_update. - Voting-unit casts revert
IVotes.VotesOverflowedVotingUnits, not theSafeCastdowncast error, andclock()narrows with a plainuint48cast rather thanSafeCast. getPastVotes/getPastTotalSupplyinline the future-timepoint check that OpenZeppelin v5.2 moved into_validateTimepoint; both revertIVotes.ERC5805FutureLookup.- Registers IVotes for ERC-165 in its init (
VotesLib.__Votes_init); OpenZeppelin's Votes has no ERC-165.
Notes:
- lattice-version: 0.1.0
- lattice-source: OpenZeppelin v5.6.1
Functions
getVotes
Returns the current voting power of account.
function getVotes(address account) public view virtual returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| account | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getPastVotes
Returns the voting power of account at timepoint (in the past).
function getPastVotes(address account, uint256 timepoint) public view virtual returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| account | address | |
| timepoint | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getPastTotalSupply
Returns the total token supply checkpointed at timepoint (in the past).
function getPastTotalSupply(uint256 timepoint) public view virtual returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| timepoint | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
delegates
Returns the current delegate of account.
function delegates(address account) public view virtual returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| account | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
delegate
Delegates votes from the caller to delegatee.
function delegate(address delegatee) public virtual;Parameters
| Name | Type | Description |
|---|---|---|
| delegatee | address |
delegateBySig
Delegates votes from the signer to delegatee via an EIP-712 signature.
Delegates the signer's ERC20Lib balance through ERC20VotesLib.delegateBySig, the same path
ERC20Votes takes.
function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s)
public
virtual;Parameters
| Name | Type | Description |
|---|---|---|
| delegatee | address | |
| nonce | uint256 | |
| expiry | uint256 | |
| v | uint8 | |
| r | bytes32 | |
| s | bytes32 |
clock
Returns the current timepoint (block timestamp or block number).
function clock() public view virtual returns (uint48);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint48 |
CLOCK_MODE
Returns a machine-readable string describing the clock mode.
See ERC-6372 for defined values. Default is "mode=timestamp".
function CLOCK_MODE() public view virtual returns (string memory);Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |
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 Votes methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
CLOCK_MODE() 0x4bf5d7e9
clock() 0x91ddadf4
delegate(address) 0x5c19a95c
delegateBySig(address,uint256,uint256,uint8,bytes32,bytes32) 0xc3cda520
delegates(address) 0x587cde1e
getPastTotalSupply(uint256) 0x8e539e8c
getPastVotes(address,uint256) 0x3a46b1a8
getVotes(address) 0x9ab24eb0
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |