UNPKG

@vechain/vebetterdao-contracts

Version:

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

72 lines (71 loc) 4.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deployGrantsManager = deployGrantsManager; const config_1 = require("@repo/config"); const contracts_1 = require("@repo/config/contracts"); const helpers_1 = require("../../helpers"); const hardhat_1 = require("hardhat"); const config_2 = require("../../helpers/config"); async function deployGrantsManager() { if (!process.env.NEXT_PUBLIC_APP_ENV) { throw new Error("Missing NEXT_PUBLIC_APP_ENV"); } const envConfig = (0, config_1.getConfig)(process.env.NEXT_PUBLIC_APP_ENV); const contractsConfig = (0, contracts_1.getContractsConfig)(process.env.NEXT_PUBLIC_APP_ENV); const deployer = (await hardhat_1.ethers.getSigners())[0]; console.log(`================ Deploying contracts on ${envConfig.network.name} (${envConfig.nodeUrl}) with ${envConfig.environment} configurations `); console.log(`================ Address used to deploy: ${deployer.address}`); // We use a temporary admin to deploy and initialize contracts then transfer role to the real admin // Also we have many roles in our contracts but we currently use one wallet for all roles const TEMP_ADMIN = envConfig.network.name === "solo" ? contractsConfig.CONTRACTS_ADMIN_ADDRESS : deployer.address; console.log("================================================================================"); console.log("Temporary admin set to ", TEMP_ADMIN); console.log("Final admin will be set to ", contractsConfig.CONTRACTS_ADMIN_ADDRESS); console.log("================================================================================"); const B3TR_GOVERNOR_ADDRESS = envConfig.b3trGovernorAddress; const TREASURY_ADDRESS = envConfig.treasuryContractAddress; const B3TR_CONTRACT_ADDRESS = envConfig.b3trContractAddress; const MINIMUM_MILESTONE_COUNT = contractsConfig.MINIMUM_MILESTONE_COUNT; console.log("Deploying proxy for Grants Manager with params:"); console.log("B3TR Governor Address: ", B3TR_GOVERNOR_ADDRESS); console.log("Treasury Address: ", TREASURY_ADDRESS); console.log("B3TR Contract Address: ", B3TR_CONTRACT_ADDRESS); console.log("Minimum Milestone Count: ", MINIMUM_MILESTONE_COUNT); const grantsManager = (await (0, helpers_1.deployProxy)("GrantsManager", [ B3TR_GOVERNOR_ADDRESS, TREASURY_ADDRESS, TEMP_ADMIN, B3TR_CONTRACT_ADDRESS, MINIMUM_MILESTONE_COUNT, ])); console.log(`================ Contract deployed at ${await grantsManager.getAddress()}`); const governor = await grantsManager.getGovernorContract(); const treasury = await grantsManager.getTreasuryContract(); const b3tr = await grantsManager.getB3trContract(); const minimumMilestoneCount = await grantsManager.getMinimumMilestoneCount(); if (governor.toLowerCase() !== envConfig.b3trGovernorAddress.toLowerCase() || treasury.toLowerCase() !== envConfig.treasuryContractAddress.toLowerCase() || b3tr.toLowerCase() !== envConfig.b3trContractAddress.toLowerCase() || minimumMilestoneCount !== BigInt(contractsConfig.MINIMUM_MILESTONE_COUNT)) { console.log("ERROR: Params are not set correctly"); process.exit(1); } console.log("================ Configuring roles"); console.log("INFO: roles will not be set automatically in this script, allowing the deployer to handle possible issues in the next days"); console.log("================================================================================"); console.log(`Updating the config file with the new Grants Manager contract address`); try { Object.assign(envConfig, { grantsManagerContractAddress: await grantsManager.getAddress() }); await (0, config_2.updateConfig)(envConfig, "GrantsManager"); console.log("Config file updated successfully"); } catch (e) { console.error("Failed to update config file, update it manually"); } console.log("================================================================================"); console.log("Grants Manager address: ", await grantsManager.getAddress()); console.log("================ Execution completed"); process.exit(0); } // Execute the main function deployGrantsManager();