Proxy upgrade with new interface base class

I'm curious if the following upgrade would be safe to perform with OpenZeppelin's upgradeable proxies.

I have a deployed ERC721 implementation contract to which I would like to add an EIP-2981 interface via upgradeable proxy. Since IERC2981.sol does not add any storage variables, would it be safe to inherit the interface class in the new implementation of my ERC721 contract at the end of my inheritance list? Something like this:

contract MyUpgradeableERC721 is A, B, IERC2981Upgradeable {
    /*
     * storage and logic carried over from previous deployment 
     **\

    /*
     * new ERC165 interface function that exposes ERC2981
     **\
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(AccessControlEnumerableUpgradeable, ERC721Upgradeable, ERC721EnumerableUpgradeable, IERC165Upgradeable)
        returns (bool)
    {
        return interfaceId == type(IERC2981Upgradeable).interfaceId || super.supportsInterface(interfaceId);
    }
     }

For the sake posterity, I'll follow up on my own post. I decided to give it a try and it looks like this was "safe" after all. Since the inheritance chain of IERC2981Upgradeable introduced no new storage variables, all of my previously deployed proxies on the Polygon mainnet seem to still function just fine, and the royalties interface is operating properly.

So anyone who needs to add EIP-2981 compatibility to their upgradeable NFT project after its already been deployed should be able to do this with no issues.

1 Like