GovernorVotes.sol 836 B

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