-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making inheritance chain more compact
- Loading branch information
1 parent
8932de8
commit fbbf0f4
Showing
4 changed files
with
258 additions
and
193 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,87 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
pragma solidity >=0.7.0 <0.9.0; | ||
|
||
import "./BaseModifier.sol"; | ||
import "./GuardableModule.sol"; | ||
import "../guard/Guardable.sol"; | ||
import "./Modifier.sol"; | ||
|
||
abstract contract GuardableModifier is Module, Guardable, Modifier { | ||
/// @dev Passes a transaction to be executed by the avatar. | ||
/// @notice Can only be called by this contract. | ||
/// @param to Destination address of module transaction. | ||
/// @param value Ether value of module transaction. | ||
/// @param data Data payload of module transaction. | ||
/// @param operation Operation type of module transaction: 0 == call, 1 == delegate call. | ||
function exec( | ||
address to, | ||
uint256 value, | ||
bytes memory data, | ||
Enum.Operation operation | ||
) internal override 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 | ||
); | ||
if (currentGuard != address(0)) { | ||
IGuard(currentGuard).checkAfterExecution("", success); | ||
} | ||
} | ||
|
||
/// @dev Passes a transaction to be executed by the target and returns data. | ||
/// @notice Can only be called by this contract. | ||
/// @param to Destination address of module transaction. | ||
/// @param value Ether value of module transaction. | ||
/// @param data Data payload of module transaction. | ||
/// @param operation Operation type of module transaction: 0 == call, 1 == delegate call. | ||
function execAndReturnData( | ||
address to, | ||
uint256 value, | ||
bytes memory data, | ||
Enum.Operation operation | ||
) internal override returns (bool success, bytes memory returnData) { | ||
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, returnData) = IAvatar(target) | ||
.execTransactionFromModuleReturnData(to, value, data, operation); | ||
|
||
abstract contract GuardableModifier is GuardableModule, BaseModifier {} | ||
if (currentGuard != address(0)) { | ||
IGuard(currentGuard).checkAfterExecution("", success); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.