GovernorTimelockControlMock.sol 2.8 KB

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