@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
104 lines (103 loc) • 5.37 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.proposeUpgradeGovernance = void 0;
const hardhat_1 = require("hardhat");
const ipfs_1 = require("./ipfs");
const proposeUpgradeGovernance = async (governor, xAllocationVoting) => {
////////////////////////////
// ---------------------- Deploy Libraries V2 ----------------------
// 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(),
GovernorProposalLogic: await GovernorProposalLogicLib.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 B3TRGovernorV2 = await hardhat_1.ethers.getContractFactory("B3TRGovernor", {
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(),
},
});
const newGovernor = await B3TRGovernorV2.deploy();
await newGovernor.waitForDeployment();
const V1Contract = await hardhat_1.ethers.getContractAt("B3TRGovernor", await governor.getAddress());
// Now we can create a proposal
const encodedFunctionCall = V1Contract.interface.encodeFunctionData("upgradeToAndCall", [
await newGovernor.getAddress(),
"0x",
]);
// Create a Blob from the proposal metadata
const metadataBlob = new Blob([
JSON.stringify({
title: "Upgrade Governor to V2",
shortDescription: "Upgrade Governor to V2",
markdownDescription: "",
}),
], {
type: "application/json",
});
// Upload the metadata Blob to IPFS
const metadataUri = await (0, ipfs_1.uploadBlobToIPFS)(metadataBlob, "metadata.json");
const currentRoundId = await xAllocationVoting.currentRoundId();
await governor.propose([await governor.getAddress()], [0], [encodedFunctionCall], metadataUri, currentRoundId + 1n, 0, {
gasLimit: 10000000,
});
};
exports.proposeUpgradeGovernance = proposeUpgradeGovernance;