From 5c68a8a63690698f068677514e432116e3af7b52 Mon Sep 17 00:00:00 2001 From: Dmytro Stebaiev Date: Fri, 23 Jun 2023 16:28:41 +0300 Subject: [PATCH] Modify schain upgrade script --- proxy/migrations/upgradeSchain.ts | 34 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/proxy/migrations/upgradeSchain.ts b/proxy/migrations/upgradeSchain.ts index 7ca359809..4a993dedc 100644 --- a/proxy/migrations/upgradeSchain.ts +++ b/proxy/migrations/upgradeSchain.ts @@ -1,4 +1,3 @@ -import { getManifestAdmin } from "@openzeppelin/hardhat-upgrades/dist/admin"; import { CommunityLocker } from "../typechain/CommunityLocker"; import { contracts, getContractKeyInAbiFile } from "./deploySchain"; import { manifestSetup } from "./generateManifest"; @@ -7,16 +6,12 @@ import { upgrade } from "./upgrade"; import chalk from "chalk"; import { ethers } from "hardhat"; -function stringValue(value: string | undefined) { - if (value) { - return value; - } else { - return ""; - } -} - async function main() { - const pathToManifest: string = stringValue(process.env.MANIFEST); + if (process.env.MANIFEST === undefined) { + console.log("Set MANIFEST environment variable"); + process.exit(1); + } + const pathToManifest = process.env.MANIFEST; await manifestSetup( pathToManifest ); await upgrade( "1.4.0", @@ -25,7 +20,24 @@ async function main() { // deploying of new contracts }, async( safeTransactions, abi ) => { - // do initialization + const communityLockerName = "CommunityLocker"; + const communityLockerFactory = await ethers.getContractFactory(communityLockerName); + const communityLockerAddress = abi[getContractKeyInAbiFile(communityLockerName) + "_address"] as string; + let communityLocker; + if (communityLockerAddress) { + communityLocker = communityLockerFactory.attach(communityLockerAddress) as CommunityLocker; + console.log(chalk.yellow("Prepare transaction to initialize timestamp")); + safeTransactions.push(encodeTransaction( + 0, + communityLockerAddress, + 0, + communityLocker.interface.encodeFunctionData("initializeTimestamp") + )); + } else { + console.log(chalk.red("CommunityLocker was not found!")); + console.log(chalk.red("Check your abi!!!")); + process.exit(1); + } }, "proxySchain" );