GovernorCompatibilityBravoMock.sol 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../governance/compatibility/GovernorCompatibilityBravo.sol";
  4. import "../governance/extensions/GovernorVotesComp.sol";
  5. import "../governance/extensions/GovernorTimelockCompound.sol";
  6. contract GovernorCompatibilityBravoMock is GovernorCompatibilityBravo, GovernorTimelockCompound, GovernorVotesComp {
  7. uint256 immutable _votingDelay;
  8. uint256 immutable _votingPeriod;
  9. uint256 immutable _proposalThreshold;
  10. constructor(
  11. string memory name_,
  12. ERC20VotesComp token_,
  13. uint256 votingDelay_,
  14. uint256 votingPeriod_,
  15. uint256 proposalThreshold_,
  16. ICompoundTimelock timelock_
  17. ) Governor(name_) GovernorVotesComp(token_) GovernorTimelockCompound(timelock_) {
  18. _votingDelay = votingDelay_;
  19. _votingPeriod = votingPeriod_;
  20. _proposalThreshold = proposalThreshold_;
  21. }
  22. function supportsInterface(bytes4 interfaceId)
  23. public
  24. view
  25. virtual
  26. override(IERC165, Governor, GovernorTimelockCompound)
  27. returns (bool)
  28. {
  29. return super.supportsInterface(interfaceId);
  30. }
  31. function votingDelay() public view override returns (uint256) {
  32. return _votingDelay;
  33. }
  34. function votingPeriod() public view override returns (uint256) {
  35. return _votingPeriod;
  36. }
  37. function proposalThreshold() public view virtual override returns (uint256) {
  38. return _proposalThreshold;
  39. }
  40. function quorum(uint256) public pure override returns (uint256) {
  41. return 0;
  42. }
  43. function state(uint256 proposalId)
  44. public
  45. view
  46. virtual
  47. override(IGovernor, Governor, GovernorTimelockCompound)
  48. returns (ProposalState)
  49. {
  50. return super.state(proposalId);
  51. }
  52. function proposalEta(uint256 proposalId)
  53. public
  54. view
  55. virtual
  56. override(IGovernorTimelock, GovernorTimelockCompound)
  57. returns (uint256)
  58. {
  59. return super.proposalEta(proposalId);
  60. }
  61. function propose(
  62. address[] memory targets,
  63. uint256[] memory values,
  64. bytes[] memory calldatas,
  65. string memory description
  66. ) public virtual override(IGovernor, Governor, GovernorCompatibilityBravo) returns (uint256) {
  67. return super.propose(targets, values, calldatas, description);
  68. }
  69. function queue(
  70. address[] memory targets,
  71. uint256[] memory values,
  72. bytes[] memory calldatas,
  73. bytes32 salt
  74. ) public virtual override(IGovernorTimelock, GovernorTimelockCompound) returns (uint256) {
  75. return super.queue(targets, values, calldatas, salt);
  76. }
  77. function execute(
  78. address[] memory targets,
  79. uint256[] memory values,
  80. bytes[] memory calldatas,
  81. bytes32 salt
  82. ) public payable virtual override(IGovernor, Governor) returns (uint256) {
  83. return super.execute(targets, values, calldatas, salt);
  84. }
  85. function _execute(
  86. uint256 proposalId,
  87. address[] memory targets,
  88. uint256[] memory values,
  89. bytes[] memory calldatas,
  90. bytes32 descriptionHash
  91. ) internal virtual override(Governor, GovernorTimelockCompound) {
  92. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  93. }
  94. /**
  95. * @notice WARNING: this is for mock purposes only. Ability to the _cancel function should be restricted for live
  96. * deployments.
  97. */
  98. function cancel(
  99. address[] memory targets,
  100. uint256[] memory values,
  101. bytes[] memory calldatas,
  102. bytes32 salt
  103. ) public returns (uint256 proposalId) {
  104. return _cancel(targets, values, calldatas, salt);
  105. }
  106. function _cancel(
  107. address[] memory targets,
  108. uint256[] memory values,
  109. bytes[] memory calldatas,
  110. bytes32 salt
  111. ) internal virtual override(Governor, GovernorTimelockCompound) returns (uint256 proposalId) {
  112. return super._cancel(targets, values, calldatas, salt);
  113. }
  114. function getVotes(address account, uint256 blockNumber)
  115. public
  116. view
  117. virtual
  118. override(IGovernor, GovernorVotesComp)
  119. returns (uint256)
  120. {
  121. return super.getVotes(account, blockNumber);
  122. }
  123. function _executor() internal view virtual override(Governor, GovernorTimelockCompound) returns (address) {
  124. return super._executor();
  125. }
  126. }