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

Remove-duplicate-exec-code #130

Merged
merged 2 commits into from
Jul 24, 2023
Merged
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
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);
}
}