IGovernorUpgradeable.sol 7.8 KB

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