@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
41 lines (40 loc) • 2.21 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);
const deployer = (await hardhat_1.ethers.getSigners())[0];
console.log(`Upgrading X2EarnRewardsPool contract at address: ${config.b3trGovernorAddress} on network: ${config.network.name} (env: ${config.environment}) with account: ${deployer.address}`);
const x2EarnRewardsPool = (await (0, helpers_1.upgradeProxy)("X2EarnRewardsPoolV2", "X2EarnRewardsPool", config.x2EarnRewardsPoolContractAddress, [config.veBetterPassportContractAddress], {
version: 3,
}));
console.log(`X2EarnRewardsPool upgraded`);
// check that upgrade was successful
const version = await x2EarnRewardsPool.version();
console.log(`New X2EarnRewardsPool version: ${version}`);
if (parseInt(version) !== 3) {
throw new Error(`X2EarnRewardsPool version is not the expected one: ${version}`);
}
// We need to assign the ACTION_REGISTRAR_ROLE inside VeBetterPassport to the X2EarnRewardsPool contract
console.log("Assigning ACTION_REGISTRAR_ROLE to X2EarnRewardsPool contract");
const veBetterPassport = await hardhat_1.ethers.getContractAt("VeBetterPassport", config.veBetterPassportContractAddress);
const ACTION_REGISTRAR_ROLE = await veBetterPassport.ACTION_REGISTRAR_ROLE();
await veBetterPassport
.connect(deployer)
.grantRole(ACTION_REGISTRAR_ROLE, config.x2EarnRewardsPoolContractAddress)
.then(async (tx) => await tx.wait());
// check that the role was assigned successfully
const hasRole = await veBetterPassport.hasRole(ACTION_REGISTRAR_ROLE, config.x2EarnRewardsPoolContractAddress);
if (!hasRole) {
throw new Error(`Failed to assign ACTION_REGISTRAR_ROLE to X2EarnRewardsPool contract`);
}
console.log("Execution completed");
process.exit(0);
}
// Execute the main function
main();