IVotes.sol 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.5.0) (governance/utils/IVotes.sol)
  3. pragma solidity ^0.8.0;
  4. /**
  5. * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.
  6. *
  7. * _Available since v4.5._
  8. */
  9. interface IVotes {
  10. /**
  11. * @dev Emitted when an account changes their delegate.
  12. */
  13. event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
  14. /**
  15. * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.
  16. */
  17. event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);
  18. /**
  19. * @dev Returns the current amount of votes that `account` has.
  20. */
  21. function getVotes(address account) external view returns (uint256);
  22. /**
  23. * @dev Returns the amount of votes that `account` had at the end of a past block (`blockNumber`).
  24. */
  25. function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);
  26. /**
  27. * @dev Returns the total supply of votes available at the end of a past block (`blockNumber`).
  28. *
  29. * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
  30. * Votes that have not been delegated are still part of total supply, even though they would not participate in a
  31. * vote.
  32. */
  33. function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);
  34. /**
  35. * @dev Returns the delegate that `account` has chosen.
  36. */
  37. function delegates(address account) external view returns (address);
  38. /**
  39. * @dev Delegates votes from the sender to `delegatee`.
  40. */
  41. function delegate(address delegatee) external;
  42. /**
  43. * @dev Delegates votes from signer to `delegatee`.
  44. */
  45. function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external;
  46. }