@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
38 lines (37 loc) • 1.81 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 treasuryAddress = config.treasuryContractAddress;
console.log(`Upgrading DBAPool contract at address: ${config.dbaPoolContractAddress} on network: ${config.network.name}`);
const dbaPoolBefore = (await hardhat_1.ethers.getContractAt("DBAPoolV2", config.dbaPoolContractAddress));
const versionBefore = await dbaPoolBefore.version();
console.log(`Current DBAPool version: ${versionBefore}`);
if (parseInt(versionBefore) !== 2) {
throw new Error(`Expected DBAPool version 2, got: ${versionBefore}`);
}
console.log("\n=== Upgrading Contract ===");
const dbaPool = (await (0, helpers_1.upgradeProxy)("DBAPoolV2", "DBAPool", config.dbaPoolContractAddress, [treasuryAddress], {
version: 3,
}));
console.log(`DBAPool upgraded successfully`);
const version = await dbaPool.version();
console.log(`New DBAPool version: ${version}`);
if (parseInt(version) !== 3) {
throw new Error(`DBAPool version is not 3: ${version}`);
}
const treasuryAddr = await dbaPool.treasuryAddress();
console.log(`Treasury address set to: ${treasuryAddr}`);
if (treasuryAddr.toLowerCase() !== treasuryAddress.toLowerCase()) {
throw new Error(`Treasury address mismatch: expected ${treasuryAddress}, got ${treasuryAddr}`);
}
console.log("\n=== Upgrade Completed Successfully ===");
process.exit(0);
}
main();