GovernorMock.sol 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../governance/Governor.sol";
  4. import "../governance/extensions/GovernorCountingSimple.sol";
  5. import "../governance/extensions/GovernorVotesQuorumFraction.sol";
  6. contract GovernorMock is Governor, GovernorVotesQuorumFraction, GovernorCountingSimple {
  7. uint256 immutable _votingDelay;
  8. uint256 immutable _votingPeriod;
  9. constructor(
  10. string memory name_,
  11. ERC20Votes token_,
  12. uint256 votingDelay_,
  13. uint256 votingPeriod_,
  14. uint256 quorumNumerator_
  15. ) Governor(name_) GovernorVotes(token_) GovernorVotesQuorumFraction(quorumNumerator_) {
  16. _votingDelay = votingDelay_;
  17. _votingPeriod = votingPeriod_;
  18. }
  19. receive() external payable {}
  20. function votingDelay() public view override returns (uint256) {
  21. return _votingDelay;
  22. }
  23. function votingPeriod() public view override returns (uint256) {
  24. return _votingPeriod;
  25. }
  26. function cancel(
  27. address[] memory targets,
  28. uint256[] memory values,
  29. bytes[] memory calldatas,
  30. bytes32 salt
  31. ) public returns (uint256 proposalId) {
  32. return _cancel(targets, values, calldatas, salt);
  33. }
  34. function getVotes(address account, uint256 blockNumber)
  35. public
  36. view
  37. virtual
  38. override(Governor, GovernorVotes)
  39. returns (uint256)
  40. {
  41. return super.getVotes(account, blockNumber);
  42. }
  43. }