Skip to content

Opensea operator filterer + toggle #303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 4, 2023
Merged

Conversation

nkrishang
Copy link
Contributor

  • Modifies the OpenSea operator filter extensions extension/DefaultOperatorFilterer and extension/OperatorFilterer to apply operator filter restrictions based on a toggle.
  • Introduces extension/OperatorFilterToggle which is the aforementioned toggle.
  • Updates TokenERC721, TokenERC1155, DropERC721 and DropERC1155 to support OpenSea operator filter with a toggle.

@nkrishang nkrishang self-assigned this Jan 4, 2023
emit OperatorRestriction(_restriction);
}

function _canSetOperatorRestriction() internal virtual returns (bool) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're not calling this anywhere

Comment on lines +328 to +369
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();

_beforeTokenTransfers(address(0), to, startTokenId, quantity);

// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint64(quantity);
_addressData[to].numberMinted += uint64(quantity);

_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);

uint256 updatedIndex = startTokenId;
uint256 end = updatedIndex + quantity;

if (to.isContract()) {
do {
emit Transfer(address(0), to, updatedIndex);
if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (updatedIndex < end);
// Reentrancy protection
if (_currentIndex != startTokenId) revert();
} else {
do {
emit Transfer(address(0), to, updatedIndex++);
} while (updatedIndex < end);
}
_currentIndex = updatedIndex;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}

Check warning

Code scanning / Slither

Reentrancy vulnerabilities

Reentrancy in ERC721AUpgradeable._safeMint(address,uint256,bytes) (contracts/eip/ERC721AVirtualApprove.sol#328-369): External calls: - ! _checkContractOnERC721Received(address(0),to,updatedIndex ++,_data) (contracts/eip/ERC721AVirtualApprove.sol#355) - IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(),from,tokenId,_data) (contracts/eip/ERC721AVirtualApprove.sol#571-583) State variables written after the call(s): - _currentIndex = updatedIndex (contracts/eip/ERC721AVirtualApprove.sol#366)
Comment on lines +565 to +584
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (
bytes4 retval
) {
return retval == IERC721ReceiverUpgradeable(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}

Check warning

Code scanning / Slither

Unused return

ERC721AUpgradeable._checkContractOnERC721Received(address,address,uint256,bytes) (contracts/eip/ERC721AVirtualApprove.sol#565-584) ignores return value by IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(),from,tokenId,_data) (contracts/eip/ERC721AVirtualApprove.sol#571-583)
bytes memory _data
) private returns (bool) {
try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (
bytes4 retval

Check notice

Code scanning / Slither

Pre-declaration usage of local variables

Variable 'ERC721AUpgradeable._checkContractOnERC721Received(address,address,uint256,bytes).retval (contracts/eip/ERC721AVirtualApprove.sol#572)' in ERC721AUpgradeable._checkContractOnERC721Received(address,address,uint256,bytes) (contracts/eip/ERC721AVirtualApprove.sol#565-584) potentially used before declaration: retval == IERC721ReceiverUpgradeable(to).onERC721Received.selector (contracts/eip/ERC721AVirtualApprove.sol#574)
bytes4 retval
) {
return retval == IERC721ReceiverUpgradeable(to).onERC721Received.selector;
} catch (bytes memory reason) {

Check notice

Code scanning / Slither

Pre-declaration usage of local variables

Variable 'ERC721AUpgradeable._checkContractOnERC721Received(address,address,uint256,bytes).reason (contracts/eip/ERC721AVirtualApprove.sol#575)' in ERC721AUpgradeable._checkContractOnERC721Received(address,address,uint256,bytes) (contracts/eip/ERC721AVirtualApprove.sol#565-584) potentially used before declaration: reason.length == 0 (contracts/eip/ERC721AVirtualApprove.sol#576)
bytes4 retval
) {
return retval == IERC721ReceiverUpgradeable(to).onERC721Received.selector;
} catch (bytes memory reason) {

Check notice

Code scanning / Slither

Pre-declaration usage of local variables

Variable 'ERC721AUpgradeable._checkContractOnERC721Received(address,address,uint256,bytes).reason (contracts/eip/ERC721AVirtualApprove.sol#575)' in ERC721AUpgradeable._checkContractOnERC721Received(address,address,uint256,bytes) (contracts/eip/ERC721AVirtualApprove.sol#565-584) potentially used before declaration: revert(uint256,uint256)(32 + reason,mload(uint256)(reason)) (contracts/eip/ERC721AVirtualApprove.sol#580)
Comment on lines +565 to +584
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (
bytes4 retval
) {
return retval == IERC721ReceiverUpgradeable(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}

Check warning

Code scanning / Slither

Assembly usage

ERC721AUpgradeable._checkContractOnERC721Received(address,address,uint256,bytes) (contracts/eip/ERC721AVirtualApprove.sol#565-584) uses assembly - INLINE ASM (contracts/eip/ERC721AVirtualApprove.sol#579-581)
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[42] private __gap;

Check warning

Code scanning / Slither

Unused state variable

ERC721AUpgradeable.__gap (contracts/eip/ERC721AVirtualApprove.sol#636) is never used in DropERC721 (contracts/drop/DropERC721.sol#32-401)
@kumaryash90 kumaryash90 merged commit 92cda4a into main Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants