Skip to content

Commit

Permalink
Modify schain upgrade script
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaStebaev committed Jun 23, 2023
1 parent 3df9f00 commit 5c68a8a
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions proxy/migrations/upgradeSchain.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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",
Expand All @@ -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"
);
Expand Down

0 comments on commit 5c68a8a

Please sign in to comment.