Add Governor contracts (#2672)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
26
contracts/governance/extensions/GovernorVotesComp.sol
Normal file
26
contracts/governance/extensions/GovernorVotesComp.sol
Normal file
@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../Governor.sol";
|
||||
import "../../token/ERC20/extensions/ERC20VotesComp.sol";
|
||||
|
||||
/**
|
||||
* @dev Extension of {Governor} for voting weight extraction from a Comp token.
|
||||
*
|
||||
* _Available since v4.3._
|
||||
*/
|
||||
abstract contract GovernorVotesComp is Governor {
|
||||
ERC20VotesComp public immutable token;
|
||||
|
||||
constructor(ERC20VotesComp token_) {
|
||||
token = token_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the voting weight from the token's built in snapshot mechanism (see {IGovernor-getVotes}).
|
||||
*/
|
||||
function getVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) {
|
||||
return token.getPriorVotes(account, blockNumber);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user