GovernorVotesCompUpgradeable.sol 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts v4.4.1 (governance/extensions/GovernorVotesComp.sol)
  3. pragma solidity ^0.8.0;
  4. import "../GovernorUpgradeable.sol";
  5. import "../../token/ERC20/extensions/ERC20VotesCompUpgradeable.sol";
  6. import "../../proxy/utils/Initializable.sol";
  7. /**
  8. * @dev Extension of {Governor} for voting weight extraction from a Comp token.
  9. *
  10. * _Available since v4.3._
  11. */
  12. abstract contract GovernorVotesCompUpgradeable is Initializable, GovernorUpgradeable {
  13. ERC20VotesCompUpgradeable public token;
  14. function __GovernorVotesComp_init(ERC20VotesCompUpgradeable token_) internal onlyInitializing {
  15. __Context_init_unchained();
  16. __ERC165_init_unchained();
  17. __IGovernor_init_unchained();
  18. __GovernorVotesComp_init_unchained(token_);
  19. }
  20. function __GovernorVotesComp_init_unchained(ERC20VotesCompUpgradeable token_) internal onlyInitializing {
  21. token = token_;
  22. }
  23. /**
  24. * Read the voting weight from the token's built in snapshot mechanism (see {IGovernor-getVotes}).
  25. */
  26. function getVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {
  27. return token.getPriorVotes(account, blockNumber);
  28. }
  29. uint256[50] private __gap;
  30. }