New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support use with implementations and proxies from OpenZeppelin Contracts 4.x #2
Comments
Same situation |
If you need to call a function on your new implementation during the upgrade (such as to call a reinitializer), you can just call If you don't need to call a function on your new implementation during the upgrade, you can do the following workaround:
|
What is different from doing this ? vm.startBroadcast(deployPrivateKey);
address implementation = address(new MyContract());
console2.log(implementation);
address proxy = address(new ERC1967Proxy(implementation, ""));
MyContract myContract = MyContract(proxy);
vm.stopBroadcast(); I believe both are using
|
In order for the validations to work, in MyContractV2, you should add an annotation to specify the previous version that it upgrades from. See examples in https://docs.openzeppelin.com/upgrades-plugins/1.x/api-core#define-reference-contracts Foundry does not use existing Hardhat artifacts. There is no need to, because the new annotation is used for validations, and you should recompile your contracts with Foundry instead of trying to reuse Hardhat compilation artifacts. Here is an example of what the upgrade script could look like:
|
Can Can we upgrade contracts with Foundry without using the library |
Right, this issue will need to be fixed in order for 4.x to be used with Upgrades.sol. To upgrade without
We still recommend validating storage layout compatibility before upgrading. You can do that using the |
Users may want to migrate from Hardhat to Foundry, and they may have contracts and/or proxies already deployed with OpenZeppelin Contracts 4.x.
This would include:
Note that we will probably not support deploying new 4.x proxies, but this feature will cover support for upgrading existing ones.
Originally requested in https://forum.openzeppelin.com/t/first-look-at-the-upcoming-openzeppelin-foundry-upgrades-library/38347/2
The text was updated successfully, but these errors were encountered: