You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
879 B
Solidity
32 lines
879 B
Solidity
2 years ago
|
// SPDX-License-Identifier: MIT
|
||
|
// OpenZeppelin Contracts (last updated v4.6.0) (governance/extensions/GovernorVotes.sol)
|
||
|
|
||
|
pragma solidity ^0.8.0;
|
||
|
|
||
|
import "../Governor.sol";
|
||
|
import "../utils/IVotes.sol";
|
||
|
|
||
|
/**
|
||
|
* @dev Extension of {Governor} for voting weight extraction from an {ERC20Votes} token, or since v4.5 an {ERC721Votes} token.
|
||
|
*
|
||
|
* _Available since v4.3._
|
||
|
*/
|
||
|
abstract contract GovernorVotes is Governor {
|
||
|
IVotes public immutable token;
|
||
|
|
||
|
constructor(IVotes tokenAddress) {
|
||
|
token = tokenAddress;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Read the voting weight from the token's built in snapshot mechanism (see {Governor-_getVotes}).
|
||
|
*/
|
||
|
function _getVotes(
|
||
|
address account,
|
||
|
uint256 blockNumber,
|
||
|
bytes memory /*params*/
|
||
|
) internal view virtual override returns (uint256) {
|
||
|
return token.getPastVotes(account, blockNumber);
|
||
|
}
|
||
|
}
|