Skip to content

Commit

Permalink
Merge pull request #130 from gnosis/remove-duplicate-exec-code
Browse files Browse the repository at this point in the history
Remove-duplicate-exec-code
  • Loading branch information
auryn-macmillan authored Jul 24, 2023
2 parents 7ce690e + a89b7c5 commit ec9d7ca
Showing 1 changed file with 11 additions and 35 deletions.
46 changes: 11 additions & 35 deletions contracts/core/Module.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,7 @@ abstract contract Module is FactoryFriendly, Guardable {
bytes memory data,
Enum.Operation operation
) internal returns (bool success) {
address currentGuard = guard;
if (currentGuard != address(0)) {
IGuard(currentGuard).checkTransaction(
/// Transaction info used by module transactions.
to,
value,
data,
operation,
/// Zero out the redundant transaction information only used for Safe multisig transctions.
0,
0,
0,
address(0),
payable(0),
"",
msg.sender
);
success = IAvatar(target).execTransactionFromModule(
to,
value,
data,
operation
);
IGuard(currentGuard).checkAfterExecution(bytes32(""), success);
} else {
success = IAvatar(target).execTransactionFromModule(
to,
value,
data,
operation
);
}
return success;
(success, ) = _exec(to, value, data, operation);
}

/// @dev Passes a transaction to be executed by the target and returns data.
Expand All @@ -93,6 +61,15 @@ abstract contract Module is FactoryFriendly, Guardable {
bytes memory data,
Enum.Operation operation
) internal returns (bool success, bytes memory returnData) {
(success, returnData) = _exec(to, value, data, operation);
}

function _exec(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation
) private returns (bool success, bytes memory returnData) {
address currentGuard = guard;
if (currentGuard != address(0)) {
IGuard(currentGuard).checkTransaction(
Expand All @@ -117,7 +94,7 @@ abstract contract Module is FactoryFriendly, Guardable {
data,
operation
);
IGuard(currentGuard).checkAfterExecution(bytes32(""), success);
IGuard(currentGuard).checkAfterExecution("", success);
} else {
(success, returnData) = IAvatar(target)
.execTransactionFromModuleReturnData(
Expand All @@ -127,6 +104,5 @@ abstract contract Module is FactoryFriendly, Guardable {
operation
);
}
return (success, returnData);
}
}

0 comments on commit ec9d7ca

Please sign in to comment.