diff --git a/.solhint.json b/.solhint.json index 2a02af4f..344cd45d 100644 --- a/.solhint.json +++ b/.solhint.json @@ -2,7 +2,7 @@ "extends": "solhint:recommended", "plugins": ["prettier"], "rules": { - "code-complexity": ["error", 8], + "code-complexity": ["error", 10], "compiler-version": ["error", ">=0.8.4"], "func-visibility": ["error", {"ignoreConstructors": true}], "max-line-length": ["error", 120], diff --git a/packages/contracts/src/TokenVoting.sol b/packages/contracts/src/TokenVoting.sol index 02267ccd..8b572335 100644 --- a/packages/contracts/src/TokenVoting.sol +++ b/packages/contracts/src/TokenVoting.sol @@ -20,7 +20,8 @@ import {MajorityVotingBase} from "./MajorityVotingBase.sol"; /// @notice The majority voting implementation using an /// [OpenZeppelin `Votes`](https://docs.openzeppelin.com/contracts/4.x/api/governance#Votes) /// compatible governance token. -/// @dev v1.3 (Release 1, Build 3). For each upgrade, if the reinitialization step is required, increment the version numbers in the modifier for both the initialize and initializeFrom functions. +/// @dev v1.3 (Release 1, Build 3). For each upgrade, if the reinitialization step is required, +/// increment the version numbers in the modifier for both the initialize and initializeFrom functions. /// @custom:security-contact sirt@aragon.org contract TokenVoting is IMembership, MajorityVotingBase { using SafeCastUpgradeable for uint256; @@ -62,10 +63,14 @@ contract TokenVoting is IMembership, MajorityVotingBase { emit MembershipContractAnnounced({definingContract: address(_token)}); } - /// @notice Reinitializes the TokenVoting after an upgrade from a previous protocol version.For each reinitialization step, use the `_fromBuild` version to decide which internal functions to call for reinitialization. - /// @dev WARNING: The contract should only be upgradeable through PSP to ensure that _fromBuild is not incorrectly passed, and that the appropriate permissions for the upgrade are properly configured. - /// @param _fromBuild The build version number of the previous implementation contract this upgrade is transitioning from. - /// @param _initData The initialization data to be passed to via `upgradeToAndCall` (see [ERC-1967](https://docs.openzeppelin.com/contracts/4.x/api/proxy#ERC1967Upgrade)). + /// @notice Reinitializes the TokenVoting after an upgrade from a previous protocol version. For each + /// reinitialization step, use the `_fromBuild` version to decide which internal functions to + /// call for reinitialization. + /// @dev WARNING: The contract should only be upgradeable through PSP to ensure that _fromBuild is not + /// incorrectly passed, and that the appropriate permissions for the upgrade are properly configured. + /// @param _fromBuild Build version number of previous implementation contract this upgrade is transitioning from. + /// @param _initData The initialization data to be passed to via `upgradeToAndCall` + /// (see [ERC-1967](https://docs.openzeppelin.com/contracts/4.x/api/proxy#ERC1967Upgrade)). function initializeFrom(uint16 _fromBuild, bytes calldata _initData) external reinitializer(2) { if (_fromBuild < 3) { ( diff --git a/packages/contracts/src/mocks/CustomExecutorMock.sol b/packages/contracts/src/mocks/CustomExecutorMock.sol index e59fa539..31986842 100644 --- a/packages/contracts/src/mocks/CustomExecutorMock.sol +++ b/packages/contracts/src/mocks/CustomExecutorMock.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.8; -import {IExecutor, Action} from "@aragon/osx-commons-contracts/src/executors/IExecutor.sol"; +import {Action} from "@aragon/osx-commons-contracts/src/executors/IExecutor.sol"; /// @dev DO NOT USE IN PRODUCTION! contract CustomExecutorMock { diff --git a/packages/contracts/test/10_unit-testing/11_plugin.ts b/packages/contracts/test/10_unit-testing/11_plugin.ts index 74effc8e..624e6f5c 100644 --- a/packages/contracts/test/10_unit-testing/11_plugin.ts +++ b/packages/contracts/test/10_unit-testing/11_plugin.ts @@ -53,7 +53,6 @@ import { import { findEvent, findEventTopicLog, - proposalIdToBytes32, TIME, getInterfaceId, pctToRatio, @@ -64,7 +63,6 @@ import { DAO, DAOStructs, DAO__factory, - MajorityVotingBase__factory, } from '@aragon/osx-ethers'; import {loadFixture, time} from '@nomicfoundation/hardhat-network-helpers'; import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers'; @@ -1878,7 +1876,6 @@ describe('TokenVoting', function () { judy, mallory, initializedPlugin, - uninitializedPlugin, token, dao, dummyActions, @@ -2282,7 +2279,6 @@ describe('TokenVoting', function () { judy, mallory, initializedPlugin, - uninitializedPlugin, token, dao, dummyActions, @@ -2551,7 +2547,7 @@ describe('TokenVoting', function () { }); it('executes target with delegate call', async () => { - let { + const { alice, bob, carol, @@ -2574,7 +2570,7 @@ describe('TokenVoting', function () { const abiA = CustomExecutorMock__factory.abi; const abiB = TokenVoting__factory.abi; - // @ts-ignore + // @ts-expect-error correct abi type const mergedABI = abiA.concat(abiB); await dao.grant( @@ -2588,7 +2584,6 @@ describe('TokenVoting', function () { operation: Operation.delegatecall, }); - // @ts-ignore const pluginMerged = (await ethers.getContractAt( mergedABI, plugin.address @@ -2760,7 +2755,6 @@ describe('TokenVoting', function () { dave, eve, frank, - grace, dao, initializedPlugin: plugin, dummyMetadata, diff --git a/packages/contracts/test/10_unit-testing/12_plugin-setup.ts b/packages/contracts/test/10_unit-testing/12_plugin-setup.ts index 2fb8c3a0..833e28cb 100644 --- a/packages/contracts/test/10_unit-testing/12_plugin-setup.ts +++ b/packages/contracts/test/10_unit-testing/12_plugin-setup.ts @@ -10,7 +10,6 @@ import { IERC20Upgradeable__factory, IVotesUpgradeable__factory, } from '../../typechain'; -import {plugins} from '../../typechain/@aragon/osx-v1.0.0'; import {IGovernanceWrappedERC20__factory} from '../../typechain/factories/src/ERC20/governance'; import {MajorityVotingBase} from '../../typechain/src/MajorityVotingBase'; import { @@ -209,7 +208,7 @@ describe('TokenVotingSetup', function () { describe('prepareInstallation', async () => { it('fails if data is empty, or not of minimum length', async () => { - const {pluginSetup, dao, prepareInstallationInputs, defaultMetadata} = + const {pluginSetup, dao, prepareInstallationInputs} = await loadFixture(fixture); // Try calling `prepareInstallation` without input data. diff --git a/packages/contracts/test/30_regression-testing/31_upgradeability.ts b/packages/contracts/test/30_regression-testing/31_upgradeability.ts index df3a2b99..8e41aa8a 100644 --- a/packages/contracts/test/30_regression-testing/31_upgradeability.ts +++ b/packages/contracts/test/30_regression-testing/31_upgradeability.ts @@ -1,5 +1,5 @@ import {createDaoProxy} from '../20_integration-testing/test-helpers'; -import {TestGovernanceERC20, TokenVoting} from '../../typechain'; +import {TestGovernanceERC20} from '../../typechain'; import {MajorityVotingBase} from '../../typechain/src'; import { INITIALIZE_SIGNATURE, @@ -91,7 +91,7 @@ describe('Upgrades', () => { // Ensure that on the `upgrade`, `initialize` can not be called. try { await deployAndUpgradeFromToCheck( - // @ts-ignore + // @ts-expect-error correct data type ...data ); throw new Error(''); @@ -100,12 +100,12 @@ describe('Upgrades', () => { } data[8] = 'initializeFrom'; - // @ts-ignore + // @ts-expect-error types castings will work data[9] = [latestInitializerVersion, encodedParamsForUpgrade]; const {proxy, fromImplementation, toImplementation} = await deployAndUpgradeFromToCheck( - // @ts-ignore + // @ts-expect-error correct data type ...data ); @@ -186,7 +186,8 @@ describe('Upgrades', () => { // Ensure that on the `upgrade`, `initialize` can not be called. try { await deployAndUpgradeFromToCheck( - // @ts-ignore + // @ts-expect-error correct data type + ...data ); throw new Error(''); @@ -194,12 +195,12 @@ describe('Upgrades', () => { expect(err.data).to.equal(AlreadyInitializedSignature); } data[8] = 'initializeFrom'; - // @ts-ignore + // @ts-expect-error types castings will work data[9] = [latestInitializerVersion, encodedParamsForUpgrade]; const {proxy, fromImplementation, toImplementation} = await deployAndUpgradeFromToCheck( - // @ts-ignore + // @ts-expect-error correct data type ...data );