@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
109 lines (108 loc) • 5.7 kB
JavaScript
"use strict";
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("Deploying new version of B3TRGovernor libraries");
// Deploy Governor Clock Logic
const GovernorClockLogic = await hardhat_1.ethers.getContractFactory("GovernorClockLogic");
const GovernorClockLogicLib = await GovernorClockLogic.deploy();
await GovernorClockLogicLib.waitForDeployment();
// Deploy Governor Configurator
const GovernorConfigurator = await hardhat_1.ethers.getContractFactory("GovernorConfigurator");
const GovernorConfiguratorLib = await GovernorConfigurator.deploy();
await GovernorConfiguratorLib.waitForDeployment();
// Deploy Governor Function Restrictions Logic
const GovernorFunctionRestrictionsLogic = await hardhat_1.ethers.getContractFactory("GovernorFunctionRestrictionsLogic");
const GovernorFunctionRestrictionsLogicLib = await GovernorFunctionRestrictionsLogic.deploy();
await GovernorFunctionRestrictionsLogicLib.waitForDeployment();
// Deploy Governor Governance Logic
const GovernorGovernanceLogic = await hardhat_1.ethers.getContractFactory("GovernorGovernanceLogic");
const GovernorGovernanceLogicLib = await GovernorGovernanceLogic.deploy();
await GovernorGovernanceLogicLib.waitForDeployment();
// Deploy Governor Quorum Logic
const GovernorQuorumLogic = await hardhat_1.ethers.getContractFactory("GovernorQuorumLogic", {
libraries: {
GovernorClockLogic: await GovernorClockLogicLib.getAddress(),
},
});
const GovernorQuorumLogicLib = await GovernorQuorumLogic.deploy();
await GovernorQuorumLogicLib.waitForDeployment();
// Deploy Governor Proposal Logic
const GovernorProposalLogic = await hardhat_1.ethers.getContractFactory("GovernorProposalLogic", {
libraries: {
GovernorClockLogic: await GovernorClockLogicLib.getAddress(),
},
});
const GovernorProposalLogicLib = await GovernorProposalLogic.deploy();
await GovernorProposalLogicLib.waitForDeployment();
// Deploy Governor Votes Logic
const GovernorVotesLogic = await hardhat_1.ethers.getContractFactory("GovernorVotesLogic", {
libraries: {
GovernorClockLogic: await GovernorClockLogicLib.getAddress(),
},
});
const GovernorVotesLogicLib = await GovernorVotesLogic.deploy();
await GovernorVotesLogicLib.waitForDeployment();
// Deploy Governor Deposit Logic
const GovernorDepositLogic = await hardhat_1.ethers.getContractFactory("GovernorDepositLogic", {
libraries: {
GovernorClockLogic: await GovernorClockLogicLib.getAddress(),
},
});
const GovernorDepositLogicLib = await GovernorDepositLogic.deploy();
await GovernorDepositLogicLib.waitForDeployment();
// Deploy Governor State Logic
const GovernorStateLogic = await hardhat_1.ethers.getContractFactory("GovernorStateLogic", {
libraries: {
GovernorClockLogic: await GovernorClockLogicLib.getAddress(),
},
});
const GovernorStateLogicLib = await GovernorStateLogic.deploy();
await GovernorStateLogicLib.waitForDeployment();
const libraries = {
B3TRGovernor: {
GovernorClockLogic: await GovernorClockLogicLib.getAddress(),
GovernorConfigurator: await GovernorConfiguratorLib.getAddress(),
GovernorDepositLogic: await GovernorDepositLogicLib.getAddress(),
GovernorFunctionRestrictionsLogic: await GovernorFunctionRestrictionsLogicLib.getAddress(),
GovernorProposalLogic: await GovernorProposalLogicLib.getAddress(),
GovernorQuorumLogic: await GovernorQuorumLogicLib.getAddress(),
GovernorStateLogic: await GovernorStateLogicLib.getAddress(),
GovernorVotesLogic: await GovernorVotesLogicLib.getAddress(),
},
};
console.log("Libraries deployed");
console.log("Libraries", libraries);
console.log(`Upgrading B3TRGovernor contract at address: ${config.b3trGovernorAddress} on network: ${config.network.name}`);
const governor = (await (0, helpers_1.upgradeProxy)("B3TRGovernorV2", "B3TRGovernor", config.b3trGovernorAddress, [], {
version: 3,
libraries: {
GovernorClockLogic: await GovernorClockLogicLib.getAddress(),
GovernorConfigurator: await GovernorConfiguratorLib.getAddress(),
GovernorDepositLogic: await GovernorDepositLogicLib.getAddress(),
GovernorFunctionRestrictionsLogic: await GovernorFunctionRestrictionsLogicLib.getAddress(),
GovernorProposalLogic: await GovernorProposalLogicLib.getAddress(),
GovernorQuorumLogic: await GovernorQuorumLogicLib.getAddress(),
GovernorStateLogic: await GovernorStateLogicLib.getAddress(),
GovernorVotesLogic: await GovernorVotesLogicLib.getAddress(),
},
}));
console.log(`B3TRGovernor upgraded`);
// check that upgrade was successful
const version = await governor.version();
console.log(`New B3TRGovernor version: ${version}`);
if (parseInt(version) !== 3) {
throw new Error(`B3TRGovernor version is not the expected one: ${version}`);
}
console.log("Execution completed");
await (0, helpers_1.saveLibrariesToFile)(libraries);
process.exit(0);
}
// Execute the main function
main();