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

29 lines • 1.5 kB
import { getBeaconAddress, isBeaconProxy, isTransparentOrUUPSProxy, isBeacon, PrepareUpgradeRequiresKindError, } from '@openzeppelin/upgrades-core'; import { deployProxyImpl, deployBeaconImpl, deployUpgradeableImpl } from './deploy-impl.js'; /** * Client-neutral orchestration of `prepareUpgrade` (and the implementation deployment used by * `prepareUpgrade`): deploys (or reuses) the new implementation for the given reference, inferring * the proxy/beacon kind from the reference's on-chain shape. */ export async function deployImplForUpgrade(binding, referenceAddress, implInfo, opts) { const provider = binding.provider; let deployedImpl; if (await isTransparentOrUUPSProxy(provider, referenceAddress)) { deployedImpl = await deployProxyImpl(binding, implInfo, opts, referenceAddress); } else if (await isBeaconProxy(provider, referenceAddress)) { const beaconAddress = await getBeaconAddress(provider, referenceAddress); deployedImpl = await deployBeaconImpl(binding, implInfo, opts, beaconAddress); } else if (await isBeacon(provider, referenceAddress)) { deployedImpl = await deployBeaconImpl(binding, implInfo, opts, referenceAddress); } else { if (opts.kind === undefined) { throw new PrepareUpgradeRequiresKindError(); } deployedImpl = await deployUpgradeableImpl(binding, implInfo, opts, referenceAddress); } return deployedImpl; } //# sourceMappingURL=prepare-upgrade.js.map