@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.5 kB
JavaScript
;
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 VoterRewards contract at address: ${config.voterRewardsContractAddress} on network: ${config.network.name}`);
const galaxyMemberContract = await hardhat_1.ethers.getContractAt("GalaxyMember", config.galaxyMemberContractAddress);
const gmVersion = await galaxyMemberContract.version();
if (parseInt(gmVersion) !== 3) {
console.log(`GalaxyMember version is not 3: ${gmVersion}`);
console.log("Please upgrade GalaxyMember contract first");
process.exit(1);
}
const voterRewardsV4 = (await (0, helpers_1.upgradeProxy)("VoterRewardsV3", "VoterRewards", config.voterRewardsContractAddress, [], {
version: 4,
}));
console.log(`VoterRewards upgraded`);
// check that upgrade was successful
const version = await voterRewardsV4.version();
console.log(`New VoterRewards version: ${version}`);
if (parseInt(version) !== 4) {
throw new Error(`VoterRewards version is not 4: ${version}`);
}
console.log("Execution completed");
process.exit(0);
}
// Execute the main function
main();