IGovernorUpgradeable.sol 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.5.0-rc.0) (governance/IGovernor.sol)
  3. pragma solidity ^0.8.0;
  4. import "../utils/introspection/ERC165Upgradeable.sol";
  5. import "../proxy/utils/Initializable.sol";
  6. /**
  7. * @dev Interface of the {Governor} core.
  8. *
  9. * _Available since v4.3._
  10. */
  11. abstract contract IGovernorUpgradeable is Initializable, IERC165Upgradeable {
  12. function __IGovernor_init() internal onlyInitializing {
  13. __IGovernor_init_unchained();
  14. }
  15. function __IGovernor_init_unchained() internal onlyInitializing {
  16. }
  17. enum ProposalState {
  18. Pending,
  19. Active,
  20. Canceled,
  21. Defeated,
  22. Succeeded,
  23. Queued,
  24. Expired,
  25. Executed
  26. }
  27. /**
  28. * @dev Emitted when a proposal is created.
  29. */
  30. event ProposalCreated(
  31. uint256 proposalId,
  32. address proposer,
  33. address[] targets,
  34. uint256[] values,
  35. string[] signatures,
  36. bytes[] calldatas,
  37. uint256 startBlock,
  38. uint256 endBlock,
  39. string description
  40. );
  41. /**
  42. * @dev Emitted when a proposal is canceled.
  43. */
  44. event ProposalCanceled(uint256 proposalId);
  45. /**
  46. * @dev Emitted when a proposal is executed.
  47. */
  48. event ProposalExecuted(uint256 proposalId);
  49. /**
  50. * @dev Emitted when a vote is cast.
  51. *
  52. * Note: `support` values should be seen as buckets. There interpretation depends on the voting module used.
  53. */
  54. event VoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason);
  55. /**
  56. * @notice module:core
  57. * @dev Name of the governor instance (used in building the ERC712 domain separator).
  58. */
  59. function name() public view virtual returns (string memory);
  60. /**
  61. * @notice module:core
  62. * @dev Version of the governor instance (used in building the ERC712 domain separator). Default: "1"
  63. */
  64. function version() public view virtual returns (string memory);
  65. /**
  66. * @notice module:voting
  67. * @dev A description of the possible `support` values for {castVote} and the way these votes are counted, meant to
  68. * be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of
  69. * key-value pairs that each describe one aspect, for example `support=bravo&quorum=for,abstain`.
  70. *
  71. * There are 2 standard keys: `support` and `quorum`.
  72. *
  73. * - `support=bravo` refers to the vote options 0 = Against, 1 = For, 2 = Abstain, as in `GovernorBravo`.
  74. * - `quorum=bravo` means that only For votes are counted towards quorum.
  75. * - `quorum=for,abstain` means that both For and Abstain votes are counted towards quorum.
  76. *
  77. * NOTE: The string can be decoded by the standard
  78. * https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[`URLSearchParams`]
  79. * JavaScript class.
  80. */
  81. // solhint-disable-next-line func-name-mixedcase
  82. function COUNTING_MODE() public pure virtual returns (string memory);
  83. /**
  84. * @notice module:core
  85. * @dev Hashing function used to (re)build the proposal id from the proposal details..
  86. */
  87. function hashProposal(
  88. address[] calldata targets,
  89. uint256[] calldata values,
  90. bytes[] calldata calldatas,
  91. bytes32 descriptionHash
  92. ) public pure virtual returns (uint256);
  93. /**
  94. * @notice module:core
  95. * @dev Current state of a proposal, following Compound's convention
  96. */
  97. function state(uint256 proposalId) public view virtual returns (ProposalState);
  98. /**
  99. * @notice module:core
  100. * @dev Block number used to retrieve user's votes and quorum. As per Compound's Comp and OpenZeppelin's
  101. * ERC20Votes, the snapshot is performed at the end of this block. Hence, voting for this proposal starts at the
  102. * beginning of the following block.
  103. */
  104. function proposalSnapshot(uint256 proposalId) public view virtual returns (uint256);
  105. /**
  106. * @notice module:core
  107. * @dev Block number at which votes close. Votes close at the end of this block, so it is possible to cast a vote
  108. * during this block.
  109. */
  110. function proposalDeadline(uint256 proposalId) public view virtual returns (uint256);
  111. /**
  112. * @notice module:user-config
  113. * @dev Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to
  114. * leave time for users to buy voting power, of delegate it, before the voting of a proposal starts.
  115. */
  116. function votingDelay() public view virtual returns (uint256);
  117. /**
  118. * @notice module:user-config
  119. * @dev Delay, in number of blocks, between the vote start and vote ends.
  120. *
  121. * NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting
  122. * duration compared to the voting delay.
  123. */
  124. function votingPeriod() public view virtual returns (uint256);
  125. /**
  126. * @notice module:user-config
  127. * @dev Minimum number of cast voted required for a proposal to be successful.
  128. *
  129. * Note: The `blockNumber` parameter corresponds to the snaphot used for counting vote. This allows to scale the
  130. * quroum depending on values such as the totalSupply of a token at this block (see {ERC20Votes}).
  131. */
  132. function quorum(uint256 blockNumber) public view virtual returns (uint256);
  133. /**
  134. * @notice module:reputation
  135. * @dev Voting power of an `account` at a specific `blockNumber`.
  136. *
  137. * Note: this can be implemented in a number of ways, for example by reading the delegated balance from one (or
  138. * multiple), {ERC20Votes} tokens.
  139. */
  140. function getVotes(address account, uint256 blockNumber) public view virtual returns (uint256);
  141. /**
  142. * @notice module:voting
  143. * @dev Returns weither `account` has cast a vote on `proposalId`.
  144. */
  145. function hasVoted(uint256 proposalId, address account) public view virtual returns (bool);
  146. /**
  147. * @dev Create a new proposal. Vote start {IGovernor-votingDelay} blocks after the proposal is created and ends
  148. * {IGovernor-votingPeriod} blocks after the voting starts.
  149. *
  150. * Emits a {ProposalCreated} event.
  151. */
  152. function propose(
  153. address[] memory targets,
  154. uint256[] memory values,
  155. bytes[] memory calldatas,
  156. string memory description
  157. ) public virtual returns (uint256 proposalId);
  158. /**
  159. * @dev Execute a successful proposal. This requires the quorum to be reached, the vote to be successful, and the
  160. * deadline to be reached.
  161. *
  162. * Emits a {ProposalExecuted} event.
  163. *
  164. * Note: some module can modify the requirements for execution, for example by adding an additional timelock.
  165. */
  166. function execute(
  167. address[] memory targets,
  168. uint256[] memory values,
  169. bytes[] memory calldatas,
  170. bytes32 descriptionHash
  171. ) public payable virtual returns (uint256 proposalId);
  172. /**
  173. * @dev Cast a vote
  174. *
  175. * Emits a {VoteCast} event.
  176. */
  177. function castVote(uint256 proposalId, uint8 support) public virtual returns (uint256 balance);
  178. /**
  179. * @dev Cast a vote with a reason
  180. *
  181. * Emits a {VoteCast} event.
  182. */
  183. function castVoteWithReason(
  184. uint256 proposalId,
  185. uint8 support,
  186. string calldata reason
  187. ) public virtual returns (uint256 balance);
  188. /**
  189. * @dev Cast a vote using the user cryptographic signature.
  190. *
  191. * Emits a {VoteCast} event.
  192. */
  193. function castVoteBySig(
  194. uint256 proposalId,
  195. uint8 support,
  196. uint8 v,
  197. bytes32 r,
  198. bytes32 s
  199. ) public virtual returns (uint256 balance);
  200. uint256[50] private __gap;
  201. }