From 862311205ab99e073823c5beaa4b69d15f1b1a88 Mon Sep 17 00:00:00 2001 From: ssups Date: Sun, 3 Sep 2023 21:43:02 +0900 Subject: [PATCH] fix: upgrade-proxy/UpgradeFunction --- packages/plugin-hardhat/src/upgrade-proxy.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/plugin-hardhat/src/upgrade-proxy.ts b/packages/plugin-hardhat/src/upgrade-proxy.ts index 4084a299d..9bfb81458 100644 --- a/packages/plugin-hardhat/src/upgrade-proxy.ts +++ b/packages/plugin-hardhat/src/upgrade-proxy.ts @@ -34,8 +34,18 @@ export function makeUpgradeProxy(hre: HardhatRuntimeEnvironment, defenderModule: const upgradeTx = await upgradeTo(nextImpl, call); const inst = attach(ImplFactory, proxyAddress); - // @ts-ignore Won't be readonly because inst was created through attach. - inst.deployTransaction = upgradeTx; + + // as is -> inst.deployTransaction = upgradeTx; + // inst(instance of ethers.Contract) dose not have property named deployTransaction but deploymentTransaction + // and it is a function which returns ethers.ContractTransactionResponse | null , not ethers.TransactionResponse itself + // it shoud be correted like below + // @ts-ignore + inst.deploymentTransaction = () => upgradeTx || null; + + // Additionally, upgradeTx is not tx about deployment (also each type is different) + // I think it's better way to not override deploymentTrnasaction with upgradeTx and just block until upgradeTx to be resolved like below code + await upgradeTx.wait(); + return inst; };