Trying to create upgradeable contracts using hardhat and OpenZeppelin Upgrades but, when calling either the deploy or upgrade script, initialize is not called (values show up as default when i check the contract in the explorer)
These are the scripts:
Deploy
import { ethers, upgrades } from 'hardhat';
import { getImplementationAddress } from '@openzeppelin/upgrades-core';
async function main() {
const WageringContract = await ethers.getContractFactory('WageringContract');
const wageringContract = await upgrades.deployProxy(
WageringContract,
[
'0xc2dd1910ca7fe8b18d315b77bd56406e9d9764ee',
'0xc2dd1910ca7fe8b18d315b77bd56406e9d9764ee',
'0xc2dd1910ca7fe8b18d315b77bd56406e9d9764ee',
'0xc2dd1910ca7fe8b18d315b77bd56406e9d9764ee',
3,
3,
'0x40af4101c5cdd511b76b28dad188e5041ecf6d4f',
'0xc2dd1910ca7fe8b18d315b77bd56406e9d9764ee',
],
{ initializer: 'initialize', kind: 'uups' }
);
await wageringContract.waitForDeployment();
console.log(
'Wagering proxy deployed to:',
await wageringContract.getAddress()
);
console.log(
'Wagering implementation deployed to:',
await getImplementationAddress(
ethers.provider,
await wageringContract.getAddress()
)
);
}
main();
And upgrade, which errors:
import { ethers, upgrades } from 'hardhat';
import { getImplementationAddress } from '@openzeppelin/upgrades-core';
const main = async (): Promise<void> => {
const NewWageringVersion = await ethers.getContractFactory('WageringV4');
console.log('Upgrading Wagering...');
await upgrades.upgradeProxy(
'0xdCE475eEdF0198abb33C59e384beC861ABbEc2CB',
NewWageringVersion,
{
kind: 'uups',
call: {
fn: 'initialize',
args: [
'0xc2dd1910ca7fe8b18d315b77bd56406e9d9764ee',
'0xc2dd1910ca7fe8b18d315b77bd56406e9d9764ee',
'0xc2dd1910ca7fe8b18d315b77bd56406e9d9764ee',
'0xc2dd1910ca7fe8b18d315b77bd56406e9d9764ee',
3,
3,
'0x40af4101c5cdd511b76b28dad188e5041ecf6d4f',
'0xc2dd1910ca7fe8b18d315b77bd56406e9d9764ee',
],
},
}
);
console.log('Wagering upgraded');
console.log(
'New wagering implementation deployed to:',
await getImplementationAddress(
ethers.provider,
'0xdCE475eEdF0198abb33C59e384beC861ABbEc2CB'
)
);
};
main()
This is the error for the upgrade: