From b70adc555607f58dbf3746e80f448dc6a99ffc04 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 8 Aug 2024 16:39:41 +0200 Subject: [PATCH] Convert type of receipt from ethers v6 to hardhat-deploy hardhat-deploy plugin expects different type of the receipt compared to what ethers v6 returns. This commit changes the type of the receipt from ethers v6 to hardhat-deploy. --- src/upgrades.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/upgrades.ts b/src/upgrades.ts index af1ee24..346d6c5 100644 --- a/src/upgrades.ts +++ b/src/upgrades.ts @@ -4,6 +4,7 @@ import type { Contract, ContractFactory, ContractTransactionResponse, + TransactionReceiptParams, } from "ethers" import type { Artifact, @@ -15,7 +16,7 @@ import type { DeployProxyOptions, UpgradeProxyOptions, } from "@openzeppelin/hardhat-upgrades/src/utils/options" -import { Libraries } from "hardhat-deploy/types" +import { Libraries, Receipt } from "hardhat-deploy/types" export interface HardhatUpgradesHelpers { deployProxy( @@ -115,6 +116,7 @@ export async function deployProxy( libraries: opts?.factoryOpts?.libraries, devdoc: "Contract deployed as upgradable proxy", args: opts?.proxyOpts?.constructorArgs, + receipt: convertReceipt(transactionReceipt), } await deployments.save(name, deployment) @@ -199,6 +201,7 @@ async function upgradeProxy( libraries: opts?.factoryOpts?.libraries, devdoc: "Contract deployed as upgradable proxy", args: opts?.proxyOpts?.constructorArgs, + receipt: convertReceipt(transactionReceipt), } await deployments.save(proxyDeploymentName, deployment) @@ -206,6 +209,27 @@ async function upgradeProxy( return [newContractInstance, deployment] } +function convertReceipt(tx: TransactionReceiptParams): Receipt { + return { + ...tx, + transactionHash: tx.hash, + transactionIndex: tx.index, + cumulativeGasUsed: tx.cumulativeGasUsed.toString(), + gasUsed: tx.gasUsed.toString(), + contractAddress: tx.contractAddress!, + to: tx.to!, + from: tx.from!, + status: tx.status!, + logs: tx.logs.map((log) => { + return { + ...log, + logIndex: log.index, + topics: log.topics.map((topic) => topic), + } + }), + } +} + export default function ( hre: HardhatRuntimeEnvironment ): HardhatUpgradesHelpers {