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

27 lines (22 loc) • 1.34 kB
import type { HardhatRuntimeEnvironment } from 'hardhat/types/hre'; import type { NetworkConnection } from 'hardhat/types/network'; import type { StringWithArtifactContractNamesAutocompletion } from 'hardhat/types/artifacts'; import { deployBeacon as engineDeployBeacon } from '../engine/deploy-beacon.js'; import type { DeployBeaconOptions } from './options.js'; import { getUpgradeableBeaconContract, UpgradeableBeaconContract } from './upgradeable-beacon.js'; import { asAddress, getContractInfo, makeBinding } from './utils.js'; export type DeployBeaconFunction = ( contractName: StringWithArtifactContractNamesAutocompletion, opts?: DeployBeaconOptions, ) => Promise<UpgradeableBeaconContract>; export function makeDeployBeacon(hre: HardhatRuntimeEnvironment, connection: NetworkConnection): DeployBeaconFunction { return async function deployBeacon( contractName: StringWithArtifactContractNamesAutocompletion, opts: DeployBeaconOptions = {}, ): Promise<UpgradeableBeaconContract> { const binding = await makeBinding(hre, connection, opts); const implInfo = await getContractInfo(hre, contractName, opts.libraries); const beaconDeployment = await engineDeployBeacon(binding, implInfo, opts); return getUpgradeableBeaconContract(connection, asAddress(beaconDeployment.address), opts.client); }; }