Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add return values to base actions router #212

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .forge-snapshots/BaseActionsRouter_mock10commands.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
62824
73034
12 changes: 6 additions & 6 deletions src/base/BaseActionsRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/mocks/MockBaseActionsRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
Loading