@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
148 lines (147 loc) • 8.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const mocha_1 = require("mocha");
const fixture_test_1 = require("../fixture.test");
const typechain_types_1 = require("../../../typechain-types");
const hardhat_1 = require("hardhat");
const chai_1 = require("chai");
const common_1 = require("../../helpers/common");
(0, mocha_1.describe)("GrantsManager - V2 Compatibility - @shard4j", function () {
let governor;
let vot3;
let b3tr;
let minterAccount;
let proposer;
let secondaryAccount;
let treasury;
let grantsManager;
let owner;
let voter;
let veBetterPassport;
let timeLock;
let grantsManagerAddress;
let treasuryAddress;
let emissions;
let xAllocationVoting;
let contractToPassToMethods;
let treasuryContract;
let grantsManagerInterface;
let governorProposalLogicInterface;
let governorInterface;
let otherAccounts;
(0, mocha_1.beforeEach)(async function () {
const fixture = await (0, fixture_test_1.setupGovernanceFixtureWithEmissions)();
governor = fixture.governor;
vot3 = fixture.vot3;
b3tr = fixture.b3tr;
minterAccount = fixture.minterAccount;
proposer = fixture.proposer;
secondaryAccount = fixture.otherAccount;
treasury = fixture.treasury;
grantsManager = fixture.grantsManager;
owner = fixture.owner;
voter = fixture.voter;
veBetterPassport = fixture.veBetterPassport;
timeLock = fixture.timeLock;
emissions = fixture.emissions;
xAllocationVoting = fixture.xAllocationVoting;
otherAccounts = fixture.otherAccounts;
// Setup proposer for all tests
await emissions.connect(minterAccount).start();
await (0, fixture_test_1.setupProposer)(proposer, b3tr, vot3, minterAccount);
await vot3.connect(proposer).approve(await governor.getAddress(), hardhat_1.ethers.parseEther("1000"));
grantsManagerAddress = await grantsManager.getAddress();
treasuryAddress = await treasury.getAddress();
treasuryContract = await hardhat_1.ethers.getContractFactory("Treasury");
contractToPassToMethods = {
b3tr,
vot3,
minterAccount,
governor,
treasury,
emissions,
xAllocationVoting,
veBetterPassport,
owner,
timeLock,
grantsManager,
};
grantsManagerInterface = typechain_types_1.GrantsManager__factory.createInterface();
governorProposalLogicInterface = typechain_types_1.GovernorProposalLogic__factory.createInterface();
governorInterface = typechain_types_1.B3TRGovernor__factory.createInterface();
});
(0, mocha_1.it)("Should NOT be able to mark grant as in development manually", async () => {
const description = "https://ipfs.io/ipfs/Qm..."; // project details metadata URI cannot be changed later
const milestonesDetailsMetadataURI = "https://ipfs.io/ipfs/Qm..."; // milestones details can be changed later
const values = [hardhat_1.ethers.parseEther("10000"), hardhat_1.ethers.parseEther("20000")];
const { proposalId } = await (0, common_1.createProposalWithMultipleFunctionsAndExecuteItGrant)(proposer, // proposer
owner, // voter
[treasury, treasury], // targets ( 2 transfers )
treasuryContract, // contract to pass to avoid re-deploying the contracts
description, // description ( will be empty in the proposal, because if modified, the proposalId and milestoneId will be modified => lost in the see)
["transferB3TR", "transferB3TR"], // functionToCall
[
[grantsManagerAddress, values[0]],
[grantsManagerAddress, values[1]],
], // args of transferb3tr
"0", // deposit amount
proposer.address, milestonesDetailsMetadataURI, // milestones
contractToPassToMethods);
//Grant should be in development and proposal should be executed
(0, chai_1.expect)(await grantsManager.grantState(proposalId)).to.equal(8); // InDevelopment state
(0, chai_1.expect)(await governor.state(proposalId)).to.equal(6); // Executed state
await (0, chai_1.expect)(governor.connect(owner).markAsCompleted(proposalId)).to.be.revertedWithCustomError(governor, "GovernorRestrictedProposal");
// State should remain the same
(0, chai_1.expect)(await grantsManager.grantState(proposalId)).to.equal(8); // InDevelopment state
(0, chai_1.expect)(await governor.state(proposalId)).to.equal(6); // Executed state
//Approve and claim all milestones
await grantsManager.connect(owner).approveMilestones(proposalId, 0);
await grantsManager.connect(owner).approveMilestones(proposalId, 1);
await grantsManager.connect(proposer).claimMilestone(proposalId, 0);
await grantsManager.connect(proposer).claimMilestone(proposalId, 1);
// Grant should be completed
(0, chai_1.expect)(await grantsManager.grantState(proposalId)).to.equal(9); // Completed state
(0, chai_1.expect)(await governor.state(proposalId)).to.equal(6); // Executed state
await (0, chai_1.expect)(governor.connect(owner).markAsCompleted(proposalId)).to.be.revertedWithCustomError(governor, "GovernorRestrictedProposal");
// State should remain the same
(0, chai_1.expect)(await grantsManager.grantState(proposalId)).to.equal(9); // Completed state
(0, chai_1.expect)(await governor.state(proposalId)).to.equal(6); // Executed state
});
(0, mocha_1.it)("Should NOT be able to mark grant as completed manually", async () => {
const description = "https://ipfs.io/ipfs/Qm..."; // project details metadata URI cannot be changed later
const milestonesDetailsMetadataURI = "https://ipfs.io/ipfs/Qm..."; // milestones details can be changed later
const values = [hardhat_1.ethers.parseEther("10000"), hardhat_1.ethers.parseEther("20000")];
const { proposalId } = await (0, common_1.createProposalWithMultipleFunctionsAndExecuteItGrant)(proposer, // proposer
owner, // voter
[treasury, treasury], // targets ( 2 transfers )
treasuryContract, // contract to pass to avoid re-deploying the contracts
description, // description ( will be empty in the proposal, because if modified, the proposalId and milestoneId will be modified => lost in the see)
["transferB3TR", "transferB3TR"], // functionToCall
[
[grantsManagerAddress, values[0]],
[grantsManagerAddress, values[1]],
], // args of transferb3tr
"0", // deposit amount
proposer.address, milestonesDetailsMetadataURI, // milestones
contractToPassToMethods);
//Grant should be in development and proposal should be executed
(0, chai_1.expect)(await grantsManager.grantState(proposalId)).to.equal(8); // InDevelopment state
(0, chai_1.expect)(await governor.state(proposalId)).to.equal(6); // Executed state
await (0, chai_1.expect)(governor.connect(owner).markAsCompleted(proposalId)).to.be.revertedWithCustomError(governor, "GovernorRestrictedProposal");
// State should remain the same
(0, chai_1.expect)(await grantsManager.grantState(proposalId)).to.equal(8); // InDevelopment state
(0, chai_1.expect)(await governor.state(proposalId)).to.equal(6); // Executed state
//Approve and claim all milestones
await grantsManager.connect(owner).approveMilestones(proposalId, 0);
await grantsManager.connect(owner).approveMilestones(proposalId, 1);
await grantsManager.connect(proposer).claimMilestone(proposalId, 0);
await grantsManager.connect(proposer).claimMilestone(proposalId, 1);
// Grant should be completed
(0, chai_1.expect)(await grantsManager.grantState(proposalId)).to.equal(9); // Completed state
(0, chai_1.expect)(await governor.state(proposalId)).to.equal(6); // Executed state
await (0, chai_1.expect)(governor.connect(owner).markAsCompleted(proposalId)).to.be.revertedWithCustomError(governor, "GovernorRestrictedProposal");
// State should remain the same
(0, chai_1.expect)(await grantsManager.grantState(proposalId)).to.equal(9); // Completed state
(0, chai_1.expect)(await governor.state(proposalId)).to.equal(6); // Executed state
});
});