UNPKG

@vechain/vebetterdao-contracts

Version:

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

62 lines (61 loc) 3.14 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) === 8) { console.log("X2EarnApps is already at version 8, 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, AppStorageUtils } = await (0, x2EarnLibraries_1.x2EarnLibraries)({ logOutput: true, latestVersionOnly: true, }); const libraries = { X2EarnApps: { AdministrationUtils: await AdministrationUtils.getAddress(), EndorsementUtils: await EndorsementUtils.getAddress(), VoteEligibilityUtils: await VoteEligibilityUtils.getAddress(), AppStorageUtils: await AppStorageUtils.getAddress(), }, }; console.log("Libraries deployed"); console.log("Libraries", libraries); console.log(`Upgrading X2EarnApps contract at address: ${config.x2EarnAppsContractAddress} on network: ${config.network.name}`); // V8 flexible endorsement default caps const MAX_POINTS_PER_NODE_PER_APP = 49; const MAX_POINTS_PER_APP = 110; console.log(`Upgrading and initializing V8 with maxPointsPerNodePerApp=${MAX_POINTS_PER_NODE_PER_APP}, maxPointsPerApp=${MAX_POINTS_PER_APP}`); const x2EarnAppsV8 = (await (0, helpers_1.upgradeProxy)("X2EarnAppsV7", "X2EarnApps", config.x2EarnAppsContractAddress, [MAX_POINTS_PER_NODE_PER_APP, MAX_POINTS_PER_APP], { version: 8, libraries: { AdministrationUtils: await AdministrationUtils.getAddress(), EndorsementUtils: await EndorsementUtils.getAddress(), VoteEligibilityUtils: await VoteEligibilityUtils.getAddress(), AppStorageUtils: await AppStorageUtils.getAddress(), }, })); console.log("X2EarnApps upgraded and initialized"); // check that upgrade was successful const version = await x2EarnAppsV8.version(); console.log(`New X2EarnApps version: ${version}`); if (parseInt(version) !== 8) { throw new Error(`X2EarnApps version is not 8: ${version}`); } console.log("Execution completed"); await (0, helpers_1.saveLibrariesToFile)(libraries); process.exit(0); } // Execute the main function main();