@openzeppelin/hardhat-upgrades
Version:
[](https://docs.openzeppelin.com/upgrades-plugins/hardhat-upgrades) [](https://www.npmjs.org/package/@openzeppelin/h
24 lines • 1.43 kB
JavaScript
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