chore: add upgrade script

This commit is contained in:
rymnc 2024-02-27 22:14:05 +05:30
parent 886891b57a
commit 2e828c37c6
No known key found for this signature in database
GPG Key ID: AAA088D5C68ECD34
2 changed files with 63 additions and 1 deletions

View File

@ -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"];

View File

@ -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"];