-
Notifications
You must be signed in to change notification settings - Fork 10
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
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 😉 |
src/upgrades.ts
Outdated
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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 thatupgradeProxy
adds to the contact's object.deployProxy
implementation:source
deploymentTransaction
implementation:source