Skip to content

Commit

Permalink
chore: fix solhint linter errors/warnings + improve code layout
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 committed Oct 4, 2023
1 parent f391a78 commit 869548e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 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
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
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
7 changes: 6 additions & 1 deletion implementations/contracts/helpers/ConstantsChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ 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 +25,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

0 comments on commit 869548e

Please sign in to comment.