IVotes.sol 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v5.4.0) (governance/utils/IVotes.sol)
  3. pragma solidity >=0.8.4;
  4. /**
  5. * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.
  6. */
  7. interface IVotes {
  8. /**
  9. * @dev The signature used has expired.
  10. */
  11. error VotesExpiredSignature(uint256 expiry);
  12. /**
  13. * @dev Emitted when an account changes their delegate.
  14. */
  15. event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
  16. /**
  17. * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of voting units.
  18. */
  19. event DelegateVotesChanged(address indexed delegate, uint256 previousVotes, uint256 newVotes);
  20. /**
  21. * @dev Returns the current amount of votes that `account` has.
  22. */
  23. function getVotes(address account) external view returns (uint256);
  24. /**
  25. * @dev Returns the amount of votes that `account` had at a specific moment in the past. If the `clock()` is
  26. * configured to use block numbers, this will return the value at the end of the corresponding block.
  27. */
  28. function getPastVotes(address account, uint256 timepoint) external view returns (uint256);
  29. /**
  30. * @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is
  31. * configured to use block numbers, this will return the value at the end of the corresponding block.
  32. *
  33. * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
  34. * Votes that have not been delegated are still part of total supply, even though they would not participate in a
  35. * vote.
  36. */
  37. function getPastTotalSupply(uint256 timepoint) external view returns (uint256);
  38. /**
  39. * @dev Returns the delegate that `account` has chosen.
  40. */
  41. function delegates(address account) external view returns (address);
  42. /**
  43. * @dev Delegates votes from the sender to `delegatee`.
  44. */
  45. function delegate(address delegatee) external;
  46. /**
  47. * @dev Delegates votes from signer to `delegatee`.
  48. */
  49. function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external;
  50. }