From 1c503d95f1686d1ee295d030a6dcf25d0b7ae427 Mon Sep 17 00:00:00 2001 From: Cristovao Honorato Date: Tue, 31 Oct 2023 15:31:08 +0100 Subject: [PATCH] Fix lint:sol --- .solhint.json | 29 ++++++++++++------------ .solhintignore | 1 + contracts/core/GuardableModifier.sol | 9 ++++++-- contracts/core/GuardableModule.sol | 7 ++++-- contracts/core/Modifier.sol | 9 ++++---- contracts/core/Module.sol | 6 +++-- contracts/factory/FactoryFriendly.sol | 2 +- contracts/guard/BaseGuard.sol | 7 +++--- contracts/guard/Guardable.sol | 7 +++--- contracts/interfaces/IAvatar.sol | 2 +- contracts/interfaces/IGuard.sol | 2 +- contracts/signature/SignatureChecker.sol | 3 ++- contracts/test/Imports.sol | 6 ----- contracts/test/TestGuard.sol | 9 +++++++- 14 files changed, 58 insertions(+), 41 deletions(-) create mode 100644 .solhintignore delete mode 100644 contracts/test/Imports.sol diff --git a/.solhint.json b/.solhint.json index 1ac53412..f4eeab0e 100644 --- a/.solhint.json +++ b/.solhint.json @@ -1,16 +1,17 @@ { - "extends": "solhint:recommended", - "rules": { - "compiler-version": "off", - "func-visibility": [ - "warn", - { - "ignoreConstructors": true - } - ], - "not-rely-on-time": "off", - "reason-string": "off", - "no-empty-blocks": "off", - "avoid-low-level-calls": "off" - } + "extends": "solhint:recommended", + "rules": { + "compiler-version": "off", + "func-visibility": [ + "warn", + { + "ignoreConstructors": true + } + ], + "not-rely-on-time": "off", + "reason-string": "off", + "no-empty-blocks": "off", + "avoid-low-level-calls": "off", + "no-inline-assembly": "off" + } } diff --git a/.solhintignore b/.solhintignore new file mode 100644 index 00000000..7ec58e1b --- /dev/null +++ b/.solhintignore @@ -0,0 +1 @@ +./contracts/test \ No newline at end of file diff --git a/contracts/core/GuardableModifier.sol b/contracts/core/GuardableModifier.sol index e630a241..984c86b3 100644 --- a/contracts/core/GuardableModifier.sol +++ b/contracts/core/GuardableModifier.sol @@ -1,8 +1,13 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import "../guard/Guardable.sol"; -import "./Modifier.sol"; +import {Enum} from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol"; + +import {Guardable} from "../guard/Guardable.sol"; +import {IAvatar} from "../interfaces/IAvatar.sol"; +import {IGuard} from "../interfaces/IGuard.sol"; +import {Modifier} from "./Modifier.sol"; +import {Module} from "./Module.sol"; abstract contract GuardableModifier is Module, Guardable, Modifier { /// @dev Passes a transaction to be executed by the avatar. diff --git a/contracts/core/GuardableModule.sol b/contracts/core/GuardableModule.sol index b0691548..39a0e0d2 100644 --- a/contracts/core/GuardableModule.sol +++ b/contracts/core/GuardableModule.sol @@ -1,8 +1,11 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import "../guard/Guardable.sol"; -import "./Module.sol"; +import {Enum} from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol"; +import {IGuard} from "../interfaces/IGuard.sol"; +import {Guardable} from "../guard/Guardable.sol"; +import {Module} from "./Module.sol"; +import {IAvatar} from "../interfaces/IAvatar.sol"; /// @title GuardableModule - A contract that can pass messages to a Module Manager contract if enabled by that contract. abstract contract GuardableModule is Module, Guardable { diff --git a/contracts/core/Modifier.sol b/contracts/core/Modifier.sol index 7e56aa3d..d44f0ee2 100644 --- a/contracts/core/Modifier.sol +++ b/contracts/core/Modifier.sol @@ -1,10 +1,11 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import "../interfaces/IAvatar.sol"; -import "../signature/ExecutionTracker.sol"; -import "../signature/SignatureChecker.sol"; -import "./Module.sol"; +import {Enum} from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol"; +import {ExecutionTracker} from "../signature/ExecutionTracker.sol"; +import {IAvatar} from "../interfaces/IAvatar.sol"; +import {Module} from "./Module.sol"; +import {SignatureChecker} from "../signature/SignatureChecker.sol"; /// @title Modifier Interface - A contract that sits between a Module and an Avatar and enforce some additional logic. abstract contract Modifier is diff --git a/contracts/core/Module.sol b/contracts/core/Module.sol index 831c9ef2..8140aef2 100644 --- a/contracts/core/Module.sol +++ b/contracts/core/Module.sol @@ -1,8 +1,10 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import "../factory/FactoryFriendly.sol"; -import "../interfaces/IAvatar.sol"; +import {Enum} from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol"; + +import {FactoryFriendly} from "../factory/FactoryFriendly.sol"; +import {IAvatar} from "../interfaces/IAvatar.sol"; /// @title Module Interface - A contract that can pass messages to a Module Manager contract if enabled by that contract. abstract contract Module is FactoryFriendly { diff --git a/contracts/factory/FactoryFriendly.sol b/contracts/factory/FactoryFriendly.sol index 96e6e43a..e996bfc2 100644 --- a/contracts/factory/FactoryFriendly.sol +++ b/contracts/factory/FactoryFriendly.sol @@ -3,7 +3,7 @@ /// @title Zodiac FactoryFriendly - A contract that allows other contracts to be initializable and pass bytes as arguments to define contract state pragma solidity >=0.7.0 <0.9.0; -import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; abstract contract FactoryFriendly is OwnableUpgradeable { function setUp(bytes memory initializeParams) public virtual; diff --git a/contracts/guard/BaseGuard.sol b/contracts/guard/BaseGuard.sol index d6d691e7..aef3aadb 100644 --- a/contracts/guard/BaseGuard.sol +++ b/contracts/guard/BaseGuard.sol @@ -1,9 +1,10 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import "@gnosis.pm/safe-contracts/contracts/common/Enum.sol"; -import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; -import "../interfaces/IGuard.sol"; +import {Enum} from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol"; +import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; + +import {IGuard} from "../interfaces/IGuard.sol"; abstract contract BaseGuard is IERC165 { function supportsInterface( diff --git a/contracts/guard/Guardable.sol b/contracts/guard/Guardable.sol index 71ed9ea2..fe2ba156 100644 --- a/contracts/guard/Guardable.sol +++ b/contracts/guard/Guardable.sol @@ -1,9 +1,10 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import "@gnosis.pm/safe-contracts/contracts/common/Enum.sol"; -import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; -import "./BaseGuard.sol"; +import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; + +import {BaseGuard} from "../guard/BaseGuard.sol"; +import {IGuard} from "../interfaces/IGuard.sol"; /// @title Guardable - A contract that manages fallback calls made to this contract contract Guardable is OwnableUpgradeable { diff --git a/contracts/interfaces/IAvatar.sol b/contracts/interfaces/IAvatar.sol index 64bf1ec1..099456cd 100644 --- a/contracts/interfaces/IAvatar.sol +++ b/contracts/interfaces/IAvatar.sol @@ -3,7 +3,7 @@ /// @title Zodiac Avatar - A contract that manages modules that can execute transactions via this contract. pragma solidity >=0.7.0 <0.9.0; -import "@gnosis.pm/safe-contracts/contracts/common/Enum.sol"; +import {Enum} from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol"; interface IAvatar { event EnabledModule(address module); diff --git a/contracts/interfaces/IGuard.sol b/contracts/interfaces/IGuard.sol index f0323f37..008a68b4 100644 --- a/contracts/interfaces/IGuard.sol +++ b/contracts/interfaces/IGuard.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import "@gnosis.pm/safe-contracts/contracts/common/Enum.sol"; +import {Enum} from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol"; interface IGuard { function checkTransaction( diff --git a/contracts/signature/SignatureChecker.sol b/contracts/signature/SignatureChecker.sol index fba4ccc5..4a8fc5b3 100644 --- a/contracts/signature/SignatureChecker.sol +++ b/contracts/signature/SignatureChecker.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.8.0 <0.9.0; -import "./IERC1271.sol"; +import {IERC1271} from "./IERC1271.sol"; /// @title SignatureChecker - A contract that retrieves and validates signatures appended to transaction calldata. /// @dev currently supports eip-712 and eip-1271 signatures @@ -116,6 +116,7 @@ abstract contract SignatureChecker { bytes calldata signature ) internal view returns (bool result) { uint256 size; + // eslint-disable-line no-inline-assembly assembly { size := extcodesize(signer) } diff --git a/contracts/test/Imports.sol b/contracts/test/Imports.sol deleted file mode 100644 index ddd872f3..00000000 --- a/contracts/test/Imports.sol +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-only -pragma solidity >=0.6.0 <0.7.0; - -// We import the contract so truffle compiles it, and we have the ABI -// available when working from truffle console. -import "@gnosis.pm/mock-contract/contracts/MockContract.sol"; diff --git a/contracts/test/TestGuard.sol b/contracts/test/TestGuard.sol index cc967626..c0fc46e4 100644 --- a/contracts/test/TestGuard.sol +++ b/contracts/test/TestGuard.sol @@ -1,7 +1,14 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; -import "../core/GuardableModule.sol"; +import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; + +import {BaseGuard} from "../guard/BaseGuard.sol"; +import {Enum} from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol"; +import {FactoryFriendly} from "../factory/FactoryFriendly.sol"; +import {GuardableModule} from "../core/GuardableModule.sol"; + +/* solhint-disable */ contract TestGuard is FactoryFriendly, BaseGuard { event PreChecked(address sender);