IVotes.sol 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.5.0-rc.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(
  46. address delegatee,
  47. uint256 nonce,
  48. uint256 expiry,
  49. uint8 v,
  50. bytes32 r,
  51. bytes32 s
  52. ) external;
  53. }