@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
36 lines (35 loc) • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("@repo/config");
const helpers_1 = require("../../../helpers");
const contracts_1 = require("@repo/config/contracts");
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);
const contractsConfig = (0, contracts_1.getContractsConfig)(process.env.NEXT_PUBLIC_APP_ENV);
console.log(`Upgrading VoterRewards contract at address: ${config.voterRewardsContractAddress} on network: ${config.network.name}`);
const emissionsContract = await hardhat_1.ethers.getContractAt("Emissions", config.emissionsContractAddress);
const emissionsVersion = await emissionsContract.version();
if (parseInt(emissionsVersion) !== 3) {
console.log(`Emissions version is not 3: ${emissionsVersion}`);
console.log("Please upgrade Emissions contract first");
process.exit(1);
}
const voterRewardsV5 = (await (0, helpers_1.upgradeProxy)("VoterRewardsV4", "VoterRewards", config.voterRewardsContractAddress, [contractsConfig.VOTER_REWARDS_LEVELS_V2, contractsConfig.GM_MULTIPLIERS_V2], {
version: 5,
}));
console.log(`VoterRewards upgraded`);
// check that upgrade was successful
const version = await voterRewardsV5.version();
console.log(`New VoterRewards version: ${version}`);
if (parseInt(version) !== 5) {
throw new Error(`VoterRewards version is not 5: ${version}`);
}
console.log("Execution completed");
process.exit(0);
}
// Execute the main function
main();