wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.18k stars 286 forks source link

Hardhat-deploy : function "upgradeTo" will shadow "upgradeTo" when deploying proxy #396

Open NufailIsmath opened 1 year ago

NufailIsmath commented 1 year ago

Error: function "upgradeTo" will shadow "upgradeTo". Getting this error when I try to run hardhat deploy

deploy.js

module.exports = async({ getNamedAccounts, deployments }) => {
    const { deploy } = deployments;
    const { deployer } = await getNamedAccounts();

    const proxyOptionBase = { proxyContract: "ECOERC1155_ERC1967Proxy" };
    const proxyOption = {
        proxyOptionBase,
        execute: {
            methodName: "upgradeTo",
            args: [],
        },
    };
    await deploy("ECOERC1155", {
        from: deployer,
        args: [],
        log: true,
        proxy: proxyOption,
    });

};
module.exports.tags = ["ECOERC1155"];

Expected behavior To deploy proxy and the implementation

versions

wighawag commented 1 year ago

this should be

const proxyOptionBase = { proxyContract: "ECOERC1155_ERC1967Proxy" };
    const proxyOption = {
        ...proxyOptionBase, // to ensure proxyContract is speciied
        execute: {
            methodName: "upgradeTo",
            args: [],
        },
    };
NufailIsmath commented 1 year ago

I tried that too, got the same error

wighawag commented 1 year ago

so maybe you contract ECOERC1155 has also a function called upgradeTo ?

temporaryna commented 1 year ago

have the same error, while trying to use an Upgradeable contract from OppenZeppelin generated with their wizzard

you can find upgradeTo method in OppenZeppelin's UUPSUpgradeable abstract contract.

@wighawag, could you please take a look at that? I really don't want to exclude UUPSUpgradeable contract, because it adds extra security on upgradeTo method.

RitzyDevBox commented 1 year ago

https://github.com/wighawag/hardhat-deploy/issues/242 this might help

wighawag commented 1 year ago

@mmelnic if the implementation has an upgradeTo then it is expected that it uses an UUPS proxy

n00b21337 commented 1 year ago

I didn't manage to make this work with upgradeTo but what I am sure is missing that upgradeTo needs to get a parametar in args with new implementation address.


      execute: {
        methodName: 'upgradeTo',
        args: [newImplementation.address],
      },