Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/upgrades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
Contract,
ContractFactory,
ContractTransactionResponse,
TransactionReceiptParams,
} from "ethers"
import type {
Artifact,
Expand All @@ -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<T extends Contract>(
Expand Down Expand Up @@ -115,6 +116,7 @@ export async function deployProxy<T extends Contract>(
libraries: opts?.factoryOpts?.libraries,
devdoc: "Contract deployed as upgradable proxy",
args: opts?.proxyOpts?.constructorArgs,
receipt: convertReceipt(transactionReceipt),
}

await deployments.save(name, deployment)
Expand Down Expand Up @@ -199,13 +201,35 @@ async function upgradeProxy<T extends Contract>(
libraries: opts?.factoryOpts?.libraries,
devdoc: "Contract deployed as upgradable proxy",
args: opts?.proxyOpts?.constructorArgs,
receipt: convertReceipt(transactionReceipt),
}

await deployments.save(proxyDeploymentName, deployment)

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 {
Expand Down