|
@@ -7,9 +7,11 @@ import "../ERC721.sol";
|
|
|
import "./IERC721Enumerable.sol";
|
|
|
|
|
|
/**
|
|
|
- * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
|
|
|
- * enumerability of all the token ids in the contract as well as all token ids owned by each
|
|
|
- * account.
|
|
|
+ * @dev This implements an optional extension of {ERC721} defined in the EIP that adds enumerability
|
|
|
+ * of all the token ids in the contract as well as all token ids owned by each account.
|
|
|
+ *
|
|
|
+ * CAUTION: `ERC721` extensions that implement custom `balanceOf` logic, such as `ERC721Consecutive`,
|
|
|
+ * interfere with enumerability and should not be used together with `ERC721Enumerable`.
|
|
|
*/
|
|
|
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
|
|
|
// Mapping from owner to list of owned token IDs
|
|
@@ -50,7 +52,7 @@ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
|
|
|
* @dev See {IERC721Enumerable-tokenByIndex}.
|
|
|
*/
|
|
|
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
|
|
|
- require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
|
|
|
+ require(index < totalSupply(), "ERC721Enumerable: global index out of bounds");
|
|
|
return _allTokens[index];
|
|
|
}
|
|
|
|
|
@@ -116,7 +118,7 @@ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
|
|
|
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
|
|
|
// then delete the last slot (swap and pop).
|
|
|
|
|
|
- uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
|
|
|
+ uint256 lastTokenIndex = balanceOf(from) - 1;
|
|
|
uint256 tokenIndex = _ownedTokensIndex[tokenId];
|
|
|
|
|
|
// When the token to delete is the last token, the swap operation is unnecessary
|