-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make ERC721Votes no longer a Draft (#3699)
(cherry picked from commit 7a14f6c)
- Loading branch information
Showing
7 changed files
with
67 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "../ERC721.sol"; | ||
import "../../../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. | ||
* | ||
* _Available since v4.5._ | ||
*/ | ||
abstract contract ERC721Votes is ERC721, Votes { | ||
/** | ||
* @dev Adjusts votes when tokens are transferred. | ||
* | ||
* Emits a {Votes-DelegateVotesChanged} event. | ||
*/ | ||
function _afterTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 tokenId | ||
) internal virtual override { | ||
_transferVotingUnits(from, to, 1); | ||
super._afterTokenTransfer(from, to, tokenId); | ||
} | ||
|
||
/** | ||
* @dev Adjusts votes when a batch of tokens is transferred. | ||
* | ||
* Emits a {Votes-DelegateVotesChanged} event. | ||
*/ | ||
function _afterConsecutiveTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 first, | ||
uint96 size | ||
) internal virtual override { | ||
_transferVotingUnits(from, to, size); | ||
super._afterConsecutiveTokenTransfer(from, to, first, size); | ||
} | ||
|
||
/** | ||
* @dev Returns the balance of `account`. | ||
*/ | ||
function _getVotingUnits(address account) internal view virtual override returns (uint256) { | ||
return balanceOf(account); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,8 @@ | ||
// SPDX-License-Identifier: MIT | ||
// OpenZeppelin Contracts (last updated v4.8.0-rc.0) (token/ERC721/extensions/draft-ERC721Votes.sol) | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "../ERC721.sol"; | ||
import "../../../governance/utils/Votes.sol"; | ||
// ERC721Votes was marked as draft due to the EIP-712 dependency. | ||
// EIP-712 is Final as of 2022-08-11. This file is deprecated. | ||
|
||
/** | ||
* @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. | ||
* | ||
* _Available since v4.5._ | ||
*/ | ||
abstract contract ERC721Votes is ERC721, Votes { | ||
/** | ||
* @dev Adjusts votes when tokens are transferred. | ||
* | ||
* Emits a {Votes-DelegateVotesChanged} event. | ||
*/ | ||
function _afterTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 tokenId | ||
) internal virtual override { | ||
_transferVotingUnits(from, to, 1); | ||
super._afterTokenTransfer(from, to, tokenId); | ||
} | ||
|
||
/** | ||
* @dev Adjusts votes when a batch of tokens is transferred. | ||
* | ||
* Emits a {Votes-DelegateVotesChanged} event. | ||
*/ | ||
function _afterConsecutiveTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 first, | ||
uint96 size | ||
) internal virtual override { | ||
_transferVotingUnits(from, to, size); | ||
super._afterConsecutiveTokenTransfer(from, to, first, size); | ||
} | ||
|
||
/** | ||
* @dev Returns the balance of `account`. | ||
*/ | ||
function _getVotingUnits(address account) internal view virtual override returns (uint256) { | ||
return balanceOf(account); | ||
} | ||
} | ||
import "./ERC721Votes.sol"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.