Skip to content

Commit

Permalink
Bump solhint
Browse files Browse the repository at this point in the history
  • Loading branch information
zZoMROT committed Dec 19, 2023
1 parent 23d6558 commit 6546e18
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 48 deletions.
13 changes: 6 additions & 7 deletions contracts/extensions/ETHOrders.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

pragma solidity 0.8.23;

import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import "@1inch/solidity-utils/contracts/libraries/SafeERC20.sol";
import "@1inch/solidity-utils/contracts/OnlyWethReceiver.sol";

Expand All @@ -28,8 +27,8 @@ contract ETHOrders is IPostInteraction, OnlyWethReceiver {
uint96 balance;
}

address private immutable _limitOrderProtocol;
IWETH private immutable _WETH; // solhint-disable-line var-name-mixedcase
address private immutable _LIMIT_ORDER_PROTOCOL;
IWETH private immutable _WETH;
/// @notice Makers and their uint96 ETH balances in single mapping.
mapping(bytes32 orderHash => ETHOrder data) public ordersMakersBalances;

Expand All @@ -38,14 +37,14 @@ contract ETHOrders is IPostInteraction, OnlyWethReceiver {

/// @notice Only limit order protocol can call this contract.
modifier onlyLimitOrderProtocol() {
if (msg.sender != _limitOrderProtocol) revert AccessDenied();
if (msg.sender != _LIMIT_ORDER_PROTOCOL) revert AccessDenied();

_;
}

constructor(IWETH weth, address limitOrderProtocol) OnlyWethReceiver(address(weth)) {
_WETH = weth;
_limitOrderProtocol = limitOrderProtocol;
_LIMIT_ORDER_PROTOCOL = limitOrderProtocol;
_WETH.approve(limitOrderProtocol, type(uint256).max);
}

Expand Down Expand Up @@ -79,7 +78,7 @@ contract ETHOrders is IPostInteraction, OnlyWethReceiver {
if (order.makingAmount != msg.value) revert InvalidOrder();
bytes calldata interaction = extension.postInteractionTargetAndData();
if (interaction.length != 20 || address(bytes20(interaction)) != address(this)) revert InvalidOrder();
orderHash = IOrderMixin(_limitOrderProtocol).hashOrder(order);
orderHash = IOrderMixin(_LIMIT_ORDER_PROTOCOL).hashOrder(order);
if (ordersMakersBalances[orderHash].maker != address(0)) revert ExistingOrder();
ordersMakersBalances[orderHash] = ETHOrder({
maker: msg.sender,
Expand All @@ -94,7 +93,7 @@ contract ETHOrders is IPostInteraction, OnlyWethReceiver {
*/
function cancelOrder(MakerTraits makerTraits, bytes32 orderHash) external {
if (ordersMakersBalances[orderHash].maker != msg.sender) revert InvalidOrder();
IOrderMixin(_limitOrderProtocol).cancelOrder(makerTraits, orderHash);
IOrderMixin(_LIMIT_ORDER_PROTOCOL).cancelOrder(makerTraits, orderHash);
uint256 refundETHAmount = ordersMakersBalances[orderHash].balance;
ordersMakersBalances[orderHash].balance = 0;
_WETH.safeWithdrawTo(refundETHAmount, msg.sender);
Expand Down
6 changes: 3 additions & 3 deletions contracts/extensions/ImmutableOwner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ pragma solidity 0.8.23;
contract ImmutableOwner {
error IOAccessDenied();

address public immutable immutableOwner;
address public immutable IMMUTABLE_OWNER;

modifier onlyImmutableOwner {
if (msg.sender != immutableOwner) revert IOAccessDenied();
if (msg.sender != IMMUTABLE_OWNER) revert IOAccessDenied();
_;
}

constructor(address _immutableOwner) {
immutableOwner = _immutableOwner;
IMMUTABLE_OWNER = _immutableOwner;
}
}
6 changes: 3 additions & 3 deletions contracts/extensions/OrderIdInvalidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ contract OrderIdInvalidator is IPreInteraction {
error InvalidOrderHash();

/// @notice Limit order protocol address.
address private immutable _limitOrderProtocol;
address private immutable _LIMIT_ORDER_PROTOCOL;
/// @notice Stores corresponding maker orders ids and hashes.
mapping(address maker => mapping(uint32 orderId => bytes32 orderHash)) private _ordersIdsHashes;

/// @notice Only limit order protocol can call this contract.
modifier onlyLimitOrderProtocol() {
if (msg.sender != _limitOrderProtocol) {
if (msg.sender != _LIMIT_ORDER_PROTOCOL) {
revert AccessDenied();
}
_;
}

constructor(address limitOrderProtocol_) {
_limitOrderProtocol = limitOrderProtocol_;
_LIMIT_ORDER_PROTOCOL = limitOrderProtocol_;
}

function preInteraction(
Expand Down
8 changes: 4 additions & 4 deletions contracts/mocks/AggregatorMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol";
contract AggregatorMock is AggregatorV2V3Interface {
error NoDataPresent();

int256 private immutable _answer;
int256 private immutable _ANSWER;

constructor(int256 answer) {
_answer = answer;
_ANSWER = answer;
}

function decimals() external pure returns (uint8) {
Expand Down Expand Up @@ -53,11 +53,11 @@ contract AggregatorMock is AggregatorV2V3Interface {
)
{
// solhint-disable-next-line not-rely-on-time
return (0, _answer, block.timestamp - 100, block.timestamp - 100, 0);
return (0, _ANSWER, block.timestamp - 100, block.timestamp - 100, 0);
}

function latestAnswer() public view returns (int256) {
return _answer;
return _ANSWER;
}

function latestTimestamp() public view returns (uint256) {
Expand Down
6 changes: 3 additions & 3 deletions contracts/mocks/HashChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ contract HashChecker is IPreInteraction, Ownable {

error IncorrectOrderHash();

bytes32 public immutable limitOrderProtocolDomainSeparator;
bytes32 public immutable LIMIT_ORDER_PROTOCOL_DOMAIN_SEPARATOR;
mapping(bytes32 => bool) public hashes;

constructor (address limitOrderProtocol, address owner_) Ownable(owner_) {
// solhint-disable-next-line avoid-low-level-calls
(, bytes memory data) = limitOrderProtocol.call(abi.encodeWithSignature("DOMAIN_SEPARATOR()"));
limitOrderProtocolDomainSeparator = abi.decode(data, (bytes32));
LIMIT_ORDER_PROTOCOL_DOMAIN_SEPARATOR = abi.decode(data, (bytes32));
}

function setHashOrderStatus(IOrderMixin.Order calldata order, bool status) external onlyOwner {
bytes32 orderHash = order.hash(limitOrderProtocolDomainSeparator);
bytes32 orderHash = order.hash(LIMIT_ORDER_PROTOCOL_DOMAIN_SEPARATOR);
hashes[orderHash] = status;
}

Expand Down
34 changes: 17 additions & 17 deletions contracts/mocks/MakerContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ contract MakerContract is IERC1271, EIP712Alien, ERC20 {
error BadPrice();
error MalformedSignature();

address immutable public protocol;
IERC20 immutable public token0;
IERC20 immutable public token1;
uint256 immutable public fee;
uint256 immutable public fee2;
address immutable public PROTOCOL;
IERC20 immutable public TOKEN0;
IERC20 immutable public TOKEN1;
uint256 immutable public FEE;
uint256 immutable public FEE2;

constructor(
address _protocol,
Expand All @@ -36,11 +36,11 @@ contract MakerContract is IERC1271, EIP712Alien, ERC20 {
EIP712Alien(_protocol, "1inch Limit Order Protocol", "4")
ERC20(name, symbol)
{
protocol = _protocol;
token0 = _token0;
token1 = _token1;
fee = _fee;
fee2 = 2e18 * _fee / (1e18 + _fee);
PROTOCOL = _protocol;
TOKEN0 = _token0;
TOKEN1 = _token1;
FEE = _fee;
FEE2 = 2e18 * _fee / (1e18 + _fee);
_token0.approve(_protocol, type(uint256).max);
_token1.approve(_protocol, type(uint256).max);
}
Expand All @@ -54,9 +54,9 @@ contract MakerContract is IERC1271, EIP712Alien, ERC20 {
}

function depositFor(IERC20 token, uint256 amount, address to) public {
if (token != token0 && token != token1) revert NotAllowedToken();
if (token != TOKEN0 && token != TOKEN1) revert NotAllowedToken();

_mint(to, amount * fee2 / 1e18);
_mint(to, amount * FEE2 / 1e18);
token.safeTransferFrom(msg.sender, address(this), amount);
}

Expand All @@ -65,10 +65,10 @@ contract MakerContract is IERC1271, EIP712Alien, ERC20 {
}

function withdrawFor(IERC20 token, uint256 amount, address to) public {
if (token != token0 && token != token1) revert NotAllowedToken();
if (token != TOKEN0 && token != TOKEN1) revert NotAllowedToken();

_burn(msg.sender, amount);
token.safeTransfer(to, amount * fee2 / 1e18);
token.safeTransfer(to, amount * FEE2 / 1e18);
}

function isValidSignature(bytes32 hash, bytes calldata signature) external view override returns(bytes4) {
Expand All @@ -81,11 +81,11 @@ contract MakerContract is IERC1271, EIP712Alien, ERC20 {

if (
(
(order.makerAsset.get() != address(token0) || order.takerAsset.get() != address(token1)) &&
(order.makerAsset.get() != address(token1) || order.takerAsset.get() != address(token0))
(order.makerAsset.get() != address(TOKEN0) || order.takerAsset.get() != address(TOKEN1)) &&
(order.makerAsset.get() != address(TOKEN1) || order.takerAsset.get() != address(TOKEN0))
) ||
order.makerTraits.hasExtension() ||
order.makingAmount * fee > order.takingAmount * 1e18 ||
order.makingAmount * FEE > order.takingAmount * 1e18 ||
order.hash(_domainSeparatorV4()) != hash
) revert BadPrice();

Expand Down
6 changes: 3 additions & 3 deletions contracts/mocks/TakerContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { IOrderMixin } from "../interfaces/IOrderMixin.sol";
import { TakerTraits } from "../libraries/TakerTraitsLib.sol";

contract TakerContract {
IOrderMixin private immutable _swap;
IOrderMixin private immutable _SWAP;

constructor(IOrderMixin swap) {
_swap = swap;
_SWAP = swap;
}

function fillOrder(
Expand All @@ -19,6 +19,6 @@ contract TakerContract {
uint256 amount,
TakerTraits takerTraits
) external payable {
_swap.fillOrder {value: msg.value} (order, r, vs, amount, takerTraits);
_SWAP.fillOrder {value: msg.value} (order, r, vs, amount, takerTraits);
}
}
2 changes: 1 addition & 1 deletion contracts/mocks/WrappedTokenMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract WrappedTokenMock is ERC20Permit, Ownable, IWETH {
emit Deposit(msg.sender, msg.value);
}

function withdraw(uint wad) public {
function withdraw(uint256 wad) public {
if (balanceOf(msg.sender) < wad) revert NotEnoughBalance();
_burn(msg.sender, wad);
payable(msg.sender).transfer(wad);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"hardhat-tracer": "2.7.0",
"rimraf": "5.0.5",
"solc": "0.8.23",
"solhint": "3.4.1",
"solhint": "3.6.2",
"solidity-coverage": "0.8.5",
"solidity-docgen": "0.5.17",
"zksync-web3": "0.17.1",
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5933,7 +5933,7 @@ semver@^7.0.0, semver@^7.3.2, semver@^7.3.4, semver@^7.3.7, semver@^7.3.8:
dependencies:
lru-cache "^6.0.0"

semver@^7.5.1, semver@^7.5.3, semver@^7.5.4:
semver@^7.5.1, semver@^7.5.2, semver@^7.5.3, semver@^7.5.4:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
Expand Down Expand Up @@ -6111,10 +6111,10 @@ solc@^0.6.7:
semver "^5.5.0"
tmp "0.0.33"

solhint@3.4.1:
version "3.4.1"
resolved "https://registry.yarnpkg.com/solhint/-/solhint-3.4.1.tgz#8ea15b21c13d1be0b53fd46d605a24d0b36a0c46"
integrity sha512-pzZn2RlZhws1XwvLPVSsxfHrwsteFf5eySOhpAytzXwKQYbTCJV6z8EevYDiSVKMpWrvbKpEtJ055CuEmzp4Xg==
solhint@3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/solhint/-/solhint-3.6.2.tgz#2b2acbec8fdc37b2c68206a71ba89c7f519943fe"
integrity sha512-85EeLbmkcPwD+3JR7aEMKsVC9YrRSxd4qkXuMzrlf7+z2Eqdfm1wHWq1ffTuo5aDhoZxp2I9yF3QkxZOxOL7aQ==
dependencies:
"@solidity-parser/parser" "^0.16.0"
ajv "^6.12.6"
Expand All @@ -6129,7 +6129,7 @@ solhint@3.4.1:
js-yaml "^4.1.0"
lodash "^4.17.21"
pluralize "^8.0.0"
semver "^6.3.0"
semver "^7.5.2"
strip-ansi "^6.0.1"
table "^6.8.1"
text-table "^0.2.0"
Expand Down

0 comments on commit 6546e18

Please sign in to comment.