@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
82 lines (81 loc) • 4.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("@repo/config");
const hardhat_1 = require("hardhat");
const helpers_1 = require("../helpers");
const libraries_1 = require("../libraries");
const xAllocationVotingLibraries_1 = require("../libraries/xAllocationVotingLibraries");
/**
* One-off script to redeploy XAllocationVoting (V9) and B3TRGovernor (V10) implementations
* after lowering the in-source skip window constants:
* - XAllocationVoting.CITIZEN_SKIP_WINDOW_BLOCKS: 720 -> 12
* - GovernorVotesLogic.GOVERNANCE_SKIP_WINDOW_BLOCKS: 720 -> 12
*
* No reinitializer is called: only `upgradeToAndCall(newImpl, "0x")`.
* Versions stay at 9 (XAllocationVoting) and 10 (B3TRGovernor).
*/
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();
console.log(`Network: ${config.network.name}`);
console.log(`Deployer: ${deployer.address}`);
console.log(`XAllocationVoting proxy: ${config.xAllocationVotingContractAddress}`);
console.log(`B3TRGovernor proxy: ${config.b3trGovernorAddress}`);
// ====== XAllocationVoting (V9, no init) ======
console.log("\n--- Deploying XAllocationVoting libraries ---");
const xAllocLibs = await (0, xAllocationVotingLibraries_1.xAllocationVotingLibraries)(true);
const xAllocLibraryAddresses = {
AutoVotingLogic: await xAllocLibs.AutoVotingLogic.getAddress(),
ExternalContractsUtils: await xAllocLibs.ExternalContractsUtils.getAddress(),
VotingSettingsUtils: await xAllocLibs.VotingSettingsUtils.getAddress(),
VotesUtils: await xAllocLibs.VotesUtils.getAddress(),
VotesQuorumFractionUtils: await xAllocLibs.VotesQuorumFractionUtils.getAddress(),
RoundEarningsSettingsUtils: await xAllocLibs.RoundEarningsSettingsUtils.getAddress(),
RoundFinalizationUtils: await xAllocLibs.RoundFinalizationUtils.getAddress(),
RoundsStorageUtils: await xAllocLibs.RoundsStorageUtils.getAddress(),
RoundVotesCountingUtils: await xAllocLibs.RoundVotesCountingUtils.getAddress(),
};
console.log("Upgrading XAllocationVoting implementation (no initializer)...");
const xAllocationVoting = (await (0, helpers_1.upgradeProxy)("XAllocationVoting", "XAllocationVoting", config.xAllocationVotingContractAddress, [], {
libraries: xAllocLibraryAddresses,
logOutput: true,
}));
const xAllocVersion = await xAllocationVoting.version();
console.log(`XAllocationVoting version: ${xAllocVersion}`);
if (parseInt(xAllocVersion) !== 9) {
throw new Error(`Unexpected XAllocationVoting version: ${xAllocVersion}`);
}
// ====== B3TRGovernor (V10, no init) ======
console.log("\n--- Deploying B3TRGovernor libraries ---");
const { GovernorClockLogicLib, GovernorConfiguratorLib, GovernorDepositLogicLib, GovernorFunctionRestrictionsLogicLib, GovernorProposalLogicLib, GovernorQuorumLogicLib, GovernorStateLogicLib, GovernorVotesLogicLib, } = await (0, libraries_1.governanceLibraries)({ logOutput: true, latestVersionOnly: true });
const governorLibraryAddresses = {
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("Upgrading B3TRGovernor implementation (no initializer)...");
const governor = (await (0, helpers_1.upgradeProxy)("B3TRGovernor", "B3TRGovernor", config.b3trGovernorAddress, [], {
libraries: governorLibraryAddresses,
logOutput: true,
}));
const governorVersion = await governor.version();
console.log(`B3TRGovernor version: ${governorVersion}`);
if (parseInt(governorVersion) !== 10) {
throw new Error(`Unexpected B3TRGovernor version: ${governorVersion}`);
}
await (0, helpers_1.saveLibrariesToFile)({
XAllocationVoting: xAllocLibraryAddresses,
B3TRGovernor: governorLibraryAddresses,
});
console.log("\nDone.");
process.exit(0);
}
main();