GovernorMockUpgradeable.sol 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../governance/extensions/GovernorProposalThresholdUpgradeable.sol";
  4. import "../governance/extensions/GovernorSettingsUpgradeable.sol";
  5. import "../governance/extensions/GovernorCountingSimpleUpgradeable.sol";
  6. import "../governance/extensions/GovernorVotesQuorumFractionUpgradeable.sol";
  7. import "../proxy/utils/Initializable.sol";
  8. contract GovernorMockUpgradeable is
  9. Initializable, GovernorProposalThresholdUpgradeable,
  10. GovernorSettingsUpgradeable,
  11. GovernorVotesQuorumFractionUpgradeable,
  12. GovernorCountingSimpleUpgradeable
  13. {
  14. function __GovernorMock_init(
  15. string memory name_,
  16. IVotesUpgradeable token_,
  17. uint256 votingDelay_,
  18. uint256 votingPeriod_,
  19. uint256 quorumNumerator_
  20. ) internal onlyInitializing {
  21. __EIP712_init_unchained(name_, version());
  22. __Governor_init_unchained(name_);
  23. __GovernorSettings_init_unchained(votingDelay_, votingPeriod_, 0);
  24. __GovernorVotes_init_unchained(token_);
  25. __GovernorVotesQuorumFraction_init_unchained(quorumNumerator_);
  26. }
  27. function __GovernorMock_init_unchained(
  28. string memory,
  29. IVotesUpgradeable,
  30. uint256,
  31. uint256,
  32. uint256
  33. ) internal onlyInitializing {}
  34. function cancel(
  35. address[] memory targets,
  36. uint256[] memory values,
  37. bytes[] memory calldatas,
  38. bytes32 salt
  39. ) public returns (uint256 proposalId) {
  40. return _cancel(targets, values, calldatas, salt);
  41. }
  42. function getVotes(address account, uint256 blockNumber)
  43. public
  44. view
  45. virtual
  46. override(IGovernorUpgradeable, GovernorVotesUpgradeable)
  47. returns (uint256)
  48. {
  49. return super.getVotes(account, blockNumber);
  50. }
  51. function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256) {
  52. return super.proposalThreshold();
  53. }
  54. function propose(
  55. address[] memory targets,
  56. uint256[] memory values,
  57. bytes[] memory calldatas,
  58. string memory description
  59. ) public virtual override(GovernorUpgradeable, GovernorProposalThresholdUpgradeable) returns (uint256) {
  60. return super.propose(targets, values, calldatas, description);
  61. }
  62. /**
  63. * @dev This empty reserved space is put in place to allow future versions to add new
  64. * variables without shifting down storage in the inheritance chain.
  65. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  66. */
  67. uint256[50] private __gap;
  68. }