From 6a0c4bae2edf3f5e76c12e209c6ab42e68b2c3b0 Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 4 Jul 2023 14:54:00 +0200 Subject: [PATCH] Temp: User local variable safeAddress --- contracts/SafeProtocolMediator.sol | 29 ++++++++++++++++------------- contracts/interfaces/Mediator.sol | 4 ++-- contracts/test/TestModule.sol | 4 ++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/contracts/SafeProtocolMediator.sol b/contracts/SafeProtocolMediator.sol index b7e070ec..080604c3 100644 --- a/contracts/SafeProtocolMediator.sol +++ b/contracts/SafeProtocolMediator.sol @@ -58,20 +58,21 @@ contract SafeProtocolMediator is ISafeProtocolMediator { /** * @notice This function executes non-delegate call(s) on a safe if the module is enabled on the Safe. * If any one of the actions fail, the transaction reverts. - * @param safe Address of the Safe instance + * @param safe A Safe instance * @param transaction A struct of type SafeTransaction containing information of about the action(s) to be executed. * Users can add logic to validate metahash through a transaction guard. * @return data bytes types containing the result of the executed action. */ function executeTransaction( - address safe, + ISafe safe, SafeTransaction calldata transaction - ) external override onlyEnabledModule(safe) returns (bytes[] memory data) { + ) external override onlyEnabledModule(address(safe)) returns (bytes[] memory data) { + address safeAddress = address(safe); data = new bytes[](transaction.actions.length); uint256 length = transaction.actions.length; for (uint256 i = 0; i < length; ++i) { SafeProtocolAction calldata safeProtocolAction = transaction.actions[i]; - (bool isActionSuccessful, bytes memory resultData) = ISafe(safe).execTransactionFromModuleReturnData( + (bool isActionSuccessful, bytes memory resultData) = safe.execTransactionFromModuleReturnData( safeProtocolAction.to, safeProtocolAction.value, safeProtocolAction.data, @@ -80,44 +81,46 @@ contract SafeProtocolMediator is ISafeProtocolMediator { // Even if one action fails, revert the transaction. if (!isActionSuccessful) { - revert ActionExecutionFailed(safe, transaction.metaHash, i); + revert ActionExecutionFailed(safeAddress, transaction.metaHash, i); } else { data[i] = resultData; } } - emit ActionsExecuted(safe, transaction.metaHash, transaction.nonce); + emit ActionsExecuted(safeAddress, transaction.metaHash, transaction.nonce); } /** * @notice This function executes a delegate call on a safe if the module is enabled and * root access it granted. - * @param safe Address of the Safe instance + * @param safe A Safe instance * @param rootAccess A struct of type SafeRootAccess containing information of about the action to be executed. * Users can add logic to validate metahash through a transaction guard. * @return data bytes types containing the result of the executed action. */ function executeRootAccess( - address safe, + ISafe safe, SafeRootAccess calldata rootAccess - ) external override onlyEnabledModule(safe) returns (bytes memory data) { + ) external override onlyEnabledModule(address(safe)) returns (bytes memory data) { + address safeAddress = address(safe); + SafeProtocolAction calldata safeProtocolAction = rootAccess.action; - if (!ISafeProtocolModule(msg.sender).requiresRootAccess() || !enabledModules[safe][msg.sender].rootAddressGranted) { + if (!ISafeProtocolModule(msg.sender).requiresRootAccess() || !enabledModules[safeAddress][msg.sender].rootAddressGranted) { revert ModuleRequiresRootAccess(msg.sender); } bool success; - (success, data) = ISafe(safe).execTransactionFromModuleReturnData( + (success, data) = safe.execTransactionFromModuleReturnData( safeProtocolAction.to, safeProtocolAction.value, safeProtocolAction.data, 1 ); if (success) { - emit RootAccessActionExecuted(safe, rootAccess.metaHash); + emit RootAccessActionExecuted(safeAddress, rootAccess.metaHash); } else { - revert RootAccessActionExecutionFailed(safe, rootAccess.metaHash); + revert RootAccessActionExecutionFailed(safeAddress, rootAccess.metaHash); } } diff --git a/contracts/interfaces/Mediator.sol b/contracts/interfaces/Mediator.sol index 64cc073e..cefc3080 100644 --- a/contracts/interfaces/Mediator.sol +++ b/contracts/interfaces/Mediator.sol @@ -18,7 +18,7 @@ interface ISafeProtocolMediator { * @return data Array of bytes types returned upon the successful execution of all the actions. The size of the array will be the same as the size of the actions * in case of succcessful execution. Empty if the call failed. */ - function executeTransaction(address safe, SafeTransaction calldata transaction) external returns (bytes[] memory data); + function executeTransaction(ISafe safe, SafeTransaction calldata transaction) external returns (bytes[] memory data); /** * @notice This function allows enabled modules to execute delegate call transactions thorugh a Safe. @@ -28,5 +28,5 @@ interface ISafeProtocolMediator { * @return data Arbitrary length bytes data returned upon the successful execution. The size of the array will be the same as the size of the actions * in case of succcessful execution. Empty if the call failed. */ - function executeRootAccess(address safe, SafeRootAccess calldata rootAccess) external returns (bytes memory data); + function executeRootAccess(ISafe safe, SafeRootAccess calldata rootAccess) external returns (bytes memory data); } diff --git a/contracts/test/TestModule.sol b/contracts/test/TestModule.sol index e92f2530..4bff1099 100644 --- a/contracts/test/TestModule.sol +++ b/contracts/test/TestModule.sol @@ -24,7 +24,7 @@ contract TestModule is BaseTestModule { ISafe safe, SafeTransaction calldata safetx ) external returns (bytes[] memory data) { - (data) = mediator.executeTransaction(address(safe), safetx); + (data) = mediator.executeTransaction(safe, safetx); } } @@ -38,6 +38,6 @@ contract TestModuleWithRootAccess is BaseTestModule { ISafe safe, SafeRootAccess calldata safeRootAccesstx ) external returns (bytes memory data) { - (data) = mediator.executeRootAccess(address(safe), safeRootAccesstx); + (data) = mediator.executeRootAccess(safe, safeRootAccesstx); } }