diff --git a/packages/contracts/deploy/helpers.ts b/packages/contracts/deploy/helpers.ts index b23bfb20e..f371f5950 100644 --- a/packages/contracts/deploy/helpers.ts +++ b/packages/contracts/deploy/helpers.ts @@ -1,6 +1,7 @@ import {promises as fs} from 'fs'; import {ethers} from 'hardhat'; import {Contract} from 'ethers'; +import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers'; import {HardhatRuntimeEnvironment} from 'hardhat/types'; import IPFS from 'ipfs-http-client'; @@ -14,7 +15,7 @@ import { PluginRepo__factory, } from '../typechain'; import {VersionCreatedEvent} from '../typechain/PluginRepo'; -import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers'; +import {PluginRepoRegisteredEvent} from '../typechain/PluginRepoRegistry'; // TODO: Add support for L2 such as Arbitrum. (https://discuss.ens.domains/t/register-using-layer-2/688) // Make sure you own the ENS set in the {{NETWORK}}_ENS_DOMAIN variable in .env @@ -223,7 +224,7 @@ export async function createPluginRepo( ); await tx.wait(); - const event = await findEventTopicLog( + const event = await findEventTopicLog( tx, PluginRepoRegistry__factory.createInterface(), 'PluginRepoRegistered' diff --git a/packages/contracts/deploy/new/40_finalize-managing-dao/30_install-multisig-on-managing-dao.ts b/packages/contracts/deploy/new/40_finalize-managing-dao/30_install-multisig-on-managing-dao.ts index 05140492b..a54a7e4cb 100644 --- a/packages/contracts/deploy/new/40_finalize-managing-dao/30_install-multisig-on-managing-dao.ts +++ b/packages/contracts/deploy/new/40_finalize-managing-dao/30_install-multisig-on-managing-dao.ts @@ -108,17 +108,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { address: installationPreparedEvent.plugin, args: [ await multisigSetup.implementation(), - await Multisig__factory.createInterface().encodeFunctionData( - 'initialize', - [ - managingDAOAddress, - approvers, - { - onlyListed: listedOnly, - minApprovals: minApprovals, - }, - ] - ), + Multisig__factory.createInterface().encodeFunctionData('initialize', [ + managingDAOAddress, + approvers, + { + onlyListed: listedOnly, + minApprovals: minApprovals, + }, + ]), ], }); diff --git a/packages/contracts/test/framework/dao/dao-factory.ts b/packages/contracts/test/framework/dao/dao-factory.ts index 5b1e9e114..eb3cb625a 100644 --- a/packages/contracts/test/framework/dao/dao-factory.ts +++ b/packages/contracts/test/framework/dao/dao-factory.ts @@ -28,6 +28,9 @@ import { IERC165__factory, PluginRepoRegistry__factory, } from '../../../typechain'; +import {DAORegisteredEvent} from '../../../typechain/DAORegistry'; +import {InstallationPreparedEvent} from '../../../typechain/PluginSetupProcessor'; +import {PluginRepoRegisteredEvent} from '../../../typechain/PluginRepoRegistry'; import {deployENSSubdomainRegistrar} from '../../test-utils/ens'; import {deployPluginSetupProcessor} from '../../test-utils/plugin-setup-processor'; @@ -110,17 +113,18 @@ async function extractInfoFromCreateDaoTx(tx: any): Promise<{ helpers: any; permissions: any; }> { - const daoRegisteredEvent = await findEventTopicLog( + const daoRegisteredEvent = await findEventTopicLog( tx, DAORegistry__factory.createInterface(), EVENTS.DAORegistered ); - const installationPreparedEvent = await findEventTopicLog( - tx, - PluginSetupProcessor__factory.createInterface(), - EVENTS.InstallationPrepared - ); + const installationPreparedEvent = + await findEventTopicLog( + tx, + PluginSetupProcessor__factory.createInterface(), + EVENTS.InstallationPrepared + ); return { dao: daoRegisteredEvent.args.dao, @@ -247,7 +251,7 @@ describe('DAOFactory: ', function () { '0x00', '0x00' ); - const event = await findEventTopicLog( + const event = await findEventTopicLog( tx, PluginRepoRegistry__factory.createInterface(), EVENTS.PluginRepoRegistered @@ -584,11 +588,12 @@ describe('DAOFactory: ', function () { '0x11', '0x11' ); - const pluginRepoRegisteredEvent = await findEventTopicLog( - tx, - PluginRepoRegistry__factory.createInterface(), - EVENTS.PluginRepoRegistered - ); + const pluginRepoRegisteredEvent = + await findEventTopicLog( + tx, + PluginRepoRegistry__factory.createInterface(), + EVENTS.PluginRepoRegistered + ); adminPluginRepoAddress = pluginRepoRegisteredEvent.args.pluginRepo; // create dao with admin plugin. @@ -611,11 +616,12 @@ describe('DAOFactory: ', function () { ); tx = await daoFactory.createDao(daoSettings, [adminPluginInstallation]); { - const installationPreparedEvent = await findEventTopicLog( - tx, - PluginSetupProcessor__factory.createInterface(), - EVENTS.InstallationPrepared - ); + const installationPreparedEvent = + await findEventTopicLog( + tx, + PluginSetupProcessor__factory.createInterface(), + EVENTS.InstallationPrepared + ); const adminFactory = new Admin__factory(signers[0]); adminPlugin = adminFactory.attach( diff --git a/packages/contracts/test/framework/plugin/plugin-setup-processor.ts b/packages/contracts/test/framework/plugin/plugin-setup-processor.ts index 5a4f9e220..b7af6c512 100644 --- a/packages/contracts/test/framework/plugin/plugin-setup-processor.ts +++ b/packages/contracts/test/framework/plugin/plugin-setup-processor.ts @@ -31,6 +31,7 @@ import { PluginCloneableSetupV2Mock__factory, PluginCloneableSetupV1MockBad__factory, } from '../../../typechain'; +import {PluginRepoRegisteredEvent} from '../../../typechain/PluginRepoRegistry'; import {deployENSSubdomainRegistrar} from '../../test-utils/ens'; import {deployNewDAO, ZERO_BYTES32} from '../../test-utils/dao'; @@ -245,11 +246,12 @@ describe('Plugin Setup Processor', function () { buildMetadata ); - const PluginRepoRegisteredEvent1 = await findEventTopicLog( - tx, - PluginRepoRegistry__factory.createInterface(), - EVENTS.PluginRepoRegistered - ); + const PluginRepoRegisteredEvent1 = + await findEventTopicLog( + tx, + PluginRepoRegistry__factory.createInterface(), + EVENTS.PluginRepoRegistered + ); const PluginRepo = new PluginRepo__factory(signers[0]); repoU = PluginRepo.attach(PluginRepoRegisteredEvent1.args.pluginRepo); @@ -268,11 +270,12 @@ describe('Plugin Setup Processor', function () { buildMetadata ); - const PluginRepoRegisteredEvent2 = await findEventTopicLog( - tx, - PluginRepoRegistry__factory.createInterface(), - EVENTS.PluginRepoRegistered - ); + const PluginRepoRegisteredEvent2 = + await findEventTopicLog( + tx, + PluginRepoRegistry__factory.createInterface(), + EVENTS.PluginRepoRegistered + ); repoC = PluginRepo.attach(PluginRepoRegisteredEvent2.args.pluginRepo); await repoC.createVersion(1, setupCV1Bad.address, EMPTY_DATA, EMPTY_DATA); await repoC.createVersion(1, setupCV2.address, EMPTY_DATA, EMPTY_DATA); diff --git a/packages/contracts/test/plugins/governance/admin/admin.ts b/packages/contracts/test/plugins/governance/admin/admin.ts index f531cc673..b0cb50a29 100644 --- a/packages/contracts/test/plugins/governance/admin/admin.ts +++ b/packages/contracts/test/plugins/governance/admin/admin.ts @@ -24,6 +24,7 @@ import { DAO__factory, } from '../../../../typechain'; import {ProposalCreatedEvent} from '../../../../typechain/Admin'; +import {ExecutedEvent} from '../../../../typechain/IDAO'; // Permissions const EXECUTE_PROPOSAL_PERMISSION_ID = ethers.utils.id( @@ -227,7 +228,7 @@ describe('Admin', function () { expect(event.args.proposalId).to.equal(nextExpectedProposalId); }); - it("calls the DAO's execute function correctly with proposalId", async () => { + it.only("calls the DAO's execute function correctly with proposalId", async () => { { const proposalId = 0; const allowFailureMap = 1; @@ -237,7 +238,8 @@ describe('Admin', function () { dummyActions, allowFailureMap ); - const event = await findEventTopicLog( + + const event = await findEventTopicLog( tx, DAO__factory.createInterface(), DAO_EVENTS.EXECUTED @@ -258,7 +260,7 @@ describe('Admin', function () { const tx = await plugin.executeProposal(dummyMetadata, dummyActions, 0); - const event = await findEventTopicLog( + const event = await findEventTopicLog( tx, DAO__factory.createInterface(), DAO_EVENTS.EXECUTED diff --git a/packages/contracts/test/plugins/governance/majority-voting/addresslist/addresslist-voting.ts b/packages/contracts/test/plugins/governance/majority-voting/addresslist/addresslist-voting.ts index 6ff1c4f83..a5aacc786 100644 --- a/packages/contracts/test/plugins/governance/majority-voting/addresslist/addresslist-voting.ts +++ b/packages/contracts/test/plugins/governance/majority-voting/addresslist/addresslist-voting.ts @@ -46,6 +46,7 @@ import { ProposalCreatedEvent, ProposalExecutedEvent, } from '../../../../../typechain/AddresslistVoting'; +import {ExecutedEvent} from '../../../../../typechain/IDAO'; export const addresslistVotingInterface = new ethers.utils.Interface([ 'function initialize(address,tuple(uint8,uint32,uint32,uint64,uint256),address[])', @@ -1026,7 +1027,7 @@ describe('AddresslistVoting', function () { .connect(signers[6]) .vote(id, VoteOption.Abstain, true); { - const event = await findEventTopicLog( + const event = await findEventTopicLog( tx, DAO__factory.createInterface(), DAO_EVENTS.EXECUTED diff --git a/packages/contracts/test/plugins/governance/majority-voting/token/token-voting.ts b/packages/contracts/test/plugins/governance/majority-voting/token/token-voting.ts index c048bb480..125ff7e44 100644 --- a/packages/contracts/test/plugins/governance/majority-voting/token/token-voting.ts +++ b/packages/contracts/test/plugins/governance/majority-voting/token/token-voting.ts @@ -49,6 +49,7 @@ import { ProposalCreatedEvent, ProposalExecutedEvent, } from '../../../../../typechain/TokenVoting'; +import {ExecutedEvent} from '../../../../../typechain/IDAO'; export const tokenVotingInterface = new ethers.utils.Interface([ 'function initialize(address,tuple(uint8,uint32,uint32,uint64,uint256),address)', @@ -1382,7 +1383,7 @@ describe('TokenVoting', function () { .connect(signers[6]) .vote(id, VoteOption.Yes, true); { - const event = await findEventTopicLog( + const event = await findEventTopicLog( tx, DAO__factory.createInterface(), DAO_EVENTS.EXECUTED diff --git a/packages/contracts/test/plugins/governance/multisig/multisig.ts b/packages/contracts/test/plugins/governance/multisig/multisig.ts index 127829571..c07036794 100644 --- a/packages/contracts/test/plugins/governance/multisig/multisig.ts +++ b/packages/contracts/test/plugins/governance/multisig/multisig.ts @@ -1170,7 +1170,7 @@ describe('Multisig', function () { // `tryExecution` is turned on but the vote is not decided yet let tx = await multisig.connect(signers[1]).approve(id, true); await expect( - findEventTopicLog( + findEventTopicLog( tx, DAO__factory.createInterface(), DAO_EVENTS.EXECUTED @@ -1182,7 +1182,7 @@ describe('Multisig', function () { // `tryExecution` is turned off and the vote is decided tx = await multisig.connect(signers[2]).approve(id, false); await expect( - findEventTopicLog( + findEventTopicLog( tx, DAO__factory.createInterface(), DAO_EVENTS.EXECUTED @@ -1192,7 +1192,7 @@ describe('Multisig', function () { // `tryEarlyExecution` is turned on and the vote is decided tx = await multisig.connect(signers[3]).approve(id, true); { - const event = await findEventTopicLog( + const event = await findEventTopicLog( tx, DAO__factory.createInterface(), DAO_EVENTS.EXECUTED diff --git a/packages/contracts/test/upgrade/dao.ts b/packages/contracts/test/upgrade/dao.ts index ec3ba4ec7..5a8ef942d 100644 --- a/packages/contracts/test/upgrade/dao.ts +++ b/packages/contracts/test/upgrade/dao.ts @@ -15,6 +15,7 @@ import {UPGRADE_PERMISSIONS} from '../test-utils/permissions'; import {findEventTopicLog} from '../../utils/event'; import {readImplementationValueFromSlot} from '../../utils/storage'; import {getInterfaceID} from '../test-utils/interfaces'; +import {UpgradedEvent} from '../../typechain/DAO'; let signers: SignerWithAddress[]; let DAO_old: DAO_V1_0_0__factory; @@ -89,7 +90,11 @@ describe('DAO Upgrade', function () { // Check the emitted implementation. const emittedImplementation = ( - await findEventTopicLog(upgradeTx, DAO_old.interface, 'Upgraded') + await findEventTopicLog( + upgradeTx, + DAO_old.interface, + 'Upgraded' + ) ).args.implementation; expect(emittedImplementation).to.equal(daoCurrentImplementaion.address); diff --git a/packages/contracts/utils/event.ts b/packages/contracts/utils/event.ts index 48f09635c..bf6dcdd8b 100644 --- a/packages/contracts/utils/event.ts +++ b/packages/contracts/utils/event.ts @@ -1,7 +1,10 @@ import {ContractTransaction} from 'ethers'; import {Interface, LogDescription} from 'ethers/lib/utils'; -export async function findEvent(tx: ContractTransaction, eventName: string) { +export async function findEvent( + tx: ContractTransaction, + eventName: string +): Promise { const receipt = await tx.wait(); const event = (receipt.events || []).find(event => event.event === eventName); @@ -12,18 +15,18 @@ export async function findEvent(tx: ContractTransaction, eventName: string) { return event as unknown as T; } -export async function findEventTopicLog( +export async function findEventTopicLog( tx: ContractTransaction, iface: Interface, eventName: string -): Promise { +): Promise { const receipt = await tx.wait(); const topic = iface.getEventTopic(eventName); const log = receipt.logs.find(x => x.topics[0] === topic); if (!log) { throw new Error(`No logs found for the topic of event "${eventName}".`); } - return iface.parseLog(log); + return iface.parseLog(log) as LogDescription & (T | LogDescription); } export async function filterEvents(tx: any, eventName: string) {