diff --git a/deploy/core/021_deploy_LinearERC20VotingWithHatsProposalCreation.ts b/deploy/core/021_deploy_LinearERC20VotingWithHatsProposalCreation.ts index 556fdf4..073e502 100644 --- a/deploy/core/021_deploy_LinearERC20VotingWithHatsProposalCreation.ts +++ b/deploy/core/021_deploy_LinearERC20VotingWithHatsProposalCreation.ts @@ -1,9 +1,9 @@ -import { HardhatRuntimeEnvironment } from "hardhat/types"; -import { DeployFunction } from "hardhat-deploy/types"; -import { deployNonUpgradeable } from "../helpers/deployNonUpgradeable"; +import { HardhatRuntimeEnvironment } from 'hardhat/types'; +import { DeployFunction } from 'hardhat-deploy/types'; +import { deployNonUpgradeable } from '../helpers/deployNonUpgradeable'; const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { - await deployNonUpgradeable(hre, "LinearERC20VotingWithHatsProposalCreation"); + await deployNonUpgradeable(hre, 'LinearERC20VotingWithHatsProposalCreation'); }; export default func; diff --git a/deploy/core/022_deploy_LinearERC721VotingWithHatsProposalCreation.ts b/deploy/core/022_deploy_LinearERC721VotingWithHatsProposalCreation.ts index 15b8bf3..c656106 100644 --- a/deploy/core/022_deploy_LinearERC721VotingWithHatsProposalCreation.ts +++ b/deploy/core/022_deploy_LinearERC721VotingWithHatsProposalCreation.ts @@ -1,9 +1,9 @@ -import { HardhatRuntimeEnvironment } from "hardhat/types"; -import { DeployFunction } from "hardhat-deploy/types"; -import { deployNonUpgradeable } from "../helpers/deployNonUpgradeable"; +import { HardhatRuntimeEnvironment } from 'hardhat/types'; +import { DeployFunction } from 'hardhat-deploy/types'; +import { deployNonUpgradeable } from '../helpers/deployNonUpgradeable'; const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { - await deployNonUpgradeable(hre, "LinearERC721VotingWithHatsProposalCreation"); + await deployNonUpgradeable(hre, 'LinearERC721VotingWithHatsProposalCreation'); }; export default func; diff --git a/test/Azorius-LinearERC20VotingWithHatsProposalCreation.test.ts b/test/Azorius-LinearERC20VotingWithHatsProposalCreation.test.ts index d05eb8d..bad3bf9 100644 --- a/test/Azorius-LinearERC20VotingWithHatsProposalCreation.test.ts +++ b/test/Azorius-LinearERC20VotingWithHatsProposalCreation.test.ts @@ -1,7 +1,8 @@ -import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers"; -import { expect } from "chai"; -import hre from "hardhat"; -import { ethers } from "ethers"; +import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'; +import { expect } from 'chai'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { ethers } from 'ethers'; +import hre from 'hardhat'; import { GnosisSafe, @@ -14,23 +15,22 @@ import { VotesERC20__factory, ModuleProxyFactory, GnosisSafeL2__factory, -} from "../typechain-types"; +} from '../typechain-types'; +import { + getGnosisSafeL2Singleton, + getGnosisSafeProxyFactory, + getModuleProxyFactory, +} from './GlobalSafeDeployments.test'; import { calculateProxyAddress, predictGnosisSafeAddress, buildSafeTransaction, safeSignTypedData, buildSignatureBytes, -} from "./helpers"; - -import { - getGnosisSafeL2Singleton, - getGnosisSafeProxyFactory, - getModuleProxyFactory, -} from "./GlobalSafeDeployments.test"; +} from './helpers'; -describe("LinearERC20VotingWithHatsProposalCreation", () => { +describe('LinearERC20VotingWithHatsProposalCreation', () => { // Deployed contracts let gnosisSafe: GnosisSafe; let azorius: Azorius; @@ -49,9 +49,7 @@ describe("LinearERC20VotingWithHatsProposalCreation", () => { // Gnosis let createGnosisSetupCalldata: string; - const saltNum = BigInt( - "0x856d90216588f9ffc124d1480a440e1c012c7a816952bc968d737bae5d4e139c" - ); + const saltNum = BigInt('0x856d90216588f9ffc124d1480a440e1c012c7a816952bc968d737bae5d4e139c'); beforeEach(async () => { gnosisSafeProxyFactory = getGnosisSafeProxyFactory(); @@ -64,7 +62,7 @@ describe("LinearERC20VotingWithHatsProposalCreation", () => { createGnosisSetupCalldata = // eslint-disable-next-line camelcase - GnosisSafeL2__factory.createInterface().encodeFunctionData("setup", [ + GnosisSafeL2__factory.createInterface().encodeFunctionData('setup', [ [gnosisSafeOwner.address], 1, ethers.ZeroAddress, @@ -79,58 +77,49 @@ describe("LinearERC20VotingWithHatsProposalCreation", () => { createGnosisSetupCalldata, saltNum, await gnosisSafeL2Singleton.getAddress(), - gnosisSafeProxyFactory + gnosisSafeProxyFactory, ); // Deploy Gnosis Safe await gnosisSafeProxyFactory.createProxyWithNonce( await gnosisSafeL2Singleton.getAddress(), createGnosisSetupCalldata, - saltNum + saltNum, ); - gnosisSafe = await hre.ethers.getContractAt( - "GnosisSafe", - predictedGnosisSafeAddress - ); + gnosisSafe = await hre.ethers.getContractAt('GnosisSafe', predictedGnosisSafeAddress); // Deploy Votes ERC-20 mastercopy contract votesERC20Mastercopy = await new VotesERC20__factory(deployer).deploy(); const votesERC20SetupCalldata = // eslint-disable-next-line camelcase - VotesERC20__factory.createInterface().encodeFunctionData("setUp", [ - abiCoder.encode( - ["string", "string", "address[]", "uint256[]"], - ["DCNT", "DCNT", [], []] - ), + VotesERC20__factory.createInterface().encodeFunctionData('setUp', [ + abiCoder.encode(['string', 'string', 'address[]', 'uint256[]'], ['DCNT', 'DCNT', [], []]), ]); await moduleProxyFactory.deployModule( await votesERC20Mastercopy.getAddress(), votesERC20SetupCalldata, - "10031021" + '10031021', ); const predictedVotesERC20Address = await calculateProxyAddress( moduleProxyFactory, await votesERC20Mastercopy.getAddress(), votesERC20SetupCalldata, - "10031021" + '10031021', ); - votesERC20 = await hre.ethers.getContractAt( - "VotesERC20", - predictedVotesERC20Address - ); + votesERC20 = await hre.ethers.getContractAt('VotesERC20', predictedVotesERC20Address); // Deploy Azorius module azoriusMastercopy = await new Azorius__factory(deployer).deploy(); const azoriusSetupCalldata = // eslint-disable-next-line camelcase - Azorius__factory.createInterface().encodeFunctionData("setUp", [ + Azorius__factory.createInterface().encodeFunctionData('setUp', [ abiCoder.encode( - ["address", "address", "address", "address[]", "uint32", "uint32"], + ['address', 'address', 'address', 'address[]', 'uint32', 'uint32'], [ gnosisSafeOwner.address, await gnosisSafe.getAddress(), @@ -138,51 +127,45 @@ describe("LinearERC20VotingWithHatsProposalCreation", () => { [], 60, // timelock period in blocks 60, // execution period in blocks - ] + ], ), ]); await moduleProxyFactory.deployModule( await azoriusMastercopy.getAddress(), azoriusSetupCalldata, - "10031021" + '10031021', ); const predictedAzoriusAddress = await calculateProxyAddress( moduleProxyFactory, await azoriusMastercopy.getAddress(), azoriusSetupCalldata, - "10031021" + '10031021', ); - azorius = await hre.ethers.getContractAt( - "Azorius", - predictedAzoriusAddress - ); + azorius = await hre.ethers.getContractAt('Azorius', predictedAzoriusAddress); // Deploy LinearERC20VotingWithHatsProposalCreation linearERC20VotingWithHatsMastercopy = - await new LinearERC20VotingWithHatsProposalCreation__factory( - deployer - ).deploy(); + await new LinearERC20VotingWithHatsProposalCreation__factory(deployer).deploy(); - const mockHatsContractAddress = - "0x1234567890123456789012345678901234567890"; + const mockHatsContractAddress = '0x1234567890123456789012345678901234567890'; const linearERC20VotingWithHatsSetupCalldata = LinearERC20VotingWithHatsProposalCreation__factory.createInterface().encodeFunctionData( - "setUp", + 'setUp', [ abiCoder.encode( [ - "address", - "address", - "address", - "uint32", - "uint256", - "uint256", - "address", - "uint256[]", + 'address', + 'address', + 'address', + 'uint32', + 'uint256', + 'uint256', + 'address', + 'uint256[]', ], [ gnosisSafeOwner.address, @@ -193,28 +176,27 @@ describe("LinearERC20VotingWithHatsProposalCreation", () => { 500000, mockHatsContractAddress, [1n], // Use a mock hat ID - ] + ], ), - ] + ], ); await moduleProxyFactory.deployModule( await linearERC20VotingWithHatsMastercopy.getAddress(), linearERC20VotingWithHatsSetupCalldata, - "10031021" + '10031021', ); - const predictedLinearERC20VotingWithHatsAddress = - await calculateProxyAddress( - moduleProxyFactory, - await linearERC20VotingWithHatsMastercopy.getAddress(), - linearERC20VotingWithHatsSetupCalldata, - "10031021" - ); + const predictedLinearERC20VotingWithHatsAddress = await calculateProxyAddress( + moduleProxyFactory, + await linearERC20VotingWithHatsMastercopy.getAddress(), + linearERC20VotingWithHatsSetupCalldata, + '10031021', + ); linearERC20VotingWithHats = await hre.ethers.getContractAt( - "LinearERC20VotingWithHatsProposalCreation", - predictedLinearERC20VotingWithHatsAddress + 'LinearERC20VotingWithHatsProposalCreation', + predictedLinearERC20VotingWithHatsAddress, ); // Enable the strategy on Azorius @@ -223,10 +205,9 @@ describe("LinearERC20VotingWithHatsProposalCreation", () => { .enableStrategy(await linearERC20VotingWithHats.getAddress()); // Create transaction on Gnosis Safe to setup Azorius module - const enableAzoriusModuleData = gnosisSafe.interface.encodeFunctionData( - "enableModule", - [await azorius.getAddress()] - ); + const enableAzoriusModuleData = gnosisSafe.interface.encodeFunctionData('enableModule', [ + await azorius.getAddress(), + ]); const enableAzoriusModuleTx = buildSafeTransaction({ to: await gnosisSafe.getAddress(), @@ -235,13 +216,7 @@ describe("LinearERC20VotingWithHatsProposalCreation", () => { nonce: await gnosisSafe.nonce(), }); - const sigs = [ - await safeSignTypedData( - gnosisSafeOwner, - gnosisSafe, - enableAzoriusModuleTx - ), - ]; + const sigs = [await safeSignTypedData(gnosisSafeOwner, gnosisSafe, enableAzoriusModuleTx)]; const signatureBytes = buildSignatureBytes(sigs); @@ -257,38 +232,23 @@ describe("LinearERC20VotingWithHatsProposalCreation", () => { enableAzoriusModuleTx.gasPrice, enableAzoriusModuleTx.gasToken, enableAzoriusModuleTx.refundReceiver, - signatureBytes - ) - ).to.emit(gnosisSafe, "ExecutionSuccess"); + signatureBytes, + ), + ).to.emit(gnosisSafe, 'ExecutionSuccess'); }); - it("Gets correctly initialized", async () => { - expect(await linearERC20VotingWithHats.owner()).to.eq( - gnosisSafeOwner.address - ); - expect(await linearERC20VotingWithHats.governanceToken()).to.eq( - await votesERC20.getAddress() - ); - expect(await linearERC20VotingWithHats.azoriusModule()).to.eq( - await azorius.getAddress() - ); + it('Gets correctly initialized', async () => { + expect(await linearERC20VotingWithHats.owner()).to.eq(gnosisSafeOwner.address); + expect(await linearERC20VotingWithHats.governanceToken()).to.eq(await votesERC20.getAddress()); + expect(await linearERC20VotingWithHats.azoriusModule()).to.eq(await azorius.getAddress()); expect(await linearERC20VotingWithHats.hatsContract()).to.eq( - "0x1234567890123456789012345678901234567890" + '0x1234567890123456789012345678901234567890', ); }); - it("Cannot call setUp function again", async () => { + it('Cannot call setUp function again', async () => { const setupParams = ethers.AbiCoder.defaultAbiCoder().encode( - [ - "address", - "address", - "address", - "uint32", - "uint256", - "uint256", - "address", - "uint256[]", - ], + ['address', 'address', 'address', 'uint32', 'uint256', 'uint256', 'address', 'uint256[]'], [ gnosisSafeOwner.address, await votesERC20.getAddress(), @@ -296,13 +256,13 @@ describe("LinearERC20VotingWithHatsProposalCreation", () => { 60, // voting period 500000, // quorum numerator 500000, // basis numerator - "0x1234567890123456789012345678901234567890", + '0x1234567890123456789012345678901234567890', [1n], - ] + ], ); - await expect( - linearERC20VotingWithHats.setUp(setupParams) - ).to.be.revertedWith("Initializable: contract is already initialized"); + await expect(linearERC20VotingWithHats.setUp(setupParams)).to.be.revertedWith( + 'Initializable: contract is already initialized', + ); }); }); diff --git a/test/Azorius-LinearERC721VotingWithHatsProposalCreation.test.ts b/test/Azorius-LinearERC721VotingWithHatsProposalCreation.test.ts index 1165f9b..4bb6427 100644 --- a/test/Azorius-LinearERC721VotingWithHatsProposalCreation.test.ts +++ b/test/Azorius-LinearERC721VotingWithHatsProposalCreation.test.ts @@ -1,7 +1,8 @@ -import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers"; -import { expect } from "chai"; -import hre from "hardhat"; -import { ethers } from "ethers"; +import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'; +import { expect } from 'chai'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { ethers } from 'ethers'; +import hre from 'hardhat'; import { GnosisSafe, @@ -14,23 +15,22 @@ import { MockERC721__factory, ModuleProxyFactory, GnosisSafeL2__factory, -} from "../typechain-types"; +} from '../typechain-types'; +import { + getGnosisSafeL2Singleton, + getGnosisSafeProxyFactory, + getModuleProxyFactory, +} from './GlobalSafeDeployments.test'; import { calculateProxyAddress, predictGnosisSafeAddress, buildSafeTransaction, safeSignTypedData, buildSignatureBytes, -} from "./helpers"; - -import { - getGnosisSafeL2Singleton, - getGnosisSafeProxyFactory, - getModuleProxyFactory, -} from "./GlobalSafeDeployments.test"; +} from './helpers'; -describe("LinearERC721VotingWithHatsProposalCreation", () => { +describe('LinearERC721VotingWithHatsProposalCreation', () => { // Deployed contracts let gnosisSafe: GnosisSafe; let azorius: Azorius; @@ -48,9 +48,7 @@ describe("LinearERC721VotingWithHatsProposalCreation", () => { // Gnosis let createGnosisSetupCalldata: string; - const saltNum = BigInt( - "0x856d90216588f9ffc124d1480a440e1c012c7a816952bc968d737bae5d4e139c" - ); + const saltNum = BigInt('0x856d90216588f9ffc124d1480a440e1c012c7a816952bc968d737bae5d4e139c'); beforeEach(async () => { gnosisSafeProxyFactory = getGnosisSafeProxyFactory(); @@ -63,7 +61,7 @@ describe("LinearERC721VotingWithHatsProposalCreation", () => { createGnosisSetupCalldata = // eslint-disable-next-line camelcase - GnosisSafeL2__factory.createInterface().encodeFunctionData("setup", [ + GnosisSafeL2__factory.createInterface().encodeFunctionData('setup', [ [gnosisSafeOwner.address], 1, ethers.ZeroAddress, @@ -78,20 +76,17 @@ describe("LinearERC721VotingWithHatsProposalCreation", () => { createGnosisSetupCalldata, saltNum, await gnosisSafeL2Singleton.getAddress(), - gnosisSafeProxyFactory + gnosisSafeProxyFactory, ); // Deploy Gnosis Safe await gnosisSafeProxyFactory.createProxyWithNonce( await gnosisSafeL2Singleton.getAddress(), createGnosisSetupCalldata, - saltNum + saltNum, ); - gnosisSafe = await hre.ethers.getContractAt( - "GnosisSafe", - predictedGnosisSafeAddress - ); + gnosisSafe = await hre.ethers.getContractAt('GnosisSafe', predictedGnosisSafeAddress); // Deploy MockERC721 contract mockERC721 = await new MockERC721__factory(deployer).deploy(); @@ -101,9 +96,9 @@ describe("LinearERC721VotingWithHatsProposalCreation", () => { const azoriusSetupCalldata = // eslint-disable-next-line camelcase - Azorius__factory.createInterface().encodeFunctionData("setUp", [ + Azorius__factory.createInterface().encodeFunctionData('setUp', [ abiCoder.encode( - ["address", "address", "address", "address[]", "uint32", "uint32"], + ['address', 'address', 'address', 'address[]', 'uint32', 'uint32'], [ gnosisSafeOwner.address, await gnosisSafe.getAddress(), @@ -111,52 +106,46 @@ describe("LinearERC721VotingWithHatsProposalCreation", () => { [], 60, // timelock period in blocks 60, // execution period in blocks - ] + ], ), ]); await moduleProxyFactory.deployModule( await azoriusMastercopy.getAddress(), azoriusSetupCalldata, - "10031021" + '10031021', ); const predictedAzoriusAddress = await calculateProxyAddress( moduleProxyFactory, await azoriusMastercopy.getAddress(), azoriusSetupCalldata, - "10031021" + '10031021', ); - azorius = await hre.ethers.getContractAt( - "Azorius", - predictedAzoriusAddress - ); + azorius = await hre.ethers.getContractAt('Azorius', predictedAzoriusAddress); // Deploy LinearERC721VotingWithHatsProposalCreation linearERC721VotingWithHatsMastercopy = - await new LinearERC721VotingWithHatsProposalCreation__factory( - deployer - ).deploy(); + await new LinearERC721VotingWithHatsProposalCreation__factory(deployer).deploy(); - const mockHatsContractAddress = - "0x1234567890123456789012345678901234567890"; + const mockHatsContractAddress = '0x1234567890123456789012345678901234567890'; const linearERC721VotingWithHatsSetupCalldata = LinearERC721VotingWithHatsProposalCreation__factory.createInterface().encodeFunctionData( - "setUp", + 'setUp', [ abiCoder.encode( [ - "address", - "address[]", - "uint256[]", - "address", - "uint32", - "uint256", - "uint256", - "address", - "uint256[]", + 'address', + 'address[]', + 'uint256[]', + 'address', + 'uint32', + 'uint256', + 'uint256', + 'address', + 'uint256[]', ], [ gnosisSafeOwner.address, @@ -168,28 +157,27 @@ describe("LinearERC721VotingWithHatsProposalCreation", () => { 500000, // basis numerator mockHatsContractAddress, [1n], // Use a mock hat ID - ] + ], ), - ] + ], ); await moduleProxyFactory.deployModule( await linearERC721VotingWithHatsMastercopy.getAddress(), linearERC721VotingWithHatsSetupCalldata, - "10031021" + '10031021', ); - const predictedLinearERC721VotingWithHatsAddress = - await calculateProxyAddress( - moduleProxyFactory, - await linearERC721VotingWithHatsMastercopy.getAddress(), - linearERC721VotingWithHatsSetupCalldata, - "10031021" - ); + const predictedLinearERC721VotingWithHatsAddress = await calculateProxyAddress( + moduleProxyFactory, + await linearERC721VotingWithHatsMastercopy.getAddress(), + linearERC721VotingWithHatsSetupCalldata, + '10031021', + ); linearERC721VotingWithHats = await hre.ethers.getContractAt( - "LinearERC721VotingWithHatsProposalCreation", - predictedLinearERC721VotingWithHatsAddress + 'LinearERC721VotingWithHatsProposalCreation', + predictedLinearERC721VotingWithHatsAddress, ); // Enable the strategy on Azorius @@ -198,10 +186,9 @@ describe("LinearERC721VotingWithHatsProposalCreation", () => { .enableStrategy(await linearERC721VotingWithHats.getAddress()); // Create transaction on Gnosis Safe to setup Azorius module - const enableAzoriusModuleData = gnosisSafe.interface.encodeFunctionData( - "enableModule", - [await azorius.getAddress()] - ); + const enableAzoriusModuleData = gnosisSafe.interface.encodeFunctionData('enableModule', [ + await azorius.getAddress(), + ]); const enableAzoriusModuleTx = buildSafeTransaction({ to: await gnosisSafe.getAddress(), @@ -210,13 +197,7 @@ describe("LinearERC721VotingWithHatsProposalCreation", () => { nonce: await gnosisSafe.nonce(), }); - const sigs = [ - await safeSignTypedData( - gnosisSafeOwner, - gnosisSafe, - enableAzoriusModuleTx - ), - ]; + const sigs = [await safeSignTypedData(gnosisSafeOwner, gnosisSafe, enableAzoriusModuleTx)]; const signatureBytes = buildSignatureBytes(sigs); @@ -232,43 +213,33 @@ describe("LinearERC721VotingWithHatsProposalCreation", () => { enableAzoriusModuleTx.gasPrice, enableAzoriusModuleTx.gasToken, enableAzoriusModuleTx.refundReceiver, - signatureBytes - ) - ).to.emit(gnosisSafe, "ExecutionSuccess"); + signatureBytes, + ), + ).to.emit(gnosisSafe, 'ExecutionSuccess'); }); - it("Gets correctly initialized", async () => { - expect(await linearERC721VotingWithHats.owner()).to.eq( - gnosisSafeOwner.address - ); - expect(await linearERC721VotingWithHats.tokenAddresses(0)).to.eq( - await mockERC721.getAddress() - ); - expect( - await linearERC721VotingWithHats.tokenWeights( - await mockERC721.getAddress() - ) - ).to.eq(1); - expect(await linearERC721VotingWithHats.azoriusModule()).to.eq( - await azorius.getAddress() - ); + it('Gets correctly initialized', async () => { + expect(await linearERC721VotingWithHats.owner()).to.eq(gnosisSafeOwner.address); + expect(await linearERC721VotingWithHats.tokenAddresses(0)).to.eq(await mockERC721.getAddress()); + expect(await linearERC721VotingWithHats.tokenWeights(await mockERC721.getAddress())).to.eq(1); + expect(await linearERC721VotingWithHats.azoriusModule()).to.eq(await azorius.getAddress()); expect(await linearERC721VotingWithHats.hatsContract()).to.eq( - "0x1234567890123456789012345678901234567890" + '0x1234567890123456789012345678901234567890', ); }); - it("Cannot call setUp function again", async () => { + it('Cannot call setUp function again', async () => { const setupParams = ethers.AbiCoder.defaultAbiCoder().encode( [ - "address", - "address[]", - "uint256[]", - "address", - "uint32", - "uint256", - "uint256", - "address", - "uint256[]", + 'address', + 'address[]', + 'uint256[]', + 'address', + 'uint32', + 'uint256', + 'uint256', + 'address', + 'uint256[]', ], [ gnosisSafeOwner.address, @@ -278,13 +249,13 @@ describe("LinearERC721VotingWithHatsProposalCreation", () => { 60, 500000, 500000, - "0x1234567890123456789012345678901234567890", + '0x1234567890123456789012345678901234567890', [1n], - ] + ], ); - await expect( - linearERC721VotingWithHats.setUp(setupParams) - ).to.be.revertedWith("Initializable: contract is already initialized"); + await expect(linearERC721VotingWithHats.setUp(setupParams)).to.be.revertedWith( + 'Initializable: contract is already initialized', + ); }); });