diff --git a/contracts/.solhint.json b/contracts/.solhint.json index 108f3996..59577431 100644 --- a/contracts/.solhint.json +++ b/contracts/.solhint.json @@ -7,11 +7,17 @@ "contract-name-camelcase": "off", "const-name-snakecase": "off", "func-name-mixedcase": "off", - "func-visibility": ["error", { "ignoreConstructors": true }], + "func-visibility": [ + "error", + { + "ignoreConstructors": true + } + ], "max-line-length": ["error", 123], "named-parameters-mapping": "warn", "no-empty-blocks": "off", "not-rely-on-time": "off", - "var-name-mixedcase": "off" + "var-name-mixedcase": "off", + "gas-calldata-parameters": "warn" } } diff --git a/contracts/package.json b/contracts/package.json index fa2b9b64..24055f4e 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -55,7 +55,7 @@ "dotenv": "^16.4.5", "ethers": "^6.12.0", "hardhat": "^2.22.3", - "solhint": "^4.5.4", + "solhint": "^5.0.3", "solhint-plugin-prettier": "^0.1.0" } } diff --git a/contracts/src/AttestationRegistry.sol b/contracts/src/AttestationRegistry.sol index 8d49f6b4..89de57b5 100644 --- a/contracts/src/AttestationRegistry.sol +++ b/contracts/src/AttestationRegistry.sol @@ -221,7 +221,7 @@ contract AttestationRegistry is OwnableUpgradeable { * @notice Bulk revokes a list of attestations for the given identifiers * @param attestationIds the IDs of the attestations to revoke */ - function bulkRevoke(bytes32[] memory attestationIds) external { + function bulkRevoke(bytes32[] calldata attestationIds) external { for (uint256 i = 0; i < attestationIds.length; i = uncheckedInc256(i)) { revoke(attestationIds[i]); } diff --git a/contracts/src/PortalRegistry.sol b/contracts/src/PortalRegistry.sol index c8da6fea..0e771981 100644 --- a/contracts/src/PortalRegistry.sol +++ b/contracts/src/PortalRegistry.sol @@ -9,7 +9,6 @@ import { DefaultPortal } from "./DefaultPortal.sol"; import { Portal } from "./types/Structs.sol"; import { IRouter } from "./interfaces/IRouter.sol"; import { IPortal } from "./interfaces/IPortal.sol"; -import { uncheckedInc256 } from "./Common.sol"; /** * @title Portal Registry @@ -198,10 +197,10 @@ contract PortalRegistry is OwnableUpgradeable { */ function deployDefaultPortal( address[] calldata modules, - string memory name, - string memory description, + string calldata name, + string calldata description, bool isRevocable, - string memory ownerName + string calldata ownerName ) external onlyAllowlisted(msg.sender) { DefaultPortal defaultPortal = new DefaultPortal(modules, address(router)); register(address(defaultPortal), name, description, isRevocable, ownerName); diff --git a/contracts/src/examples/portals/EASPortal.sol b/contracts/src/examples/portals/EASPortal.sol index a7b24139..b36271b6 100644 --- a/contracts/src/examples/portals/EASPortal.sol +++ b/contracts/src/examples/portals/EASPortal.sol @@ -91,7 +91,7 @@ contract EASPortal is AbstractPortal { * as this ID won't be incremented before the end of the transaction. * If you need to check the attestation ID, please use the `replace` method. */ - function bulkAttest(AttestationRequest[] memory attestationsRequests) external payable { + function bulkAttest(AttestationRequest[] calldata attestationsRequests) external payable { for (uint256 i = 0; i < attestationsRequests.length; i = uncheckedInc256(i)) { attest(attestationsRequests[i]); } diff --git a/contracts/src/examples/portals/PausablePortal.sol b/contracts/src/examples/portals/PausablePortal.sol index 2940c286..9b01e6fb 100644 --- a/contracts/src/examples/portals/PausablePortal.sol +++ b/contracts/src/examples/portals/PausablePortal.sol @@ -3,10 +3,8 @@ pragma solidity 0.8.21; import { Pausable } from "@openzeppelin/contracts/security/Pausable.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; -import { IERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import { AbstractPortal } from "../../abstracts/AbstractPortal.sol"; -import { Attestation, AttestationPayload } from "../../types/Structs.sol"; -import { IPortal } from "../../interfaces/IPortal.sol"; +import { AttestationPayload } from "../../types/Structs.sol"; /** * @title Pausable Portal diff --git a/contracts/src/stdlib/IndexerModule.sol b/contracts/src/stdlib/IndexerModule.sol index 7c7f6c3a..a30b6f5c 100644 --- a/contracts/src/stdlib/IndexerModule.sol +++ b/contracts/src/stdlib/IndexerModule.sol @@ -77,7 +77,7 @@ contract IndexerModule is AbstractModule { * @param subject The subject to retrieve attestation IDs for. * @return An array of attestation IDs. */ - function getAttestationIdsBySubject(bytes memory subject) external view returns (bytes32[] memory) { + function getAttestationIdsBySubject(bytes calldata subject) external view returns (bytes32[] memory) { return attestationIdsBySubject[subject]; } @@ -88,7 +88,7 @@ contract IndexerModule is AbstractModule { * @return An array of attestation IDs. */ function getAttestationIdsBySubjectBySchema( - bytes memory subject, + bytes calldata subject, bytes32 schemaId ) external view returns (bytes32[] memory) { return attestationIdsBySubjectBySchema[subject][schemaId]; @@ -129,7 +129,7 @@ contract IndexerModule is AbstractModule { */ function getAttestationIdsByPortalBySubject( address portal, - bytes memory subject + bytes calldata subject ) external view returns (bytes32[] memory) { return attestationIdsByPortalBySubject[portal][subject]; } diff --git a/contracts/src/stdlib/IndexerModuleV2.sol b/contracts/src/stdlib/IndexerModuleV2.sol index 360d65cd..51f640ed 100644 --- a/contracts/src/stdlib/IndexerModuleV2.sol +++ b/contracts/src/stdlib/IndexerModuleV2.sol @@ -94,7 +94,7 @@ contract IndexerModuleV2 is AbstractModuleV2 { * @param subject The subject to retrieve attestation IDs for. * @return An array of attestation IDs. */ - function getAttestationIdsBySubject(bytes memory subject) external view returns (bytes32[] memory) { + function getAttestationIdsBySubject(bytes calldata subject) external view returns (bytes32[] memory) { return attestationIdsBySubject[subject]; } @@ -105,7 +105,7 @@ contract IndexerModuleV2 is AbstractModuleV2 { * @return An array of attestation IDs. */ function getAttestationIdsBySubjectBySchema( - bytes memory subject, + bytes calldata subject, bytes32 schemaId ) external view returns (bytes32[] memory) { return attestationIdsBySubjectBySchema[subject][schemaId]; @@ -146,7 +146,7 @@ contract IndexerModuleV2 is AbstractModuleV2 { */ function getAttestationIdsByPortalBySubject( address portal, - bytes memory subject + bytes calldata subject ) external view returns (bytes32[] memory) { return attestationIdsByPortalBySubject[portal][subject]; } diff --git a/contracts/test/PortalRegistry.t.sol b/contracts/test/PortalRegistry.t.sol index 029e7b4f..6d039f8b 100644 --- a/contracts/test/PortalRegistry.t.sol +++ b/contracts/test/PortalRegistry.t.sol @@ -12,8 +12,6 @@ import { ModuleRegistryMock } from "./mocks/ModuleRegistryMock.sol"; import { ValidPortalMock } from "./mocks/ValidPortalMock.sol"; import { InvalidPortalMock } from "./mocks/InvalidPortalMock.sol"; import { IPortalImplementation } from "./mocks/IPortalImplementation.sol"; -import "../src/PortalRegistry.sol"; -import "../src/PortalRegistry.sol"; contract PortalRegistryTest is Test { address public user = makeAddr("user"); diff --git a/contracts/test/examples/portals/PausablePortal.t.sol b/contracts/test/examples/portals/PausablePortal.t.sol index 0493a328..e0dc3475 100644 --- a/contracts/test/examples/portals/PausablePortal.t.sol +++ b/contracts/test/examples/portals/PausablePortal.t.sol @@ -9,11 +9,10 @@ import { AttestationPayload } from "../../../src/types/Structs.sol"; import { AttestationRegistryMock } from "../../mocks/AttestationRegistryMock.sol"; import { PortalRegistryMock } from "../../mocks/PortalRegistryMock.sol"; import { ModuleRegistryMock } from "../../mocks/ModuleRegistryMock.sol"; -import { Pausable } from "@openzeppelin/contracts/security/Pausable.sol"; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; contract PausablePortalTest is Test { - address portalOwner = makeAddr("portalOwner"); + address public portalOwner = makeAddr("portalOwner"); PausablePortal public pausablePortal; address[] public modules = new address[](0); ModuleRegistryMock public moduleRegistryMock = new ModuleRegistryMock(); diff --git a/contracts/test/mocks/AttestationRegistryMock.sol b/contracts/test/mocks/AttestationRegistryMock.sol index fbc28757..b07c44f8 100644 --- a/contracts/test/mocks/AttestationRegistryMock.sol +++ b/contracts/test/mocks/AttestationRegistryMock.sol @@ -85,7 +85,7 @@ contract AttestationRegistryMock { return attestations[attestationId]; } - function generateAttestationId(uint256 id) internal view returns (bytes32) { + function generateAttestationId(uint256 id) internal pure returns (bytes32) { // This is a mock implementation, 1000 is considered as chain prefix return bytes32(abi.encode(1000 + id)); } diff --git a/contracts/test/mocks/EASRegistryMock.sol b/contracts/test/mocks/EASRegistryMock.sol index 8653ce22..c8b4f7d8 100644 --- a/contracts/test/mocks/EASRegistryMock.sol +++ b/contracts/test/mocks/EASRegistryMock.sol @@ -13,7 +13,7 @@ contract EASRegistryMock is IEAS { return attestations[uid]; } - function addAttestation(Attestation memory attestation) external { + function addAttestation(Attestation calldata attestation) external { attestations[attestation.uid] = attestation; } } diff --git a/contracts/test/mocks/PortalRegistryMock.sol b/contracts/test/mocks/PortalRegistryMock.sol index 75f86e2d..b115e9c3 100644 --- a/contracts/test/mocks/PortalRegistryMock.sol +++ b/contracts/test/mocks/PortalRegistryMock.sol @@ -14,10 +14,10 @@ contract PortalRegistryMock { function register( address id, - string memory name, - string memory description, + string calldata name, + string calldata description, bool isRevocable, - string memory ownerName + string calldata ownerName ) external { Portal memory newPortal = Portal(id, msg.sender, new address[](0), isRevocable, name, description, ownerName); portals[id] = newPortal; diff --git a/contracts/test/mocks/PortalRegistryNotAllowlistedMock.sol b/contracts/test/mocks/PortalRegistryNotAllowlistedMock.sol index 7d5ad8f1..c6f39545 100644 --- a/contracts/test/mocks/PortalRegistryNotAllowlistedMock.sol +++ b/contracts/test/mocks/PortalRegistryNotAllowlistedMock.sol @@ -14,10 +14,10 @@ contract PortalRegistryNotAllowlistedMock { function register( address id, - string memory name, - string memory description, + string calldata name, + string calldata description, bool isRevocable, - string memory ownerName + string calldata ownerName ) external { Portal memory newPortal = Portal(id, msg.sender, new address[](0), isRevocable, name, description, ownerName); portals[id] = newPortal;