ERC165Checker; is it required to check support for ERC-165 AND any given interface, or just the latter?

My contract needs to check whether an external contract supports a standard interface, I want the function to be as cheap as possible, therefore my question is; does the checking contract need to detect support for ERC-165 AND the other given interface, or just the latter?

I mean, technically it is possible to implement a supportsInterface function that only returns true for the given interface and not for ERC-165, which would make it non compliant to the standard, but do I really need to check for both?

My contract is an NFT marketplace, therefore NFTs should support eip165 by default; would it be unwise to check directly for support of the particular interface I am interested in? The NatSpec comments above the private _supportsERC165Interface function read:

@dev Assumes that account contains a contract that supports ERC165, otherwise the behavior of this method is undefined.

What's the worse that could happen?

Thank you in advance. Kind regards.

edit: i read the question wrong, so ignore my previous answer.

All your contract wants to know if the other contract supports an interface, so you will only have check if that interface is supported. You do not have to implement ERC-165 yourself.

However if you call supportsInterface on the external contract, then you are already assuming the external contract implements ERC-165 :slight_smile: Which might not be true.

Calling the supportsInterface from ERC165Checker will perform the supportsERC165 check before it check the actual interface you are checking for. So to answer the question in the title, no you do not have to check for ERC-165 itself.
Checking in your contract if the contract supports the interface you are looking for directly instead of using the ERC165Checker might be slightly cheaper however as your check will only perform 1 call instead of 2.