Skip to content

Commit

Permalink
Merge remote-tracking branch 'template/develop' into feature/metadata…
Browse files Browse the repository at this point in the history
…-refactor
  • Loading branch information
heueristik committed Apr 18, 2024
2 parents 8feffbf + a779deb commit cb6eaf6
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 277 deletions.
4 changes: 2 additions & 2 deletions packages/contracts/deploy/10_create_repo/11_create_repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

// Get the PluginRepo address and deployment block number from the txn and event therein
const eventLog =
await findEventTopicLog<PluginRepoRegistryEvents.PluginRepoRegisteredEvent>(
tx,
findEventTopicLog<PluginRepoRegistryEvents.PluginRepoRegisteredEvent>(
await tx.wait(),
PluginRepoRegistry__factory.createInterface(),
'PluginRepoRegistered'
);
Expand Down
13 changes: 5 additions & 8 deletions packages/contracts/deploy/20_new_version/23_publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ import {
isLocal,
pluginEnsDomain,
} from '../../utils/helpers';
import {
PLUGIN_REPO_PERMISSIONS,
toHex,
uploadToIPFS,
} from '@aragon/osx-commons-sdk';
import {PLUGIN_REPO_PERMISSIONS, uploadToIPFS} from '@aragon/osx-commons-sdk';
import {ethers} from 'hardhat';
import {writeFile} from 'fs/promises';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
Expand Down Expand Up @@ -114,9 +111,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
.createVersion(
VERSION.release,
setup.address,
toHex(buildMetadataURI),
toHex(releaseMetadataURI)
);
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(buildMetadataURI)),
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(releaseMetadataURI))
);

await tx.wait();

Expand Down
8 changes: 4 additions & 4 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"clean": "rimraf ./artifacts ./cache ./coverage ./typechain ./types ./coverage.json && yarn typechain"
},
"dependencies": {
"@aragon/osx-commons-contracts": "1.4.0-alpha.3",
"@openzeppelin/contracts": "^4.9.5",
"@openzeppelin/contracts-upgradeable": "^4.9.5"
"@aragon/osx-commons-contracts": "1.4.0-alpha.4",
"@openzeppelin/contracts": "^4.9.6",
"@openzeppelin/contracts-upgradeable": "^4.9.6"
},
"devDependencies": {
"@aragon/osx-commons-configs": "0.4.0",
"@aragon/osx-commons-sdk": "0.0.1-alpha.5",
"@aragon/osx-ethers": "1.4.0-alpha.0",
"@aragon/osx-commons-sdk": "0.0.1-alpha.8",
"@aragon/osx-v1.0.0": "npm:@aragon/[email protected]",
"@aragon/osx-v1.3.0": "npm:@aragon/[email protected]",
"@ethersproject/abi": "^5.7.0",
Expand Down
66 changes: 32 additions & 34 deletions packages/contracts/test/10_unit-testing/11_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ import {Multisig__factory, Multisig} from '../test-utils/typechain-versions';
import {
getInterfaceId,
proposalIdToBytes32,
IDAO_EVENTS,
IMEMBERSHIP_EVENTS,
IPROPOSAL_EVENTS,
findEvent,
findEventTopicLog,
TIME,
Expand All @@ -37,6 +34,7 @@ import {DAO, DAOStructs, DAO__factory} from '@aragon/osx-ethers';
import {loadFixture, time} from '@nomicfoundation/hardhat-network-helpers';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
import {expect} from 'chai';
import {eventually} from 'chai-as-promised';
import {BigNumber} from 'ethers';
import {ethers} from 'hardhat';

Expand Down Expand Up @@ -84,8 +82,8 @@ async function fixture(): Promise<FixtureResult> {
[dao.address, defaultInitData.members, defaultInitData.settings]
);
const deploymentTx1 = await proxyFactory.deployUUPSProxy(pluginInitdata);
const proxyCreatedEvent1 = await findEvent<ProxyCreatedEvent>(
deploymentTx1,
const proxyCreatedEvent1 = findEvent<ProxyCreatedEvent>(
await deploymentTx1.wait(),
proxyFactory.interface.getEvent('ProxyCreated').name
);
const initializedPlugin = Multisig__factory.connect(
Expand All @@ -95,8 +93,8 @@ async function fixture(): Promise<FixtureResult> {

// Deploy an uninitialized plugin proxy.
const deploymentTx2 = await proxyFactory.deployUUPSProxy([]);
const proxyCreatedEvent2 = await findEvent<ProxyCreatedEvent>(
deploymentTx2,
const proxyCreatedEvent2 = findEvent<ProxyCreatedEvent>(
await deploymentTx2.wait(),
proxyFactory.interface.getEvent('ProxyCreated').name
);
const uninitializedPlugin = Multisig__factory.connect(
Expand Down Expand Up @@ -516,7 +514,7 @@ describe('Multisig', function () {
await expect(
plugin.connect(alice).addAddresses([dave.address, eve.address])
)
.to.emit(plugin, IMEMBERSHIP_EVENTS.MembersAdded)
.to.emit(plugin, 'MembersAdded')
.withArgs([dave.address, eve.address]);

// Check that Dave and Eve are listed now.
Expand Down Expand Up @@ -582,7 +580,7 @@ describe('Multisig', function () {

// Call `removeAddresses` as Alice to remove Bob.
await expect(plugin.connect(alice).removeAddresses([bob.address]))
.to.emit(plugin, IMEMBERSHIP_EVENTS.MembersRemoved)
.to.emit(plugin, 'MembersRemoved')
.withArgs([bob.address]);

// Check that Bob is removed while Alice and Carol remains listed.
Expand Down Expand Up @@ -770,7 +768,7 @@ describe('Multisig', function () {
endDate
)
)
.to.emit(plugin, IPROPOSAL_EVENTS.ProposalCreated)
.to.emit(plugin, 'ProposalCreated')
.withArgs(
expectedProposalId,
alice.address,
Expand Down Expand Up @@ -926,7 +924,7 @@ describe('Multisig', function () {
endDate
)
)
.to.emit(plugin, IPROPOSAL_EVENTS.ProposalCreated)
.to.emit(plugin, 'ProposalCreated')
.withArgs(
expectedProposalId,
dave.address,
Expand Down Expand Up @@ -1051,8 +1049,8 @@ describe('Multisig', function () {
expect(await plugin.isListed(dave.address)).to.equal(true);

// Check the `ProposalCreatedEvent` for the creator and proposalId.
const event = await findEvent<ProposalCreatedEvent>(
tx4,
const event = findEvent<ProposalCreatedEvent>(
await tx4.wait(),
'ProposalCreated'
);
expect(event.args.proposalId).to.equal(id);
Expand Down Expand Up @@ -1098,7 +1096,7 @@ describe('Multisig', function () {
endDate
)
)
.to.emit(plugin, IPROPOSAL_EVENTS.ProposalCreated)
.to.emit(plugin, 'ProposalCreated')
.withArgs(id, alice.address, startDate, endDate, dummyMetadata, [], 0);

const latestBlock = await ethers.provider.getBlock('latest');
Expand Down Expand Up @@ -1153,7 +1151,7 @@ describe('Multisig', function () {
endDate
)
)
.to.emit(plugin, IPROPOSAL_EVENTS.ProposalCreated)
.to.emit(plugin, 'ProposalCreated')
.withArgs(
id,
alice.address,
Expand Down Expand Up @@ -1608,7 +1606,7 @@ describe('Multisig', function () {
const tx = await plugin.connect(alice).approve(id, false);

// Check the `Approved` event and make sure that Alice is emitted as the approver.
const event = await findEvent<ApprovedEvent>(tx, 'Approved');
const event = findEvent<ApprovedEvent>(await tx.wait(), 'Approved');
expect(event.args.proposalId).to.eq(id);
expect(event.args.approver).to.eq(alice.address);

Expand Down Expand Up @@ -2045,12 +2043,12 @@ describe('Multisig', function () {
let tx = await plugin.connect(alice).approve(id, true);
await expect(
findEventTopicLog<ExecutedEvent>(
tx,
await tx.wait(),
DAO__factory.createInterface(),
IDAO_EVENTS.Executed
'Executed'
)
).to.rejectedWith(
`Event "${IDAO_EVENTS.Executed}" could not be found in transaction ${tx.hash}.`
`Event "Executed" could not be found in transaction ${tx.hash}.`
);

expect(await plugin.canExecute(id)).to.equal(false);
Expand All @@ -2059,23 +2057,23 @@ describe('Multisig', function () {
tx = await plugin.connect(bob).approve(id, false);
await expect(
findEventTopicLog<ExecutedEvent>(
tx,
await tx.wait(),
DAO__factory.createInterface(),
IDAO_EVENTS.Executed
'Executed'
)
).to.rejectedWith(
`Event "${IDAO_EVENTS.Executed}" could not be found in transaction ${tx.hash}.`
`Event "Executed" could not be found in transaction ${tx.hash}.`
);

// Approve and try execution as Carol while `minApprovals` threshold is reached already.
tx = await plugin.connect(carol).approve(id, true);

// Check that the proposal got executed by checking the `Executed` event emitted by the DAO.
{
const event = await findEventTopicLog<ExecutedEvent>(
tx,
const event = findEventTopicLog<ExecutedEvent>(
await tx.wait(),
DAO__factory.createInterface(),
IDAO_EVENTS.Executed
'Executed'
);

expect(event.args.actor).to.equal(plugin.address);
Expand All @@ -2092,9 +2090,9 @@ describe('Multisig', function () {

// Check that the proposal got executed by checking the `ProposalExecuted` event emitted by the plugin.
{
const event = await findEvent<ProposalExecutedEvent>(
tx,
IPROPOSAL_EVENTS.ProposalExecuted
const event = findEvent<ProposalExecutedEvent>(
await tx.wait(),
'ProposalExecuted'
);
expect(event.args.proposalId).to.equal(id);
}
Expand Down Expand Up @@ -2144,9 +2142,9 @@ describe('Multisig', function () {
// Execute the proposal and check that the `Executed` and `ProposalExecuted` event is emitted
// and that the `Approved` event is not emitted.
await expect(plugin.connect(alice).execute(id))
.to.emit(dao, IDAO_EVENTS.Executed)
.to.emit(plugin, IPROPOSAL_EVENTS.ProposalExecuted)
.to.not.emit(plugin, MULTISIG_EVENTS.Approved);
.to.emit(dao, 'Executed')
.to.emit(plugin, 'ProposalExecuted')
.to.not.emit(plugin, 'Approved');
});

it('emits the `Approved`, `ProposalExecuted`, and `Executed` events if execute is called inside the `approve` method', async () => {
Expand Down Expand Up @@ -2187,9 +2185,9 @@ describe('Multisig', function () {
// Approve and execute the proposal as Bob and check that the `Executed`, `ProposalExecuted`, and `Approved`
// event is not emitted.
await expect(plugin.connect(bob).approve(id, true))
.to.emit(dao, IDAO_EVENTS.Executed)
.to.emit(plugin, IPROPOSAL_EVENTS.ProposalExecuted)
.to.emit(plugin, MULTISIG_EVENTS.Approved);
.to.emit(dao, 'Executed')
.to.emit(plugin, 'ProposalExecuted')
.to.emit(plugin, 'Approved');
});

it("reverts if the proposal hasn't started yet", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
PERMISSION_MANAGER_FLAGS,
PLUGIN_REPO_PERMISSIONS,
UnsupportedNetworkError,
toHex,
uploadToIPFS,
} from '@aragon/osx-commons-sdk';
import {
Expand Down Expand Up @@ -82,7 +81,9 @@ describe(`Deployment on network '${productionNetworkName}'`, function () {
JSON.stringify(METADATA.build, null, 2)
)}`;

expect(results.buildMetadata).to.equal(toHex(buildMetadataURI));
expect(results.buildMetadata).to.equal(
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(buildMetadataURI))
);
});
});
});
Expand Down
31 changes: 15 additions & 16 deletions packages/contracts/test/20_integration-testing/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export async function installPLugin(
});

const preparedEvent =
await findEvent<PluginSetupProcessorEvents.InstallationPreparedEvent>(
prepareTx,
findEvent<PluginSetupProcessorEvents.InstallationPreparedEvent>(
await prepareTx.wait(),
psp.interface.getEvent('InstallationPrepared').name
);

Expand Down Expand Up @@ -74,8 +74,8 @@ export async function installPLugin(
});

const appliedEvent =
await findEvent<PluginSetupProcessorEvents.InstallationAppliedEvent>(
applyTx,
findEvent<PluginSetupProcessorEvents.InstallationAppliedEvent>(
await applyTx.wait(),
psp.interface.getEvent('InstallationApplied').name
);

Expand Down Expand Up @@ -109,7 +109,7 @@ export async function uninstallPLugin(

const preparedEvent =
await findEvent<PluginSetupProcessorEvents.UninstallationPreparedEvent>(
prepareTx,
await prepareTx.wait(),
psp.interface.getEvent('UninstallationPrepared').name
);

Expand All @@ -130,8 +130,8 @@ export async function uninstallPLugin(
});

const appliedEvent =
await findEvent<PluginSetupProcessorEvents.UninstallationAppliedEvent>(
applyTx,
findEvent<PluginSetupProcessorEvents.UninstallationAppliedEvent>(
await applyTx.wait(),
psp.interface.getEvent('UninstallationApplied').name
);

Expand Down Expand Up @@ -167,8 +167,8 @@ export async function updatePlugin(
},
});
const preparedEvent =
await findEvent<PluginSetupProcessorEvents.UpdatePreparedEvent>(
prepareTx,
findEvent<PluginSetupProcessorEvents.UpdatePreparedEvent>(
await prepareTx.wait(),
psp.interface.getEvent('UpdatePrepared').name
);

Expand All @@ -194,11 +194,10 @@ export async function updatePlugin(
)
),
});
const appliedEvent =
await findEvent<PluginSetupProcessorEvents.UpdateAppliedEvent>(
applyTx,
psp.interface.getEvent('UpdateApplied').name
);
const appliedEvent = findEvent<PluginSetupProcessorEvents.UpdateAppliedEvent>(
await applyTx.wait(),
psp.interface.getEvent('UpdateApplied').name
);

return {prepareTx, applyTx, preparedEvent, appliedEvent};
}
Expand Down Expand Up @@ -364,8 +363,8 @@ export async function createDaoProxy(
]
);
const tx = await daoProxyFactory.deployUUPSProxy(daoInitData);
const event = await findEvent<ProxyCreatedEvent>(
tx,
const event = findEvent<ProxyCreatedEvent>(
await tx.wait(),
daoProxyFactory.interface.getEvent('ProxyCreated').name
);
const dao = DAO__factory.connect(event.args.proxy, deployer);
Expand Down
21 changes: 7 additions & 14 deletions packages/contracts/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import {
getLatestNetworkDeployment,
getNetworkNameByAlias,
} from '@aragon/osx-commons-configs';
import {
UnsupportedNetworkError,
VersionTag,
findEvent,
} from '@aragon/osx-commons-sdk';
import {UnsupportedNetworkError, findEvent} from '@aragon/osx-commons-sdk';
import {
DAO,
DAO__factory,
Expand Down Expand Up @@ -192,7 +188,7 @@ export async function getPastVersionCreatedEvents(
}

export type LatestVersion = {
versionTag: VersionTag;
versionTag: PluginRepo.VersionStruct;
pluginSetupContract: string;
releaseMetadata: string;
buildMetadata: string;
Expand All @@ -219,14 +215,11 @@ export async function createVersion(

console.log(`Creating build for release ${releaseNumber} with tx ${tx.hash}`);

await tx.wait();

const versionCreatedEvent =
await findEvent<PluginRepoEvents.VersionCreatedEvent>(
tx,
pluginRepo.interface.events['VersionCreated(uint8,uint16,address,bytes)']
.name
);
const versionCreatedEvent = findEvent<PluginRepoEvents.VersionCreatedEvent>(
await tx.wait(),
pluginRepo.interface.events['VersionCreated(uint8,uint16,address,bytes)']
.name
);

// Check if versionCreatedEvent is not undefined
if (versionCreatedEvent) {
Expand Down
Loading

0 comments on commit cb6eaf6

Please sign in to comment.