Skip to content

Commit

Permalink
chore(contracts): Fix lint issues on contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
alainncls committed Nov 22, 2024
1 parent 6725ef2 commit 03a5cdd
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 30 deletions.
10 changes: 8 additions & 2 deletions contracts/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion contracts/src/AttestationRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
7 changes: 3 additions & 4 deletions contracts/src/PortalRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/examples/portals/EASPortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
4 changes: 1 addition & 3 deletions contracts/src/examples/portals/PausablePortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/stdlib/IndexerModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand All @@ -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];
Expand Down Expand Up @@ -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];
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/stdlib/IndexerModuleV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand All @@ -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];
Expand Down Expand Up @@ -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];
}
Expand Down
2 changes: 0 additions & 2 deletions contracts/test/PortalRegistry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 1 addition & 2 deletions contracts/test/examples/portals/PausablePortal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/mocks/AttestationRegistryMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/mocks/EASRegistryMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
6 changes: 3 additions & 3 deletions contracts/test/mocks/PortalRegistryMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions contracts/test/mocks/PortalRegistryNotAllowlistedMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 03a5cdd

Please sign in to comment.