diff --git a/script/Compute7579CalldataHash.s.sol b/script/Compute7579CalldataHash.s.sol index f91fde90..f112efe7 100644 --- a/script/Compute7579CalldataHash.s.sol +++ b/script/Compute7579CalldataHash.s.sol @@ -3,83 +3,16 @@ pragma solidity ^0.8.25; import { Script } from "forge-std/Script.sol"; import { console } from "forge-std/console.sol"; -import { EmailRecoverySubjectHandler } from "src/handlers/EmailRecoverySubjectHandler.sol"; -import { EmailRecoveryManager } from "src/EmailRecoveryManager.sol"; -import { Verifier } from "ether-email-auth/packages/contracts/src/utils/Verifier.sol"; -import { ECDSAOwnedDKIMRegistry } from - "ether-email-auth/packages/contracts/src/utils/ECDSAOwnedDKIMRegistry.sol"; -import { EmailAuth } from "ether-email-auth/packages/contracts/src/EmailAuth.sol"; -import { EmailRecoveryFactory } from "src/EmailRecoveryFactory.sol"; contract Compute7579CalldataHash is Script { - bytes4 functionSelector = bytes4(keccak256(bytes("changeOwner(address,address,address)"))); - function run() public { - address accountAddr = vm.envAddress("ACCOUNT"); - address recoveryModuleAddr = vm.envAddress("RECOVERY_MODULE"); + bytes4 functionSelector = bytes4(keccak256(bytes("changeOwner(address)"))); address newOwner = vm.envAddress("NEW_OWNER"); - bytes memory recoveryCalldata = - abi.encodeWithSelector(functionSelector, accountAddr, newOwner, recoveryModuleAddr); - console.log("recoveryCalldata", vm.toString(recoveryCalldata)); - bytes32 calldataHash = keccak256(recoveryCalldata); - console.log("calldataHash", vm.toString(calldataHash)); - // vm.startBroadcast(vm.envUint("PRIVATE_KEY")); - // address verifier = vm.envOr("VERIFIER", address(0)); - // address dkimRegistry = vm.envOr("DKIM_REGISTRY", address(0)); - // address dkimRegistrySigner = vm.envOr("SIGNER", address(0)); - // address emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); - - // if (verifier == address(0)) { - // verifier = address(new Verifier()); - // // vm.setEnv("VERIFIER", vm.toString(verifier)); - // console.log("Deployed Verifier at", verifier); - // } - // if (dkimRegistry == address(0)) { - // require( - // dkimRegistrySigner != address(0), - // "DKIM_REGISTRY_SIGNER is required" - // ); - // dkimRegistry = address( - // new ECDSAOwnedDKIMRegistry(dkimRegistrySigner) - // ); - // // vm.setEnv("DKIM_REGISTRY", vm.toString(dkimRegistry)); - // console.log("Deployed DKIM Registry at", dkimRegistry); - // } - - // if (emailAuthImpl == address(0)) { - // emailAuthImpl = address(new EmailAuth()); - // // vm.setEnv("EMAIL_AUTH_IMPL", vm.toString(emailAuthImpl)); - // console.log("Deployed Email Auth at", emailAuthImpl); - // } - - // EmailRecoverySubjectHandler emailRecoveryHandler = new EmailRecoverySubjectHandler(); - // // vm.setEnv( - // // "RECOVERY_HANDLER", - // // vm.toString(address(emailRecoveryHandler)) - // // ); - // address _factory = vm.envOr("RECOVERY_FACTORY", address(0)); - // if (_factory == address(0)) { - // _factory = address(new EmailRecoveryFactory()); - // // vm.setEnv("RECOVERY_FACTORY", vm.toString(_factory)); - // console.log("Deployed Email Recovery Factory at", _factory); - // } - // EmailRecoveryFactory factory = EmailRecoveryFactory(_factory); - // (address manager, address module) = factory.deployUniversalEmailRecoveryModule( - // verifier, - // dkimRegistry, - // emailAuthImpl, - // address(emailRecoveryHandler) - // ); - // // vm.setEnv("RECOVERY_MANAGER", vm.toString(manager)); - // // vm.setEnv("RECOVERY_MODULE", vm.toString(module)); + bytes memory recoveryCalldata = abi.encodeWithSelector(functionSelector, newOwner); + bytes32 calldataHash = keccak256(recoveryCalldata); - // console.log( - // "Deployed Email Recovery Handler at", - // address(emailRecoveryHandler) - // ); - // console.log("Deployed Email Recovery Manager at", vm.toString(manager)); - // console.log("Deployed Email Recovery Module at", vm.toString(module)); - // vm.stopBroadcast(); + console.log("recoveryCalldata", vm.toString(recoveryCalldata)); + console.log("calldataHash", vm.toString(calldataHash)); } } diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol deleted file mode 100644 index d7c353b7..00000000 --- a/script/Deploy.s.sol +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.25; - -import { Script } from "forge-std/Script.sol"; -import { EmailRecoverySubjectHandler } from "src/handlers/EmailRecoverySubjectHandler.sol"; -import { EmailRecoveryManager } from "src/EmailRecoveryManager.sol"; -import { UniversalEmailRecoveryModule } from "src/modules/UniversalEmailRecoveryModule.sol"; - -contract DeployScript is Script { - function run() public { - bytes32 salt = bytes32(uint256(0)); - - address verifier = 0xEdC642bbaD91E21cCE6cd436Fdc6F040FD0fF998; - address dkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78; - address emailAuthImpl = 0x1C76Aa365c17B40c7E944DcCdE4dC6e6D2A7b748; - - vm.startBroadcast(vm.envUint("PRIVATE_KEY")); - - EmailRecoverySubjectHandler emailRecoveryHandler = new EmailRecoverySubjectHandler(); - - EmailRecoveryManager emailRecoveryManager = new EmailRecoveryManager{ salt: salt }( - verifier, dkimRegistry, emailAuthImpl, address(emailRecoveryHandler) - ); - - new UniversalEmailRecoveryModule(address(emailRecoveryManager)); - - vm.stopBroadcast(); - } -} diff --git a/script/Deploy7579TestAccount.s.sol b/script/Deploy7579TestAccount.s.sol index ca1217de..a5d7941f 100644 --- a/script/Deploy7579TestAccount.s.sol +++ b/script/Deploy7579TestAccount.s.sol @@ -6,7 +6,7 @@ import { console } from "forge-std/console.sol"; import { EmailAccountRecovery } from "ether-email-auth/packages/contracts/src/EmailAccountRecovery.sol"; import { IEmailRecoveryManager } from "../src/interfaces/IEmailRecoveryManager.sol"; -import { RhinestoneModuleKit, AccountInstance } from "modulekit/ModuleKit.sol"; +import { RhinestoneModuleKit } from "modulekit/ModuleKit.sol"; import { OwnableValidator } from "src/test/OwnableValidator.sol"; import { ModuleKitHelpers, ModuleKitUserOp } from "modulekit/ModuleKit.sol"; import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; @@ -48,7 +48,7 @@ contract Deploy7579TestAccountScript is RhinestoneModuleKit, Script { PackedUserOperation userOp; bytes32 userOpHash; - bytes4 functionSelector = bytes4(keccak256(bytes("changeOwner(address,address,address)"))); + bytes4 functionSelector = bytes4(keccak256(bytes("changeOwner(address)"))); function run() public { privKey = vm.envUint("PRIVATE_KEY"); @@ -96,7 +96,6 @@ contract Deploy7579TestAccountScript is RhinestoneModuleKit, Script { validatorAddr = vm.envOr("VALIDATOR", address(0)); if (validatorAddr == address(0)) { validatorAddr = address(new OwnableValidator()); - // vm.setEnv("VALIDATOR", vm.toString(validatorAddress)); console.log("Deployed Ownable Validator at", validatorAddr); } OwnableValidator validator = OwnableValidator(validatorAddr); @@ -114,11 +113,7 @@ contract Deploy7579TestAccountScript is RhinestoneModuleKit, Script { BootstrapConfig[] memory executors = new BootstrapConfig[](1); managerAddr = vm.envAddress("RECOVERY_MANAGER"); require(managerAddr != address(0), "RECOVERY_MANAGER is required"); - // address guardianAddr = EmailAccountRecovery(managerAddr) - // .computeEmailAuthAddress(account, accountSalt); - // console.log("Guardian's EmailAuth address", guardianAddr); - // guardians[0] = guardianAddr; - // guardianWeights[0] = 1; + bytes memory recoveryModuleInstallData = abi.encode( validatorAddr, bytes("0"), @@ -226,59 +221,11 @@ contract Deploy7579TestAccountScript is RhinestoneModuleKit, Script { IEntryPoint(ENTRYPOINT_ADDR).handleOps{ gas: 3e6 }(userOps, payable(deployer)); console.log("changeThreshold UserOps are executed"); - // AccountInstance memory instance = makeAccountInstance(accountSalt); - - // instance.installModule({ - // moduleTypeId: MODULE_TYPE_VALIDATOR, - // module: validatorAddress, - // data: abi.encode( - // vm.envOr("OWNER", deployer), - // vm.envAddress("RECOVERY_MODULE") - // ) - // }); - - // bytes4 functionSelector = bytes4( - // keccak256(bytes("changeOwner(address,address,address)")) - // ); - // managerAddr = vm.envAddress("RECOVERY_MANAGER"); - // require(managerAddr != address(0), "RECOVERY_MANAGER is required"); - - // address guardianAddr = EmailAccountRecovery(managerAddr) - // .computeEmailAuthAddress(instance.account, accountSalt); - // console.log("Guardian's EmailAuth address", guardianAddr); - // address[] memory guardians = new address[](1); - // guardians[0] = guardianAddr; - // uint256[] memory guardianWeights = new uint256[](1); - // guardianWeights[0] = 1; - // uint threshold = 1; - // bytes memory recoveryModuleInstallData = abi.encode( - // validatorAddress, - // bytes("0"), - // functionSelector, - // guardians, - // guardianWeights, - // threshold, - // 1 seconds, - // 2 weeks - // ); - // instance.installModule({ - // moduleTypeId: MODULE_TYPE_EXECUTOR, - // module: vm.envAddress("RECOVERY_MODULE"), - // data: recoveryModuleInstallData - // }); vm.stopBroadcast(); } function getNonce(address account, address validator) internal returns (uint256 nonce) { uint192 key = uint192(bytes24(bytes20(address(validator)))); - // console.log("shifted key", uint256(key) << 64); - // console.log( - // "raw nonce", - // NonceManager(ENTRYPOINT_ADDR).nonceSequenceNumber( - // address(account), - // key - // ) - // ); nonce = IEntryPoint(ENTRYPOINT_ADDR).getNonce(address(account), key); } } diff --git a/script/DeployEmailRecoveryModule.s.sol b/script/DeployEmailRecoveryModule.s.sol new file mode 100644 index 00000000..259d5fd0 --- /dev/null +++ b/script/DeployEmailRecoveryModule.s.sol @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +import { Script } from "forge-std/Script.sol"; +import { console } from "forge-std/console.sol"; +import { EmailRecoverySubjectHandler } from "src/handlers/EmailRecoverySubjectHandler.sol"; +import { Verifier } from "ether-email-auth/packages/contracts/src/utils/Verifier.sol"; +import { ECDSAOwnedDKIMRegistry } from + "ether-email-auth/packages/contracts/src/utils/ECDSAOwnedDKIMRegistry.sol"; +import { EmailAuth } from "ether-email-auth/packages/contracts/src/EmailAuth.sol"; +import { EmailRecoveryFactory } from "src/EmailRecoveryFactory.sol"; +import { OwnableValidator } from "src/test/OwnableValidator.sol"; + +contract DeployEmailRecoveryModuleScript is Script { + function run() public { + vm.startBroadcast(vm.envUint("PRIVATE_KEY")); + address verifier = vm.envOr("VERIFIER", address(0)); + address dkimRegistry = vm.envOr("DKIM_REGISTRY", address(0)); + address dkimRegistrySigner = vm.envOr("SIGNER", address(0)); + address emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); + address validatorAddr = vm.envOr("VALIDATOR", address(0)); + + if (verifier == address(0)) { + verifier = address(new Verifier()); + console.log("Deployed Verifier at", verifier); + } + + if (dkimRegistry == address(0)) { + require(dkimRegistrySigner != address(0), "DKIM_REGISTRY_SIGNER is required"); + dkimRegistry = address(new ECDSAOwnedDKIMRegistry(dkimRegistrySigner)); + console.log("Deployed DKIM Registry at", dkimRegistry); + } + + if (emailAuthImpl == address(0)) { + emailAuthImpl = address(new EmailAuth()); + console.log("Deployed Email Auth at", emailAuthImpl); + } + + if (validatorAddr == address(0)) { + validatorAddr = address(new OwnableValidator()); + console.log("Deployed Ownable Validator at", validatorAddr); + } + + EmailRecoverySubjectHandler emailRecoveryHandler = new EmailRecoverySubjectHandler(); + + address _factory = vm.envOr("RECOVERY_FACTORY", address(0)); + if (_factory == address(0)) { + _factory = address(new EmailRecoveryFactory(verifier, emailAuthImpl)); + console.log("Deployed Email Recovery Factory at", _factory); + } + { + EmailRecoveryFactory factory = EmailRecoveryFactory(_factory); + (address module, address manager, address subjectHandler) = factory + .deployEmailRecoveryModule( + bytes32(uint256(0)), + bytes32(uint256(0)), + bytes32(uint256(0)), + type(EmailRecoverySubjectHandler).creationCode, + dkimRegistry, + validatorAddr, + bytes4(keccak256(bytes("changeOwner(address)"))) + ); + + console.log("Deployed Email Recovery Module at", vm.toString(module)); + console.log("Deployed Email Recovery Manager at", vm.toString(manager)); + console.log("Deployed Email Recovery Handler at", vm.toString(subjectHandler)); + vm.stopBroadcast(); + } + } +} diff --git a/script/Deploy7579Controller.s.sol b/script/DeployUniversalEmailRecoveryModule.s.sol similarity index 77% rename from script/Deploy7579Controller.s.sol rename to script/DeployUniversalEmailRecoveryModule.s.sol index b92e7130..2d4853e5 100644 --- a/script/Deploy7579Controller.s.sol +++ b/script/DeployUniversalEmailRecoveryModule.s.sol @@ -4,14 +4,13 @@ pragma solidity ^0.8.25; import { Script } from "forge-std/Script.sol"; import { console } from "forge-std/console.sol"; import { EmailRecoverySubjectHandler } from "src/handlers/EmailRecoverySubjectHandler.sol"; -import { EmailRecoveryManager } from "src/EmailRecoveryManager.sol"; import { Verifier } from "ether-email-auth/packages/contracts/src/utils/Verifier.sol"; import { ECDSAOwnedDKIMRegistry } from "ether-email-auth/packages/contracts/src/utils/ECDSAOwnedDKIMRegistry.sol"; import { EmailAuth } from "ether-email-auth/packages/contracts/src/EmailAuth.sol"; import { EmailRecoveryFactory } from "src/EmailRecoveryFactory.sol"; -contract Deploy7579ControllerScript is Script { +contract DeployUniversalEmailRecoveryModuleScript is Script { function run() public { vm.startBroadcast(vm.envUint("PRIVATE_KEY")); address verifier = vm.envOr("VERIFIER", address(0)); @@ -21,32 +20,25 @@ contract Deploy7579ControllerScript is Script { if (verifier == address(0)) { verifier = address(new Verifier()); - // vm.setEnv("VERIFIER", vm.toString(verifier)); console.log("Deployed Verifier at", verifier); } if (dkimRegistry == address(0)) { require(dkimRegistrySigner != address(0), "DKIM_REGISTRY_SIGNER is required"); dkimRegistry = address(new ECDSAOwnedDKIMRegistry(dkimRegistrySigner)); - // vm.setEnv("DKIM_REGISTRY", vm.toString(dkimRegistry)); console.log("Deployed DKIM Registry at", dkimRegistry); } if (emailAuthImpl == address(0)) { emailAuthImpl = address(new EmailAuth()); - // vm.setEnv("EMAIL_AUTH_IMPL", vm.toString(emailAuthImpl)); console.log("Deployed Email Auth at", emailAuthImpl); } EmailRecoverySubjectHandler emailRecoveryHandler = new EmailRecoverySubjectHandler(); - // vm.setEnv( - // "RECOVERY_HANDLER", - // vm.toString(address(emailRecoveryHandler)) - // ); + address _factory = vm.envOr("RECOVERY_FACTORY", address(0)); if (_factory == address(0)) { - _factory = address(new EmailRecoveryFactory(verifier, dkimRegistry, emailAuthImpl)); - // vm.setEnv("RECOVERY_FACTORY", vm.toString(_factory)); + _factory = address(new EmailRecoveryFactory(verifier, emailAuthImpl)); console.log("Deployed Email Recovery Factory at", _factory); } { @@ -56,14 +48,13 @@ contract Deploy7579ControllerScript is Script { bytes32(uint256(0)), bytes32(uint256(0)), bytes32(uint256(0)), - type(EmailRecoverySubjectHandler).creationCode + type(EmailRecoverySubjectHandler).creationCode, + dkimRegistry ); - // vm.setEnv("RECOVERY_MANAGER", vm.toString(manager)); - // vm.setEnv("RECOVERY_MODULE", vm.toString(module)); - console.log("Deployed Email Recovery Handler at", vm.toString(subjectHandler)); - console.log("Deployed Email Recovery Manager at", vm.toString(manager)); console.log("Deployed Email Recovery Module at", vm.toString(module)); + console.log("Deployed Email Recovery Manager at", vm.toString(manager)); + console.log("Deployed Email Recovery Handler at", vm.toString(subjectHandler)); vm.stopBroadcast(); } } diff --git a/src/EmailRecoveryFactory.sol b/src/EmailRecoveryFactory.sol index c84bbfb2..6fd181f0 100644 --- a/src/EmailRecoveryFactory.sol +++ b/src/EmailRecoveryFactory.sol @@ -8,16 +8,14 @@ import { EmailRecoveryModule } from "./modules/EmailRecoveryModule.sol"; contract EmailRecoveryFactory { address public immutable verifier; - address public immutable dkimRegistry; address public immutable emailAuthImpl; event EmailRecoveryModuleDeployed( address emailRecoveryModule, address emailRecoveryManager, address subjectHandler ); - constructor(address _verifier, address _dkimRegistry, address _emailAuthImpl) { + constructor(address _verifier, address _emailAuthImpl) { verifier = _verifier; - dkimRegistry = _dkimRegistry; emailAuthImpl = _emailAuthImpl; } @@ -26,6 +24,7 @@ contract EmailRecoveryFactory { bytes32 recoveryManagerSalt, bytes32 recoveryModuleSalt, bytes memory subjectHandlerBytecode, + address dkimRegistry, address validator, bytes4 functionSelector ) @@ -60,7 +59,8 @@ contract EmailRecoveryFactory { bytes32 subjectHandlerSalt, bytes32 recoveryManagerSalt, bytes32 recoveryModuleSalt, - bytes memory subjectHandlerBytecode + bytes memory subjectHandlerBytecode, + address dkimRegistry ) external returns (address, address, address) diff --git a/src/test/OwnableValidator.sol b/src/test/OwnableValidator.sol index 2aff8e67..eb5933e5 100644 --- a/src/test/OwnableValidator.sol +++ b/src/test/OwnableValidator.sol @@ -74,7 +74,7 @@ contract OwnableValidator is ERC7579ValidatorBase { : EIP1271_FAILED; } - function changeOwner(address account, address authorizedAccount, address newOwner) external { + function changeOwner(address newOwner) external { owners[msg.sender] = newOwner; } diff --git a/test/integration/OwnableValidatorRecovery/EmailRecoveryModule/EmailRecoveryModuleBase.t.sol b/test/integration/OwnableValidatorRecovery/EmailRecoveryModule/EmailRecoveryModuleBase.t.sol index d99ede2b..7a1d716c 100644 --- a/test/integration/OwnableValidatorRecovery/EmailRecoveryModule/EmailRecoveryModuleBase.t.sol +++ b/test/integration/OwnableValidatorRecovery/EmailRecoveryModule/EmailRecoveryModuleBase.t.sol @@ -50,11 +50,9 @@ abstract contract OwnableValidatorRecovery_EmailRecoveryModule_Base is Integrati validator = new OwnableValidator(); validatorAddress = address(validator); isInstalledContext = bytes("0"); - functionSelector = bytes4(keccak256(bytes("changeOwner(address,address,address)"))); + functionSelector = bytes4(keccak256(bytes("changeOwner(address)"))); - emailRecoveryFactory = new EmailRecoveryFactory( - address(verifier), address(ecdsaOwnedDkimRegistry), address(emailAuthImpl) - ); + emailRecoveryFactory = new EmailRecoveryFactory(address(verifier), address(emailAuthImpl)); emailRecoveryHandler = new EmailRecoverySubjectHandler(); // Deploy EmailRecoveryManager & EmailRecoveryModule @@ -68,20 +66,15 @@ abstract contract OwnableValidatorRecovery_EmailRecoveryModule_Base is Integrati recoveryManagerSalt, recoveryModuleSalt, subjectHandlerBytecode, + address(ecdsaOwnedDkimRegistry), validatorAddress, functionSelector ); emailRecoveryManager = EmailRecoveryManager(emailRecoveryManagerAddress); - recoveryCalldata1 = abi.encodeWithSelector( - functionSelector, accountAddress1, recoveryModuleAddress, newOwner1 - ); - recoveryCalldata2 = abi.encodeWithSelector( - functionSelector, accountAddress2, recoveryModuleAddress, newOwner2 - ); - recoveryCalldata3 = abi.encodeWithSelector( - functionSelector, accountAddress3, recoveryModuleAddress, newOwner3 - ); + recoveryCalldata1 = abi.encodeWithSelector(functionSelector, newOwner1); + recoveryCalldata2 = abi.encodeWithSelector(functionSelector, newOwner2); + recoveryCalldata3 = abi.encodeWithSelector(functionSelector, newOwner3); calldataHash1 = keccak256(recoveryCalldata1); calldataHash2 = keccak256(recoveryCalldata2); calldataHash3 = keccak256(recoveryCalldata3); diff --git a/test/integration/OwnableValidatorRecovery/UniversalEmailRecoveryModule/UniversalEmailRecoveryModuleBase.t.sol b/test/integration/OwnableValidatorRecovery/UniversalEmailRecoveryModule/UniversalEmailRecoveryModuleBase.t.sol index 2592b9e1..f754d023 100644 --- a/test/integration/OwnableValidatorRecovery/UniversalEmailRecoveryModule/UniversalEmailRecoveryModuleBase.t.sol +++ b/test/integration/OwnableValidatorRecovery/UniversalEmailRecoveryModule/UniversalEmailRecoveryModuleBase.t.sol @@ -46,9 +46,7 @@ abstract contract OwnableValidatorRecovery_UniversalEmailRecoveryModule_Base is function setUp() public virtual override { super.setUp(); - emailRecoveryFactory = new EmailRecoveryFactory( - address(verifier), address(ecdsaOwnedDkimRegistry), address(emailAuthImpl) - ); + emailRecoveryFactory = new EmailRecoveryFactory(address(verifier), address(emailAuthImpl)); emailRecoveryHandler = new EmailRecoverySubjectHandler(); // Deploy EmailRecoveryManager & UniversalEmailRecoveryModule @@ -58,7 +56,11 @@ abstract contract OwnableValidatorRecovery_UniversalEmailRecoveryModule_Base is bytes memory subjectHandlerBytecode = type(EmailRecoverySubjectHandler).creationCode; (recoveryModuleAddress, emailRecoveryManagerAddress,) = emailRecoveryFactory .deployUniversalEmailRecoveryModule( - subjectHandlerSalt, recoveryManagerSalt, recoveryModuleSalt, subjectHandlerBytecode + subjectHandlerSalt, + recoveryManagerSalt, + recoveryModuleSalt, + subjectHandlerBytecode, + address(ecdsaOwnedDkimRegistry) ); emailRecoveryManager = EmailRecoveryManager(emailRecoveryManagerAddress); @@ -66,16 +68,10 @@ abstract contract OwnableValidatorRecovery_UniversalEmailRecoveryModule_Base is validator = new OwnableValidator(); validatorAddress = address(validator); isInstalledContext = bytes("0"); - functionSelector = bytes4(keccak256(bytes("changeOwner(address,address,address)"))); - recoveryCalldata1 = abi.encodeWithSelector( - functionSelector, accountAddress1, recoveryModuleAddress, newOwner1 - ); - recoveryCalldata2 = abi.encodeWithSelector( - functionSelector, accountAddress2, recoveryModuleAddress, newOwner2 - ); - recoveryCalldata3 = abi.encodeWithSelector( - functionSelector, accountAddress3, recoveryModuleAddress, newOwner3 - ); + functionSelector = bytes4(keccak256(bytes("changeOwner(address)"))); + recoveryCalldata1 = abi.encodeWithSelector(functionSelector, newOwner1); + recoveryCalldata2 = abi.encodeWithSelector(functionSelector, newOwner2); + recoveryCalldata3 = abi.encodeWithSelector(functionSelector, newOwner3); calldataHash1 = keccak256(recoveryCalldata1); calldataHash2 = keccak256(recoveryCalldata2); calldataHash3 = keccak256(recoveryCalldata3); diff --git a/test/integration/SafeRecovery/SafeRecovery.t.sol b/test/integration/SafeRecovery/SafeRecovery.t.sol index 0e110ce6..aaa2d4f0 100644 --- a/test/integration/SafeRecovery/SafeRecovery.t.sol +++ b/test/integration/SafeRecovery/SafeRecovery.t.sol @@ -9,21 +9,21 @@ import { Safe } from "@safe-global/safe-contracts/contracts/Safe.sol"; import { IEmailRecoveryManager } from "src/interfaces/IEmailRecoveryManager.sol"; import { GuardianStorage, GuardianStatus } from "src/libraries/EnumerableGuardianMap.sol"; -import { UniversalEmailRecoveryModule } from "src/modules/UniversalEmailRecoveryModule.sol"; +import { EmailRecoveryModule } from "src/modules/EmailRecoveryModule.sol"; import { SafeIntegrationBase } from "./SafeIntegrationBase.t.sol"; contract SafeRecovery_Integration_Test is SafeIntegrationBase { using ModuleKitHelpers for *; using ModuleKitUserOp for *; - UniversalEmailRecoveryModule recoveryModule; + EmailRecoveryModule recoveryModule; address recoveryModuleAddress; bytes4 functionSelector; // function setUp() public override { // super.setUp(); - // recoveryModule = new UniversalEmailRecoveryModule(address(emailRecoveryManager)); + // recoveryModule = new EmailRecoveryModule(address(emailRecoveryManager)); // recoveryModuleAddress = address(recoveryModule); // functionSelector = bytes4(keccak256(bytes("changeOwner(address,address,address)"))); diff --git a/test/unit/EmailRecoveryFactory/deployEmailRecoveryModule.t.sol b/test/unit/EmailRecoveryFactory/deployEmailRecoveryModule.t.sol index ca63e9bf..4a28f2a8 100644 --- a/test/unit/EmailRecoveryFactory/deployEmailRecoveryModule.t.sol +++ b/test/unit/EmailRecoveryFactory/deployEmailRecoveryModule.t.sol @@ -12,9 +12,7 @@ import { EmailRecoveryModule } from "src/modules/EmailRecoveryModule.sol"; contract EmailRecoveryFactory_deployAll_Test is UnitBase { function setUp() public override { super.setUp(); - emailRecoveryFactory = new EmailRecoveryFactory( - address(verifier), address(dkimRegistry), address(emailAuthImpl) - ); + emailRecoveryFactory = new EmailRecoveryFactory(address(verifier), address(emailAuthImpl)); } function test_DeployEmailRecoveryModule_Succeeds() public { @@ -54,6 +52,7 @@ contract EmailRecoveryFactory_deployAll_Test is UnitBase { recoveryManagerSalt, recoveryModuleSalt, subjectHandlerBytecode, + address(dkimRegistry), validatorAddress, functionSelector ); diff --git a/test/unit/EmailRecoveryFactory/deployUniversalEmailRecoveryModule.t.sol b/test/unit/EmailRecoveryFactory/deployUniversalEmailRecoveryModule.t.sol index 5a96b157..01444523 100644 --- a/test/unit/EmailRecoveryFactory/deployUniversalEmailRecoveryModule.t.sol +++ b/test/unit/EmailRecoveryFactory/deployUniversalEmailRecoveryModule.t.sol @@ -12,9 +12,7 @@ import { UniversalEmailRecoveryModule } from "src/modules/UniversalEmailRecovery contract EmailRecoveryFactory_deployUniversalEmailRecoveryModule_Test is UnitBase { function setUp() public override { super.setUp(); - emailRecoveryFactory = new EmailRecoveryFactory( - address(verifier), address(dkimRegistry), address(emailAuthImpl) - ); + emailRecoveryFactory = new EmailRecoveryFactory(address(verifier), address(emailAuthImpl)); } function test_DeployUniversalEmailRecoveryModule_Succeeds() public { @@ -49,7 +47,11 @@ contract EmailRecoveryFactory_deployUniversalEmailRecoveryModule_Test is UnitBas (address emailRecoveryModule, address emailRecoveryManager, address subjectHandler) = emailRecoveryFactory.deployUniversalEmailRecoveryModule( - subjectHandlerSalt, recoveryManagerSalt, recoveryModuleSalt, subjectHandlerBytecode + subjectHandlerSalt, + recoveryManagerSalt, + recoveryModuleSalt, + subjectHandlerBytecode, + address(dkimRegistry) ); assertEq(emailRecoveryManager, expectedManager); diff --git a/test/unit/SafeUnitBase.t.sol b/test/unit/SafeUnitBase.t.sol index a5c93254..afc1d760 100644 --- a/test/unit/SafeUnitBase.t.sol +++ b/test/unit/SafeUnitBase.t.sol @@ -64,9 +64,7 @@ abstract contract SafeUnitBase is IntegrationBase { // Deploy handler, manager and module safeRecoverySubjectHandler = new SafeRecoverySubjectHandlerHarness(); - emailRecoveryFactory = new EmailRecoveryFactory( - address(verifier), address(ecdsaOwnedDkimRegistry), address(emailAuthImpl) - ); + emailRecoveryFactory = new EmailRecoveryFactory(address(verifier), address(emailAuthImpl)); emailRecoveryManager = new EmailRecoveryManagerHarness( address(verifier), diff --git a/test/unit/UnitBase.t.sol b/test/unit/UnitBase.t.sol index 19c99efa..a552339a 100644 --- a/test/unit/UnitBase.t.sol +++ b/test/unit/UnitBase.t.sol @@ -109,9 +109,7 @@ abstract contract UnitBase is RhinestoneModuleKit, Test { // Deploy handler, manager and module emailRecoveryHandler = new EmailRecoverySubjectHandler(); - emailRecoveryFactory = new EmailRecoveryFactory( - address(verifier), address(dkimRegistry), address(emailAuthImpl) - ); + emailRecoveryFactory = new EmailRecoveryFactory(address(verifier), address(emailAuthImpl)); emailRecoveryManager = new EmailRecoveryManagerHarness( address(verifier), @@ -159,10 +157,8 @@ abstract contract UnitBase is RhinestoneModuleKit, Test { 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 - ); + functionSelector = bytes4(keccak256(bytes("changeOwner(address)"))); + recoveryCalldata = abi.encodeWithSelector(functionSelector, newOwner); calldataHash = keccak256(recoveryCalldata); // Install modules diff --git a/test/unit/modules/EmailRecoveryModule/EmailRecoveryModuleBase.t.sol b/test/unit/modules/EmailRecoveryModule/EmailRecoveryModuleBase.t.sol index ea91b171..841f1d9d 100644 --- a/test/unit/modules/EmailRecoveryModule/EmailRecoveryModuleBase.t.sol +++ b/test/unit/modules/EmailRecoveryModule/EmailRecoveryModuleBase.t.sol @@ -111,17 +111,13 @@ abstract contract EmailRecoveryModuleBase is RhinestoneModuleKit, Test { 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 - ); + functionSelector = bytes4(keccak256(bytes("changeOwner(address)"))); + recoveryCalldata = abi.encodeWithSelector(functionSelector, newOwner); calldataHash = keccak256(recoveryCalldata); // Deploy handler, manager and module emailRecoveryHandler = new EmailRecoverySubjectHandler(); - emailRecoveryFactory = new EmailRecoveryFactory( - address(verifier), address(dkimRegistry), address(emailAuthImpl) - ); + emailRecoveryFactory = new EmailRecoveryFactory(address(verifier), address(emailAuthImpl)); emailRecoveryManager = new EmailRecoveryManagerHarness( address(verifier),