Skip to content

Commit

Permalink
Pass isInstalledContext to onInstall
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGuilding committed Jun 20, 2024
1 parent 50a2b77 commit aee7b4e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/modules/EmailRecoveryModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ abstract contract OwnableValidatorRecoveryBase is IntegrationBase {
address validatorAddress;

OwnableValidator validator;
bytes isInstalledContext;
bytes4 functionSelector;
bytes recoveryCalldata;
bytes32 calldataHash;
Expand All @@ -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
Expand All @@ -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
)
});
}
Expand Down
1 change: 1 addition & 0 deletions test/integration/SafeRecovery/SafeRecovery.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions test/unit/EmailRecoveryManager/configureRecovery.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ contract EmailRecoveryManager_configureRecovery_Test is UnitBase {
module: recoveryModuleAddress,
data: abi.encode(
validatorAddress,
isInstalledContext,
functionSelector,
guardians,
guardianWeights,
Expand Down
11 changes: 10 additions & 1 deletion test/unit/UnitBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ abstract contract UnitBase is RhinestoneModuleKit, Test {
address validatorAddress;

OwnableValidator validator;
bytes isInstalledContext;
bytes4 functionSelector;
bytes recoveryCalldata;
bytes32 calldataHash;
Expand Down Expand Up @@ -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
Expand All @@ -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
)
});
}
Expand Down
9 changes: 8 additions & 1 deletion test/unit/modules/EmailRecoveryModule/onInstall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
});

Expand Down

0 comments on commit aee7b4e

Please sign in to comment.