Hi all, I have a question. Imagine I have an upgradeable contract in it's first version (V1) that extends ERC2771ContextUpgradeable which has among other things this:
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable _trustedForwarder;

/// @custom:oz-upgrades-unsafe-allow constructor
constructor(address trustedForwarder) {
_trustedForwarder = trustedForwarder;
}
In this case, I'm forced to set in my V1 contract the following constructor:
// @custom:oz-upgrades-unsafe-allow constructor
constructor(address _trustedForwarder)
ERC2771ContextUpgradeable(_trustedForwarder)
initializer
{
}
The thing is that if I create a new V2 contract that inherits from V1 that for example adds a new function, I'll be forced to set the same constructor than in V1 but the problem is that the variable that was being initialized was immutable so I can't mutate it. Am I wrong or missing something? Anyone can point me to another alternative solution? Thank you so much

Mar 9, 2022, 8:56 PM
If I leave an empty constructor solhint complains about my contract to tell me that should be marked as abstract, but not if I put the same constructor, that's why I was thinking that I was forced to that
For example, if I set this content on V2 contract:
constructor() initializer {}

function version() public pure override returns (string memory) {
return "2.0";
}
Solhint tells me Contract "V2" should be marked as abstract. but not if I set the same constructor. Does it make sense?
I think that is specified here: https://docs.soliditylang.org/en/v0.8.12/contracts.html?#arguments-for-base-constructors
Mar 9, 2022, 9:27 PM

© 2024 Draquery.com All rights reserved.