Skip to content

Commit

Permalink
fix solhint issues under src/v0.8/automation (#11065)
Browse files Browse the repository at this point in the history
  • Loading branch information
shileiwill authored Oct 27, 2023
1 parent 7206a62 commit c95d8f8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"prepublishOnly": "pnpm compile && ./scripts/prepublish_generate_abi_folder",
"publish-beta": "pnpm publish --tag beta",
"publish-prod": "npm dist-tag add @chainlink/contracts@0.8.0 latest",
"solhint": "solhint --max-warnings 377 \"./src/v0.8/**/*.sol\""
"solhint": "solhint --max-warnings 350 \"./src/v0.8/**/*.sol\""
},
"files": [
"src/v0.8",
Expand Down
5 changes: 3 additions & 2 deletions contracts/src/v0.8/automation/AutomationBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ contract AutomationBase {
* @notice method that allows it to be simulated via eth_call by checking that
* the sender is the zero address.
*/
function preventExecution() internal view {
function _preventExecution() internal view {
// solhint-disable-next-line avoid-tx-origin
if (tx.origin != address(0)) {
revert OnlySimulatedBackend();
}
Expand All @@ -19,7 +20,7 @@ contract AutomationBase {
* that the sender is the zero address.
*/
modifier cannotExecute() {
preventExecution();
_preventExecution();
_;
}
}
4 changes: 2 additions & 2 deletions contracts/src/v0.8/automation/AutomationCompatible.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./AutomationBase.sol";
import "./interfaces/AutomationCompatibleInterface.sol";
import {AutomationBase} from "./AutomationBase.sol";
import {AutomationCompatibleInterface} from "./interfaces/AutomationCompatibleInterface.sol";

abstract contract AutomationCompatible is AutomationBase, AutomationCompatibleInterface {}
10 changes: 6 additions & 4 deletions contracts/src/v0.8/automation/Chainable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,31 @@ contract Chainable {
/**
* @dev addresses of the next contract in the chain **have to be immutable/constant** or the system won't work
*/
address private immutable FALLBACK_ADDRESS;
address private immutable i_FALLBACK_ADDRESS;

/**
* @param fallbackAddress the address of the next contract in the chain
*/
constructor(address fallbackAddress) {
FALLBACK_ADDRESS = fallbackAddress;
i_FALLBACK_ADDRESS = fallbackAddress;
}

/**
* @notice returns the address of the next contract in the chain
*/
function fallbackTo() external view returns (address) {
return FALLBACK_ADDRESS;
return i_FALLBACK_ADDRESS;
}

/**
* @notice the fallback function routes the call to the next contract in the chain
* @dev most of the implementation is copied directly from OZ's Proxy contract
*/
// solhint-disable payable-fallback
// solhint-disable-next-line no-complex-fallback
fallback() external {
// copy to memory for assembly access
address next = FALLBACK_ADDRESS;
address next = i_FALLBACK_ADDRESS;
// copied directly from OZ's Proxy contract
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
Expand Down
5 changes: 3 additions & 2 deletions contracts/src/v0.8/automation/ExecutionPrevention.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ abstract contract ExecutionPrevention {
* @notice method that allows it to be simulated via eth_call by checking that
* the sender is the zero address.
*/
function preventExecution() internal view {
function _preventExecution() internal view {
// solhint-disable-next-line avoid-tx-origin
if (tx.origin != address(0)) {
revert OnlySimulatedBackend();
}
Expand All @@ -19,7 +20,7 @@ abstract contract ExecutionPrevention {
* that the sender is the zero address.
*/
modifier cannotExecute() {
preventExecution();
_preventExecution();
_;
}
}
6 changes: 4 additions & 2 deletions contracts/src/v0.8/automation/HeartbeatRequester.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: MIT
// solhint-disable-next-line one-contract-per-file
pragma solidity 0.8.6;

import "./../interfaces/TypeAndVersionInterface.sol";
import "../shared/access/ConfirmedOwner.sol";
import {TypeAndVersionInterface} from "./../interfaces/TypeAndVersionInterface.sol";
import {ConfirmedOwner} from "../shared/access/ConfirmedOwner.sol";

// defines some interfaces for type safety and reduces encoding/decoding
// does not use the full interfaces intentionally because the requester only uses a fraction of them
Expand Down Expand Up @@ -32,6 +33,7 @@ contract HeartbeatRequester is TypeAndVersionInterface, ConfirmedOwner {
* - HeartbeatRequester 1.0.0: The requester fetches the latest aggregator address from proxy, and request a new round
* using the aggregator address.
*/
// solhint-disable-next-line chainlink-solidity/all-caps-constant-storage-variables
string public constant override typeAndVersion = "HeartbeatRequester 1.0.0";

constructor() ConfirmedOwner(msg.sender) {}
Expand Down
6 changes: 4 additions & 2 deletions contracts/src/v0.8/automation/UpkeepTranscoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

pragma solidity ^0.8.0;

import "./interfaces/UpkeepTranscoderInterface.sol";
import "../interfaces/TypeAndVersionInterface.sol";
import {UpkeepTranscoderInterface} from "./interfaces/UpkeepTranscoderInterface.sol";
import {TypeAndVersionInterface} from "../interfaces/TypeAndVersionInterface.sol";
import {UpkeepFormat} from "./UpkeepFormat.sol";

/**
* @notice Transcoder for converting upkeep data from one keeper
Expand All @@ -16,6 +17,7 @@ contract UpkeepTranscoder is UpkeepTranscoderInterface, TypeAndVersionInterface
* @notice versions:
* - UpkeepTranscoder 1.0.0: placeholder to allow new formats in the future
*/
// solhint-disable-next-line chainlink-solidity/all-caps-constant-storage-variables
string public constant override typeAndVersion = "UpkeepTranscoder 1.0.0";

/**
Expand Down

0 comments on commit c95d8f8

Please sign in to comment.