Skip to content

Commit

Permalink
chore: adapt contracts and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
heueristik committed Apr 23, 2024
1 parent 5c9ac9a commit fd78ff1
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 288 deletions.
18 changes: 9 additions & 9 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
"name": "@aragon/osx-commons-contracts",
"license": "AGPL-3.0-or-later",
"description": "The Aragon OSx contracts package containing common utilities",
"version": "1.4.0-alpha.4",
"version": "1.4.0-alpha.5",
"author": {
"name": "aragon",
"url": "https://github.com/aragon"
},
"devDependencies": {
"@aragon/osx-commons-sdk": "0.0.1-alpha.5",
"@aragon/osx-commons-sdk": "0.0.1-alpha.11",
"@aragon/osx-commons-configs": "0.4.0",
"@aragon/osx-ethers-v1.0.0": "npm:@aragon/[email protected]",
"@aragon/osx-ethers-v1.3.0": "npm:@aragon/[email protected]",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/constants": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@ethersproject/abi": "5.7.0",
"@ethersproject/abstract-signer": "5.7.0",
"@ethersproject/bignumber": "5.7.0",
"@ethersproject/bytes": "5.7.0",
"@ethersproject/constants": "5.7.0",
"@ethersproject/providers": "5.7.2",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
"@nomicfoundation/hardhat-network-helpers": "^1.0.10",
"@nomicfoundation/hardhat-toolbox": "^2.0.2",
Expand All @@ -32,7 +32,7 @@
"chai": "^4.3.7",
"cross-env": "^7.0.3",
"dotenv": "^16.3.1",
"ethers": "^5.7.2",
"ethers": "5.7.2",
"hardhat": "^2.13.1",
"hardhat-deploy": "^0.11.26",
"hardhat-gas-reporter": "^1.0.9",
Expand Down
17 changes: 6 additions & 11 deletions contracts/test/plugin/extensions/proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ import {
} from '../../../typechain';
import {ExecutedEvent} from '../../../typechain/src/dao/IDAO';
import {erc165ComplianceTests} from '../../helpers';
import {
IDAO_EVENTS,
IPROPOSAL_EVENTS,
findEventTopicLog,
getInterfaceId,
} from '@aragon/osx-commons-sdk';
import {findEventTopicLog, getInterfaceId} from '@aragon/osx-commons-sdk';
import {IProposal__factory as IProposal_V1_0_0__factory} from '@aragon/osx-ethers-v1.0.0';
import {loadFixture, time} from '@nomicfoundation/hardhat-network-helpers';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
Expand Down Expand Up @@ -117,7 +112,7 @@ function proposalBaseTests(fixture: () => Promise<FixtureResult>) {
exampleData.allowFailureMap
)
)
.to.emit(proposalMock, IPROPOSAL_EVENTS.ProposalCreated)
.to.emit(proposalMock, 'ProposalCreated')
.withArgs(
expectedProposalId,
creator.address,
Expand Down Expand Up @@ -168,7 +163,7 @@ function proposalBaseTests(fixture: () => Promise<FixtureResult>) {
exampleData.allowFailureMap
)
)
.to.emit(proposalMock, IPROPOSAL_EVENTS.ProposalExecuted)
.to.emit(proposalMock, 'ProposalExecuted')
.withArgs(proposalId);
});

Expand All @@ -195,10 +190,10 @@ function proposalBaseTests(fixture: () => Promise<FixtureResult>) {
exampleData.actions,
exampleData.allowFailureMap
);
const event = await findEventTopicLog<ExecutedEvent>(
tx,
const event = findEventTopicLog<ExecutedEvent>(
await tx.wait(),
IDAO__factory.createInterface(),
IDAO_EVENTS.Executed
'Executed'
);

expect(event.args.actor).to.equal(expectedActor);
Expand Down
13 changes: 4 additions & 9 deletions contracts/test/plugin/plugin-clonable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ import {
} from '../../typechain/src/utils/deployment/ProxyFactory';
import {erc165ComplianceTests, getOzInitializedSlotValue} from '../helpers';
import {osxCommonsContractsVersion} from '../utils/versioning/protocol-version';
import {
findEvent,
getInterfaceId,
PluginType,
PROXY_FACTORY_EVENTS,
} from '@aragon/osx-commons-sdk';
import {PluginType, findEvent, getInterfaceId} from '@aragon/osx-commons-sdk';
import {loadFixture} from '@nomicfoundation/hardhat-network-helpers';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
import {expect} from 'chai';
Expand All @@ -32,9 +27,9 @@ describe('PluginCloneable', function () {

// Deploy an uninitialized clone
const tx = await proxyFactory.deployMinimalProxy([]);
const event = await findEvent<ProxyCreatedEvent>(
tx,
PROXY_FACTORY_EVENTS.ProxyCreated
const event = findEvent<ProxyCreatedEvent>(
await tx.wait(),
'ProxyCreated'
);
const clone = Build1Factory.attach(event.args.proxy);

Expand Down
31 changes: 15 additions & 16 deletions contracts/test/plugin/plugin-uups-upgradeable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
getInterfaceId,
PLUGIN_UUPS_UPGRADEABLE_PERMISSIONS,
PluginType,
PROXY_FACTORY_EVENTS,
} from '@aragon/osx-commons-sdk';
import {loadFixture} from '@nomicfoundation/hardhat-network-helpers';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
Expand All @@ -35,9 +34,9 @@ describe('PluginUUPSUpgradeable', function () {

// Deploy an uninitialized proxy
const tx = await proxyFactory.deployUUPSProxy([]);
const event = await findEvent<ProxyCreatedEvent>(
tx,
PROXY_FACTORY_EVENTS.ProxyCreated
const event = findEvent<ProxyCreatedEvent>(
await tx.wait(),
'ProxyCreated'
);
const proxy = Build1Factory.attach(event.args.proxy);

Expand Down Expand Up @@ -145,9 +144,9 @@ describe('PluginUUPSUpgradeable', function () {

// Deploy an uninitialized build 1 proxy
const tx = await proxyFactory.deployUUPSProxy([]);
const event = await findEvent<ProxyCreatedEvent>(
tx,
PROXY_FACTORY_EVENTS.ProxyCreated
const event = findEvent<ProxyCreatedEvent>(
await tx.wait(),
'ProxyCreated'
);
const proxy = Build1Factory.attach(event.args.proxy);

Expand All @@ -166,9 +165,9 @@ describe('PluginUUPSUpgradeable', function () {

// Deploy an initialized build 1 proxy
const tx = await proxyFactory.deployUUPSProxy(initCalldata);
const event = await findEvent<ProxyCreatedEvent>(
tx,
PROXY_FACTORY_EVENTS.ProxyCreated
const event = findEvent<ProxyCreatedEvent>(
await tx.wait(),
'ProxyCreated'
);
const proxy = Build1Factory.attach(event.args.proxy);

Expand Down Expand Up @@ -200,9 +199,9 @@ describe('PluginUUPSUpgradeable', function () {

// Create an initialized build 1 proxy
const tx = await proxyFactory.deployUUPSProxy(initCalldata);
const event = await findEvent<ProxyCreatedEvent>(
tx,
PROXY_FACTORY_EVENTS.ProxyCreated
const event = findEvent<ProxyCreatedEvent>(
await tx.wait(),
'ProxyCreated'
);
const proxy = Build1Factory.attach(event.args.proxy);

Expand Down Expand Up @@ -235,9 +234,9 @@ describe('PluginUUPSUpgradeable', function () {

// Deploy an initialized build 1 proxy
const tx = await proxyFactory.deployUUPSProxy(initCalldata);
const event = await findEvent<ProxyCreatedEvent>(
tx,
PROXY_FACTORY_EVENTS.ProxyCreated
const event = findEvent<ProxyCreatedEvent>(
await tx.wait(),
'ProxyCreated'
);
const proxy = Build1Factory.attach(event.args.proxy);

Expand Down
20 changes: 12 additions & 8 deletions contracts/test/plugin/setup/plugin-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import {IPluginSetup} from '../../../typechain/src/plugin/setup/PluginSetup';
import {erc165ComplianceTests} from '../../helpers';
import {osxCommonsContractsVersion} from '../../utils/versioning/protocol-version';
import {ADDRESS, getInterfaceId} from '@aragon/osx-commons-sdk';
import {getInterfaceId} from '@aragon/osx-commons-sdk';
import {
IPluginSetup__factory as IPluginSetup_V1_0_0__factory,
Plugin__factory,
Expand All @@ -31,15 +31,19 @@ describe('IPluginSetup', function () {
});
});

const ADDRESS_ZERO = `0x${'0'.repeat(40)}`;
const ADDRESS_ONE = `0x${'0'.repeat(39)}1`;
const ADDRESS_TWO = `0x${'0'.repeat(39)}2`;

describe('PluginSetup', async () => {
pluginSetupBaseTests(pluginSetupFixture);

describe('prepareUpdate', async () => {
it('reverts when called', async () => {
const {pluginSetupMock} = await loadFixture(pluginSetupFixture);

const dummyDaoAddr = ADDRESS.ONE;
const dummyPluginAddr = ADDRESS.TWO;
const dummyDaoAddr = ADDRESS_ONE;
const dummyPluginAddr = ADDRESS_TWO;
const dummyFromBuildNumber = 123;
const setupPayload: IPluginSetup.SetupPayloadStruct = {
plugin: dummyPluginAddr,
Expand Down Expand Up @@ -69,8 +73,8 @@ describe('PluginUpgradeableSetup', async () => {
pluginUUPSUpgradeableSetupFixture
);

const dummyDaoAddr = ADDRESS.ONE;
const dummyPluginAddr = ADDRESS.TWO;
const dummyDaoAddr = ADDRESS_ONE;
const dummyPluginAddr = ADDRESS_TWO;
const setupPayload: IPluginSetup.SetupPayloadStruct = {
plugin: dummyPluginAddr,
currentHelpers: [],
Expand All @@ -97,8 +101,8 @@ describe('PluginUpgradeableSetup', async () => {
deployer
).deploy();

const dummyDaoAddr = ADDRESS.ONE;
const dummyPluginAddr = ADDRESS.TWO;
const dummyDaoAddr = ADDRESS_ONE;
const dummyPluginAddr = ADDRESS_TWO;
const dummyFromBuildNumber = 123;
const setupPayload: IPluginSetup.SetupPayloadStruct = {
plugin: dummyPluginAddr,
Expand All @@ -124,7 +128,7 @@ function pluginSetupBaseTests(fixture: () => Promise<FixtureResult>) {
const implementation = await pluginSetupMock.implementation();

// Check that an address is returned
expect(implementation).to.not.equal(ADDRESS.ZERO);
expect(implementation).to.not.equal(ADDRESS_ZERO);

// Check that it supports the `IPlugin` interface
const plugin = Plugin__factory.connect(implementation, deployer);
Expand Down
37 changes: 18 additions & 19 deletions contracts/test/utils/deployment/proxy-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ import {
ProxyFactory__factory,
} from '../../../typechain';
import {ProxyCreatedEvent} from '../../../typechain/src/utils/deployment/ProxyFactory';
import {
ADDRESS,
findEvent,
PROXY_FACTORY_EVENTS,
} from '@aragon/osx-commons-sdk';
import {findEvent} from '@aragon/osx-commons-sdk';
import {loadFixture} from '@nomicfoundation/hardhat-network-helpers';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
import {expect} from 'chai';
import {ethers} from 'hardhat';

const ADDRESS_ZERO = `0x${'0'.repeat(40)}`;
const ADDRESS_LAST = `0x${'f'.repeat(40)}`;

describe('ProxyFactory', function () {
describe('deployUUPSProxy', function () {
it('deploys an initialized proxy if initialization data is provided', async () => {
Expand All @@ -32,9 +31,9 @@ describe('ProxyFactory', function () {
const tx = await proxyFactory.deployUUPSProxy(initCalldata);

// Get the proxy address from the event
const event = await findEvent<ProxyCreatedEvent>(
tx,
PROXY_FACTORY_EVENTS.ProxyCreated
const event = findEvent<ProxyCreatedEvent>(
await tx.wait(),
'ProxyCreated'
);
const proxy = PluginUUPSUpgradeableMockBuild1__factory.connect(
event.args.proxy,
Expand All @@ -61,8 +60,8 @@ describe('ProxyFactory', function () {

// Get the proxy address from the event
const event = await findEvent<ProxyCreatedEvent>(
tx,
PROXY_FACTORY_EVENTS.ProxyCreated
await tx.wait(),
'ProxyCreated'
);
const proxy = PluginUUPSUpgradeableMockBuild1__factory.connect(
event.args.proxy,
Expand All @@ -75,7 +74,7 @@ describe('ProxyFactory', function () {
.to.equal(implementation.address);

// Check that the proxy is not initialized
expect(await proxy.dao()).to.equal(ADDRESS.ZERO);
expect(await proxy.dao()).to.equal(ADDRESS_ZERO);
expect(await proxy.state1()).to.equal(0);
});
});
Expand All @@ -89,9 +88,9 @@ describe('ProxyFactory', function () {
const tx = await proxyFactory.deployMinimalProxy(initCalldata);

// Get the proxy address from the event
const event = await findEvent<ProxyCreatedEvent>(
tx,
PROXY_FACTORY_EVENTS.ProxyCreated
const event = findEvent<ProxyCreatedEvent>(
await tx.wait(),
'ProxyCreated'
);
const proxy = PluginCloneableMockBuild1__factory.connect(
event.args.proxy,
Expand All @@ -111,16 +110,16 @@ describe('ProxyFactory', function () {

// Get the proxy address from the event
const event = await findEvent<ProxyCreatedEvent>(
tx,
PROXY_FACTORY_EVENTS.ProxyCreated
await tx.wait(),
'ProxyCreated'
);
const proxy = PluginCloneableMockBuild1__factory.connect(
event.args.proxy,
deployer
);

// Check that the proxy is not initialized
expect(await proxy.dao()).to.equal(ADDRESS.ZERO);
expect(await proxy.dao()).to.equal(ADDRESS_ZERO);
expect(await proxy.state1()).to.equal(0);
});
});
Expand All @@ -146,7 +145,7 @@ async function uupsProxyFixture(): Promise<FixtureResult> {
);

// Create a mock address with a valid checksum
const daoMockAddr = ethers.utils.getAddress(ADDRESS.LAST);
const daoMockAddr = ethers.utils.getAddress(ADDRESS_LAST);

const initCalldata = implementation.interface.encodeFunctionData(
'initialize',
Expand All @@ -168,7 +167,7 @@ async function minimalProxyFixture(): Promise<FixtureResult> {
);

// Create a mock address with a valid checksum
const daoMockAddr = ethers.utils.getAddress(ADDRESS.LAST);
const daoMockAddr = ethers.utils.getAddress(ADDRESS_LAST);

const initCalldata = implementation.interface.encodeFunctionData(
'initialize',
Expand Down
Loading

0 comments on commit fd78ff1

Please sign in to comment.