Skip to content

Commit

Permalink
chore: bump solhint, integrate Husky and lint-staged
Browse files Browse the repository at this point in the history
  • Loading branch information
smol-ninja committed Aug 28, 2024
1 parent 5eb674a commit 0bcf94e
Show file tree
Hide file tree
Showing 87 changed files with 312 additions and 382 deletions.
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
bun lint-staged
4 changes: 4 additions & 0 deletions .lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"*.{json,md,svg,yml}": "prettier --write"
"*.sol":
- "bun solhint --fix --noPrompt"
- "forge fmt"
1 change: 1 addition & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"func-name-mixedcase": "off",
"func-visibility": ["error", { "ignoreConstructors": true }],
"gas-custom-errors": "off",
"imports-order": "warn",
"max-line-length": ["error", 124],
"named-parameters-mapping": "warn",
"no-empty-blocks": "off",
Expand Down
Binary file modified bun.lockb
Binary file not shown.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
},
"devDependencies": {
"forge-std": "github:foundry-rs/forge-std#v1.8.2",
"husky": "^9.1.4",
"lint-staged": "^15.2.8",
"prettier": "^3.3.2",
"solady": "0.0.208",
"solarray": "github:evmcheb/solarray#a547630",
"solhint": "^5.0.1"
"solhint": "^5.0.3"
},
"files": [
"artifacts",
Expand Down Expand Up @@ -66,8 +68,11 @@
"build:smt": "FOUNDRY_PROFILE=smt forge build",
"clean": "rm -rf artifacts broadcast cache docs out out-optimized out-svg",
"lint": "bun run lint:sol && bun run prettier:check",
"lint:fix": "bun run lint:sol:fix && forge fmt",
"lint:sol": "forge fmt --check && bun solhint \"{benchmark,precompiles,script,src,test}/**/*.sol\"",
"lint:sol:fix": "bun solhint \"{benchmark,precompiles,script,src,test}/**/*.sol\" --fix --noPrompt",
"prepack": "bun install && bash ./shell/prepare-artifacts.sh",
"prepare": "husky",
"prettier:check": "prettier --check \"**/*.{json,md,svg,yml}\"",
"prettier:write": "prettier --write \"**/*.{json,md,svg,yml}\"",
"test": "forge test",
Expand Down
22 changes: 13 additions & 9 deletions precompiles/Precompiles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// solhint-disable max-line-length,no-inline-assembly,reason-string
pragma solidity >=0.8.22;

import { ILockupNFTDescriptor } from "../src/core/interfaces/ILockupNFTDescriptor.sol";
import { LockupNFTDescriptor } from "../src/core/LockupNFTDescriptor.sol";
import { ISablierLockupDynamic } from "../src/core/interfaces/ISablierLockupDynamic.sol";
import { ISablierLockupLinear } from "../src/core/interfaces/ISablierLockupLinear.sol";
import { ISablierLockupTranched } from "../src/core/interfaces/ISablierLockupTranched.sol";
import { ISablierBatchLockup } from "../src/periphery/interfaces/ISablierBatchLockup.sol";
import { ISablierMerkleFactory } from "../src/periphery/interfaces/ISablierMerkleFactory.sol";
import { ILockupNFTDescriptor } from "./../src/core/interfaces/ILockupNFTDescriptor.sol";
import { ISablierLockupDynamic } from "./../src/core/interfaces/ISablierLockupDynamic.sol";
import { ISablierLockupLinear } from "./../src/core/interfaces/ISablierLockupLinear.sol";
import { ISablierLockupTranched } from "./../src/core/interfaces/ISablierLockupTranched.sol";
import { LockupNFTDescriptor } from "./../src/core/LockupNFTDescriptor.sol";
import { ISablierBatchLockup } from "./../src/periphery/interfaces/ISablierBatchLockup.sol";
import { ISablierMerkleFactory } from "./../src/periphery/interfaces/ISablierMerkleFactory.sol";

/// @notice This is useful for external integrations seeking to test against the exact deployed bytecode, as recompiling
/// with via IR enabled would be time-consuming.
Expand Down Expand Up @@ -182,7 +182,9 @@ contract Precompiles {
}

/// @notice Deploys all Core contracts.
function deployCore(address initialAdmin)
function deployCore(
address initialAdmin
)
public
returns (
ILockupNFTDescriptor nftDescriptor,
Expand Down Expand Up @@ -236,7 +238,9 @@ contract Precompiles {
/// 4. {SablierLockupTranched}
/// 5. {SablierBatchLockup}
/// 6. {SablierMerkleFactory}
function deployProtocol(address initialAdmin)
function deployProtocol(
address initialAdmin
)
public
returns (
ILockupNFTDescriptor nftDescriptor,
Expand Down
13 changes: 6 additions & 7 deletions script/DeployDeterministicProtocol.s.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { LockupNFTDescriptor } from "../src/core/LockupNFTDescriptor.sol";
import { SablierLockupDynamic } from "../src/core/SablierLockupDynamic.sol";
import { SablierLockupLinear } from "../src/core/SablierLockupLinear.sol";
import { SablierLockupTranched } from "../src/core/SablierLockupTranched.sol";
import { SablierMerkleFactory } from "../src/periphery/SablierMerkleFactory.sol";
import { SablierBatchLockup } from "../src/periphery/SablierBatchLockup.sol";

import { LockupNFTDescriptor } from "./../src/core/LockupNFTDescriptor.sol";
import { SablierLockupDynamic } from "./../src/core/SablierLockupDynamic.sol";
import { SablierLockupLinear } from "./../src/core/SablierLockupLinear.sol";
import { SablierLockupTranched } from "./../src/core/SablierLockupTranched.sol";
import { SablierBatchLockup } from "./../src/periphery/SablierBatchLockup.sol";
import { SablierMerkleFactory } from "./../src/periphery/SablierMerkleFactory.sol";
import { BaseScript } from "./Base.s.sol";

/// @notice Deploys the Lockup Protocol at deterministic addresses across chains.
Expand Down
13 changes: 6 additions & 7 deletions script/DeployProtocol.s.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { LockupNFTDescriptor } from "../src/core/LockupNFTDescriptor.sol";
import { SablierLockupDynamic } from "../src/core/SablierLockupDynamic.sol";
import { SablierLockupLinear } from "../src/core/SablierLockupLinear.sol";
import { SablierLockupTranched } from "../src/core/SablierLockupTranched.sol";
import { SablierMerkleFactory } from "../src/periphery/SablierMerkleFactory.sol";
import { SablierBatchLockup } from "../src/periphery/SablierBatchLockup.sol";

import { LockupNFTDescriptor } from "./../src/core/LockupNFTDescriptor.sol";
import { SablierLockupDynamic } from "./../src/core/SablierLockupDynamic.sol";
import { SablierLockupLinear } from "./../src/core/SablierLockupLinear.sol";
import { SablierLockupTranched } from "./../src/core/SablierLockupTranched.sol";
import { SablierBatchLockup } from "./../src/periphery/SablierBatchLockup.sol";
import { SablierMerkleFactory } from "./../src/periphery/SablierMerkleFactory.sol";
import { BaseScript } from "./Base.s.sol";

/// @notice Deploys the Lockup Protocol.
Expand Down
10 changes: 4 additions & 6 deletions script/core/GenerateSVG.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
pragma solidity >=0.8.22 <0.9.0;

import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";

import { LockupNFTDescriptor } from "../../src/core/LockupNFTDescriptor.sol";
import { NFTSVG } from "../../src/core/libraries/NFTSVG.sol";
import { SVGElements } from "../../src/core/libraries/SVGElements.sol";

import { BaseScript } from "../Base.s.sol";
import { NFTSVG } from "./../../src/core/libraries/NFTSVG.sol";
import { SVGElements } from "./../../src/core/libraries/SVGElements.sol";
import { LockupNFTDescriptor } from "./../../src/core/LockupNFTDescriptor.sol";
import { BaseScript } from "./../Base.s.sol";

/// @notice Generates an NFT SVG using the user-provided parameters.
contract GenerateSVG is BaseScript, LockupNFTDescriptor {
Expand Down
7 changes: 3 additions & 4 deletions script/periphery/DeployPeriphery.s.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { SablierMerkleFactory } from "../../src/periphery/SablierMerkleFactory.sol";
import { SablierBatchLockup } from "../../src/periphery/SablierBatchLockup.sol";

import { BaseScript } from "../Base.s.sol";
import { SablierBatchLockup } from "./../../src/periphery/SablierBatchLockup.sol";
import { SablierMerkleFactory } from "./../../src/periphery/SablierMerkleFactory.sol";
import { BaseScript } from "./../Base.s.sol";

/// @notice Deploys all Periphery contract in the following order:
///
Expand Down
4 changes: 1 addition & 3 deletions src/core/LockupNFTDescriptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/I
import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import { Base64 } from "@openzeppelin/contracts/utils/Base64.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";

import { ILockupNFTDescriptor } from "./interfaces/ILockupNFTDescriptor.sol";
import { ISablierLockup } from "./interfaces/ISablierLockup.sol";
import { Lockup } from "./types/DataTypes.sol";

import { Errors } from "./libraries/Errors.sol";
import { NFTSVG } from "./libraries/NFTSVG.sol";
import { SVGElements } from "./libraries/SVGElements.sol";
import { Lockup } from "./types/DataTypes.sol";

/*
Expand Down
11 changes: 5 additions & 6 deletions src/core/abstracts/SablierLockup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { UD60x18 } from "@prb/math/src/UD60x18.sol";

import { ILockupNFTDescriptor } from "../interfaces/ILockupNFTDescriptor.sol";
import { ISablierLockupRecipient } from "../interfaces/ISablierLockupRecipient.sol";
import { ISablierLockup } from "../interfaces/ISablierLockup.sol";
import { Errors } from "../libraries/Errors.sol";
import { Lockup } from "../types/DataTypes.sol";
import { ILockupNFTDescriptor } from "./../interfaces/ILockupNFTDescriptor.sol";
import { ISablierLockup } from "./../interfaces/ISablierLockup.sol";
import { ISablierLockupRecipient } from "./../interfaces/ISablierLockupRecipient.sol";
import { Errors } from "./../libraries/Errors.sol";
import { Lockup } from "./../types/DataTypes.sol";
import { Adminable } from "./Adminable.sol";
import { NoDelegateCall } from "./NoDelegateCall.sol";

Expand Down
10 changes: 4 additions & 6 deletions src/periphery/abstracts/SablierMerkleBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { MerkleProof } from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import { BitMaps } from "@openzeppelin/contracts/utils/structs/BitMaps.sol";

import { Adminable } from "../../core/abstracts/Adminable.sol";

import { ISablierMerkleBase } from "../interfaces/ISablierMerkleBase.sol";
import { MerkleBase } from "../types/DataTypes.sol";
import { Errors } from "../libraries/Errors.sol";
import { Adminable } from "./../../core/abstracts/Adminable.sol";
import { ISablierMerkleBase } from "./../interfaces/ISablierMerkleBase.sol";
import { Errors } from "./../libraries/Errors.sol";
import { MerkleBase } from "./../types/DataTypes.sol";

/// @title SablierMerkleBase
/// @notice See the documentation in {ISablierMerkleBase}.
Expand Down
5 changes: 2 additions & 3 deletions src/periphery/interfaces/ISablierMerkleLT.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22;

import { ISablierLockupTranched } from "../../core/interfaces/ISablierLockupTranched.sol";

import { ISablierLockupTranched } from "./../../core/interfaces/ISablierLockupTranched.sol";
import { MerkleLT } from "./../types/DataTypes.sol";
import { ISablierMerkleBase } from "./ISablierMerkleBase.sol";
import { MerkleLT } from "../types/DataTypes.sol";

/// @title ISablierMerkleLT
/// @notice Merkle Lockup campaign that creates LockupTranched streams.
Expand Down
6 changes: 2 additions & 4 deletions test/Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity >=0.8.22 <0.9.0;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import { ILockupNFTDescriptor } from "src/core/interfaces/ILockupNFTDescriptor.sol";
import { ISablierLockupDynamic } from "src/core/interfaces/ISablierLockupDynamic.sol";
import { ISablierLockupLinear } from "src/core/interfaces/ISablierLockupLinear.sol";
Expand All @@ -19,11 +18,10 @@ import { ISablierMerkleLL } from "src/periphery/interfaces/ISablierMerkleLL.sol"
import { ISablierMerkleLT } from "src/periphery/interfaces/ISablierMerkleLT.sol";
import { SablierBatchLockup } from "src/periphery/SablierBatchLockup.sol";
import { SablierMerkleFactory } from "src/periphery/SablierMerkleFactory.sol";

import { ERC20Mock } from "./mocks/erc20/ERC20Mock.sol";
import { ERC20MissingReturn } from "./mocks/erc20/ERC20MissingReturn.sol";
import { Noop } from "./mocks/Noop.sol";
import { ERC20Mock } from "./mocks/erc20/ERC20Mock.sol";
import { RecipientGood } from "./mocks/Hooks.sol";
import { Noop } from "./mocks/Noop.sol";
import { Assertions } from "./utils/Assertions.sol";
import { Calculations } from "./utils/Calculations.sol";
import { Constants } from "./utils/Constants.sol";
Expand Down
5 changes: 2 additions & 3 deletions test/core/fork/Fork.t.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.22 <0.9.0;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

import { Base_Test } from "../../Base.t.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Base_Test } from "./../../Base.t.sol";

/// @notice Common logic needed by all fork tests.
abstract contract Fork_Test is Base_Test {
Expand Down
65 changes: 32 additions & 33 deletions test/core/integration/concrete/lockup-dynamic/LockupDynamic.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,39 @@
pragma solidity >=0.8.22 <0.9.0;

import { ISablierLockup } from "src/core/interfaces/ISablierLockup.sol";

import { LockupDynamic_Integration_Shared_Test } from "../../shared/lockup-dynamic/LockupDynamic.t.sol";
import { Integration_Test } from "../../Integration.t.sol";
import { AllowToHook_Integration_Concrete_Test } from "../lockup/allow-to-hook/allowToHook.t.sol";
import { Burn_Integration_Concrete_Test } from "../lockup/burn/burn.t.sol";
import { Cancel_Integration_Concrete_Test } from "../lockup/cancel/cancel.t.sol";
import { CancelMultiple_Integration_Concrete_Test } from "../lockup/cancel-multiple/cancelMultiple.t.sol";
import { GetAsset_Integration_Concrete_Test } from "../lockup/get-asset/getAsset.t.sol";
import { GetDepositedAmount_Integration_Concrete_Test } from "../lockup/get-deposited-amount/getDepositedAmount.t.sol";
import { GetEndTime_Integration_Concrete_Test } from "../lockup/get-end-time/getEndTime.t.sol";
import { GetRecipient_Integration_Concrete_Test } from "../lockup/get-recipient/getRecipient.t.sol";
import { GetRefundedAmount_Integration_Concrete_Test } from "../lockup/get-refunded-amount/getRefundedAmount.t.sol";
import { GetSender_Integration_Concrete_Test } from "../lockup/get-sender/getSender.t.sol";
import { GetStartTime_Integration_Concrete_Test } from "../lockup/get-start-time/getStartTime.t.sol";
import { GetWithdrawnAmount_Integration_Concrete_Test } from "../lockup/get-withdrawn-amount/getWithdrawnAmount.t.sol";
import { IsAllowedToHook_Integration_Concrete_Test } from "../lockup/is-allowed-to-hook/isAllowedToHook.t.sol";
import { IsCancelable_Integration_Concrete_Test } from "../lockup/is-cancelable/isCancelable.t.sol";
import { IsCold_Integration_Concrete_Test } from "../lockup/is-cold/isCold.t.sol";
import { IsDepleted_Integration_Concrete_Test } from "../lockup/is-depleted/isDepleted.t.sol";
import { IsStream_Integration_Concrete_Test } from "../lockup/is-stream/isStream.t.sol";
import { IsTransferable_Integration_Concrete_Test } from "../lockup/is-transferable/isTransferable.t.sol";
import { IsWarm_Integration_Concrete_Test } from "../lockup/is-warm/isWarm.t.sol";
import { RefundableAmountOf_Integration_Concrete_Test } from "../lockup/refundable-amount-of/refundableAmountOf.t.sol";
import { Renounce_Integration_Concrete_Test } from "../lockup/renounce/renounce.t.sol";
import { SetNFTDescriptor_Integration_Concrete_Test } from "../lockup/set-nft-descriptor/setNFTDescriptor.t.sol";
import { StatusOf_Integration_Concrete_Test } from "../lockup/status-of/statusOf.t.sol";
import { TransferFrom_Integration_Concrete_Test } from "../lockup/transfer-from/transferFrom.t.sol";
import { WasCanceled_Integration_Concrete_Test } from "../lockup/was-canceled/wasCanceled.t.sol";
import { Withdraw_Integration_Concrete_Test } from "../lockup/withdraw/withdraw.t.sol";
import { WithdrawHooks_Integration_Concrete_Test } from "../lockup/withdraw-hooks/withdrawHooks.t.sol";
import { WithdrawMax_Integration_Concrete_Test } from "../lockup/withdraw-max/withdrawMax.t.sol";
import { Integration_Test } from "./../../Integration.t.sol";
import { LockupDynamic_Integration_Shared_Test } from "./../../shared/lockup-dynamic/LockupDynamic.t.sol";
import { AllowToHook_Integration_Concrete_Test } from "./../lockup/allow-to-hook/allowToHook.t.sol";
import { Burn_Integration_Concrete_Test } from "./../lockup/burn/burn.t.sol";
import { CancelMultiple_Integration_Concrete_Test } from "./../lockup/cancel-multiple/cancelMultiple.t.sol";
import { Cancel_Integration_Concrete_Test } from "./../lockup/cancel/cancel.t.sol";
import { GetAsset_Integration_Concrete_Test } from "./../lockup/get-asset/getAsset.t.sol";
import { GetDepositedAmount_Integration_Concrete_Test } from "./../lockup/get-deposited-amount/getDepositedAmount.t.sol";
import { GetEndTime_Integration_Concrete_Test } from "./../lockup/get-end-time/getEndTime.t.sol";
import { GetRecipient_Integration_Concrete_Test } from "./../lockup/get-recipient/getRecipient.t.sol";
import { GetRefundedAmount_Integration_Concrete_Test } from "./../lockup/get-refunded-amount/getRefundedAmount.t.sol";
import { GetSender_Integration_Concrete_Test } from "./../lockup/get-sender/getSender.t.sol";
import { GetStartTime_Integration_Concrete_Test } from "./../lockup/get-start-time/getStartTime.t.sol";
import { GetWithdrawnAmount_Integration_Concrete_Test } from "./../lockup/get-withdrawn-amount/getWithdrawnAmount.t.sol";
import { IsAllowedToHook_Integration_Concrete_Test } from "./../lockup/is-allowed-to-hook/isAllowedToHook.t.sol";
import { IsCancelable_Integration_Concrete_Test } from "./../lockup/is-cancelable/isCancelable.t.sol";
import { IsCold_Integration_Concrete_Test } from "./../lockup/is-cold/isCold.t.sol";
import { IsDepleted_Integration_Concrete_Test } from "./../lockup/is-depleted/isDepleted.t.sol";
import { IsStream_Integration_Concrete_Test } from "./../lockup/is-stream/isStream.t.sol";
import { IsTransferable_Integration_Concrete_Test } from "./../lockup/is-transferable/isTransferable.t.sol";
import { IsWarm_Integration_Concrete_Test } from "./../lockup/is-warm/isWarm.t.sol";
import { RefundableAmountOf_Integration_Concrete_Test } from "./../lockup/refundable-amount-of/refundableAmountOf.t.sol";
import { Renounce_Integration_Concrete_Test } from "./../lockup/renounce/renounce.t.sol";
import { SetNFTDescriptor_Integration_Concrete_Test } from "./../lockup/set-nft-descriptor/setNFTDescriptor.t.sol";
import { StatusOf_Integration_Concrete_Test } from "./../lockup/status-of/statusOf.t.sol";
import { TransferFrom_Integration_Concrete_Test } from "./../lockup/transfer-from/transferFrom.t.sol";
import { WasCanceled_Integration_Concrete_Test } from "./../lockup/was-canceled/wasCanceled.t.sol";
import { WithdrawHooks_Integration_Concrete_Test } from "./../lockup/withdraw-hooks/withdrawHooks.t.sol";
import { WithdrawMaxAndTransfer_Integration_Concrete_Test } from
"../lockup/withdraw-max-and-transfer/withdrawMaxAndTransfer.t.sol";
import { WithdrawMultiple_Integration_Concrete_Test } from "../lockup/withdraw-multiple/withdrawMultiple.t.sol";
"./../lockup/withdraw-max-and-transfer/withdrawMaxAndTransfer.t.sol";
import { WithdrawMax_Integration_Concrete_Test } from "./../lockup/withdraw-max/withdrawMax.t.sol";
import { WithdrawMultiple_Integration_Concrete_Test } from "./../lockup/withdraw-multiple/withdrawMultiple.t.sol";
import { Withdraw_Integration_Concrete_Test } from "./../lockup/withdraw/withdraw.t.sol";

/*//////////////////////////////////////////////////////////////////////////
NON-SHARED ABSTRACT TEST
Expand Down
Loading

0 comments on commit 0bcf94e

Please sign in to comment.