From 3a6d31c9329b4452355cd56f2de5608e2865903f Mon Sep 17 00:00:00 2001 From: Sara Reynolds Date: Fri, 26 Jul 2024 15:53:10 -0400 Subject: [PATCH] add return values to base actions router --- .../BaseActionsRouter_mock10commands.snap | 2 +- src/base/BaseActionsRouter.sol | 12 ++++++------ test/mocks/MockBaseActionsRouter.sol | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.forge-snapshots/BaseActionsRouter_mock10commands.snap b/.forge-snapshots/BaseActionsRouter_mock10commands.snap index d99d3dfd..822a52af 100644 --- a/.forge-snapshots/BaseActionsRouter_mock10commands.snap +++ b/.forge-snapshots/BaseActionsRouter_mock10commands.snap @@ -1 +1 @@ -62824 \ No newline at end of file +73034 \ No newline at end of file diff --git a/src/base/BaseActionsRouter.sol b/src/base/BaseActionsRouter.sol index e88b1fe8..ff1d74b5 100644 --- a/src/base/BaseActionsRouter.sol +++ b/src/base/BaseActionsRouter.sol @@ -20,8 +20,8 @@ abstract contract BaseActionsRouter is SafeCallback { /// @notice internal function that triggers the execution of a set of actions on v4 /// @dev inheriting contracts should call this function to trigger execution - function _executeActions(bytes calldata params) internal { - poolManager.unlock(params); + function _executeActions(bytes calldata params) internal returns (bytes[] memory) { + return abi.decode(poolManager.unlock(params), (bytes[])); } /// @notice function that is called by the PoolManager through the SafeCallback.unlockCallback @@ -32,18 +32,18 @@ abstract contract BaseActionsRouter is SafeCallback { uint256 numActions = actions.length; if (numActions != params.length) revert LengthMismatch(); + bytes[] memory results = new bytes[](numActions); for (uint256 actionIndex = 0; actionIndex < numActions; actionIndex++) { uint256 action = actions[actionIndex]; - _handleAction(action, params[actionIndex]); + results[actionIndex] = _handleAction(action, params[actionIndex]); } - // TODO do we want to return anything? - return ""; + return abi.encode(results); } /// @notice function to handle the parsing and execution of an action and its parameters - function _handleAction(uint256 action, bytes calldata params) internal virtual; + function _handleAction(uint256 action, bytes calldata params) internal virtual returns (bytes memory); /// @notice function that returns address considered executer of the actions /// @dev The other context functions, _msgData and _msgValue, are not supported by this contract diff --git a/test/mocks/MockBaseActionsRouter.sol b/test/mocks/MockBaseActionsRouter.sol index 071b23ea..6ba1982f 100644 --- a/test/mocks/MockBaseActionsRouter.sol +++ b/test/mocks/MockBaseActionsRouter.sol @@ -25,7 +25,7 @@ contract MockBaseActionsRouter is BaseActionsRouter, ReentrancyLock { _executeActions(params); } - function _handleAction(uint256 action, bytes calldata params) internal override { + function _handleAction(uint256 action, bytes calldata params) internal override returns (bytes memory) { if (action < Actions.SETTLE) { if (action == Actions.SWAP) _swap(params); else if (action == Actions.INCREASE_LIQUIDITY) _increaseLiquidity(params); @@ -40,6 +40,7 @@ contract MockBaseActionsRouter is BaseActionsRouter, ReentrancyLock { else if (action == Actions.BURN_6909) _burn6909(params); else revert UnsupportedAction(action); } + return ""; } function _msgSender() internal view override returns (address) {