UNPKG

@vechain/vebetterdao-contracts

Version:

Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.

80 lines (79 loc) 4.49 kB
import { getConfig } from "@repo/config"; import { ethers } from "hardhat"; import { saveLibrariesToFile, upgradeProxy } from "../helpers"; import { governanceLibraries } from "../libraries"; import { xAllocationVotingLibraries } from "../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 = getConfig(process.env.NEXT_PUBLIC_APP_ENV); const [deployer] = await 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 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 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 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 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 saveLibrariesToFile({ XAllocationVoting: xAllocLibraryAddresses, B3TRGovernor: governorLibraryAddresses, }); console.log("\nDone."); process.exit(0); } main();