From c966afd4278600a8ed27e4493b18ca1f109a9672 Mon Sep 17 00:00:00 2001 From: highskore Date: Mon, 4 Nov 2024 05:42:56 +0100 Subject: [PATCH] chore: resolve solc warnings --- src/deployment/RegistryDeployer.sol | 2 +- src/test/ModuleKitHelpers.sol | 71 ++++++--------------- src/test/helpers/ERC7579Helpers.sol | 10 +-- src/test/helpers/HelperBase.sol | 99 ++++++++++------------------- src/test/helpers/KernelHelpers.sol | 16 ++--- src/test/helpers/NexusHelpers.sol | 40 ++++-------- src/test/helpers/SafeHelpers.sol | 14 ++-- test/Diff.t.sol | 4 +- test/RegistryDeployer.t.sol | 10 ++- test/mocks/MockValidatorFalse.sol | 20 ++++-- 10 files changed, 109 insertions(+), 177 deletions(-) diff --git a/src/deployment/RegistryDeployer.sol b/src/deployment/RegistryDeployer.sol index 22aa5ed9..9fe02ddb 100644 --- a/src/deployment/RegistryDeployer.sol +++ b/src/deployment/RegistryDeployer.sol @@ -188,7 +188,7 @@ contract RegistryDeployer { } // <---- OTHER ----> - function isContract(address _addr) internal returns (bool isContract) { + function isContract(address _addr) internal view returns (bool _isContract) { uint32 size; assembly { size := extcodesize(_addr) diff --git a/src/test/ModuleKitHelpers.sol b/src/test/ModuleKitHelpers.sol index 3d940cbe..de6ec950 100644 --- a/src/test/ModuleKitHelpers.sol +++ b/src/test/ModuleKitHelpers.sol @@ -96,11 +96,8 @@ library ModuleKitHelpers { { bytes memory erc7579ExecCall = HelperBase(instance.accountHelper).encode(target, value, callData); - (userOpData.userOp, userOpData.userOpHash) = HelperBase(instance.accountHelper).execUserOp({ - instance: instance, - callData: erc7579ExecCall, - txValidator: txValidator - }); + (userOpData.userOp, userOpData.userOpHash) = + HelperBase(instance.accountHelper).execUserOp(instance, erc7579ExecCall, txValidator); userOpData.entrypoint = instance.aux.entrypoint; } @@ -113,11 +110,8 @@ library ModuleKitHelpers { returns (UserOpData memory userOpData) { bytes memory erc7579ExecCall = HelperBase(instance.accountHelper).encode(executions); - (userOpData.userOp, userOpData.userOpHash) = HelperBase(instance.accountHelper).execUserOp({ - instance: instance, - callData: erc7579ExecCall, - txValidator: txValidator - }); + (userOpData.userOp, userOpData.userOpHash) = + HelperBase(instance.accountHelper).execUserOp(instance, erc7579ExecCall, txValidator); userOpData.entrypoint = instance.aux.entrypoint; } @@ -286,14 +280,7 @@ library ModuleKitHelpers { { // get userOp with correct nonce for selected txValidator (userOpData.userOp, userOpData.userOpHash) = HelperBase(instance.accountHelper) - .configModuleUserOp({ - instance: instance, - moduleType: moduleType, - module: module, - initData: initData, - isInstall: true, - txValidator: txValidator - }); + .configModuleUserOp(instance, moduleType, module, initData, true, txValidator); userOpData.entrypoint = instance.aux.entrypoint; } @@ -309,14 +296,7 @@ library ModuleKitHelpers { { // get userOp with correct nonce for selected txValidator (userOpData.userOp, userOpData.userOpHash) = HelperBase(instance.accountHelper) - .configModuleUserOp({ - instance: instance, - moduleType: moduleType, - module: module, - initData: initData, - isInstall: false, - txValidator: txValidator - }); + .configModuleUserOp(instance, moduleType, module, initData, false, txValidator); userOpData.entrypoint = instance.aux.entrypoint; } @@ -654,12 +634,9 @@ library ModuleKitHelpers { internal returns (bool) { - return HelperBase(instance.accountHelper).isValidSignature({ - instance: instance, - validator: validator, - hash: hash, - signature: signature - }); + return HelperBase(instance.accountHelper).isValidSignature( + instance, validator, hash, signature + ); } function formatERC1271Hash( @@ -670,11 +647,7 @@ library ModuleKitHelpers { internal returns (bytes32) { - return HelperBase(instance.accountHelper).formatERC1271Hash({ - instance: instance, - validator: validator, - hash: hash - }); + return HelperBase(instance.accountHelper).formatERC1271Hash(instance, validator, hash); } function formatERC1271Signature( @@ -685,11 +658,9 @@ library ModuleKitHelpers { internal returns (bytes memory) { - return HelperBase(instance.accountHelper).formatERC1271Signature({ - instance: instance, - validator: validator, - signature: signature - }); + return HelperBase(instance.accountHelper).formatERC1271Signature( + instance, validator, signature + ); } function signDefault(UserOpData memory userOpData) internal pure returns (UserOpData memory) { @@ -753,14 +724,14 @@ library ModuleKitHelpers { instance.installModule(1, address(instance.smartSession), ""); } // Setup session data - Session memory session = Session({ - sessionValidator: ISessionValidator(address(instance.defaultSessionValidator)), - salt: salt, - sessionValidatorInitData: "mockInitData", - userOpPolicies: userOpPolicies, - erc7739Policies: erc7739Policy, - actions: actionDatas - }); + Session memory session = Session( + ISessionValidator(address(instance.defaultSessionValidator)), + "mockInitData", + salt, + userOpPolicies, + erc7739Policy, + actionDatas + ); // Enable session return instance.addSession(session); } diff --git a/src/test/helpers/ERC7579Helpers.sol b/src/test/helpers/ERC7579Helpers.sol index cc0eae60..f3e9c41e 100644 --- a/src/test/helpers/ERC7579Helpers.sol +++ b/src/test/helpers/ERC7579Helpers.sol @@ -81,8 +81,8 @@ contract ERC7579Helpers is HelperBase { * get callData to install fallback on ERC7579 Account */ function getInstallFallbackData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -100,8 +100,8 @@ contract ERC7579Helpers is HelperBase { * get callData to uninstall fallback on ERC7579 Account */ function getUninstallFallbackData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -136,7 +136,7 @@ contract ERC7579Helpers is HelperBase { } function formatERC1271Signature( - AccountInstance memory instance, + AccountInstance memory, // instance address validator, bytes memory signature ) diff --git a/src/test/helpers/HelperBase.sol b/src/test/helpers/HelperBase.sol index b2f560c6..32eb6e9d 100644 --- a/src/test/helpers/HelperBase.sol +++ b/src/test/helpers/HelperBase.sol @@ -66,31 +66,11 @@ abstract contract HelperBase { } bytes memory callData; if (isInstall) { - initData = getInstallModuleData({ - instance: instance, - moduleType: moduleType, - module: module, - initData: initData - }); - callData = getInstallModuleCallData({ - instance: instance, - moduleType: moduleType, - module: module, - initData: initData - }); + initData = getInstallModuleData(instance, moduleType, module, initData); + callData = getInstallModuleCallData(instance, moduleType, module, initData); } else { - initData = getUninstallModuleData({ - instance: instance, - moduleType: moduleType, - module: module, - initData: initData - }); - callData = getUninstallModuleCallData({ - instance: instance, - moduleType: moduleType, - module: module, - initData: initData - }); + initData = getUninstallModuleData(instance, moduleType, module, initData); + callData = getUninstallModuleCallData(instance, moduleType, module, initData); } userOp = PackedUserOperation({ @@ -109,7 +89,7 @@ abstract contract HelperBase { } function getInstallModuleCallData( - AccountInstance memory instance, + AccountInstance memory, // instance uint256 moduleType, address module, bytes memory initData @@ -123,7 +103,7 @@ abstract contract HelperBase { } function getUninstallModuleCallData( - AccountInstance memory instance, + AccountInstance memory, // instance uint256 moduleType, address module, bytes memory initData @@ -140,8 +120,8 @@ abstract contract HelperBase { * get callData to install validator on ERC7579 Account */ function getInstallValidatorData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -156,8 +136,8 @@ abstract contract HelperBase { * get callData to uninstall validator on ERC7579 Account */ function getUninstallValidatorData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -172,8 +152,8 @@ abstract contract HelperBase { * get callData to install executor on ERC7579 Account */ function getInstallExecutorData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -188,8 +168,8 @@ abstract contract HelperBase { * get callData to uninstall executor on ERC7579 Account */ function getUninstallExecutorData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -204,8 +184,8 @@ abstract contract HelperBase { * get callData to install hook on ERC7579 Account */ function getInstallHookData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -220,8 +200,8 @@ abstract contract HelperBase { * get callData to uninstall hook on ERC7579 Account */ function getUninstallHookData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -236,8 +216,8 @@ abstract contract HelperBase { * get callData to install fallback on ERC7579 Account */ function getInstallFallbackData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -252,8 +232,8 @@ abstract contract HelperBase { * get callData to uninstall fallback on ERC7579 Account */ function getUninstallFallbackData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -305,16 +285,13 @@ abstract contract HelperBase { returns (bytes memory) { if (moduleType == MODULE_TYPE_VALIDATOR) { - return - getInstallValidatorData({ instance: instance, module: module, initData: initData }); + return getInstallValidatorData(instance, module, initData); } else if (moduleType == MODULE_TYPE_EXECUTOR) { - return - getInstallExecutorData({ instance: instance, module: module, initData: initData }); + return getInstallExecutorData(instance, module, initData); } else if (moduleType == MODULE_TYPE_HOOK) { - return getInstallHookData({ instance: instance, module: module, initData: initData }); + return getInstallHookData(instance, module, initData); } else if (moduleType == MODULE_TYPE_FALLBACK) { - return - getInstallFallbackData({ instance: instance, module: module, initData: initData }); + return getInstallFallbackData(instance, module, initData); } else { revert("Invalid module type"); } @@ -332,19 +309,13 @@ abstract contract HelperBase { returns (bytes memory) { if (moduleType == MODULE_TYPE_VALIDATOR) { - return getUninstallValidatorData({ - instance: instance, - module: module, - initData: initData - }); + return getUninstallValidatorData(instance, module, initData); } else if (moduleType == MODULE_TYPE_EXECUTOR) { - return - getUninstallExecutorData({ instance: instance, module: module, initData: initData }); + return getUninstallExecutorData(instance, module, initData); } else if (moduleType == MODULE_TYPE_HOOK) { - return getUninstallHookData({ instance: instance, module: module, initData: initData }); + return getUninstallHookData(instance, module, initData); } else if (moduleType == MODULE_TYPE_FALLBACK) { - return - getUninstallFallbackData({ instance: instance, module: module, initData: initData }); + return getUninstallFallbackData(instance, module, initData); } else { revert("Invalid module type"); } @@ -356,7 +327,7 @@ abstract contract HelperBase { function isValidSignature( AccountInstance memory instance, - address validator, + address, // validator bytes32 hash, bytes memory signature ) @@ -370,8 +341,8 @@ abstract contract HelperBase { } function formatERC1271Hash( - AccountInstance memory instance, - address validator, + AccountInstance memory, // instance + address, //validator bytes32 hash ) public @@ -382,8 +353,8 @@ abstract contract HelperBase { } function formatERC1271Signature( - AccountInstance memory instance, - address validator, + AccountInstance memory, // instance + address, // validator bytes memory signature ) public diff --git a/src/test/helpers/KernelHelpers.sol b/src/test/helpers/KernelHelpers.sol index 8e83838a..94a15fda 100644 --- a/src/test/helpers/KernelHelpers.sol +++ b/src/test/helpers/KernelHelpers.sol @@ -186,8 +186,6 @@ contract KernelHelpers is HelperBase { }); } - uint256 nonce = getNonce(instance, callData, txValidator); - address execHook = getExecHook(instance, txValidator); if (execHook != address(0) && execHook != address(1)) { callData = abi.encodePacked(Kernel.executeUserOp.selector, callData); @@ -237,7 +235,7 @@ contract KernelHelpers is HelperBase { */ function getInstallValidatorData( AccountInstance memory instance, - address module, + address, // module bytes memory initData ) public @@ -257,7 +255,7 @@ contract KernelHelpers is HelperBase { */ function getInstallExecutorData( AccountInstance memory instance, - address module, + address, // module bytes memory initData ) public @@ -277,7 +275,7 @@ contract KernelHelpers is HelperBase { */ function getInstallFallbackData( AccountInstance memory instance, - address module, + address, // module bytes memory initData ) public @@ -300,8 +298,8 @@ contract KernelHelpers is HelperBase { * https://github.com/zerodevapp/kernel/blob/a807c8ec354a77ebb7cdb73c5be9dd315cda0df2/src/Kernel.sol#L402-L403 */ function getUninstallFallbackData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -432,7 +430,7 @@ contract KernelHelpers is HelperBase { function formatERC1271Hash( AccountInstance memory instance, - address validator, + address, // validator bytes32 hash ) public @@ -445,7 +443,7 @@ contract KernelHelpers is HelperBase { } function formatERC1271Signature( - AccountInstance memory instance, + AccountInstance memory, // instance address validator, bytes memory signature ) diff --git a/src/test/helpers/NexusHelpers.sol b/src/test/helpers/NexusHelpers.sol index 20539407..85e35593 100644 --- a/src/test/helpers/NexusHelpers.sol +++ b/src/test/helpers/NexusHelpers.sol @@ -19,6 +19,7 @@ contract NexusHelpers is HelperBase { address txValidator ) public + view override returns (PackedUserOperation memory userOp, bytes32 userOpHash) { @@ -52,6 +53,7 @@ contract NexusHelpers is HelperBase { address txValidator ) public + view override returns (PackedUserOperation memory userOp, bytes32 userOpHash) { @@ -61,31 +63,11 @@ contract NexusHelpers is HelperBase { } bytes memory callData; if (isInstall) { - initData = getInstallModuleData({ - instance: instance, - moduleType: moduleType, - module: module, - initData: initData - }); - callData = getInstallModuleCallData({ - instance: instance, - moduleType: moduleType, - module: module, - initData: initData - }); + initData = getInstallModuleData(instance, moduleType, module, initData); + callData = getInstallModuleCallData(instance, moduleType, module, initData); } else { - initData = getUninstallModuleData({ - instance: instance, - moduleType: moduleType, - module: module, - initData: initData - }); - callData = getUninstallModuleCallData({ - instance: instance, - moduleType: moduleType, - module: module, - initData: initData - }); + initData = getUninstallModuleData(instance, moduleType, module, initData); + callData = getUninstallModuleCallData(instance, moduleType, module, initData); } userOp = PackedUserOperation({ @@ -194,8 +176,8 @@ contract NexusHelpers is HelperBase { * get callData to install fallback on ERC7579 Account */ function getInstallFallbackData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -213,8 +195,8 @@ contract NexusHelpers is HelperBase { * get callData to uninstall fallback on ERC7579 Account */ function getUninstallFallbackData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -249,7 +231,7 @@ contract NexusHelpers is HelperBase { } function formatERC1271Signature( - AccountInstance memory instance, + AccountInstance memory, // instance address validator, bytes memory signature ) diff --git a/src/test/helpers/SafeHelpers.sol b/src/test/helpers/SafeHelpers.sol index 8e485f0e..82ae9474 100644 --- a/src/test/helpers/SafeHelpers.sol +++ b/src/test/helpers/SafeHelpers.sol @@ -133,8 +133,8 @@ contract SafeHelpers is HelperBase { * get callData to install hook on ERC7579 Account */ function getInstallHookData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -150,8 +150,8 @@ contract SafeHelpers is HelperBase { * get callData to uninstall hook on ERC7579 Account */ function getUninstallHookData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -167,8 +167,8 @@ contract SafeHelpers is HelperBase { * get callData to uninstall fallback on ERC7579 Account */ function getUninstallFallbackData( - AccountInstance memory instance, - address module, + AccountInstance memory, // instance + address, // module bytes memory initData ) public @@ -279,7 +279,7 @@ contract SafeHelpers is HelperBase { } function formatERC1271Signature( - AccountInstance memory instance, + AccountInstance memory, // instance address validator, bytes memory signature ) diff --git a/test/Diff.t.sol b/test/Diff.t.sol index 44155c7b..0355db39 100644 --- a/test/Diff.t.sol +++ b/test/Diff.t.sol @@ -525,8 +525,6 @@ contract ERC7579DifferentialModuleKitLibTest is BaseTest { function testERC1271() public { bytes32 unformattedHash = keccak256("test"); - bytes32 hash = - instance.formatERC1271Hash(address(instance.defaultValidator), unformattedHash); bool isValid = instance.isValidSignature({ validator: address(instance.defaultValidator), @@ -636,7 +634,7 @@ contract ERC7579DifferentialModuleKitLibTest is BaseTest { // Set simulate mode to false instance.simulateUserOp(false); // Install a module - address module = address(new MockK1Validator()); + module = address(new MockK1Validator()); // Start state diff recording instance.startStateDiffRecording(); instance.installModule({ diff --git a/test/RegistryDeployer.t.sol b/test/RegistryDeployer.t.sol index 5fecdc3d..5fe8cdb3 100644 --- a/test/RegistryDeployer.t.sol +++ b/test/RegistryDeployer.t.sol @@ -182,7 +182,7 @@ contract RegistryDeployerTest is RegistryDeployer, BaseTest { return address(new MockValidator{ salt: salt }()); } - function predictAddress(bytes32 salt) public returns (address) { + function predictAddress(bytes32 salt) public view returns (address) { bytes32 hash = keccak256( abi.encodePacked( bytes1(0xff), address(this), salt, keccak256(type(MockValidator).creationCode) @@ -191,7 +191,13 @@ contract RegistryDeployerTest is RegistryDeployer, BaseTest { return address(uint160(uint256(hash))); } - function supportsInterface(bytes4 interfaceID) external view returns (bool) { + function supportsInterface( + bytes4 // interfaceID + ) + external + pure + returns (bool) + { return true; } } diff --git a/test/mocks/MockValidatorFalse.sol b/test/mocks/MockValidatorFalse.sol index 94a3a91d..ac287f0f 100644 --- a/test/mocks/MockValidatorFalse.sol +++ b/test/mocks/MockValidatorFalse.sol @@ -11,8 +11,8 @@ contract MockValidatorFalse is ERC7579ValidatorBase { function onUninstall(bytes calldata data) external virtual override { } function validateUserOp( - PackedUserOperation calldata userOp, - bytes32 userOpHash + PackedUserOperation calldata, // userOp + bytes32 // userOpHash ) external virtual @@ -23,9 +23,9 @@ contract MockValidatorFalse is ERC7579ValidatorBase { } function isValidSignatureWithSender( - address sender, - bytes32 hash, - bytes calldata data + address, // sender + bytes32, // hash + bytes calldata // signature ) external view @@ -40,7 +40,13 @@ contract MockValidatorFalse is ERC7579ValidatorBase { return typeID == TYPE_VALIDATOR; } - function isInitialized(address smartAccount) external pure returns (bool) { + function isInitialized( + address // smartAccount + ) + external + pure + returns (bool) + { return false; } @@ -50,7 +56,7 @@ contract MockValidatorFalse is ERC7579ValidatorBase { bytes calldata ) external - view + pure override returns (bool validSig) {