mirror of openzeppelin-contracts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// OpenZeppelin Contracts v4.4.0-rc.0 (governance/extensions/GovernorVotes.sol)
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
import "../Governor.sol";
|
|
|
|
import "../../token/ERC20/extensions/ERC20Votes.sol";
|
|
|
|
import "../../utils/math/Math.sol";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev Extension of {Governor} for voting weight extraction from an {ERC20Votes} token.
|
|
|
|
*
|
|
|
|
* _Available since v4.3._
|
|
|
|
*/
|
|
|
|
abstract contract GovernorVotes is Governor {
|
|
|
|
ERC20Votes public immutable token;
|
|
|
|
|
|
|
|
constructor(ERC20Votes tokenAddress) {
|
|
|
|
token = tokenAddress;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.getPastVotes(account, blockNumber);
|
|
|
|
}
|
|
|
|
}
|