Add support for constructor in logic holding contracts.
See original GitHub issueWhen deploying the logic contract for a proxy, you are expected to replace the constructor with an initialize function, for the part that is instance-specific (let’s say the name and symbol of an ERC20). This is verified by the plugin, which will refuse to work with implementations that have non-trivial constructors
However, it can still make sense to have a constructor that sets an immutable variable (such as the address of a forwarder for the ERC2771Context
). That way the logic contract can “hardcode” the forwarder in an immutable variable, and then all instances use the same forwarder out of the box, without having to initialize it.
Therefore, I think it would be useful to have a way to bypass this check and provide constructor arguments for the logic contract.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:11 (5 by maintainers)
You can find it here: https://github.com/OpenZeppelin/openzeppelin-upgrades/compare/master...lbeder:ctor-args?expand=1 and other than the issue with the caching of the logic contract (which causes the tests to fail) - it’s good for review.
Bypassing the check is now implemented, and basic immutable variables should work with the appropriate overrides:
Empty constructors should also be possible:
But it’s still not possible to provide arguments to the constructor.