1234567891011121314151617181920212223242526272829303132333435363738394041 |
- // SPDX-License-Identifier: MIT
- // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/extensions/ERC721Votes.sol)
- pragma solidity ^0.8.19;
- import {ERC721} from "../ERC721.sol";
- import {Votes} from "../../../governance/utils/Votes.sol";
- /**
- * @dev Extension of ERC721 to support voting and delegation as implemented by {Votes}, where each individual NFT counts
- * as 1 vote unit.
- *
- * Tokens do not count as votes until they are delegated, because votes must be tracked which incurs an additional cost
- * on every transfer. Token holders can either delegate to a trusted representative who will decide how to make use of
- * the votes in governance decisions, or they can delegate to themselves to be their own representative.
- */
- abstract contract ERC721Votes is ERC721, Votes {
- /**
- * @dev See {ERC721-_afterTokenTransfer}. Adjusts votes when tokens are transferred.
- *
- * Emits a {IVotes-DelegateVotesChanged} event.
- */
- function _afterTokenTransfer(
- address from,
- address to,
- uint256 firstTokenId,
- uint256 batchSize
- ) internal virtual override {
- _transferVotingUnits(from, to, batchSize);
- super._afterTokenTransfer(from, to, firstTokenId, batchSize);
- }
- /**
- * @dev Returns the balance of `account`.
- *
- * WARNING: Overriding this function will likely result in incorrect vote tracking.
- */
- function _getVotingUnits(address account) internal view virtual override returns (uint256) {
- return balanceOf(account);
- }
- }
|