GovernorVotesCompUpgradeable.sol 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. __GovernorVotesComp_init_unchained(token_);
  16. }
  17. function __GovernorVotesComp_init_unchained(ERC20VotesCompUpgradeable token_) internal onlyInitializing {
  18. token = token_;
  19. }
  20. /**
  21. * Read the voting weight from the token's built in snapshot mechanism (see {IGovernor-getVotes}).
  22. */
  23. function getVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {
  24. return token.getPriorVotes(account, blockNumber);
  25. }
  26. /**
  27. * @dev This empty reserved space is put in place to allow future versions to add new
  28. * variables without shifting down storage in the inheritance chain.
  29. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  30. */
  31. uint256[50] private __gap;
  32. }