Shall I include `initialize/initializeVx` selectors in the supportsInterface?

Hi Team,

I was wondering if you could give your advice about Upgradeable Contracts. We're heavily using OZ. As you know, OZ's abstract contracts have functions such as __init... for example:

function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
        __ERC20_init_unchained(name_, symbol_);
    }

This means that I need initialize function in my most derived contract(let's call it mainContract) from which I will call __ERC20_init.

The question is would I include initialize.selector in the supportsInterface function in my mainContract ? In the beginning I did, but when upgrade requirement happens(assuming new param is needed to be passed), as you know, 2 steps are need to be followed:

  • add initializeV2 function that will be called on the upgrade
  • initialize itself needs to be changed to expect this new param.

If we include initialize selector in the supportsInterface, this is problematic because since initialize also changes due to new param, its selector becomes different. There're 2 ways to solve this:

  • Either never include initialize.selector in the supportsInterface at all.
  • leave old initialize in which revert occurs and add new newInitialize and add this as well in the supportsInterface.

I am inclined to go with first option. What's the best practice ? do you include initialize selector in the supportsInterface ? The same question would arise whether we include initializeV2 in the selectors. Happy to hear your thoughts as I am curious about best practices.

Thanks so much.

Do you have a specific need to include the initializers in the interface? Those are only called during proxy deployment or upgrade, so I'd assume the caller should know which initializer function is available.

For example, we don't include the initializer in supportsInterface in the contracts generated by https://wizard.openzeppelin.com/. You can see this if you choose ERC721 and enable Enumerable and Upgradeability.