From aee7b4e7792fb470f7eb4e9138de0323fea198a9 Mon Sep 17 00:00:00 2001 From: JohnGuilding Date: Thu, 20 Jun 2024 16:50:09 +0100 Subject: [PATCH] Pass isInstalledContext to onInstall --- src/modules/EmailRecoveryModule.sol | 8 +++++--- .../OwnableValidatorRecoveryBase.t.sol | 11 ++++++++++- test/integration/SafeRecovery/SafeRecovery.t.sol | 1 + .../unit/EmailRecoveryManager/configureRecovery.t.sol | 1 + test/unit/UnitBase.t.sol | 11 ++++++++++- test/unit/modules/EmailRecoveryModule/onInstall.t.sol | 9 ++++++++- 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/modules/EmailRecoveryModule.sol b/src/modules/EmailRecoveryModule.sol index 91f29527..d7ad724f 100644 --- a/src/modules/EmailRecoveryModule.sol +++ b/src/modules/EmailRecoveryModule.sol @@ -66,16 +66,18 @@ contract EmailRecoveryModule is ERC7579ExecutorBase, IRecoveryModule { if (data.length == 0) revert InvalidOnInstallData(); ( address validator, + bytes memory isInstalledContext, bytes4 initialSelector, address[] memory guardians, uint256[] memory weights, uint256 threshold, uint256 delay, uint256 expiry - ) = abi.decode(data, (address, bytes4, address[], uint256[], uint256, uint256, uint256)); + ) = abi.decode( + data, (address, bytes, bytes4, address[], uint256[], uint256, uint256, uint256) + ); - // TODO: Should isInstalledContext be passed in? - allowValidatorRecovery(validator, bytes("0"), initialSelector); + allowValidatorRecovery(validator, isInstalledContext, initialSelector); _execute({ to: emailRecoveryManager, diff --git a/test/integration/OwnableValidatorRecovery/OwnableValidatorRecoveryBase.t.sol b/test/integration/OwnableValidatorRecovery/OwnableValidatorRecoveryBase.t.sol index 685b0f9e..18702a97 100644 --- a/test/integration/OwnableValidatorRecovery/OwnableValidatorRecoveryBase.t.sol +++ b/test/integration/OwnableValidatorRecovery/OwnableValidatorRecoveryBase.t.sol @@ -28,6 +28,7 @@ abstract contract OwnableValidatorRecoveryBase is IntegrationBase { address validatorAddress; OwnableValidator validator; + bytes isInstalledContext; bytes4 functionSelector; bytes recoveryCalldata; bytes32 calldataHash; @@ -51,6 +52,7 @@ abstract contract OwnableValidatorRecoveryBase is IntegrationBase { // Deploy validator to be recovered validator = new OwnableValidator(); validatorAddress = address(validator); + isInstalledContext = bytes("0"); functionSelector = bytes4(keccak256(bytes("changeOwner(address,address,address)"))); recoveryCalldata = abi.encodeWithSignature( "changeOwner(address,address,address)", accountAddress, recoveryModuleAddress, newOwner @@ -77,7 +79,14 @@ abstract contract OwnableValidatorRecoveryBase is IntegrationBase { moduleTypeId: MODULE_TYPE_EXECUTOR, module: recoveryModuleAddress, data: abi.encode( - validatorAddress, functionSelector, guardians, guardianWeights, threshold, delay, expiry + validatorAddress, + isInstalledContext, + functionSelector, + guardians, + guardianWeights, + threshold, + delay, + expiry ) }); } diff --git a/test/integration/SafeRecovery/SafeRecovery.t.sol b/test/integration/SafeRecovery/SafeRecovery.t.sol index a425b798..62ecb9d4 100644 --- a/test/integration/SafeRecovery/SafeRecovery.t.sol +++ b/test/integration/SafeRecovery/SafeRecovery.t.sol @@ -33,6 +33,7 @@ contract SafeRecovery_Integration_Test is SafeIntegrationBase { // module: recoveryModuleAddress, // data: abi.encode( // address(safe), // FIXME: requires rhinestone change + // isInstalledContext, // functionSelector, // guardians, // guardianWeights, diff --git a/test/unit/EmailRecoveryManager/configureRecovery.t.sol b/test/unit/EmailRecoveryManager/configureRecovery.t.sol index 925c1af7..4c3da33a 100644 --- a/test/unit/EmailRecoveryManager/configureRecovery.t.sol +++ b/test/unit/EmailRecoveryManager/configureRecovery.t.sol @@ -55,6 +55,7 @@ contract EmailRecoveryManager_configureRecovery_Test is UnitBase { module: recoveryModuleAddress, data: abi.encode( validatorAddress, + isInstalledContext, functionSelector, guardians, guardianWeights, diff --git a/test/unit/UnitBase.t.sol b/test/unit/UnitBase.t.sol index d9dd96ba..c4fdf6c5 100644 --- a/test/unit/UnitBase.t.sol +++ b/test/unit/UnitBase.t.sol @@ -51,6 +51,7 @@ abstract contract UnitBase is RhinestoneModuleKit, Test { address validatorAddress; OwnableValidator validator; + bytes isInstalledContext; bytes4 functionSelector; bytes recoveryCalldata; bytes32 calldataHash; @@ -155,6 +156,7 @@ abstract contract UnitBase is RhinestoneModuleKit, Test { // Deploy validator to be recovered validator = new OwnableValidator(); validatorAddress = address(validator); + isInstalledContext = bytes("0"); functionSelector = bytes4(keccak256(bytes("changeOwner(address,address,address)"))); recoveryCalldata = abi.encodeWithSignature( "changeOwner(address,address,address)", accountAddress, recoveryModuleAddress, newOwner @@ -171,7 +173,14 @@ abstract contract UnitBase is RhinestoneModuleKit, Test { moduleTypeId: MODULE_TYPE_EXECUTOR, module: recoveryModuleAddress, data: abi.encode( - validatorAddress, functionSelector, guardians, guardianWeights, threshold, delay, expiry + validatorAddress, + isInstalledContext, + functionSelector, + guardians, + guardianWeights, + threshold, + delay, + expiry ) }); } diff --git a/test/unit/modules/EmailRecoveryModule/onInstall.t.sol b/test/unit/modules/EmailRecoveryModule/onInstall.t.sol index fff8d855..42ba8be5 100644 --- a/test/unit/modules/EmailRecoveryModule/onInstall.t.sol +++ b/test/unit/modules/EmailRecoveryModule/onInstall.t.sol @@ -39,7 +39,14 @@ contract EmailRecoveryModule_onInstall_Test is UnitBase { moduleTypeId: MODULE_TYPE_EXECUTOR, module: recoveryModuleAddress, data: abi.encode( - validatorAddress, functionSelector, guardians, guardianWeights, threshold, delay, expiry + validatorAddress, + isInstalledContext, + functionSelector, + guardians, + guardianWeights, + threshold, + delay, + expiry ) });