From bdd2c99fd2a00b83c6bf57afed1240a5a9f66a14 Mon Sep 17 00:00:00 2001 From: Kushagra Nigam <93257324+TheMarvelFan@users.noreply.github.com> Date: Sun, 3 Nov 2024 20:09:55 +0530 Subject: [PATCH] added: IBatch Interface (#326) * Created IBatch interface and inherited it into ISablierFlowBase interface * address my feedback * chore: update inherited components --------- Co-authored-by: TheMarvelFan Co-authored-by: andreivladbrg Co-authored-by: smol-ninja --- src/SablierFlow.sol | 6 +++--- src/abstracts/Batch.sol | 10 +++++----- src/interfaces/IBatch.sol | 9 +++++++++ src/interfaces/ISablierFlow.sol | 4 +++- src/interfaces/ISablierFlowBase.sol | 1 - 5 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 src/interfaces/IBatch.sol diff --git a/src/SablierFlow.sol b/src/SablierFlow.sol index 2495e0d8..5b0487d6 100644 --- a/src/SablierFlow.sol +++ b/src/SablierFlow.sol @@ -21,10 +21,10 @@ import { Broker, Flow } from "./types/DataTypes.sol"; /// @title SablierFlow /// @notice See the documentation in {ISablierFlow}. contract SablierFlow is - Batch, // 0 inherited components + Batch, // 1 inherited components NoDelegateCall, // 0 inherited components - ISablierFlow, // 4 inherited components - SablierFlowBase // 8 inherited components + ISablierFlow, // 7 inherited components + SablierFlowBase // 5 inherited components { using SafeCast for uint256; using SafeERC20 for IERC20; diff --git a/src/abstracts/Batch.sol b/src/abstracts/Batch.sol index d35346cb..47a86d48 100644 --- a/src/abstracts/Batch.sol +++ b/src/abstracts/Batch.sol @@ -1,19 +1,19 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22; +import { IBatch } from "../interfaces/IBatch.sol"; import { Errors } from "../libraries/Errors.sol"; /// @title Batch -/// @notice This contract implements logic to batch call any function. +/// @notice See the documentation in {IBatch}. /// @dev Forked from: https://github.com/boringcrypto/BoringSolidity/blob/master/contracts/BoringBatchable.sol -abstract contract Batch { +abstract contract Batch is IBatch { /*////////////////////////////////////////////////////////////////////////// USER-FACING NON-CONSTANT FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ - /// @notice Allows batched call to self, `this` contract. - /// @param calls An array of inputs for each call. - function batch(bytes[] calldata calls) external { + /// @inheritdoc IBatch + function batch(bytes[] calldata calls) external override { uint256 count = calls.length; for (uint256 i = 0; i < count; ++i) { diff --git a/src/interfaces/IBatch.sol b/src/interfaces/IBatch.sol new file mode 100644 index 00000000..b4125adb --- /dev/null +++ b/src/interfaces/IBatch.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity >=0.8.22; + +/// @notice This contract implements logic to batch call any function. +interface IBatch { + /// @notice Allows batched call to self, `this` contract. + /// @param calls An array of inputs for each call. + function batch(bytes[] calldata calls) external; +} diff --git a/src/interfaces/ISablierFlow.sol b/src/interfaces/ISablierFlow.sol index 229e50d3..41feb991 100644 --- a/src/interfaces/ISablierFlow.sol +++ b/src/interfaces/ISablierFlow.sol @@ -5,12 +5,14 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { UD21x18 } from "@prb/math/src/UD21x18.sol"; import { Broker, Flow } from "./../types/DataTypes.sol"; +import { IBatch } from "./IBatch.sol"; import { ISablierFlowBase } from "./ISablierFlowBase.sol"; /// @title ISablierFlow /// @notice Creates and manages Flow streams with linear streaming functions. interface ISablierFlow is - ISablierFlowBase // 4 inherited component + IBatch, // 0 inherited interface + ISablierFlowBase // 5 inherited component { /*////////////////////////////////////////////////////////////////////////// EVENTS diff --git a/src/interfaces/ISablierFlowBase.sol b/src/interfaces/ISablierFlowBase.sol index 4d17f1c7..164d7857 100644 --- a/src/interfaces/ISablierFlowBase.sol +++ b/src/interfaces/ISablierFlowBase.sol @@ -6,7 +6,6 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import { UD21x18 } from "@prb/math/src/UD21x18.sol"; import { UD60x18 } from "@prb/math/src/UD60x18.sol"; - import { Flow } from "./../types/DataTypes.sol"; import { IAdminable } from "./IAdminable.sol"; import { IFlowNFTDescriptor } from "./IFlowNFTDescriptor.sol";