GovernorVotes.sol 826 B

123456789101112131415161718192021222324252627
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.5.0-rc.0) (governance/extensions/GovernorVotes.sol)
  3. pragma solidity ^0.8.0;
  4. import "../Governor.sol";
  5. import "../utils/IVotes.sol";
  6. /**
  7. * @dev Extension of {Governor} for voting weight extraction from an {ERC20Votes} token, or since v4.5 an {ERC721Votes} token.
  8. *
  9. * _Available since v4.3._
  10. */
  11. abstract contract GovernorVotes is Governor {
  12. IVotes public immutable token;
  13. constructor(IVotes tokenAddress) {
  14. token = tokenAddress;
  15. }
  16. /**
  17. * Read the voting weight from the token's built in snapshot mechanism (see {IGovernor-getVotes}).
  18. */
  19. function getVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {
  20. return token.getPastVotes(account, blockNumber);
  21. }
  22. }