Skip to content

Commit

Permalink
fix: pass correct deinitdata to fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
kopy-kat committed Apr 4, 2024
1 parent b122877 commit 579ea0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions accounts/safe7579/src/core/ModuleManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,14 @@ abstract contract ModuleManager is AccessControl, Receiver, ExecutionHelper {
return $fallback.handler != address(0);
}

function _uninstallFallbackHandler(address handler, bytes calldata initData) internal virtual {
(bytes4 functionSig) = abi.decode(initData, (bytes4));
function _uninstallFallbackHandler(
address handler,
bytes calldata deInitData
)
internal
virtual
{
bytes4 functionSig = bytes4(deInitData[0:4]);

ModuleManagerStorage storage $mms = $moduleManager[msg.sender];
$mms._fallbacks[functionSig].handler = address(0);
Expand All @@ -216,7 +222,7 @@ abstract contract ModuleManager is AccessControl, Receiver, ExecutionHelper {
safe: msg.sender,
target: handler,
value: 0,
callData: abi.encodeCall(IModule.onUninstall, (initData))
callData: abi.encodeWithSelector(IModule.onUninstall.selector, (deInitData[4:]))
});
}

Expand Down
2 changes: 1 addition & 1 deletion accounts/safe7579/test/SafeERC7579.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ contract Safe7579Test is TestBaseUtil {

vm.prank(address(safe));
IERC7579Account(address(safe)).uninstallModule(
3, address(_fallback), abi.encode(MockFallback.target.selector, CALLTYPE_SINGLE, "")
3, address(_fallback), abi.encodePacked(MockFallback.target.selector, "")
);
vm.prank(address(safe));
IERC7579Account(address(safe)).installModule(
Expand Down

0 comments on commit 579ea0b

Please sign in to comment.