GovernorTimelockControlMock.sol 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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(bytes4 interfaceId)
  28. public
  29. view
  30. override(Governor, GovernorTimelockControl)
  31. returns (bool)
  32. {
  33. return super.supportsInterface(interfaceId);
  34. }
  35. function quorum(uint256 blockNumber)
  36. public
  37. view
  38. override(IGovernor, GovernorVotesQuorumFraction)
  39. returns (uint256)
  40. {
  41. return super.quorum(blockNumber);
  42. }
  43. function cancel(
  44. address[] memory targets,
  45. uint256[] memory values,
  46. bytes[] memory calldatas,
  47. bytes32 descriptionHash
  48. ) public returns (uint256 proposalId) {
  49. return _cancel(targets, values, calldatas, descriptionHash);
  50. }
  51. /**
  52. * Overriding nightmare
  53. */
  54. function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
  55. return super.state(proposalId);
  56. }
  57. function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256) {
  58. return super.proposalThreshold();
  59. }
  60. function _execute(
  61. uint256 proposalId,
  62. address[] memory targets,
  63. uint256[] memory values,
  64. bytes[] memory calldatas,
  65. bytes32 descriptionHash
  66. ) internal override(Governor, GovernorTimelockControl) {
  67. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  68. }
  69. function _cancel(
  70. address[] memory targets,
  71. uint256[] memory values,
  72. bytes[] memory calldatas,
  73. bytes32 descriptionHash
  74. ) internal override(Governor, GovernorTimelockControl) returns (uint256 proposalId) {
  75. return super._cancel(targets, values, calldatas, descriptionHash);
  76. }
  77. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  78. return super._executor();
  79. }
  80. function nonGovernanceFunction() external {}
  81. }