Skip to content

Commit 92bd5a6

Browse files
authored
Merge pull request #46 from keep-network/upgrade-proxy-issue
Extract deployment transaction from upgraded contract 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 that upgradeProxy adds to the contact's object.
2 parents b5fb923 + e077028 commit 92bd5a6

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/upgrades.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import "@openzeppelin/hardhat-upgrades"
22

3-
import type { Contract, ContractFactory } from "ethers"
3+
import type {
4+
Contract,
5+
ContractFactory,
6+
ContractTransactionResponse,
7+
} from "ethers"
48
import type {
59
Artifact,
610
FactoryOptions,
@@ -149,7 +153,13 @@ async function upgradeProxy<T extends Contract>(
149153
opts?.proxyOpts
150154
)) as T
151155

152-
const deploymentTransaction = newContractInstance.deploymentTransaction()
156+
// This is a workaround to get the deployment transaction. The upgradeProxy attaches
157+
// the deployment transaction to the field under a different name than ethers
158+
// contract.deploymentTransaction() function expects.
159+
// TODO: Remove this workaround once the issue is fixed on the OpenZeppelin side.
160+
// Tracked in: https://github.com/keep-network/hardhat-helpers/issues/49
161+
const deploymentTransaction =
162+
newContractInstance.deployTransaction as unknown as ContractTransactionResponse
153163

154164
// Let the transaction propagate across the ethereum nodes. This is mostly to
155165
// wait for all Alchemy nodes to catch up their state.

0 commit comments

Comments
 (0)