Skip to content

Commit

Permalink
Add public getVotesWithParams to Governor
Browse files Browse the repository at this point in the history
  • Loading branch information
apbendi committed Feb 26, 2022
1 parent 6e2b447 commit 455efe8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
14 changes: 13 additions & 1 deletion contracts/governance/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor {
interfaceId ==
(type(IGovernor).interfaceId ^
this.castVoteWithReasonAndParams.selector ^
this.castVoteWithReasonAndParamsBySig.selector) ||
this.castVoteWithReasonAndParamsBySig.selector ^
this.getVotesWithParams.selector) ||
interfaceId == type(IGovernor).interfaceId ||
super.supportsInterface(interfaceId);
}
Expand Down Expand Up @@ -392,6 +393,17 @@ abstract contract Governor is Context, ERC165, EIP712, IGovernor {
return _getVotes(account, blockNumber, _defaultParams());
}

/**
* @dev See {IGovernor-getVotesWithParams}.
*/
function getVotesWithParams(
address account,
uint256 blockNumber,
bytes memory params
) public view virtual override returns (uint256) {
return _getVotes(account, blockNumber, params);
}

/**
* @dev See {IGovernor-castVote}.
*/
Expand Down
10 changes: 10 additions & 0 deletions contracts/governance/IGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ abstract contract IGovernor is IERC165 {
*/
function getVotes(address account, uint256 blockNumber) public view virtual returns (uint256);

/**
* @notice module:reputation
* @dev Voting power of an `account` at a specific `blockNumber` given additional encoded parameters.
*/
function getVotesWithParams(
address account,
uint256 blockNumber,
bytes memory params
) public view virtual returns (uint256);

/**
* @notice module:voting
* @dev Returns weither `account` has cast a vote on `proposalId`.
Expand Down
1 change: 1 addition & 0 deletions test/utils/introspection/SupportsInterface.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const INTERFACES = {
'votingPeriod()',
'quorum(uint256)',
'getVotes(address,uint256)',
'getVotesWithParams(address,uint256,bytes)',
'hasVoted(uint256,address)',
'propose(address[],uint256[],bytes[],string)',
'execute(address[],uint256[],bytes[],bytes32)',
Expand Down

0 comments on commit 455efe8

Please sign in to comment.