Skip to content

Commit

Permalink
refactor execution helper
Browse files Browse the repository at this point in the history
  • Loading branch information
livingrockrises committed Jul 7, 2024
1 parent 3197d80 commit 2826033
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/Nexus.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ contract Nexus is INexus, BaseAccount, ExecutionHelper, ModuleManager, UUPSUpgra
} else if (callType == CALLTYPE_BATCH) {
returnData = _handleBatchExecutionAndReturnData(executionCalldata, execType);
} else if (callType == CALLTYPE_DELEGATECALL) {
_handleDelegateCallExecution(executionCalldata, execType);
returnData = _handleDelegateCallExecutionAndReturnData(executionCalldata, execType);
} else {
revert UnsupportedCallType(callType);
}
Expand Down
14 changes: 14 additions & 0 deletions contracts/base/ExecutionHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,18 @@ contract ExecutionHelper is IExecutionHelperEventsAndErrors {
else if (execType == EXECTYPE_TRY) returnData = _tryExecuteBatch(executions);
else revert UnsupportedExecType(execType);
}

/// @dev Executes a single transaction based on the specified execution type.
/// @param executionCalldata The calldata containing the transaction details (target address, value, and data).
/// @param execType The execution type, which can be DEFAULT (revert on failure) or TRY (return on failure).
function _handleDelegateCallExecutionAndReturnData(bytes calldata executionCalldata, ExecType execType) internal returns(bytes[] memory returnData) {
(address delegate, bytes calldata callData) = executionCalldata.decodeDelegateCall();
if (execType == EXECTYPE_DEFAULT) {
returnData[0] = _executeDelegatecall(delegate, callData);
}
else if (execType == EXECTYPE_TRY) {
(, returnData[0]) = _tryExecuteDelegatecall(delegate, callData);
}
else revert UnsupportedExecType(execType);
}
}

0 comments on commit 2826033

Please sign in to comment.