Extract deployment transaction from upgraded contract#46
Conversation
After proxy contract is upgraded we had a problem with extracting deployment transaction via `contract.deploymentTransaction()` from ethers. It was happening because OpenZeppelin's `upgradeProxy` was replacing deployment tx on the proxy contract but the field was different than what ethers function expected. Let's make it work by directly using the field that `upgradeProxy` adds on the contact's object.
|
Other things I noticed that could be improved in
Lmk what you think about the priorities of these issues, they aren't blocking but I think nice to have 😉 |
| // This is a workaround to get the deployment transaction. The upgradeProxy attaches | ||
| // the deployment transaction to the field under a different name than ethers | ||
| // contract.deploymentTransaction() function expects. | ||
| const deploymentTransaction = | ||
| newContractInstance.deployTransaction as unknown as ContractTransactionResponse |
There was a problem hiding this comment.
Does it mean it is an issue in the OpenZeppelin upgrade plugin? If so, we should open an issue in their GitHub repository and link it from here.
There was a problem hiding this comment.
Probably it is something on their side unless that's again an issue with changes between different major ethers versions. Will check what is going on, if ethers was ever using that field name
|
Found a PR that would fix it on the OpenZeppelin's side |
Please open three separate issues in this repository: unit test for upgrades, types problem, and one to eliminate the workaround we implemented in this PR once it is fixed on the OpenZeppelin side. Let's please also post a link to the third issue from the workaround comment in the code. The workaround itself looks good to me but I would like it to refer to the issue so that everyone working with this code is aware of the need to remove it at some point in future. |
|
Nice investigation! 🕵🏻♀️ |
What
After the proxy contract was upgraded we had a problem with extracting the deployment transaction via
contract.deploymentTransaction()from ethers.It was happening because OpenZeppelin's
upgradeProxywas replacing deployment tx on the proxy contract but the field was different than what ethers function expected. Let's make it work by directly using the field thatupgradeProxyadds to the contact's object.deployProxyimplementation:source

deploymentTransactionimplementation:source
