@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
60 lines (59 loc) • 3.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("@repo/config");
const helpers_1 = require("../../../helpers");
const autoVotingLibraries_1 = require("../../../libraries/autoVotingLibraries");
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);
// Verify RelayerRewardsPool exists in config
if (!config.relayerRewardsPoolContractAddress) {
throw new Error("RelayerRewardsPool contract address not found in config. Please deploy RelayerRewardsPool first.");
}
const { AutoVotingLogic } = await (0, autoVotingLibraries_1.autoVotingLibraries)();
console.log("AutoVotingLogic Library deployed address: ", await AutoVotingLogic.getAddress());
console.log(`Upgrading XAllocationVoting contract at address: ${config.xAllocationVotingContractAddress} on network: ${config.network.name}`);
const xAllocationVotingV8 = (await (0, helpers_1.upgradeProxy)("XAllocationVotingV7", "XAllocationVotingV8", config.xAllocationVotingContractAddress, [], {
version: 8,
libraries: {
AutoVotingLogic: await AutoVotingLogic.getAddress(),
},
}));
console.log(`XAllocationVoting upgraded`);
// check that upgrade was successful
const version = await xAllocationVotingV8.version();
console.log(`New XAllocationVoting version: ${version}`);
if (parseInt(version) !== 8) {
throw new Error(`XAllocationVoting version is not 8: ${version}`);
}
// Set up auto-voting integration with RelayerRewardsPool
console.log("Setting up auto-voting integration...");
const deployer = (await hardhat_1.ethers.getSigners())[0];
// Set RelayerRewardsPool address in XAllocationVoting
console.log("Setting RelayerRewardsPool address in XAllocationVoting...");
await xAllocationVotingV8
.connect(deployer)
.setRelayerRewardsPoolAddress(config.relayerRewardsPoolContractAddress)
.then(async (tx) => await tx.wait());
// Grant POOL_ADMIN_ROLE to XAllocationVoting in RelayerRewardsPool
console.log("Granting POOL_ADMIN_ROLE to XAllocationVoting in RelayerRewardsPool...");
const relayerRewardsPool = (await hardhat_1.ethers.getContractAt("RelayerRewardsPool", config.relayerRewardsPoolContractAddress));
const POOL_ADMIN_ROLE = await relayerRewardsPool.POOL_ADMIN_ROLE();
await relayerRewardsPool
.connect(deployer)
.grantRole(POOL_ADMIN_ROLE, config.xAllocationVotingContractAddress)
.then(async (tx) => await tx.wait());
// Verify the role was granted successfully
const hasRole = await relayerRewardsPool.hasRole(POOL_ADMIN_ROLE, config.xAllocationVotingContractAddress);
if (!hasRole) {
throw new Error("Failed to grant POOL_ADMIN_ROLE to XAllocationVoting in RelayerRewardsPool");
}
console.log("XAllocationVoting v8 upgrade and auto-voting integration completed successfully");
console.log("Next step: Run VoterRewards v6 upgrade");
console.log("Execution completed");
process.exit(0);
}
main();