UNPKG

@openzeppelin/hardhat-upgrades

Version:

[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-blue)](https://docs.openzeppelin.com/upgrades-plugins/hardhat-upgrades) [![NPM Package](https://img.shields.io/npm/v/@openzeppelin/hardhat-upgrades.svg)](https://www.npmjs.org/package/@openzeppelin/h

24 lines • 1.43 kB
import { getContractAddress } from './utils/index.js'; import { enableDefender } from './defender/utils.js'; import { deployImplForUpgrade as engineDeployImplForUpgrade } from './engine/prepare-upgrade.js'; import { makeEthersBinding, contractInfo, txResponseOf } from './ethers-binding.js'; export function makePrepareUpgrade(hre, defenderModule, connection) { return async function prepareUpgrade(referenceAddressOrContract, ImplFactory, opts = {}) { opts = enableDefender(hre, defenderModule, opts); const deployedImpl = await deployImplForUpgrade(hre, referenceAddressOrContract, ImplFactory, opts, connection); if (opts.getTxResponse && deployedImpl.txResponse) { return deployedImpl.txResponse; } else { return deployedImpl.impl; } }; } export async function deployImplForUpgrade(hre, referenceAddressOrContract, ImplFactory, opts = {}, connection) { const referenceAddress = await getContractAddress(referenceAddressOrContract); const binding = makeEthersBinding(hre, connection, ImplFactory.runner, opts); const deployedImpl = await engineDeployImplForUpgrade(binding, referenceAddress, contractInfo(ImplFactory), opts); const txResponse = opts.getTxResponse ? await txResponseOf(deployedImpl.deployment, connection) : undefined; return { impl: deployedImpl.impl, txResponse }; } //# sourceMappingURL=prepare-upgrade.js.map