GovernorVotesComp.sol 858 B

12345678910111213141516171819202122232425262728293031
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts v4.4.1 (governance/extensions/GovernorVotesComp.sol)
  3. pragma solidity ^0.8.0;
  4. import "../Governor.sol";
  5. import "../../token/ERC20/extensions/ERC20VotesComp.sol";
  6. /**
  7. * @dev Extension of {Governor} for voting weight extraction from a Comp token.
  8. *
  9. * _Available since v4.3._
  10. */
  11. abstract contract GovernorVotesComp is Governor {
  12. ERC20VotesComp public immutable token;
  13. constructor(ERC20VotesComp token_) {
  14. token = token_;
  15. }
  16. /**
  17. * Read the voting weight from the token's built in snapshot mechanism (see {Governor-_getVotes}).
  18. */
  19. function _getVotes(
  20. address account,
  21. uint256 blockNumber,
  22. bytes memory /*params*/
  23. ) internal view virtual override returns (uint256) {
  24. return token.getPriorVotes(account, blockNumber);
  25. }
  26. }