UNPKG

@vechain/vebetterdao-contracts

Version:

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

34 lines (33 loc) 1.6 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"); 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); console.log(`Upgrading X2EarnRewardsPool contract at address: ${config.x2EarnRewardsPoolContractAddress} on network: ${config.network.name}`); const x2EarnRewardsPoolCurrent = await hardhat_1.ethers.getContractAt("X2EarnRewardsPool", config.x2EarnRewardsPoolContractAddress); const currentVersion = await x2EarnRewardsPoolCurrent.version(); console.log("Current contract version:", currentVersion); if (parseInt(currentVersion) === 7) { console.log("X2EarnRewardsPool is already at version 7, skipping upgrade"); process.exit(0); } const x2EarnRewardsPool = (await (0, helpers_1.upgradeProxy)("X2EarnRewardsPoolV6", "X2EarnRewardsPool", config.x2EarnRewardsPoolContractAddress, [], { version: 7, })); console.log(`X2EarnRewardsPool upgraded`); // check that upgrade was successful const version = await x2EarnRewardsPool.version(); console.log(`New X2EarnRewardsPool version: ${version}`); if (parseInt(version) !== 7) { throw new Error(`X2EarnRewardsPool version is not the expected one: ${version}`); } console.log("Execution completed"); process.exit(0); } // Execute the main function main();