Hi, I am having an issue upgrading my contract using upgradeProxy when I adding a new parameter.
I am using truffle to do migration using upgradeProxy:
Hi Frangio, thank you for helping. as upgradeProxy does not provide any args as parameter like deployProxy, i tried to deploy the BoxV3 using deployProxy before I pass it into upgradeProxy but also not working
Ok, the thing is when you use upgradeProxy you’re changing the implementation of a contract that has already been initialized. So calling the initializer wouldn’t make sense. It would definitely make sense to call a function that “migrates” to the new version and initializes only the new state variables. There is nothing currently in the plugin to help you with that, although we do want to add it soon:
In the meantime you have to define a function and call it manually.
Just following up here - it would seem that based off the discussion in #62 there is a clear direction forward, but I may be missing it.
I have a Transparent Proxy and would like to do some form of an upgradeToAndCall, but am using (and would like to continue to use) OZ Upgrades with hardhat.
Hi! Just went through this same process and asked the same questions myself. Here is how I did it.
So you've got to the point where you want to call upgradeToAndCall on the ProxyAdmin, providing your newly created "migration function".
You're still going to want to use the upgrades.upgradeProxy function, but notice the third parameter is of type "UpgradeOptions" which looks like {call?: { fn: string; args?: unknown[] } | string}.
Notice if your migration function takes params, you can supply an object with your function name and arguments.
Thanks for sharing @Bridgerz. This is actually a relatively recent feature so it wasn't available before, but it's exactly what others in this thread would have needed.