Document voting counting until casted in GovernorCountingOverridable (#5309)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Ernesto García
2024-11-22 23:45:05 +08:00
committed by GitHub
parent ccb39d2765
commit 23f4452b21

View File

@ -52,6 +52,11 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
/**
* @dev See {IGovernor-hasVoted}.
*
* NOTE: Calling {castVote} (or similar) casts a vote using the voting power that is delegated to the voter.
* Conversely, calling {castOverrideVote} (or similar) uses the voting power of the account itself, from its asset
* balances. Casting an "override vote" does not count as voting and won't be reflected by this getter. Consider
* using {hasVotedOverride} to check if an account has casted an "override vote" for a given proposal id.
*/
function hasVoted(uint256 proposalId, address account) public view virtual override returns (bool) {
return _proposalVotes[proposalId].voteReceipt[account].casted != 0;
@ -120,7 +125,11 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
return totalWeight;
}
/// @dev Variant of {Governor-_countVote} that deals with vote overrides.
/**
* @dev Variant of {Governor-_countVote} that deals with vote overrides.
*
* NOTE: See {hasVoted} for more details about the difference between {castVote} and {castOverrideVote}.
*/
function _countOverride(uint256 proposalId, address account, uint8 support) internal virtual returns (uint256) {
ProposalVote storage proposalVote = _proposalVotes[proposalId];
@ -150,7 +159,7 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
return overridenWeight;
}
/// @dev variant of {Governor-_castVote} that deals with vote overrides.
/// @dev Variant of {Governor-_castVote} that deals with vote overrides.
function _castOverride(
uint256 proposalId,
address account,