wighawag / hardhat-deploy

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

function "owner" will shadow "owner". Please update code to avoid conflict #411

Closed omryozgrappa closed 1 year ago

omryozgrappa commented 1 year ago

Describe the bug I am unable to upgrade a uups proxy contract

To Reproduce

I've created the following contracts:

pragma solidity ^0.8.0;

import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol';
import 'hardhat/console.sol';

contract StorageV0 {
    string internal _name;
    uint256 internal _randomValue;
}

contract StorageV1 is StorageV0 {
    uint256 internal _randomValue2;
}

contract ProxyTest is UUPSUpgradeable, OwnableUpgradeable, StorageV0 {
    function initialize(
        string calldata __name,
        uint256 __randomValue
    ) public initializer {
        __Ownable_init();
        _name = __name;
        _randomValue = __randomValue;
        console.log('********** ProxyTest initialized **********');
    }

    function name() public view returns (string memory) {
        return _name;
    }

    function randomValue() public view returns (uint256) {
        return _randomValue;
    }

    function _authorizeUpgrade(
        address newImplementation
    ) internal override onlyOwner {}
}

contract ProxyTestV2 is UUPSUpgradeable, OwnableUpgradeable, StorageV1 {
    function initialize(uint256 __randomValue2) public initializer {
        __Ownable_init();
        _randomValue2 = __randomValue2;
        console.log('********** ProxyTest initialized **********');
    }

    function randomValue2() public view returns (uint256) {
        return _randomValue2;
    }

    function _authorizeUpgrade(
        address newImplementation
    ) internal override onlyOwner {}
}
  1. execute:

    
    await deploy('ProxyTest', {
        from: deployerAddress,
        args:[],
    
        proxy:  {
            proxyContract: 'UUPS',
            execute: {
                methodName: 'initialize', // Function to call when deployed first time.
                args: [
                    'Grappa Badge',
                    1,
                ],
            },
        },
        contract: 'ProxyTest',
    })

await deploy('ProxyTestV2', { from: deployerAddress, args:[],

    proxy:  {
        proxyContract: 'ProxyTest',
        execute: {
            methodName: 'initialize', // Function to call when deployed first time.
            args: [
                2
            ],
        },
    },
    contract: 'ProxyTest',
})


2. See error:

Error: function "owner" will shadow "owner". Please update code to avoid conflict

**Expected behavior**
I expected the ProxyTestV2 will be deployed as the new implementation of ProxyTest proxy contract.

**versions**
"hardhat": "^2.12.2",
"hardhat-deploy": "0.11.22",
"hardhat-deploy-ethers": "^0.3.0-beta.13",
wighawag commented 1 year ago

you can change the proxy contract being used once a proxy is deployed. You can change the implementation though