Skip to content

Commit

Permalink
build: upgrade solhint + fix solidity linter errors (#237)
Browse files Browse the repository at this point in the history
* build: upgrade solhint version to `3.6.2`

* chore: fix solhint linter errors/warnings + improve code layout
  • Loading branch information
CJ42 authored Oct 5, 2023
1 parent 3426b5f commit 40c492a
Show file tree
Hide file tree
Showing 11 changed files with 569 additions and 1,181 deletions.
2 changes: 2 additions & 0 deletions implementations/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"rules": {
"compiler-version": ["error", "^0.8.0"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"no-unused-import": "error",
"no-global-import": "error",
"reason-string": ["warn", { "maxLength": 120 }],
"no-empty-blocks": ["off"]
}
Expand Down
3 changes: 1 addition & 2 deletions implementations/contracts/ERC725.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.5;

// modules
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {OwnableUnset} from "./custom/OwnableUnset.sol";
import {ERC725XCore} from "./ERC725XCore.sol";
import {ERC725YCore} from "./ERC725YCore.sol";
Expand Down Expand Up @@ -37,7 +36,7 @@ contract ERC725 is ERC725XCore, ERC725YCore {
}

/**
* @inheritdoc ERC165
* @inheritdoc ERC725XCore
*/
function supportsInterface(
bytes4 interfaceId
Expand Down
3 changes: 1 addition & 2 deletions implementations/contracts/ERC725InitAbstract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.5;

// modules
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {
Initializable
} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
Expand Down Expand Up @@ -45,7 +44,7 @@ abstract contract ERC725InitAbstract is
}

/**
* @inheritdoc ERC165
* @inheritdoc ERC725XCore
*/
function supportsInterface(
bytes4 interfaceId
Expand Down
26 changes: 21 additions & 5 deletions implementations/contracts/ERC725XCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ import {
OPERATION_4_DELEGATECALL
} from "./constants.sol";

import "./errors.sol";
import {
ERC725X_InsufficientBalance,
ERC725X_UnknownOperationType,
ERC725X_MsgValueDisallowedInStaticCall,
ERC725X_MsgValueDisallowedInDelegateCall,
ERC725X_CreateOperationsRequireEmptyRecipientAddress,
ERC725X_ContractDeploymentFailed,
ERC725X_NoContractBytecodeProvided,
ERC725X_ExecuteParametersLengthMismatch,
ERC725X_ExecuteParametersEmptyArray
} from "./errors.sol";

/**
* @title Core implementation of ERC725X sub-standard, a generic executor.
Expand Down Expand Up @@ -105,21 +115,25 @@ abstract contract ERC725XCore is OwnableUnset, ERC165, IERC725X {

// Deploy with CREATE
if (operationType == OPERATION_1_CREATE) {
if (target != address(0))
if (target != address(0)) {
revert ERC725X_CreateOperationsRequireEmptyRecipientAddress();
}
return _deployCreate(value, data);
}

// Deploy with CREATE2
if (operationType == OPERATION_2_CREATE2) {
if (target != address(0))
if (target != address(0)) {
revert ERC725X_CreateOperationsRequireEmptyRecipientAddress();
}
return _deployCreate2(value, data);
}

// STATICCALL
if (operationType == OPERATION_3_STATICCALL) {
if (value != 0) revert ERC725X_MsgValueDisallowedInStaticCall();
if (value != 0) {
revert ERC725X_MsgValueDisallowedInStaticCall();
}
return _executeStaticCall(target, data);
}

Expand All @@ -136,7 +150,9 @@ abstract contract ERC725XCore is OwnableUnset, ERC165, IERC725X {
// - run selfdestruct in the context of this contract
//
if (operationType == OPERATION_4_DELEGATECALL) {
if (value != 0) revert ERC725X_MsgValueDisallowedInDelegateCall();
if (value != 0) {
revert ERC725X_MsgValueDisallowedInDelegateCall();
}
return _executeDelegateCall(target, data);
}

Expand Down
1 change: 0 additions & 1 deletion implementations/contracts/ERC725Y.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.4;

// modules
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {OwnableUnset} from "./custom/OwnableUnset.sol";
import {ERC725YCore} from "./ERC725YCore.sol";

Expand Down
6 changes: 5 additions & 1 deletion implementations/contracts/ERC725YCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import {OwnableUnset} from "./custom/OwnableUnset.sol";
// constants
import {_INTERFACEID_ERC725Y} from "./constants.sol";

import "./errors.sol";
import {
ERC725Y_MsgValueDisallowed,
ERC725Y_DataKeysValuesLengthMismatch,
ERC725Y_DataKeysValuesEmptyArray
} from "./errors.sol";

/**
* @title Core implementation of ERC725Y sub-standard, a general data key/value store.
Expand Down
4 changes: 3 additions & 1 deletion implementations/contracts/helpers/ConstantsChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import {IERC725X} from "../interfaces/IERC725X.sol";
import {IERC725Y} from "../interfaces/IERC725Y.sol";

// constants
import "../constants.sol";
import {_INTERFACEID_ERC725X, _INTERFACEID_ERC725Y} from "../constants.sol";

/**
* @dev Contract used to calculate constants
*/
contract ConstantsChecker {
function getERC725XInterfaceID() public pure returns (bytes4) {
// solhint-disable-next-line custom-errors
require(
_INTERFACEID_ERC725X == type(IERC725X).interfaceId,
"hardcoded _INTERFACEID_ERC725X in `constants.sol` does not match `type(IERC725X).interfaceId`"
Expand All @@ -21,6 +22,7 @@ contract ConstantsChecker {
}

function getERC725YInterfaceID() public pure returns (bytes4) {
// solhint-disable-next-line custom-errors
require(
_INTERFACEID_ERC725Y == type(IERC725Y).interfaceId,
"hardcoded _INTERFACEID_ERC725Y in `constants.sol` does not match `type(IERC725Y).interfaceId`"
Expand Down
2 changes: 2 additions & 0 deletions implementations/contracts/helpers/CustomRevertTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ contract RevertTester {
}

function revertMeWithStringView() public pure {
// solhint-disable-next-line custom-errors
revert("I reverted");
}

function revertMeWithStringErrorNotView() public pure {
// solhint-disable-next-line custom-errors
revert("I reverted");
}

Expand Down
2 changes: 1 addition & 1 deletion implementations/contracts/helpers/ERC725XPayableTester.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "../ERC725X.sol";
import {ERC725X} from "../ERC725X.sol";

/**
* @title ERC725XPayableTester
Expand Down
Loading

0 comments on commit 40c492a

Please sign in to comment.