From cf7a312306bac52266609132bde7b6bec38cf43c Mon Sep 17 00:00:00 2001 From: Ben DiFrancesco Date: Wed, 22 Dec 2021 10:26:28 -0500 Subject: [PATCH] Add a virtual method specifying default additional voting params --- contracts/governance/Governor.sol | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/contracts/governance/Governor.sol b/contracts/governance/Governor.sol index a4046eb47e8..540c0a77be8 100644 --- a/contracts/governance/Governor.sol +++ b/contracts/governance/Governor.sol @@ -192,6 +192,16 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor { bytes memory params ) internal virtual; + /** + * @dev Default additional encoded parameters used by castVote methods that don't include them + * + * Note: Should be overriden by specific implementations to use an appropriate value, the + * meaning of the additional params, in the context of that implementation + */ + function _defaultParams() internal view virtual returns (bytes memory) { + return ""; + } + /** * @dev See {IGovernor-propose}. */ @@ -309,7 +319,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor { */ function castVote(uint256 proposalId, uint8 support) public virtual override returns (uint256) { address voter = _msgSender(); - return _castVote(proposalId, voter, support, "", ""); + return _castVote(proposalId, voter, support, "", _defaultParams()); } /** @@ -320,7 +330,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor { uint8 support, string calldata reason ) public virtual override returns (uint256) { - return castVoteWithReasonAndParams(proposalId, support, reason, ""); + return castVoteWithReasonAndParams(proposalId, support, reason, _defaultParams()); } /** @@ -352,7 +362,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor { r, s ); - return _castVote(proposalId, voter, support, "", ""); + return _castVote(proposalId, voter, support, "", _defaultParams()); } /**