wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.19k stars 292 forks source link

Deploying a Proxy contract with a preexistent ProxyAdmin #346

Closed simsbluebox closed 2 years ago

simsbluebox commented 2 years ago

After reading the documentation and taking a glimpse at the code, I wondered if there is a way to define a ProxyAdmin deployed by another framework (Truffle) before. Using the viaAdminContract seems to search in the current Hardhat deployments db/path, or try to deploy a new one.

    proxy: {
    proxyContract: "OpenZeppelinTransparentProxy",
    viaAdminContract: ?
    },
wighawag commented 2 years ago

you can add a file in the deployments/<network> folder and add the abi + address in it

simsbluebox commented 2 years ago

Apart from the file, as you suggested, I only provided the ProxyAdmin's owner, and it worked perfectly! This is the tested snippet:

const result = await deploy(ContractName,{
    from: deployer,
    proxy: {
      proxyContract: "OpenZeppelinTransparentProxy",
      owner: ProxyAdminOwner,
      viaAdminContract: {
        name: "ProxyAdmin"
      },
    },
    log: true,
});

Thanks for your help @wighawag !