@openzeppelin/hardhat-upgrades
Version:
[](https://docs.openzeppelin.com/upgrades-plugins/hardhat-upgrades) [](https://www.npmjs.org/package/@openzeppelin/h
29 lines • 1.54 kB
JavaScript
import { Manifest, logWarning, isBeacon, DeployBeaconProxyUnsupportedError, DeployBeaconProxyKindError, } from '@openzeppelin/upgrades-core';
import { getInitializerData } from './initializer-data.js';
import { getBeaconProxyContractInfo } from './artifacts.js';
/**
* Client-neutral orchestration of `deployBeaconProxy`. `attachToAbi` is the ABI of the beacon's
* current implementation, used only to encode the initializer call.
*/
export async function deployBeaconProxy(binding, beaconAddress, attachToAbi, args, opts) {
const provider = binding.provider;
const manifest = await Manifest.forNetwork(provider);
if (opts.kind !== undefined && opts.kind !== 'beacon') {
throw new DeployBeaconProxyKindError(opts.kind);
}
opts.kind = 'beacon';
if (!(await isBeacon(provider, beaconAddress))) {
throw new DeployBeaconProxyUnsupportedError(beaconAddress);
}
const data = getInitializerData(binding, attachToAbi, args, opts.initializer);
if (await manifest.getAdmin()) {
logWarning(`A proxy admin was previously deployed on this network`, [
`This is not natively used with the current kind of proxy ('beacon').`,
`Changes to the admin will have no effect on this new proxy.`,
]);
}
const proxyDeployment = Object.assign({ kind: opts.kind }, await binding.deployProxy(getBeaconProxyContractInfo(), [beaconAddress, data]));
await manifest.addProxy(proxyDeployment);
return proxyDeployment;
}
//# sourceMappingURL=deploy-beacon-proxy.js.map