UNPKG

@vechain/vebetterdao-contracts

Version:

Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.

57 lines (56 loc) 2.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const config_1 = require("@repo/config"); const helpers_1 = require("../../../helpers"); const hardhat_1 = require("hardhat"); const x2EarnLibraries_1 = require("../../../libraries/x2EarnLibraries"); async function main() { if (!process.env.NEXT_PUBLIC_APP_ENV) { throw new Error("Missing NEXT_PUBLIC_APP_ENV"); } const config = (0, config_1.getConfig)(process.env.NEXT_PUBLIC_APP_ENV); const deployer = (await hardhat_1.ethers.getSigners())[0]; // check if already at the desired version const x2EarnApps = await hardhat_1.ethers.getContractAt("X2EarnApps", config.x2EarnAppsContractAddress); const currentVersion = await x2EarnApps.version(); console.log("Current contract version:", currentVersion); if (parseInt(currentVersion) === 7) { console.log("X2EarnApps is already at version 7, you are upgrading to the same version"); } console.log(`Deploying X2EarnApps libraries on network: ${config.network.name} (env: ${config.environment}) with account: ${deployer.address}`); const { AdministrationUtils, EndorsementUtils, VoteEligibilityUtils } = await (0, x2EarnLibraries_1.x2EarnLibraries)({ logOutput: true, latestVersionOnly: true, }); const libraries = { X2EarnApps: { AdministrationUtils: await AdministrationUtils.getAddress(), EndorsementUtils: await EndorsementUtils.getAddress(), VoteEligibilityUtils: await VoteEligibilityUtils.getAddress(), }, }; console.log("Libraries deployed"); console.log("Libraries", libraries); console.log(`Upgrading X2EarnApps contract at address: ${config.x2EarnAppsContractAddress} on network: ${config.network.name}`); console.log(`StargateNFT contract address: ${config.stargateNFTContractAddress}`); const x2EarnAppsV7 = (await (0, helpers_1.upgradeProxy)("X2EarnAppsV6", "X2EarnApps", config.x2EarnAppsContractAddress, [config.stargateNFTContractAddress], { version: 7, libraries: { AdministrationUtils: await AdministrationUtils.getAddress(), EndorsementUtils: await EndorsementUtils.getAddress(), VoteEligibilityUtils: await VoteEligibilityUtils.getAddress(), }, })); console.log(`X2EarnApps upgraded`); // check that upgrade was successful const version = await x2EarnAppsV7.version(); console.log(`New X2EarnApps version: ${version}`); if (parseInt(version) !== 7) { throw new Error(`X2EarnApps version is not 7: ${version}`); } console.log("Execution completed"); await (0, helpers_1.saveLibrariesToFile)(libraries); process.exit(0); } // Execute the main function main();