GovernorTimelockControlMock.sol 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../governance/extensions/GovernorTimelockControl.sol";
  4. import "../governance/extensions/GovernorCountingSimple.sol";
  5. import "../governance/extensions/GovernorVotesQuorumFraction.sol";
  6. contract GovernorTimelockControlMock is GovernorTimelockControl, 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. TimelockController timelock_,
  15. uint256 quorumNumerator_
  16. )
  17. Governor(name_)
  18. GovernorTimelockControl(timelock_)
  19. GovernorVotes(token_)
  20. GovernorVotesQuorumFraction(quorumNumerator_)
  21. {
  22. _votingDelay = votingDelay_;
  23. _votingPeriod = votingPeriod_;
  24. }
  25. function supportsInterface(bytes4 interfaceId)
  26. public
  27. view
  28. virtual
  29. override(Governor, GovernorTimelockControl)
  30. returns (bool)
  31. {
  32. return super.supportsInterface(interfaceId);
  33. }
  34. function votingDelay() public view override(IGovernor, Governor) returns (uint256) {
  35. return _votingDelay;
  36. }
  37. function votingPeriod() public view override(IGovernor, Governor) returns (uint256) {
  38. return _votingPeriod;
  39. }
  40. function quorum(uint256 blockNumber)
  41. public
  42. view
  43. override(IGovernor, Governor, GovernorVotesQuorumFraction)
  44. returns (uint256)
  45. {
  46. return super.quorum(blockNumber);
  47. }
  48. function cancel(
  49. address[] memory targets,
  50. uint256[] memory values,
  51. bytes[] memory calldatas,
  52. bytes32 descriptionHash
  53. ) public returns (uint256 proposalId) {
  54. return _cancel(targets, values, calldatas, descriptionHash);
  55. }
  56. /**
  57. * Overriding nightmare
  58. */
  59. function state(uint256 proposalId)
  60. public
  61. view
  62. virtual
  63. override(Governor, GovernorTimelockControl)
  64. returns (ProposalState)
  65. {
  66. return super.state(proposalId);
  67. }
  68. function _execute(
  69. uint256 proposalId,
  70. address[] memory targets,
  71. uint256[] memory values,
  72. bytes[] memory calldatas,
  73. bytes32 descriptionHash
  74. ) internal virtual override(Governor, GovernorTimelockControl) {
  75. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  76. }
  77. function _cancel(
  78. address[] memory targets,
  79. uint256[] memory values,
  80. bytes[] memory calldatas,
  81. bytes32 descriptionHash
  82. ) internal virtual override(Governor, GovernorTimelockControl) returns (uint256 proposalId) {
  83. return super._cancel(targets, values, calldatas, descriptionHash);
  84. }
  85. function getVotes(address account, uint256 blockNumber)
  86. public
  87. view
  88. virtual
  89. override(IGovernor, Governor, GovernorVotes)
  90. returns (uint256)
  91. {
  92. return super.getVotes(account, blockNumber);
  93. }
  94. function _executor() internal view virtual override(Governor, GovernorTimelockControl) returns (address) {
  95. return super._executor();
  96. }
  97. }