diff --git a/contracts/interfaces/IBaalAndVaultSummoner.sol b/contracts/interfaces/IBaalAndVaultSummoner.sol index 3f9b595..19f699c 100644 --- a/contracts/interfaces/IBaalAndVaultSummoner.sol +++ b/contracts/interfaces/IBaalAndVaultSummoner.sol @@ -11,5 +11,4 @@ interface IBaalAndVaultSummoner { bytes32 referrer, string memory name ) external returns (address _daoAddress, address _vaultAddress); - -} \ No newline at end of file +} diff --git a/deploy/004_deploy_bv_factory.ts b/deploy/004_deploy_bv_factory.ts index 8fa6f81..786035f 100644 --- a/deploy/004_deploy_bv_factory.ts +++ b/deploy/004_deploy_bv_factory.ts @@ -32,7 +32,7 @@ const deployFn: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { from: deployer, args: [], proxy: { - proxyContract: 'OpenZeppelinTransparentProxy', + proxyContract: 'UUPS', methodName: 'initialize', }, log: true, diff --git a/package.json b/package.json index 6c7bc99..8d08f46 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@daohaus/baal-contracts", - "version": "1.2.12", + "version": "1.2.13", "description": "Lo, also it is the time of His rain.", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 9fd1185..a2d0ad9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,4 +32,6 @@ export * from "./signDelegation"; export * from "./signPermit"; export * from "./signVote"; export * from "./util"; +export * from "./addresses/setup"; +export { deployments as DEPLOYMENT_ADDRESSES } from "./addresses/deployed"; export * from "../test/utils"; diff --git a/test/BaalSafe.test.ts b/test/BaalSafe.test.ts index fed43cf..1ef866b 100644 --- a/test/BaalSafe.test.ts +++ b/test/BaalSafe.test.ts @@ -11,14 +11,12 @@ import { ProposalType, PROPOSAL_STATES, revertMessages, - setShamanProposal, setupBaal, SHAMAN_PERMISSIONS, - submitAndProcessProposal, verifyProposal, } from './utils/baal'; import { blockTime, moveForwardPeriods } from './utils/evm'; -import { baalSetup, mockBaalLessSharesSetup, Signer } from './utils/fixtures'; +import { baalSetup, mockBaalLessSharesSetup, ProposalHelpers, Signer } from './utils/fixtures'; import signDelegation from "../src/signDelegation"; import signVote from "../src/signVote"; import { sharesRevertMessages } from './utils/token'; @@ -63,6 +61,8 @@ describe("Baal contract", function () { const yes = true; const no = false; + let proposalHelpers: ProposalHelpers; + beforeEach(async function () { forwarder = '0x0000000000000000000000000000000000000420'; @@ -76,7 +76,8 @@ describe("Baal contract", function () { MultiSend, WETH, DAI, - signers + signers, + helpers, } = await baalSetup({ daoSettings: deploymentConfig, forwarderAddress: forwarder, @@ -92,6 +93,8 @@ describe("Baal contract", function () { dai = DAI; users = signers; + proposalHelpers = helpers; + chainId = Number(await getChainId()); const selfTransferAction = encodeMultiAction( @@ -191,7 +194,7 @@ describe("Baal contract", function () { ); await expect( - submitAndProcessProposal({ + proposalHelpers.submitAndProcessProposal({ baal, encodedAction, proposal, @@ -226,7 +229,7 @@ describe("Baal contract", function () { ); await expect( - submitAndProcessProposal({ + proposalHelpers.submitAndProcessProposal({ baal, encodedAction, proposal, @@ -261,7 +264,7 @@ describe("Baal contract", function () { ); await expect( - submitAndProcessProposal({ + proposalHelpers.submitAndProcessProposal({ baal, encodedAction, proposal, @@ -296,7 +299,7 @@ describe("Baal contract", function () { ); await expect( - submitAndProcessProposal({ + proposalHelpers.submitAndProcessProposal({ baal, encodedAction, proposal, @@ -336,7 +339,7 @@ describe("Baal contract", function () { ); await expect( - submitAndProcessProposal({ + proposalHelpers.submitAndProcessProposal({ baal, encodedAction, proposal, @@ -1230,56 +1233,56 @@ describe("Baal contract", function () { }); it("setShamans - 0 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, 0); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, 0); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.NONE); }); it("setShamans - 1 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 2 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.MANAGER); }); it("setShamans - 3 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_MANAGER); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_MANAGER); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 4 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.GOVERNANCE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.GOVERNANCE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.GOVERNANCE); }); it("setShamans - 5 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_GOVERNANCE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_GOVERNANCE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 6 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER_GOVERNANCE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER_GOVERNANCE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.MANAGER_GOVERNANCE); }); it("setShamans - 7 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.summoner.address, SHAMAN_PERMISSIONS.ALL); // use summoner bc shaman default = 7 + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.summoner.address, SHAMAN_PERMISSIONS.ALL); // use summoner bc shaman default = 7 const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.summoner.address)).to.equal(SHAMAN_PERMISSIONS.NONE); @@ -1315,56 +1318,56 @@ describe("Baal contract", function () { }); it("setShamans - 0 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.NONE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.NONE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.NONE); }); it("setShamans - 1 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ADMIN); }); it("setShamans - 2 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 3 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_MANAGER); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_MANAGER); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 4 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.GOVERNANCE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.GOVERNANCE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.GOVERNANCE); }); it("setShamans - 5 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_GOVERNANCE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_GOVERNANCE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ADMIN_GOVERNANCE); }); it("setShamans - 6 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER_GOVERNANCE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER_GOVERNANCE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 7 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.summoner.address, SHAMAN_PERMISSIONS.ALL); // use summoner bc shaman default = 7 + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.summoner.address, SHAMAN_PERMISSIONS.ALL); // use summoner bc shaman default = 7 const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.summoner.address)).to.equal(SHAMAN_PERMISSIONS.NONE); @@ -1400,56 +1403,56 @@ describe("Baal contract", function () { }); it("setShamans - 0 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.NONE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.NONE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.NONE); }); it("setShamans - 1 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ADMIN); }); it("setShamans - 2 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.MANAGER); }); it("setShamans - 3 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_MANAGER); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_MANAGER); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ADMIN_MANAGER); }); it("setShamans - 4 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.GOVERNANCE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.GOVERNANCE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 5 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_GOVERNANCE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_GOVERNANCE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 6 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER_GOVERNANCE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER_GOVERNANCE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 7 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.summoner.address, SHAMAN_PERMISSIONS.ALL); // use summoner bc shaman default = 7 + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.summoner.address, SHAMAN_PERMISSIONS.ALL); // use summoner bc shaman default = 7 const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.summoner.address)).to.equal(SHAMAN_PERMISSIONS.NONE); @@ -1491,56 +1494,56 @@ describe("Baal contract", function () { }); it("setShamans - 0 - success", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.NONE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.NONE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, false]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.NONE); }); it("setShamans - 1 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 2 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 3 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_MANAGER); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_MANAGER); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 4 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.GOVERNANCE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.GOVERNANCE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 5 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_GOVERNANCE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.ADMIN_GOVERNANCE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 6 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER_GOVERNANCE); + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.shaman.address, SHAMAN_PERMISSIONS.MANAGER_GOVERNANCE); const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.shaman.address)).to.equal(SHAMAN_PERMISSIONS.ALL); }); it("setShamans - 7 - fail", async () => { - const id = await setShamanProposal(baal, multisend, users.summoner.address, SHAMAN_PERMISSIONS.ALL); // use summoner bc shaman default = 7 + const id = await proposalHelpers.setShamanProposal(baal, multisend, users.summoner.address, SHAMAN_PERMISSIONS.ALL); // use summoner bc shaman default = 7 const propStatus = await baal.getProposalStatus(id); expect(propStatus).to.eql([false, true, true, true]); // [cancelled, processed, passed, actionFailed] expect(await baal.shamans(users.summoner.address)).to.equal(SHAMAN_PERMISSIONS.NONE); @@ -3024,7 +3027,7 @@ describe("Baal contract", function () { [0] ); - await expect(submitAndProcessProposal({ + await expect(proposalHelpers.submitAndProcessProposal({ baal, encodedAction, proposal, @@ -3057,7 +3060,7 @@ describe("Baal contract", function () { [0] ); - await expect(submitAndProcessProposal({ + await expect(proposalHelpers.submitAndProcessProposal({ baal, encodedAction, proposal, @@ -3090,7 +3093,7 @@ describe("Baal contract", function () { [0] ); - await expect(submitAndProcessProposal({ + await expect(proposalHelpers.submitAndProcessProposal({ baal, encodedAction, proposal, @@ -3123,7 +3126,7 @@ describe("Baal contract", function () { [0] ); - await expect(submitAndProcessProposal({ + await expect(proposalHelpers.submitAndProcessProposal({ baal, encodedAction, proposal, diff --git a/test/Tribute.test.ts b/test/Tribute.test.ts index 38a95e4..27d68b8 100644 --- a/test/Tribute.test.ts +++ b/test/Tribute.test.ts @@ -9,8 +9,7 @@ import { revertMessages, } from './utils/baal'; import { moveForwardPeriods } from './utils/evm'; -import { baalSetup, Signer } from './utils/fixtures'; -import { submitAndProcessTributeProposal } from './utils/tribute'; +import { baalSetup, ProposalHelpers, Signer } from './utils/fixtures'; import { Baal, TestERC20, @@ -42,6 +41,8 @@ describe("Tribute proposal type", function () { const yes = true; const no = false; + let proposalHelpers: ProposalHelpers; + beforeEach(async () => { const { Baal, @@ -52,7 +53,8 @@ describe("Tribute proposal type", function () { MultiSend, TributeMinion, WETH, - signers + signers, + helpers, } = await baalSetup({}); baal = Baal; @@ -65,6 +67,8 @@ describe("Tribute proposal type", function () { // poster = Poster; tributeMinion = TributeMinion; users = signers; + + proposalHelpers = helpers; }); describe("Dangerous proposal tribute", () => { @@ -181,7 +185,7 @@ describe("Tribute proposal type", function () { const currentShares = await sharesToken.balanceOf(users.applicant.address); - users.applicant.tributeMinion && await submitAndProcessTributeProposal({ + users.applicant.tributeMinion && await proposalHelpers.submitAndProcessTributeProposal({ tributeMinion: users.applicant.tributeMinion, baal, applicantAddress: users.applicant.address, @@ -236,7 +240,7 @@ describe("Tribute proposal type", function () { const currentShares = await sharesToken.balanceOf(users.applicant.address); - users.applicant.tributeMinion && await submitAndProcessTributeProposal({ + users.applicant.tributeMinion && await proposalHelpers.submitAndProcessTributeProposal({ tributeMinion: users.applicant.tributeMinion, baal, applicantAddress: users.applicant.address, @@ -269,7 +273,7 @@ describe("Tribute proposal type", function () { // await users.summoner.weth?.approve(tributeMinion.address, tribute); - // users.summoner.tributeMinion && await submitAndProcessTributeProposal({ + // users.summoner.tributeMinion && await proposalHelpers.submitAndProcessTributeProposal({ // tributeMinion: users.summoner.tributeMinion, // baal, // applicantAddress: users.summoner.address, diff --git a/test/utils/baal.ts b/test/utils/baal.ts index 73d8c95..2e29d08 100644 --- a/test/utils/baal.ts +++ b/test/utils/baal.ts @@ -113,7 +113,7 @@ export enum SHAMAN_PERMISSIONS { ALL, }; -export const defaultDAOSettings = { +export const defaultDAOSettings: DAOSettings = { GRACE_PERIOD_IN_SECONDS: 43200, VOTING_PERIOD_IN_SECONDS: 432000, PROPOSAL_OFFERING: 0, @@ -301,21 +301,27 @@ export const setupBaal = async ({ return await getNewBaalAddresses(tx); }; +export type ProposalParams = { + baal: Baal; + encodedAction: string; + proposal: ProposalType; + proposalId?: BigNumberish; + daoSettings?: DAOSettings; + extraSeconds?: number; +}; + export const submitAndProcessProposal = async ({ baal, encodedAction, proposal, proposalId, - }: { - baal: Baal; - encodedAction: string; - proposal: ProposalType; - proposalId?: BigNumberish; - }) => { + daoSettings = defaultDAOSettings, + extraSeconds = 2, + }: ProposalParams) => { await baal.submitProposal(encodedAction, proposal.expiration, proposal.baalGas, ethers.utils.id(proposal.details)); const id = proposalId ? proposalId : await baal.proposalCount(); await baal.submitVote(id, true); - await moveForwardPeriods(defaultDAOSettings.VOTING_PERIOD_IN_SECONDS, 2); + await moveForwardPeriods(daoSettings.VOTING_PERIOD_IN_SECONDS, extraSeconds); return await baal.processProposal(id, encodedAction); }; @@ -323,7 +329,9 @@ export const setShamanProposal = async ( baal: Baal, multisend: MultiSend, shamanAddress: string, - permission: BigNumberish + permission: BigNumberish, + daoSettings = defaultDAOSettings, + extraSeconds = 2, ) => { const setShaman = baal.interface.encodeFunctionData('setShamans', [ [shamanAddress], @@ -341,7 +349,7 @@ export const setShamanProposal = async ( await baal.submitProposal(setShamanAction, 0, 0, ''); const proposalId = await baal.proposalCount(); await baal.submitVote(proposalId, true); - await moveForwardPeriods(defaultDAOSettings.VOTING_PERIOD_IN_SECONDS, 2); + await moveForwardPeriods(daoSettings.VOTING_PERIOD_IN_SECONDS, extraSeconds); await baal.processProposal(proposalId, setShamanAction); return proposalId; }; diff --git a/test/utils/fixtures.ts b/test/utils/fixtures.ts index a426f91..59ff835 100644 --- a/test/utils/fixtures.ts +++ b/test/utils/fixtures.ts @@ -2,7 +2,9 @@ import { deployments } from 'hardhat'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { Baal, BaalLessShares, BaalSummoner, GnosisSafe, Loot, MockBaal, MultiSend, Poster, Shares, TestERC20, TributeMinion } from '../../src/types'; -import { DAOSettings, NewBaalAddresses, NewBaalParams, SummonSetup, defaultDAOSettings, defaultSummonSetup, setupBaal } from './baal'; +import { DAOSettings, NewBaalAddresses, NewBaalParams, ProposalParams, ProposalType, SummonSetup, defaultDAOSettings, defaultSummonSetup, setShamanProposal, setupBaal, submitAndProcessProposal } from './baal'; +import { BigNumberish, ContractTransaction } from 'ethers'; +import { TributeProposalParams, TributeProposalStatus, submitAndProcessTributeProposal } from './tribute'; export type Signer = { address: string; @@ -16,7 +18,13 @@ export type Signer = { dai?: TestERC20; }; -type BaalSetupType = { +export type ProposalHelpers = { + submitAndProcessProposal: (params: Omit) => Promise, + submitAndProcessTributeProposal: (params: Omit) => Promise, + setShamanProposal: (baal: Baal, multisend: MultiSend, shamanAddress: string, permission: BigNumberish) => Promise, +}; + +export type BaalSetupType = { Loot: Loot; Shares: Shares; Baal: Baal; @@ -30,6 +38,8 @@ type BaalSetupType = { signers: { [key: string]: Signer; }; + daoSettings: DAOSettings; + helpers: ProposalHelpers; } type MockBaalSetupType = { @@ -189,7 +199,7 @@ export const baalSetup = deployments.createFixture ) => { const { ethers, deployments, getNamedAccounts, getUnnamedAccounts } = hre; const { deployer } = await getNamedAccounts(); - const [summoner, applicant, shaman, s1, s2, s3, s4, s5, s6] = await getUnnamedAccounts(); + const [summoner, applicant, shaman] = await getUnnamedAccounts(); await deployments.fixture(['Infra', 'TributeMinion', 'BaalSummoner', ...(options?.fixtureTags || [])]); // Deployment Tags @@ -213,14 +223,16 @@ export const baalSetup = deployments.createFixture }; const applicantDist = { shares, loot }; + const daoSettings = { + ...defaultDAOSettings, + ...options?.daoSettings, + }; + const setupParams: NewBaalParams = { baalSummoner, baalSingleton, poster, - config: { - ...defaultDAOSettings, - ...options?.daoSettings, - }, + config: daoSettings, adminConfig: [sharesPaused, lootPaused], shamans: [[shaman], [shamanPermissions]], shares: [ @@ -260,6 +272,7 @@ export const baalSetup = deployments.createFixture : await setupUsersDefault({ addresses, baal, hre }); return { + daoSettings, Loot: lootToken, Shares: sharesToken, // Baal: (await ethers.getContract('Baal', deployer)) as Baal, @@ -272,6 +285,17 @@ export const baalSetup = deployments.createFixture WETH: weth, DAI: dai, signers, + helpers: { + setShamanProposal: (baal, multisend, shamanAddress, permission) => { + return setShamanProposal(baal, multisend, shamanAddress, permission, daoSettings); + }, + submitAndProcessProposal: (params) => { + return submitAndProcessProposal({ ...params, daoSettings }); + }, + submitAndProcessTributeProposal(params) { + return submitAndProcessTributeProposal({ ...params, daoSettings }); + }, + } }; diff --git a/test/utils/tribute.ts b/test/utils/tribute.ts index d4a0a03..15958cf 100644 --- a/test/utils/tribute.ts +++ b/test/utils/tribute.ts @@ -1,10 +1,33 @@ -import { defaultDAOSettings } from './baal'; +import { DAOSettings, defaultDAOSettings } from './baal'; import { moveForwardPeriods } from './evm'; import { Baal, TributeMinion } from '../../src/types'; import { BigNumber } from 'ethers'; const yes = true; +export type TributeProposalParams = { + tributeMinion: TributeMinion, + baal: Baal, + applicantAddress: string, + tributeToken: string, + tribute: number, + requestedShares: number, + requestedLoot: number, + sponsor?: boolean; + proposalId?: number; + proposalOffering?: number; + proposalExpiration?: number; + proposalBaalGas?: number; + daoSettings?: DAOSettings; + extraSeconds?: number; +}; + +export type TributeProposalStatus = { + spentInGas: BigNumber; + state: number; + propStatus: [boolean, boolean, boolean, boolean]; +}; + export const submitAndProcessTributeProposal = async ({ tributeMinion, baal, @@ -18,20 +41,9 @@ export const submitAndProcessTributeProposal = async ({ proposalOffering = 0, proposalExpiration = 0, proposalBaalGas = 0, -}: { - tributeMinion: TributeMinion, - baal: Baal, - applicantAddress: string, - tributeToken: string, - tribute: number, - requestedShares: number, - requestedLoot: number, - sponsor?: boolean; - proposalId?: number; - proposalOffering?: number; - proposalExpiration?: number; - proposalBaalGas?: number; -}) => { + daoSettings = defaultDAOSettings, + extraSeconds = 2, +}: TributeProposalParams): Promise => { const tx_1 = await tributeMinion.submitTributeProposal( baal.address, @@ -49,7 +61,7 @@ export const submitAndProcessTributeProposal = async ({ const tx_2_r = tx_2 ? await tx_2.wait() : undefined; const tx_3 = await baal.submitVote(proposalId, yes); const tx_3_r = await tx_3.wait(); - await moveForwardPeriods(defaultDAOSettings.VOTING_PERIOD_IN_SECONDS, 2); + await moveForwardPeriods(daoSettings.VOTING_PERIOD_IN_SECONDS, extraSeconds); const encodedProposal = await tributeMinion.encodeTributeProposal( baal.address,