diff --git a/contracts/governance/Governor.sol b/contracts/governance/Governor.sol index 63c7b556ca1..dd6af79fa04 100644 --- a/contracts/governance/Governor.sol +++ b/contracts/governance/Governor.sol @@ -179,6 +179,15 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor { */ function _voteSucceeded(uint256 proposalId) internal view virtual returns (bool); + /** + * @dev Check the voting weight of an account. + */ + function _getVotes( + address account, + uint256 blockNumber, + bytes memory params + ) internal view virtual returns (uint256); + /** * @dev Register a vote with a given support and voting weight. * @@ -314,6 +323,13 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor { return proposalId; } + /** + * @dev See {IGovernor-getVotes}. + */ + function getVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) { + return _getVotes(account, blockNumber, _defaultParams()); + } + /** * @dev See {IGovernor-castVote}. */ @@ -381,7 +397,7 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor { ProposalCore storage proposal = _proposals[proposalId]; require(state(proposalId) == ProposalState.Active, "Governor: vote not currently active"); - uint256 weight = getVotes(account, proposal.voteStart.getDeadline()); + uint256 weight = _getVotes(account, proposal.voteStart.getDeadline(), params); _countVote(proposalId, account, support, weight, params); emit VoteCast(account, proposalId, support, weight, reason); diff --git a/contracts/governance/extensions/GovernorVotes.sol b/contracts/governance/extensions/GovernorVotes.sol index ee3f88e3562..343fc63add9 100644 --- a/contracts/governance/extensions/GovernorVotes.sol +++ b/contracts/governance/extensions/GovernorVotes.sol @@ -19,9 +19,9 @@ abstract contract GovernorVotes is Governor { } /** - * Read the voting weight from the token's built in snapshot mechanism (see {IGovernor-getVotes}). + * Read the voting weight from the token's built in snapshot mechanism (see {Governor-_getVotes}). */ - function getVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) { + function _getVotes(address account, uint256 blockNumber, bytes memory /*params*/) internal view virtual override returns (uint256) { return token.getPastVotes(account, blockNumber); } } diff --git a/contracts/governance/extensions/GovernorVotesComp.sol b/contracts/governance/extensions/GovernorVotesComp.sol index 9eb87a35fa4..ef7a0ef18bf 100644 --- a/contracts/governance/extensions/GovernorVotesComp.sol +++ b/contracts/governance/extensions/GovernorVotesComp.sol @@ -19,9 +19,9 @@ abstract contract GovernorVotesComp is Governor { } /** - * Read the voting weight from the token's built in snapshot mechanism (see {IGovernor-getVotes}). + * Read the voting weight from the token's built in snapshot mechanism (see {Governor-_getVotes}). */ - function getVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) { + function _getVotes(address account, uint256 blockNumber, bytes memory /*params*/) internal view virtual override returns (uint256) { return token.getPriorVotes(account, blockNumber); } } diff --git a/contracts/mocks/GovernorCompMock.sol b/contracts/mocks/GovernorCompMock.sol index 9dcbc536d0e..c2d8733e032 100644 --- a/contracts/mocks/GovernorCompMock.sol +++ b/contracts/mocks/GovernorCompMock.sol @@ -28,14 +28,4 @@ contract GovernorCompMock is GovernorVotesComp, GovernorCountingSimple { ) public returns (uint256 proposalId) { return _cancel(targets, values, calldatas, salt); } - - function getVotes(address account, uint256 blockNumber) - public - view - virtual - override(IGovernor, GovernorVotesComp) - returns (uint256) - { - return super.getVotes(account, blockNumber); - } } diff --git a/contracts/mocks/GovernorCompatibilityBravoMock.sol b/contracts/mocks/GovernorCompatibilityBravoMock.sol index 60afbb918e9..8f295f62faa 100644 --- a/contracts/mocks/GovernorCompatibilityBravoMock.sol +++ b/contracts/mocks/GovernorCompatibilityBravoMock.sol @@ -124,16 +124,6 @@ contract GovernorCompatibilityBravoMock is return super._cancel(targets, values, calldatas, salt); } - function getVotes(address account, uint256 blockNumber) - public - view - virtual - override(IGovernor, GovernorVotesComp) - returns (uint256) - { - return super.getVotes(account, blockNumber); - } - function _executor() internal view virtual override(Governor, GovernorTimelockCompound) returns (address) { return super._executor(); } diff --git a/contracts/mocks/GovernorMock.sol b/contracts/mocks/GovernorMock.sol index 85233f55951..dafb0a0a7a5 100644 --- a/contracts/mocks/GovernorMock.sol +++ b/contracts/mocks/GovernorMock.sol @@ -35,16 +35,6 @@ contract GovernorMock is return _cancel(targets, values, calldatas, salt); } - function getVotes(address account, uint256 blockNumber) - public - view - virtual - override(IGovernor, GovernorVotes) - returns (uint256) - { - return super.getVotes(account, blockNumber); - } - function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256) { return super.proposalThreshold(); } diff --git a/contracts/mocks/GovernorTimelockCompoundMock.sol b/contracts/mocks/GovernorTimelockCompoundMock.sol index aeba5b86a80..88a8829280c 100644 --- a/contracts/mocks/GovernorTimelockCompoundMock.sol +++ b/contracts/mocks/GovernorTimelockCompoundMock.sol @@ -92,16 +92,6 @@ contract GovernorTimelockCompoundMock is return super._cancel(targets, values, calldatas, salt); } - function getVotes(address account, uint256 blockNumber) - public - view - virtual - override(IGovernor, GovernorVotes) - returns (uint256) - { - return super.getVotes(account, blockNumber); - } - function _executor() internal view virtual override(Governor, GovernorTimelockCompound) returns (address) { return super._executor(); } diff --git a/contracts/mocks/GovernorTimelockControlMock.sol b/contracts/mocks/GovernorTimelockControlMock.sol index 97376c8253a..b056e5313ef 100644 --- a/contracts/mocks/GovernorTimelockControlMock.sol +++ b/contracts/mocks/GovernorTimelockControlMock.sol @@ -92,16 +92,6 @@ contract GovernorTimelockControlMock is return super._cancel(targets, values, calldatas, descriptionHash); } - function getVotes(address account, uint256 blockNumber) - public - view - virtual - override(IGovernor, GovernorVotes) - returns (uint256) - { - return super.getVotes(account, blockNumber); - } - function _executor() internal view virtual override(Governor, GovernorTimelockControl) returns (address) { return super._executor(); } diff --git a/contracts/mocks/GovernorVoteMock.sol b/contracts/mocks/GovernorVoteMock.sol index 23ccf6bc09c..60a3d41355e 100644 --- a/contracts/mocks/GovernorVoteMock.sol +++ b/contracts/mocks/GovernorVoteMock.sol @@ -28,14 +28,4 @@ contract GovernorVoteMocks is GovernorVotes, GovernorCountingSimple { ) public returns (uint256 proposalId) { return _cancel(targets, values, calldatas, salt); } - - function getVotes(address account, uint256 blockNumber) - public - view - virtual - override(IGovernor, GovernorVotes) - returns (uint256) - { - return super.getVotes(account, blockNumber); - } } diff --git a/contracts/mocks/wizard/MyGovernor1.sol b/contracts/mocks/wizard/MyGovernor1.sol index bd524ee55a2..a80d8400c5e 100644 --- a/contracts/mocks/wizard/MyGovernor1.sol +++ b/contracts/mocks/wizard/MyGovernor1.sol @@ -40,15 +40,6 @@ contract MyGovernor1 is return super.quorum(blockNumber); } - function getVotes(address account, uint256 blockNumber) - public - view - override(IGovernor, GovernorVotes) - returns (uint256) - { - return super.getVotes(account, blockNumber); - } - function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) { return super.state(proposalId); } diff --git a/contracts/mocks/wizard/MyGovernor2.sol b/contracts/mocks/wizard/MyGovernor2.sol index 3a5c983e0b3..34c608c5cc2 100644 --- a/contracts/mocks/wizard/MyGovernor2.sol +++ b/contracts/mocks/wizard/MyGovernor2.sol @@ -46,15 +46,6 @@ contract MyGovernor2 is return super.quorum(blockNumber); } - function getVotes(address account, uint256 blockNumber) - public - view - override(IGovernor, GovernorVotes) - returns (uint256) - { - return super.getVotes(account, blockNumber); - } - function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) { return super.state(proposalId); } diff --git a/contracts/mocks/wizard/MyGovernor3.sol b/contracts/mocks/wizard/MyGovernor3.sol index 835a893a3a4..70e4e87f046 100644 --- a/contracts/mocks/wizard/MyGovernor3.sol +++ b/contracts/mocks/wizard/MyGovernor3.sol @@ -44,15 +44,6 @@ contract MyGovernor is return super.quorum(blockNumber); } - function getVotes(address account, uint256 blockNumber) - public - view - override(IGovernor, GovernorVotes) - returns (uint256) - { - return super.getVotes(account, blockNumber); - } - function state(uint256 proposalId) public view