From 516a77ba37cdac8d1e6eb47ffb8c2a7cb809ed55 Mon Sep 17 00:00:00 2001 From: TheMarvelFan Date: Sun, 3 Nov 2024 01:43:41 +0530 Subject: [PATCH 1/3] Created IBatch interface and inherited it into ISablierFlowBase interface --- src/abstracts/Batch.sol | 6 ++++-- src/interfaces/IBatch.sol | 9 +++++++++ src/interfaces/ISablierFlowBase.sol | 5 +++-- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 src/interfaces/IBatch.sol diff --git a/src/abstracts/Batch.sol b/src/abstracts/Batch.sol index d35346cb..7497318e 100644 --- a/src/abstracts/Batch.sol +++ b/src/abstracts/Batch.sol @@ -2,18 +2,20 @@ pragma solidity >=0.8.22; import { Errors } from "../libraries/Errors.sol"; +import { IBatch } from "../interfaces/IBatch.sol"; /// @title Batch /// @notice This contract implements logic to batch call any function. /// @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 //////////////////////////////////////////////////////////////////////////*/ + /// @inheritdoc IBatch /// @notice Allows batched call to self, `this` contract. /// @param calls An array of inputs for each call. - function batch(bytes[] calldata calls) external { + function batch(bytes[] calldata calls) external virtual 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/ISablierFlowBase.sol b/src/interfaces/ISablierFlowBase.sol index 4d17f1c7..18d0c10f 100644 --- a/src/interfaces/ISablierFlowBase.sol +++ b/src/interfaces/ISablierFlowBase.sol @@ -6,9 +6,9 @@ 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 { IBatch } from "./IBatch.sol"; import { IFlowNFTDescriptor } from "./IFlowNFTDescriptor.sol"; /// @title ISablierFlowBase @@ -18,7 +18,8 @@ import { IFlowNFTDescriptor } from "./IFlowNFTDescriptor.sol"; interface ISablierFlowBase is IERC4906, // 2 inherited components IERC721Metadata, // 2 inherited components - IAdminable // 0 inherited components + IAdminable, // 0 inherited components + IBatch // 0 inherited components { /// @notice Emitted when the contract admin collects protocol revenue accrued. /// @param admin The address of the contract admin. From d6def544d1285498c6392fc482701c71dd7a8d32 Mon Sep 17 00:00:00 2001 From: andreivladbrg Date: Sun, 3 Nov 2024 16:14:03 +0200 Subject: [PATCH 2/3] address my feedback --- src/SablierFlow.sol | 4 ++-- src/abstracts/Batch.sol | 8 +++----- src/interfaces/ISablierFlow.sol | 2 ++ src/interfaces/ISablierFlowBase.sol | 5 ++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/SablierFlow.sol b/src/SablierFlow.sol index 2495e0d8..9b8a41fe 100644 --- a/src/SablierFlow.sol +++ b/src/SablierFlow.sol @@ -21,9 +21,9 @@ 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 + ISablierFlow, // 5 inherited components SablierFlowBase // 8 inherited components { using SafeCast for uint256; diff --git a/src/abstracts/Batch.sol b/src/abstracts/Batch.sol index 7497318e..47a86d48 100644 --- a/src/abstracts/Batch.sol +++ b/src/abstracts/Batch.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22; -import { Errors } from "../libraries/Errors.sol"; 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 is IBatch { /*////////////////////////////////////////////////////////////////////////// @@ -13,9 +13,7 @@ abstract contract Batch is IBatch { //////////////////////////////////////////////////////////////////////////*/ /// @inheritdoc IBatch - /// @notice Allows batched call to self, `this` contract. - /// @param calls An array of inputs for each call. - function batch(bytes[] calldata calls) external virtual override { + function batch(bytes[] calldata calls) external override { uint256 count = calls.length; for (uint256 i = 0; i < count; ++i) { diff --git a/src/interfaces/ISablierFlow.sol b/src/interfaces/ISablierFlow.sol index 229e50d3..9f7dc561 100644 --- a/src/interfaces/ISablierFlow.sol +++ b/src/interfaces/ISablierFlow.sol @@ -5,11 +5,13 @@ 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 + IBatch, // 0 inherited interface ISablierFlowBase // 4 inherited component { /*////////////////////////////////////////////////////////////////////////// diff --git a/src/interfaces/ISablierFlowBase.sol b/src/interfaces/ISablierFlowBase.sol index 18d0c10f..109b823d 100644 --- a/src/interfaces/ISablierFlowBase.sol +++ b/src/interfaces/ISablierFlowBase.sol @@ -8,7 +8,7 @@ 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 { IBatch } from "./IBatch.sol"; + import { IFlowNFTDescriptor } from "./IFlowNFTDescriptor.sol"; /// @title ISablierFlowBase @@ -18,8 +18,7 @@ import { IFlowNFTDescriptor } from "./IFlowNFTDescriptor.sol"; interface ISablierFlowBase is IERC4906, // 2 inherited components IERC721Metadata, // 2 inherited components - IAdminable, // 0 inherited components - IBatch // 0 inherited components + IAdminable // 0 inherited components { /// @notice Emitted when the contract admin collects protocol revenue accrued. /// @param admin The address of the contract admin. From b7836448dfc9ea843e1925a88c826c8f6dffdd48 Mon Sep 17 00:00:00 2001 From: smol-ninja Date: Sun, 3 Nov 2024 14:30:27 +0000 Subject: [PATCH 3/3] chore: update inherited components --- src/SablierFlow.sol | 4 ++-- src/interfaces/ISablierFlow.sol | 2 +- src/interfaces/ISablierFlowBase.sol | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/SablierFlow.sol b/src/SablierFlow.sol index 9b8a41fe..5b0487d6 100644 --- a/src/SablierFlow.sol +++ b/src/SablierFlow.sol @@ -23,8 +23,8 @@ import { Broker, Flow } from "./types/DataTypes.sol"; contract SablierFlow is Batch, // 1 inherited components NoDelegateCall, // 0 inherited components - ISablierFlow, // 5 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/interfaces/ISablierFlow.sol b/src/interfaces/ISablierFlow.sol index 9f7dc561..41feb991 100644 --- a/src/interfaces/ISablierFlow.sol +++ b/src/interfaces/ISablierFlow.sol @@ -12,7 +12,7 @@ import { ISablierFlowBase } from "./ISablierFlowBase.sol"; /// @notice Creates and manages Flow streams with linear streaming functions. interface ISablierFlow is IBatch, // 0 inherited interface - ISablierFlowBase // 4 inherited component + ISablierFlowBase // 5 inherited component { /*////////////////////////////////////////////////////////////////////////// EVENTS diff --git a/src/interfaces/ISablierFlowBase.sol b/src/interfaces/ISablierFlowBase.sol index 109b823d..164d7857 100644 --- a/src/interfaces/ISablierFlowBase.sol +++ b/src/interfaces/ISablierFlowBase.sol @@ -8,7 +8,6 @@ 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"; /// @title ISablierFlowBase