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 newnewInitialize
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.