Skip to content

Commit

Permalink
refactor: removed protocol version constants and use package.json ver…
Browse files Browse the repository at this point in the history
…sion
  • Loading branch information
heueristik committed Jan 4, 2024
1 parent ab48d9f commit bb605b2
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 66 deletions.
10 changes: 4 additions & 6 deletions packages/contracts/test/core/dao/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from '../../test-utils/dao';
import {ZERO_BYTES32, daoExampleURI} from '../../test-utils/dao';
import {
CURRENT_PROTOCOL_VERSION,
osxContractsVersion,
IMPLICIT_INITIAL_PROTOCOL_VERSION,
} from '../../test-utils/protocol-version';
import {deployWithProxy} from '../../test-utils/proxy';
Expand Down Expand Up @@ -359,7 +359,7 @@ describe('DAO', function () {
expect(fromProtocolVersion).to.deep.equal(
IMPLICIT_INITIAL_PROTOCOL_VERSION
);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});

it('from v1.3.0', async () => {
Expand All @@ -386,7 +386,7 @@ describe('DAO', function () {

expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 3, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});
});

Expand Down Expand Up @@ -436,9 +436,7 @@ describe('DAO', function () {

describe('Protocol version', async () => {
it('returns the current protocol version', async () => {
expect(await dao.protocolVersion()).to.deep.equal(
CURRENT_PROTOCOL_VERSION
);
expect(await dao.protocolVersion()).to.deep.equal(osxContractsVersion());
});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/test/framework/dao/dao-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {InstallationPreparedEvent} from '../../../typechain/PluginSetupProcessor
import {daoExampleURI, deployNewDAO} from '../../test-utils/dao';
import {deployENSSubdomainRegistrar} from '../../test-utils/ens';
import {deployPluginSetupProcessor} from '../../test-utils/plugin-setup-processor';
import {CURRENT_PROTOCOL_VERSION} from '../../test-utils/protocol-version';
import {osxContractsVersion} from '../../test-utils/protocol-version';
import {deployWithProxy} from '../../test-utils/proxy';
import {
createApplyInstallationParams,
Expand Down Expand Up @@ -281,7 +281,7 @@ describe('DAOFactory: ', function () {
context('Protocol version', async () => {
it('returns the current protocol version', async () => {
expect(await daoFactory.protocolVersion()).to.deep.equal(
CURRENT_PROTOCOL_VERSION
osxContractsVersion()
);
});
});
Expand Down
11 changes: 4 additions & 7 deletions packages/contracts/test/framework/dao/dao-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import {DAORegistry__factory as DAORegistry_V1_3_0__factory} from '../../../type
import {ensDomainHash, ensLabelHash} from '../../../utils/ens';
import {deployNewDAO} from '../../test-utils/dao';
import {deployENSSubdomainRegistrar} from '../../test-utils/ens';
import {
CURRENT_PROTOCOL_VERSION,
IMPLICIT_INITIAL_PROTOCOL_VERSION,
} from '../../test-utils/protocol-version';
import {osxContractsVersion} from '../../test-utils/protocol-version';
import {deployWithProxy} from '../../test-utils/proxy';
import {
getProtocolVersion,
Expand Down Expand Up @@ -253,7 +250,7 @@ describe('DAORegistry', function () {
describe('Protocol version', async () => {
it('returns the current protocol version', async () => {
expect(await daoRegistry.protocolVersion()).to.deep.equal(
CURRENT_PROTOCOL_VERSION
osxContractsVersion()
);
});
});
Expand Down Expand Up @@ -311,7 +308,7 @@ describe('DAORegistry', function () {

expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});

it('from v1.3.0', async () => {
Expand Down Expand Up @@ -339,7 +336,7 @@ describe('DAORegistry', function () {

expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../../../typechain';
import {deployNewDAO} from '../../test-utils/dao';
import {deployENSSubdomainRegistrar} from '../../test-utils/ens';
import {CURRENT_PROTOCOL_VERSION} from '../../test-utils/protocol-version';
import {osxContractsVersion} from '../../test-utils/protocol-version';
import {
deployMockPluginSetup,
deployPluginRepoRegistry,
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('PluginRepoFactory: ', function () {
describe('Protocol version', async () => {
it('returns the current protocol version', async () => {
expect(await pluginRepoFactory.protocolVersion()).to.deep.equal(
CURRENT_PROTOCOL_VERSION
osxContractsVersion()
);
});
});
Expand Down
11 changes: 4 additions & 7 deletions packages/contracts/test/framework/plugin/plugin-repo-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {PluginRepoRegistry__factory as PluginRepoRegistry_V1_3_0__factory} from
import {ensDomainHash} from '../../../utils/ens';
import {deployNewDAO} from '../../test-utils/dao';
import {deployENSSubdomainRegistrar} from '../../test-utils/ens';
import {
CURRENT_PROTOCOL_VERSION,
IMPLICIT_INITIAL_PROTOCOL_VERSION,
} from '../../test-utils/protocol-version';
import {osxContractsVersion} from '../../test-utils/protocol-version';
import {deployWithProxy} from '../../test-utils/proxy';
import {deployNewPluginRepo} from '../../test-utils/repo';
import {
Expand Down Expand Up @@ -257,7 +254,7 @@ describe('PluginRepoRegistry', function () {
describe('Protocol version', async () => {
it('returns the current protocol version', async () => {
expect(await pluginRepoRegistry.protocolVersion()).to.deep.equal(
CURRENT_PROTOCOL_VERSION
osxContractsVersion()
);
});
});
Expand Down Expand Up @@ -317,7 +314,7 @@ describe('PluginRepoRegistry', function () {

expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});

it('from v1.3.0', async () => {
Expand Down Expand Up @@ -347,7 +344,7 @@ describe('PluginRepoRegistry', function () {

expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});
});
});
11 changes: 4 additions & 7 deletions packages/contracts/test/framework/plugin/plugin-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import {
import {PluginRepo__factory as PluginRepo_V1_0_0__factory} from '../../../typechain/@aragon/osx-v1.0.1/framework/plugin/repo/PluginRepo.sol';
import {PluginRepo__factory as PluginRepo_V1_3_0__factory} from '../../../typechain/@aragon/osx-v1.3.0/framework/plugin/repo/PluginRepo.sol';
import {ZERO_BYTES32} from '../../test-utils/dao';
import {
CURRENT_PROTOCOL_VERSION,
IMPLICIT_INITIAL_PROTOCOL_VERSION,
} from '../../test-utils/protocol-version';
import {osxContractsVersion} from '../../test-utils/protocol-version';
import {tagHash} from '../../test-utils/psp/hash-helpers';
import {
deployMockPluginSetup,
Expand Down Expand Up @@ -125,7 +122,7 @@ describe('PluginRepo', function () {

expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});

it('from v1.3.0', async () => {
Expand All @@ -152,7 +149,7 @@ describe('PluginRepo', function () {

expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 3, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});
});

Expand Down Expand Up @@ -184,7 +181,7 @@ describe('PluginRepo', function () {
describe('Protocol version', async () => {
it('returns the current protocol version', async () => {
expect(await pluginRepo.protocolVersion()).to.deep.equal(
CURRENT_PROTOCOL_VERSION
osxContractsVersion()
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {PluginRepoRegisteredEvent} from '../../../typechain/PluginRepoRegistry';
import {deployNewDAO, ZERO_BYTES32} from '../../test-utils/dao';
import {deployENSSubdomainRegistrar} from '../../test-utils/ens';
import {deployPluginSetupProcessor} from '../../test-utils/plugin-setup-processor';
import {CURRENT_PROTOCOL_VERSION} from '../../test-utils/protocol-version';
import {osxContractsVersion} from '../../test-utils/protocol-version';
import {
installPlugin,
updatePlugin,
Expand Down Expand Up @@ -315,9 +315,7 @@ describe('PluginSetupProcessor', function () {

describe('Protocol version', async () => {
it('returns the current protocol version', async () => {
expect(await psp.protocolVersion()).to.deep.equal(
CURRENT_PROTOCOL_VERSION
);
expect(await psp.protocolVersion()).to.deep.equal(osxContractsVersion());
});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/test/framework/plugin/plugin-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
PluginCloneableSetupV1Mock,
PluginCloneableSetupV1Mock__factory,
} from '../../../typechain';
import {CURRENT_PROTOCOL_VERSION} from '../../test-utils/protocol-version';
import {osxContractsVersion} from '../../test-utils/protocol-version';
import {getInterfaceId} from '@aragon/osx-commons-sdk';
import {expect} from 'chai';
import {ethers} from 'hardhat';
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('PluginSetup', function () {
describe('Protocol version', async () => {
it('returns the current protocol version', async () => {
expect(await setupMock.protocolVersion()).to.deep.equal(
CURRENT_PROTOCOL_VERSION
osxContractsVersion()
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {ENSSubdomainRegistrar__factory as ENSSubdomainRegistrar_V1_3_0__factory}
import {ensDomainHash, ensLabelHash} from '../../../../utils/ens';
import {deployNewDAO} from '../../../test-utils/dao';
import {setupResolver} from '../../../test-utils/ens';
import {CURRENT_PROTOCOL_VERSION} from '../../../test-utils/protocol-version';
import {osxContractsVersion} from '../../../test-utils/protocol-version';
import {deployWithProxy} from '../../../test-utils/proxy';
import {
getProtocolVersion,
Expand Down Expand Up @@ -338,7 +338,7 @@ describe('ENSSubdomainRegistrar', function () {

expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});

it('from v1.3.0', async () => {
Expand Down Expand Up @@ -368,7 +368,7 @@ describe('ENSSubdomainRegistrar', function () {

expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ import {
} from '../../../../../typechain/AddresslistVoting';
import {ExecutedEvent} from '../../../../../typechain/DAO';
import {deployNewDAO} from '../../../../test-utils/dao';
import {
CURRENT_PROTOCOL_VERSION,
IMPLICIT_INITIAL_PROTOCOL_VERSION,
} from '../../../../test-utils/protocol-version';
import {osxContractsVersion} from '../../../../test-utils/protocol-version';
import {deployWithProxy} from '../../../../test-utils/proxy';
import {
getProtocolVersion,
Expand Down Expand Up @@ -180,7 +177,7 @@ describe('AddresslistVoting', function () {
);
expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});

it('from v1.3.0', async () => {
Expand Down Expand Up @@ -208,7 +205,7 @@ describe('AddresslistVoting', function () {
);
expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ import {
ProposalExecutedEvent,
} from '../../../../../typechain/TokenVoting';
import {deployNewDAO} from '../../../../test-utils/dao';
import {
CURRENT_PROTOCOL_VERSION,
IMPLICIT_INITIAL_PROTOCOL_VERSION,
} from '../../../../test-utils/protocol-version';
import {osxContractsVersion} from '../../../../test-utils/protocol-version';
import {deployWithProxy} from '../../../../test-utils/proxy';
import {
getProtocolVersion,
Expand Down Expand Up @@ -249,7 +246,7 @@ describe('TokenVoting', function () {
);
expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});

it('from v1.3.0', async () => {
Expand Down Expand Up @@ -277,7 +274,7 @@ describe('TokenVoting', function () {
);
expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});
});

Expand Down
15 changes: 8 additions & 7 deletions packages/contracts/test/plugins/governance/multisig/multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ import {
ProposalExecutedEvent,
} from '../../../../typechain/Multisig';
import {deployNewDAO} from '../../../test-utils/dao';
import {
CURRENT_PROTOCOL_VERSION,
IMPLICIT_INITIAL_PROTOCOL_VERSION,
} from '../../../test-utils/protocol-version';
import {osxContractsVersion} from '../../../test-utils/protocol-version';
import {deployWithProxy} from '../../../test-utils/proxy';
import {
getProtocolVersion,
deployAndUpgradeFromToCheck,
deployAndUpgradeSelfCheck,
} from '../../../test-utils/uups-upgradeable';
import {MULTISIG_EVENTS, MULTISIG_INTERFACE} from './multisig-constants';
import {
MULTISIG_EVENTS,
MULTISIG_INTERFACE,
MultisigSettings,
} from './multisig-constants';
import {
getInterfaceId,
proposalIdToBytes32,
Expand Down Expand Up @@ -242,7 +243,7 @@ describe('Multisig', function () {

expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});

it('from v1.3.0', async () => {
Expand Down Expand Up @@ -270,7 +271,7 @@ describe('Multisig', function () {

expect(fromProtocolVersion).to.not.deep.equal(toProtocolVersion);
expect(fromProtocolVersion).to.deep.equal([1, 0, 0]);
expect(toProtocolVersion).to.deep.equal(CURRENT_PROTOCOL_VERSION);
expect(toProtocolVersion).to.deep.equal(osxContractsVersion());
});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/test/protocol-version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ProtocolVersionMock__factory} from '../typechain';
import {osxCommonsContractsNPMVersion} from './test-utils/protocol-version';
import {osxContractsVersion} from './test-utils/protocol-version';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
import {expect} from 'chai';
import {ethers} from 'hardhat';
Expand All @@ -15,7 +15,7 @@ describe('ProtocolVersion', function () {
signers[0]
).deploy();
expect(await versionedContract.protocolVersion()).to.deep.equal(
osxCommonsContractsNPMVersion()
osxContractsVersion()
);
});
});
7 changes: 2 additions & 5 deletions packages/contracts/test/test-utils/protocol-version.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import {version} from '../../package.json';

// The current protocol version number as specified by the `getProtocolVersion()` function in `ProtocolVersion.sol`.
export const CURRENT_PROTOCOL_VERSION: [number, number, number] = [1, 4, 0];

// The protocol version number of contracts not having a `getProtocolVersion()` function because they don't inherit from `ProtocolVersion.sol` yet.
export const IMPLICIT_INITIAL_PROTOCOL_VERSION: [number, number, number] = [
1, 0, 0,
];

/**
* Returns the NPM version number from the `osx-commons-contracts` package.json file
* Returns the NPM version number from the `osx` package.json file
*/
export function osxCommonsContractsNPMVersion(): [number, number, number] {
export function osxContractsVersion(): [number, number, number] {
const trimmedVersion = version.split('-')[0];
const semver = trimmedVersion.split('.');
return [Number(semver[0]), Number(semver[1]), Number(semver[2])];
Expand Down

0 comments on commit bb605b2

Please sign in to comment.