Why is `supportsInterface` of ERC712 implementation overriding both ERC165 and IERC165?

:1234: Code to reproduce

The ERC721 contract found in the 4.2.0 version of @openzeppelin/contracts lib inherits from

contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {

and effectively overrides the supportsInterface function, but doing:

function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {

i.e. overriding both ERC165 and IERC165. I don't see the point of adding the IERC165 here, and furthermore it is not even imported atop the contract.

Thanks for clarification

This is enforced by Solidity. :frowning:

so you mean that solidity imposes that each override specifies all the overridden classes? and since ERC721 is ERC165 & ERC165 is IERC165, one has to write both ERC165 and IERC165 ? I am a bit surprised because it means then that you have to know what is inside any contract you inherit from.

Also, this IERC165 is not imported in the contract but I guess available at compile time because ERC165 is imported, which in turn imports it.

On the other hand, why not then contract ERC721 is Context, ERC165, IERC165, IERC721, IERC721Metadata { which would then make clearer the fact that the interface is enforced and maybe already fulfilled by ERC165?

Exactly!! I am also highly critical of this and have been meaning to make a proposal to improve it but it's a lot to put into words.

1 Like

Personally I don't think this is necessary. By inheriting ERC165 it is already very clear that IERC165 is implemented.

I have never done any proposal yet but if you feel like there is something (I am also rather new to solidity), I would be happy to help / to try to write down something.