# ProposalGovernor

[Git Source](https://github.com/EntreDevelopers-Lab-Inc/Mezz-Companies/blob/f7a3e84e3dd5bb33c4bd7f77283983f9e8ba20b2/src/core/governance/ProposalGovernor.sol)

**Inherits:** ContextUpgradeable, MezzGovernor, MezzEIP712, NoncesUpgradeable, IProposalGovernor

**Author:** Daniel Yamagata

A base class that provides functionality for on-chain proposals and voting. This contract does not implement the execution of proposals

*This contract is heavily inspired by* [*OpenZeppelin's Governor contract*](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/7294d34c17ca215c201b3772ff67036fa4b1ef12/contracts/governance/Governor.sol)*.*

## State Variables

### \_BALLOT\_TYPEHASH

```solidity
bytes32 internal constant _BALLOT_TYPEHASH =
    keccak256("Ballot(uint256 proposalId,uint8 support,address voter,uint256 nonce)");
```

### \_EXTENDED\_BALLOT\_TYPEHASH

```solidity
bytes32 internal constant _EXTENDED_BALLOT_TYPEHASH =
    keccak256("ExtendedBallot(uint256 proposalId,uint8 support,address voter,uint256 nonce,string reason,bytes params)");
```

### SUPER\_MAJORITY\_PERCENTAGE

```solidity
uint256 public constant SUPER_MAJORITY_PERCENTAGE = Constants.SUPER_MAJORITY_PERCENTAGE;
```

### ProposalGovernorStorageLocation

```solidity
bytes32 private constant ProposalGovernorStorageLocation =
    0x1f64e26c32eddaf99df35a9898d9e2c7b2a05db947531695b541d0030f865a00;
```

## Functions

### \_getProposalGovernorStorage

```solidity
function _getProposalGovernorStorage() internal pure returns (ProposalGovernorStorage storage $);
```

### \_\_ProposalGovernor\_init

```solidity
function __ProposalGovernor_init() internal onlyInitializing;
```

### setQuorumPercentage

Sets a new quourm percentage

*Only callable via governance itself*

```solidity
function setQuorumPercentage(uint256 newQuorumPercentage) external onlyMezzGovernance;
```

**Parameters**

| Name                  | Type      | Description               |
| --------------------- | --------- | ------------------------- |
| `newQuorumPercentage` | `uint256` | The new quorum percentage |

### setProposalThresholdPercentage

Sets a new proposal threshold percentage

*Only callable via governance itself*

```solidity
function setProposalThresholdPercentage(uint256 newProposalThresholdPercentage) external onlyMezzGovernance;
```

**Parameters**

| Name                             | Type      | Description                           |
| -------------------------------- | --------- | ------------------------------------- |
| `newProposalThresholdPercentage` | `uint256` | The new proposal threshold percentage |

### setVotingDelay

Sets a new voting delay

*Only callable via governance itself*

```solidity
function setVotingDelay(uint256 newVotingDelay) external onlyMezzGovernance;
```

**Parameters**

| Name             | Type      | Description          |
| ---------------- | --------- | -------------------- |
| `newVotingDelay` | `uint256` | The new voting delay |

### setVotingPeriod

Sets a new voting period

*Only callable via governance itself*

```solidity
function setVotingPeriod(uint256 newVotingPeriod) external onlyMezzGovernance;
```

**Parameters**

| Name              | Type      | Description           |
| ----------------- | --------- | --------------------- |
| `newVotingPeriod` | `uint256` | The new voting period |

### castVote

Casts the caller's votes towards the proposal associated with 'proposalId' There are three different vote types defined by the following enum:

* 0: Against
* 1: For
* 2: Abstain

*A voter can only vote once and cannot revoke or change their vote. Votes are calculated from the proposal's snapshot and the counting of votes is bespoke and must be implemented by the inheritor*

```solidity
function castVote(uint256 proposalId, uint8 support) public virtual returns (uint256);
```

**Parameters**

| Name         | Type      | Description                                 |
| ------------ | --------- | ------------------------------------------- |
| `proposalId` | `uint256` | The ID of the proposal to cast the vote for |
| `support`    | `uint8`   | The vote type                               |

**Returns**

| Name     | Type      | Description                       |
| -------- | --------- | --------------------------------- |
| `<none>` | `uint256` | The number of votes of the caller |

### castVoteWithReason

Casts the caller's votes with a 'reason' towards the proposal associated with 'proposalId'

*The 'reason' is not stored on-chain but, rather, emitted in an event*

```solidity
function castVoteWithReason(uint256 proposalId, uint8 support, string calldata reason)
    public
    virtual
    returns (uint256);
```

**Parameters**

| Name         | Type      | Description                                 |
| ------------ | --------- | ------------------------------------------- |
| `proposalId` | `uint256` | The ID of the proposal to cast the vote for |
| `support`    | `uint8`   | The vote type                               |
| `reason`     | `string`  | The reason for the vote                     |

**Returns**

| Name     | Type      | Description                       |
| -------- | --------- | --------------------------------- |
| `<none>` | `uint256` | The number of votes of the caller |

### castVoteWithReasonAndParams

Casts the caller's votes with a 'reason' and 'params' towards the proposal associated with 'proposalId'

*'params' are bespoke, abi-encoded arguments that could be used for casting a vote*

```solidity
function castVoteWithReasonAndParams(uint256 proposalId, uint8 support, string calldata reason, bytes memory params)
    public
    virtual
    returns (uint256);
```

**Parameters**

| Name         | Type      | Description                                 |
| ------------ | --------- | ------------------------------------------- |
| `proposalId` | `uint256` | The ID of the proposal to cast the vote for |
| `support`    | `uint8`   | The vote type                               |
| `reason`     | `string`  | The reason for the vote                     |
| `params`     | `bytes`   | The abi-encoded parameters for the vote     |

**Returns**

| Name     | Type      | Description                       |
| -------- | --------- | --------------------------------- |
| `<none>` | `uint256` | The number of votes of the caller |

### castVoteBySig

Casts the votes of 'voter' towards the proposal associated with 'proposalId' via an EIP-712 signature

*Reference: <https://eips.ethereum.org/EIPS/eip-712>*

```solidity
function castVoteBySig(uint256 proposalId, uint8 support, address voter, bytes memory signature)
    public
    virtual
    returns (uint256);
```

**Parameters**

| Name         | Type      | Description                                 |
| ------------ | --------- | ------------------------------------------- |
| `proposalId` | `uint256` | The ID of the proposal to cast the vote for |
| `support`    | `uint8`   | The vote type                               |
| `voter`      | `address` | The address of the voter                    |
| `signature`  | `bytes`   | The EIP-712 signature of the voter          |

**Returns**

| Name     | Type      | Description                      |
| -------- | --------- | -------------------------------- |
| `<none>` | `uint256` | The number of votes of the voter |

### castVoteWithReasonAndParamsBySig

Casts the votes of 'voter' towards the proposal associated with 'proposalId' via an EIP-712 signature

\_Reference: <https://eips.ethereum.org/EIPS/eip-712_&#x20>;

*'params' are bespoke, abi-encoded arguments that could be used for casting a vote*

```solidity
function castVoteWithReasonAndParamsBySig(
    uint256 proposalId,
    uint8 support,
    address voter,
    string calldata reason,
    bytes memory params,
    bytes memory signature
) public virtual returns (uint256);
```

**Parameters**

| Name         | Type      | Description                                 |
| ------------ | --------- | ------------------------------------------- |
| `proposalId` | `uint256` | The ID of the proposal to cast the vote for |
| `support`    | `uint8`   | The vote type                               |
| `voter`      | `address` | The address of the voter                    |
| `reason`     | `string`  | The reason for the vote                     |
| `params`     | `bytes`   | The abi-encoded parameters for the vote     |
| `signature`  | `bytes`   | The EIP-712 signature of the voter          |

**Returns**

| Name     | Type      | Description                      |
| -------- | --------- | -------------------------------- |
| `<none>` | `uint256` | The number of votes of the voter |

### \_castVote

```solidity
function _castVote(uint256 proposalId, address account, uint8 support, string memory reason)
    internal
    virtual
    returns (uint256);
```

### \_castVote

*Overridden by inheriting contracts. Inheritors should query votes and count them towards a proposal*

```solidity
function _castVote(uint256 proposalId, address account, uint8 support, string memory reason, bytes memory params)
    internal
    virtual
    returns (uint256);
```

### state

Returns the state of a proposal associated with 'proposalId' as a ProposalState enum

```solidity
function state(uint256 proposalId) public view virtual returns (IModifiedGovernor.ProposalState);
```

### hasVoted

Returns true if 'account' has voted on a proposal with 'proposalId', false otherwise

```solidity
function hasVoted(uint256 proposalId, address account) public view virtual returns (bool);
```

**Returns**

| Name     | Type   | Description                                    |
| -------- | ------ | ---------------------------------------------- |
| `<none>` | `bool` | True if the account has voted, false otherwise |

### getReceipt

Returns the voting receipt of 'account' for the proposal with 'proposalId'

```solidity
function getReceipt(uint256 proposalId, address account) external view returns (DataTypes.Receipt memory);
```

**Returns**

| Name     | Type                | Description                                              |
| -------- | ------------------- | -------------------------------------------------------- |
| `<none>` | `DataTypes.Receipt` | The receipt of the account as a DataTypes.Receipt struct |

### getProposalVotes

Returns the total votes for the proposal with 'proposalId'

```solidity
function getProposalVotes(uint256 proposalId) external view returns (DataTypes.ProposalVotes memory);
```

**Returns**

| Name     | Type                      | Description                                                          |
| -------- | ------------------------- | -------------------------------------------------------------------- |
| `<none>` | `DataTypes.ProposalVotes` | The total votes for the proposal as a DataTypes.ProposalVotes struct |

### votingDelay

Returns the voting delay in seconds

```solidity
function votingDelay() public view virtual returns (uint256);
```

**Returns**

| Name     | Type      | Description                 |
| -------- | --------- | --------------------------- |
| `<none>` | `uint256` | The voting delay in seconds |

### votingPeriod

Returns the voting period

```solidity
function votingPeriod() public view virtual returns (uint256);
```

**Returns**

| Name     | Type      | Description                  |
| -------- | --------- | ---------------------------- |
| `<none>` | `uint256` | The voting period in seconds |

### quorumPercentage

Returns the quorum percentage

```solidity
function quorumPercentage() public view virtual returns (uint256);
```

**Returns**

| Name     | Type      | Description                                              |
| -------- | --------- | -------------------------------------------------------- |
| `<none>` | `uint256` | The quorum percentage multiplied by the precision factor |

### proposalThresholdPercentage

Returns the proposal threshold percentage

```solidity
function proposalThresholdPercentage() public view virtual returns (uint256);
```

**Returns**

| Name     | Type      | Description                                                          |
| -------- | --------- | -------------------------------------------------------------------- |
| `<none>` | `uint256` | The proposal threshold percentage multiplied by the precision factor |

### getBallotTransactionHash

Returns the ballot transaction hash, which is used in casting votes by signature

*The returned transaction hash should be signed by the voter to create a valid signature Reference: <https://eips.ethereum.org/EIPS/eip-712>*

```solidity
function getBallotTransactionHash(uint256 proposalId, uint8 support, address voter, uint256 nonce)
    public
    view
    virtual
    returns (bytes32);
```

### getBallotStructHash

Return the ballot struct hash

*Reference: <https://eips.ethereum.org/EIPS/eip-712>*

```solidity
function getBallotStructHash(uint256 proposalId, uint8 support, address voter, uint256 nonce)
    public
    view
    virtual
    returns (bytes32);
```

### getExtendedBallotTransactionHash

Returns the extended ballot transaction hash, which is used in casting votes with reasons and params by signature

*The returned transaction hash should be signed by the voter to create a valid signature Reference: <https://eips.ethereum.org/EIPS/eip-712>*

```solidity
function getExtendedBallotTransactionHash(
    uint256 proposalId,
    uint8 support,
    address voter,
    uint256 nonce,
    string memory reason,
    bytes memory params
) public view virtual returns (bytes32);
```

### getExtendedBallotStructHash

Returns the extended ballot struct hash

*Reference: <https://eips.ethereum.org/EIPS/eip-712>*

```solidity
function getExtendedBallotStructHash(
    uint256 proposalId,
    uint8 support,
    address voter,
    uint256 nonce,
    string memory reason,
    bytes memory params
) public view virtual returns (bytes32);
```

### coreId

Returns the coreId of the implementation as a bytes32

*The core ID is the keccak256 hash of the contract name followed by a version under the following syntax: "mezzanine.coreId.ContractName.vX" For example, the core ID of the 2nd version of the Treasury would be the following: keccak256(abi.encodePacked("mezzanine.coreId.Treasury.v2"))*

```solidity
function coreId() public pure virtual override(Credentialed, ICredentialed) returns (bytes32);
```

### version

Returns the version of the implementation as a uint256

```solidity
function version() public pure virtual override(Credentialed, ICredentialed) returns (uint256);
```

### clock

*EIP-6372 support*

```solidity
function clock() public view virtual returns (uint48);
```

### CLOCK\_MODE

*EIP-6372 support*

```solidity
function CLOCK_MODE() public view virtual returns (string memory);
```

### \_countVote

*Counts a vote for a given proposal. Sets the receipt in storage Assumes that the weight has already been calculated*

```solidity
function _countVote(uint256 proposalId, address account, uint8 support, uint256 votes, bytes memory) internal virtual;
```

### \_voteSucceeded

*Returns whether or not the vote succeeded for a given proposal*

```solidity
function _voteSucceeded(uint256 proposalId) internal view virtual returns (bool);
```

**Returns**

| Name     | Type   | Description                                                               |
| -------- | ------ | ------------------------------------------------------------------------- |
| `<none>` | `bool` | True if the for votes are greater than the against votes, false otherwise |

### supportsInterface

*EIP-165 support. Reference: <https://eips.ethereum.org/EIPS/eip-165>*

```solidity
function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(MezzEIP712, MezzUUPSUpgradeable, IERC165)
    returns (bool);
```

## Structs

### ProposalGovernorStorage

```solidity
struct ProposalGovernorStorage {
    uint256 _proposalThresholdPercentage;
    uint256 _quorumPercentage;
    uint256 _votingPeriod;
    uint256 _votingDelay;
    mapping(uint256 => DataTypes.ProposalVotes) _proposalVotes;
    mapping(uint256 => mapping(address => DataTypes.Receipt)) _receipts;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mezzanine.xyz/smart-contracts/source-code/core/mezzgovernor/proposalgovernor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
