UNPKG

@vechain/vebetterdao-contracts

Version:

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

58 lines (57 loc) 3.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const config_1 = require("@repo/config"); const helpers_1 = require("../../../helpers"); const contracts_1 = require("@repo/config/contracts"); const xAllocationVotingLibraries_1 = require("../../../libraries/xAllocationVotingLibraries"); 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 contractsConfig = (0, contracts_1.getContractsConfig)(process.env.NEXT_PUBLIC_APP_ENV); if (!config.navigatorRegistryContractAddress) { throw new Error("Missing NavigatorRegistry contract address"); } console.log("Deploying XAllocationVoting V9 libraries..."); const xAllocLibs = await (0, xAllocationVotingLibraries_1.xAllocationVotingLibraries)(true); const libraryAddresses = { 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("Libraries deployed:", libraryAddresses); console.log(`Upgrading XAllocationVoting contract at address: ${config.xAllocationVotingContractAddress} on network: ${config.network.name}`); // V9: Refactored from modules to libraries + freshness multiplier + hasUserVotedForApp + skip window const xAllocationVoting = (await (0, helpers_1.upgradeProxy)("XAllocationVotingV8", "XAllocationVoting", config.xAllocationVotingContractAddress, [config.navigatorRegistryContractAddress, contractsConfig.XALLOCATION_CITIZEN_SKIP_WINDOW_BLOCKS], { version: 9, libraries: libraryAddresses, })); console.log(`XAllocationVoting upgraded`); const version = await xAllocationVoting.version(); console.log(`New XAllocationVoting version: ${version}`); if (parseInt(version) !== 9) { throw new Error(`XAllocationVoting version is not the expected one: ${version}`); } // check that navigator registry was correctly set by accessing directly the storage slot const navigatorRegistry = await xAllocationVoting.navigatorRegistry(); console.log(`Navigator registry: ${navigatorRegistry}`); if (navigatorRegistry.toLowerCase() !== config.navigatorRegistryContractAddress.toLowerCase()) { throw new Error("Navigator registry was not correctly set"); } const skipWindow = await xAllocationVoting.citizenSkipWindowBlocks(); console.log(`Citizen skip window: ${skipWindow}`); if (Number(skipWindow) !== contractsConfig.XALLOCATION_CITIZEN_SKIP_WINDOW_BLOCKS) { throw new Error(`Citizen skip window mismatch: ${skipWindow} !== ${contractsConfig.XALLOCATION_CITIZEN_SKIP_WINDOW_BLOCKS}`); } await (0, helpers_1.saveLibrariesToFile)({ XAllocationVoting: libraryAddresses }); console.log("Execution completed"); process.exit(0); } main();