diff --git a/deploy/001_deploy_rln_registry.ts b/deploy/001_deploy_rln_registry.ts index b736568..d98889c 100644 --- a/deploy/001_deploy_rln_registry.ts +++ b/deploy/001_deploy_rln_registry.ts @@ -1,5 +1,5 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"; -import { DeployFunction, DeploymentSubmission } from "hardhat-deploy/types"; +import { DeployFunction } from "hardhat-deploy/types"; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { deployments, getUnnamedAccounts } = hre; @@ -26,5 +26,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { }; export default func; +func.skip = async (hre: HardhatRuntimeEnvironment) => { + if (hre.network.name === "sepolia") { + return true; + } + return false; +}; func.tags = ["WakuRlnRegistry"]; func.dependencies = ["PoseidonHasher"]; diff --git a/deploy/003_deploy_rln_v2.ts b/deploy/003_deploy_rln_v2.ts new file mode 100644 index 0000000..a9b6870 --- /dev/null +++ b/deploy/003_deploy_rln_v2.ts @@ -0,0 +1,56 @@ +import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { DeployFunction } from "hardhat-deploy/types"; + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getUnnamedAccounts } = hre; + const { deploy } = deployments; + + const [deployer] = await getUnnamedAccounts(); + + const implRes = await deploy("WakuRlnRegistry_Implementation", { + contract: "WakuRlnRegistry", + from: deployer, + log: true, + skipIfAlreadyDeployed: false, + }); + + const existingProxy = await deployments.get("WakuRlnRegistry_Proxy"); + existingProxy.abi.push({ + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address", + }, + ], + name: "upgradeTo", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }); + existingProxy.abi.push({ + inputs: [], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }); + const existingProxyContract = new hre.ethers.Contract( + existingProxy.address, + existingProxy.abi, + hre.ethers.provider.getSigner(deployer) + ); + + const upgradeTx = await existingProxyContract.upgradeTo(implRes.address); + await upgradeTx.wait(); + const implContract = new hre.ethers.Contract( + implRes.address, + implRes.abi, + hre.ethers.provider.getSigner(deployer) + ); + await implContract.initialize(); +}; + +export default func; +func.tags = ["WakuRlnRegistry_v2"]; +func.dependencies = ["WakuRlnRegistry"];