From e872038cd1084d013d991939ceda2b6f12386f3d Mon Sep 17 00:00:00 2001 From: cyl19970726 <15258378443@163.com> Date: Wed, 18 Jan 2023 16:35:51 +0800 Subject: [PATCH] add upgrade script --- scripts/upgrade.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 scripts/upgrade.ts diff --git a/scripts/upgrade.ts b/scripts/upgrade.ts new file mode 100644 index 0000000..9be5c28 --- /dev/null +++ b/scripts/upgrade.ts @@ -0,0 +1,24 @@ +import { ethers } from "hardhat"; + +async function main(proxyAddr:string) { + + const Git3 = await ethers.getContractFactory("Git3Hub"); + const git3 = await Git3.deploy(); + let logicReceipt = await git3.deployed() + + let proxyInstance = await ethers.getContractAt("UpgradeableProxy",proxyAddr); + // Proxy don't need to init Git3 contract because the constructor is empty. + let initSelector = "0x"; + let [operator,] = await ethers.getSigners(); + let receipt = await proxyInstance + .connect(operator) + .upgradeToAndCall(git3.address, initSelector); + await receipt.wait(); + + console.log("upgradeTxHash:",receipt.hash); +} + +main(process.argv0).catch((error) => { + console.error(error); + process.exitCode = 1; +});