Ignore specific warnings and make the rest into errors (#3695)

(cherry picked from commit 046121e080)
This commit is contained in:
Francisco
2022-09-22 17:33:13 -03:00
committed by Francisco Giordano
parent 8740d8f7f3
commit 089f9b95af
7 changed files with 490 additions and 58 deletions

View File

@ -0,0 +1,62 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../token/ERC721/extensions/ERC721Consecutive.sol";
import "../token/ERC721/extensions/ERC721Enumerable.sol";
contract ERC721ConsecutiveEnumerableMock is ERC721Consecutive, ERC721Enumerable {
constructor(
string memory name,
string memory symbol,
address[] memory receivers,
uint96[] memory amounts
) ERC721(name, symbol) {
for (uint256 i = 0; i < receivers.length; ++i) {
_mintConsecutive(receivers[i], amounts[i]);
}
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
function _ownerOf(uint256 tokenId) internal view virtual override(ERC721, ERC721Consecutive) returns (address) {
return super._ownerOf(tokenId);
}
function _mint(address to, uint256 tokenId) internal virtual override(ERC721, ERC721Consecutive) {
super._mint(to, tokenId);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721, ERC721Enumerable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721, ERC721Consecutive) {
super._afterTokenTransfer(from, to, tokenId);
}
function _beforeConsecutiveTokenTransfer(
address from,
address to,
uint256 first,
uint96 size
) internal virtual override(ERC721, ERC721Enumerable) {
super._beforeConsecutiveTokenTransfer(from, to, first, size);
}
}

View File

@ -95,62 +95,6 @@ contract ERC721ConsecutiveMock is ERC721Burnable, ERC721Consecutive, ERC721Pausa
}
}
contract ERC721ConsecutiveEnumerableMock is ERC721Consecutive, ERC721Enumerable {
constructor(
string memory name,
string memory symbol,
address[] memory receivers,
uint96[] memory amounts
) ERC721(name, symbol) {
for (uint256 i = 0; i < receivers.length; ++i) {
_mintConsecutive(receivers[i], amounts[i]);
}
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
function _ownerOf(uint256 tokenId) internal view virtual override(ERC721, ERC721Consecutive) returns (address) {
return super._ownerOf(tokenId);
}
function _mint(address to, uint256 tokenId) internal virtual override(ERC721, ERC721Consecutive) {
super._mint(to, tokenId);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721, ERC721Enumerable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721, ERC721Consecutive) {
super._afterTokenTransfer(from, to, tokenId);
}
function _beforeConsecutiveTokenTransfer(
address from,
address to,
uint256 first,
uint96 size
) internal virtual override(ERC721, ERC721Enumerable) {
super._beforeConsecutiveTokenTransfer(from, to, first, size);
}
}
contract ERC721ConsecutiveNoConstructorMintMock is ERC721Consecutive {
constructor(string memory name, string memory symbol) ERC721(name, symbol) {
_mint(msg.sender, 0);

View File

@ -106,9 +106,13 @@ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
address,
address,
uint256,
uint96
uint96 size
) internal virtual override {
revert("ERC721Enumerable: consecutive transfers not supported");
// We revert because enumerability is not supported with consecutive batch minting.
// This conditional is only needed to silence spurious warnings about unreachable code.
if (size > 0) {
revert("ERC721Enumerable: consecutive transfers not supported");
}
}
/**