@openzeppelin/hardhat-upgrades
Version:
[](https://docs.openzeppelin.com/upgrades-plugins/hardhat-upgrades) [](https://www.npmjs.org/package/@openzeppelin/h
24 lines • 1.41 kB
JavaScript
import { ContractFactory } from 'ethers';
import { UpgradesError } from '@openzeppelin/upgrades-core';
import { getContractAddress } from './utils/index.js';
import { enableDefender } from './defender/utils.js';
import { getContractInstance } from './utils/contract-instance.js';
import { makeEthersBinding, contractInfo } from './ethers-binding.js';
import { deployBeaconProxy as engineDeployBeaconProxy } from './engine/deploy-beacon-proxy.js';
export function makeDeployBeaconProxy(hre, defenderModule, connection) {
return async function deployBeaconProxy(beacon, attachTo, args = [], opts = {}) {
if (!(attachTo instanceof ContractFactory)) {
throw new UpgradesError(`attachTo must specify a contract factory`, () => `Include the contract factory for the beacon's current implementation in the attachTo parameter`);
}
if (!Array.isArray(args)) {
opts = args;
args = [];
}
opts = enableDefender(hre, defenderModule, opts);
const binding = makeEthersBinding(hre, connection, attachTo.runner, opts);
const beaconAddress = await getContractAddress(beacon);
const proxyDeployment = await engineDeployBeaconProxy(binding, beaconAddress, contractInfo(attachTo).abi, args, opts);
return getContractInstance(hre, attachTo, opts, proxyDeployment);
};
}
//# sourceMappingURL=deploy-beacon-proxy.js.map