GovernorTimelockControlMock.sol 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../governance/extensions/GovernorTimelockControl.sol";
  4. import "../governance/extensions/GovernorSettings.sol";
  5. import "../governance/extensions/GovernorCountingSimple.sol";
  6. import "../governance/extensions/GovernorVotesQuorumFraction.sol";
  7. contract GovernorTimelockControlMock is
  8. GovernorSettings,
  9. GovernorTimelockControl,
  10. GovernorVotesQuorumFraction,
  11. GovernorCountingSimple
  12. {
  13. constructor(
  14. string memory name_,
  15. IVotes token_,
  16. uint256 votingDelay_,
  17. uint256 votingPeriod_,
  18. TimelockController timelock_,
  19. uint256 quorumNumerator_
  20. )
  21. Governor(name_)
  22. GovernorTimelockControl(timelock_)
  23. GovernorSettings(votingDelay_, votingPeriod_, 0)
  24. GovernorVotes(token_)
  25. GovernorVotesQuorumFraction(quorumNumerator_)
  26. {}
  27. function supportsInterface(
  28. bytes4 interfaceId
  29. ) public view override(Governor, GovernorTimelockControl) returns (bool) {
  30. return super.supportsInterface(interfaceId);
  31. }
  32. function quorum(
  33. uint256 blockNumber
  34. ) public view override(IGovernor, GovernorVotesQuorumFraction) returns (uint256) {
  35. return super.quorum(blockNumber);
  36. }
  37. function cancel(
  38. address[] memory targets,
  39. uint256[] memory values,
  40. bytes[] memory calldatas,
  41. bytes32 descriptionHash
  42. ) public returns (uint256 proposalId) {
  43. return _cancel(targets, values, calldatas, descriptionHash);
  44. }
  45. /**
  46. * Overriding nightmare
  47. */
  48. function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
  49. return super.state(proposalId);
  50. }
  51. function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256) {
  52. return super.proposalThreshold();
  53. }
  54. function _execute(
  55. uint256 proposalId,
  56. address[] memory targets,
  57. uint256[] memory values,
  58. bytes[] memory calldatas,
  59. bytes32 descriptionHash
  60. ) internal override(Governor, GovernorTimelockControl) {
  61. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  62. }
  63. function _cancel(
  64. address[] memory targets,
  65. uint256[] memory values,
  66. bytes[] memory calldatas,
  67. bytes32 descriptionHash
  68. ) internal override(Governor, GovernorTimelockControl) returns (uint256 proposalId) {
  69. return super._cancel(targets, values, calldatas, descriptionHash);
  70. }
  71. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  72. return super._executor();
  73. }
  74. function nonGovernanceFunction() external {}
  75. }