Hello,
I have the following upgradeable contract:
import "./IMyCustomErc20.sol";
contract MyContract is UUPSUpgradeable {
/// @custom:storage-location erc7201:storage.MyContract
struct MyContractStorage {
IMyCustomErc20 customErc20;
}
// keccak256(abi.encode(uint256(keccak256("storage.MyContract")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant MyContractStorageLocation =
0xba46220259871765522240056f76631a28aa19c5092d6dd51d6b858b4ebcb300;
function _getMyContractStorage() private pure returns (MyContractStorage storage $) {
assembly {
$.slot := MyContractStorageLocation
}
}
function initialize(address _customErc20) public {
MyContractStorage storage $ = _getMyContractStorage();
$.customErc20 = IMyCustomErc20(_customErc20);
}
}
Now let's say that I add some new functionality to my other contract (the MyCustomErc20Token) and I update the IMyCustomErc20 interface. Do I need to update MyContract to support the new interface like this?
import "./IMyCustomErc20.sol";
import "./IMyCustomErc20V2.sol";
....
/// @custom:storage-location erc7201:storage.MyContract
struct MyContractStorage {
IMyCustomErc20 customErc20;
IMyCustomErc20V2 customErc20V2;
}
....
or can I just update the IMyCustomErc20 file without creating a V2 version and my contract will support by default all the new changes I made?
Are there any potential storage issues after upgrading or any other issues to be aware of if the change of the interface doesn't affect storage conflicts?