Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions lib/modulekit
Submodule modulekit added at 59e1c9
2 changes: 1 addition & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ forge-std/=node_modules/forge-std/src/
solady/=node_modules/solady/src/
solarray/=node_modules/solarray/src/
@prb/math/=node_modules/@prb/math/src/
ExcessivelySafeCall/=node_modules/excessively-safe-call/src/
ExcessivelySafeCall/=node_modules/excessively-safe-call/src/
8 changes: 4 additions & 4 deletions src/deployment/precompiles/Safe7579Precompiles.sol

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/module-bases/utils/ERC7579Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ uint256 constant MODULE_TYPE_HOOK = 4;
uint256 constant MODULE_TYPE_POLICY = 5;
uint256 constant MODULE_TYPE_SIGNER = 6;
uint256 constant MODULE_TYPE_STATELESS_VALIDATOR = 7;
uint256 constant MODULE_TYPE_PREVALIDATION_HOOK_ERC1271 = 8;
uint256 constant MODULE_TYPE_PREVALIDATION_HOOK_ERC4337 = 9;
88 changes: 81 additions & 7 deletions src/test/helpers/HelperBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
MODULE_TYPE_VALIDATOR,
MODULE_TYPE_EXECUTOR,
MODULE_TYPE_HOOK,
MODULE_TYPE_FALLBACK
MODULE_TYPE_FALLBACK,
MODULE_TYPE_PREVALIDATION_HOOK_ERC1271,
MODULE_TYPE_PREVALIDATION_HOOK_ERC4337
} from "../../accounts/common/interfaces/IERC7579Module.sol";
import { IERC1271, EIP1271_MAGIC_VALUE } from "../../Interfaces.sol";

Expand Down Expand Up @@ -197,7 +199,7 @@ abstract contract HelperBase {
data = initData;
}

/// @notice get callData to install executor on ERC7579 Account
/// @notice get callData to install executor on an ERC7579 Account
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to install the executor
function getInstallExecutorData(
Expand All @@ -213,7 +215,7 @@ abstract contract HelperBase {
data = initData;
}

/// @notice get callData to uninstall executor on ERC7579 Account
/// @notice get callData to uninstall executor on an ERC7579 Account
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to uninstall the executor
function getUninstallExecutorData(
Expand All @@ -229,7 +231,7 @@ abstract contract HelperBase {
data = initData;
}

/// @notice get callData to install hook on ERC7579 Account
/// @notice get callData to install hook on an ERC7579 Account
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to install the hook
function getInstallHookData(
Expand All @@ -245,7 +247,7 @@ abstract contract HelperBase {
data = initData;
}

/// @notice get callData to uninstall hook on ERC7579 Account
/// @notice get callData to uninstall hook on an ERC7579 Account
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to uninstall the hook
function getUninstallHookData(
Expand All @@ -261,7 +263,7 @@ abstract contract HelperBase {
data = initData;
}

/// @notice get callData to install fallback on ERC7579 Account
/// @notice get callData to install fallback on an ERC7579 Account
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to install the fallback
function getInstallFallbackData(
Expand All @@ -277,7 +279,7 @@ abstract contract HelperBase {
data = initData;
}

/// @notice get callData to uninstall fallback on ERC7579 Account
/// @notice get callData to uninstall fallback on an ERC7579 Account
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to uninstall the fallback
function getUninstallFallbackData(
Expand All @@ -293,6 +295,70 @@ abstract contract HelperBase {
data = initData;
}

/// @notice get callData to install an ERC1271 prevalidation hook
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to install the prevalidation hook ERC1271
function getInstallPrevalidationHookERC1271Data(
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
view
virtual
returns (bytes memory data)
{
data = initData;
}

/// @notice get callData to install an ERC4337 prevalidation hook ERC4337
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to install the prevalidation hook ERC4337
function getInstallPrevalidationHookERC4337Data(
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
view
virtual
returns (bytes memory data)
{
data = initData;
}

/// @notice get callData to uninstall an ERC1271 prevalidation hook
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to uninstall the prevalidation hook ERC1271
function getUninstallPrevalidationHookERC1271Data(
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
view
virtual
returns (bytes memory data)
{
data = initData;
}

/// @notice get callData to uninstall an ERC4337 prevalidation hook
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to uninstall the prevalidation hook ERC4337
function getUninstallPrevalidationHookERC4337Data(
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
view
virtual
returns (bytes memory data)
{
data = initData;
}

/*//////////////////////////////////////////////////////////////////////////
MODULE UTILS
//////////////////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -362,6 +428,10 @@ abstract contract HelperBase {
return getInstallHookData(instance, module, initData);
} else if (moduleType == MODULE_TYPE_FALLBACK) {
return getInstallFallbackData(instance, module, initData);
} else if (moduleType == MODULE_TYPE_PREVALIDATION_HOOK_ERC1271) {
return getInstallPrevalidationHookERC1271Data(instance, module, initData);
} else if (moduleType == MODULE_TYPE_PREVALIDATION_HOOK_ERC4337) {
return getInstallPrevalidationHookERC4337Data(instance, module, initData);
} else {
revert("Invalid module type");
}
Expand Down Expand Up @@ -392,6 +462,10 @@ abstract contract HelperBase {
return getUninstallHookData(instance, module, initData);
} else if (moduleType == MODULE_TYPE_FALLBACK) {
return getUninstallFallbackData(instance, module, initData);
} else if (moduleType == MODULE_TYPE_PREVALIDATION_HOOK_ERC1271) {
return getUninstallPrevalidationHookERC1271Data(instance, module, initData);
} else if (moduleType == MODULE_TYPE_PREVALIDATION_HOOK_ERC4337) {
return getUninstallPrevalidationHookERC4337Data(instance, module, initData);
} else {
revert("Invalid module type");
}
Expand Down
79 changes: 78 additions & 1 deletion src/test/helpers/SafeHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
MODULE_TYPE_HOOK,
MODULE_TYPE_VALIDATOR,
MODULE_TYPE_EXECUTOR,
MODULE_TYPE_FALLBACK
MODULE_TYPE_FALLBACK,
MODULE_TYPE_PREVALIDATION_HOOK_ERC1271,
MODULE_TYPE_PREVALIDATION_HOOK_ERC4337
} from "../../accounts/common/interfaces/IERC7579Module.sol";
import { HookType } from "../../accounts/safe/types/DataTypes.sol";
import { CALLTYPE_STATIC } from "../../accounts/common/lib/ModeLib.sol";
Expand Down Expand Up @@ -271,6 +273,74 @@ contract SafeHelpers is HelperBase {
data = abi.encode(selector, _initData);
}

/// @notice get callData to install an ERC1271 prevalidation hook
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to install the prevalidation hook ERC1271
function getInstallPrevalidationHookERC1271Data(
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
view
virtual
override
returns (bytes memory data)
{
data = abi.encode(MODULE_TYPE_PREVALIDATION_HOOK_ERC1271, initData);
}

/// @notice get callData to install an ERC4337 prevalidation hook ERC4337
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to install the prevalidation hook ERC4337
function getInstallPrevalidationHookERC4337Data(
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
view
virtual
override
returns (bytes memory data)
{
data = abi.encode(MODULE_TYPE_PREVALIDATION_HOOK_ERC4337, initData);
}

/// @notice get callData to uninstall an ERC1271 prevalidation hook
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to uninstall the prevalidation hook ERC1271
function getUninstallPrevalidationHookERC1271Data(
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
view
virtual
override
returns (bytes memory data)
{
data = abi.encode(MODULE_TYPE_PREVALIDATION_HOOK_ERC1271, initData);
}

/// @notice get callData to uninstall an ERC4337 prevalidation hook
/// @param initData bytes the data to pass to the module
/// @return data bytes the callData to uninstall the prevalidation hook ERC4337
function getUninstallPrevalidationHookERC4337Data(
AccountInstance memory, // instance
address, // module
bytes memory initData
)
public
view
virtual
override
returns (bytes memory data)
{
data = abi.encode(MODULE_TYPE_PREVALIDATION_HOOK_ERC4337, initData);
}

/// @notice Checks if a module is installed on an account instance
/// @param instance AccountInstance the account instance to check
/// @param moduleTypeId uint256 the type of the module
Expand All @@ -293,6 +363,13 @@ contract SafeHelpers is HelperBase {
data = abi.encode(HookType.GLOBAL, bytes4(0x0), data);
}

if (
moduleTypeId == MODULE_TYPE_PREVALIDATION_HOOK_ERC4337
|| moduleTypeId == MODULE_TYPE_PREVALIDATION_HOOK_ERC1271
) {
data = abi.encode(moduleTypeId, data);
}

return IERC7579Account(instance.account).isModuleInstalled(moduleTypeId, module, data);
}

Expand Down
Loading