wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.17k stars 283 forks source link

Deterministic proxyArgs error #432

Closed tcoratger closed 11 months ago

tcoratger commented 1 year ago

Bug description

By using the deterministic function of deployments with a proxy in the form of an object with a specified proxyContract, the proxyArgs part doesn’t seem to work. Indeed, the default arguments is a 3 elements array ["{implementation}", "{admin}", "{data}"] that do not appear to be modified in the source code by passing a specific proxyArgs array argument. Despite the indication of an empty array, the error indicating 3 arguments persists (Error: expected 2 constructor arguments, got 3).

On the other hand, I don’t understand why I have to give two arguments for the constructor there as an UUPS proxy, knowing that I don’t have to specify these parameters for the deploy function or for the dedicated hardhat function:

const grtPool = await upgrades.deployProxy(
        await ethers.getContractFactory(
            "contracts/v0.1.0/GrtPool.sol:GrtPool"
        )
    );

To Reproduce

const result = await deterministic(
    "GrtPool",
    {
      contract: `contracts/v${protocolVersion}/GrtPool.sol:GrtPool`,
      from: owner,
      args: [],
      log: true,
      proxy: {
        owner: owner,
        proxyArgs: [],
        proxyContract: 'UUPS',
        execute: {
          init: {
            methodName: "initializePool",
            args: [getGrtAddress(hre.network.name)],
          },
        },
      },
      salt: ethers.utils.keccak256(
        ethers.utils.arrayify(ethers.utils.toUtf8Bytes("GrtPool9"))
      ),
    }
  );

Error:

Error: expected 2 constructor arguments, got 3

Expected behavior

In this case, I would giveproxyArgs: [] like in the deploy function case that works for this case

const result = await deploy(
    "GrtPool",
    {
      contract: `contracts/v${protocolVersion}/GrtPool.sol:GrtPool`,
      from: owner,
      args: [],
      log: true,
      proxy: {
        owner: owner,
        proxyArgs: [],
        proxyContract: 'UUPS',
        //"OpenZeppelinTransparentProxy", "ERC1967Proxy", "UUPS", "ERC1967Stub"
        execute: {
          init: {
            methodName: "initializePool",
            args: [getGrtAddress(hre.network.name)],
          },
        },
      },
    }
  );

Versions