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/Deploy7579Controller.s.sol b/script/Deploy7579Controller.s.sol index 0177e65c..86e19ac4 100644 --- a/script/Deploy7579Controller.s.sol +++ b/script/Deploy7579Controller.s.sol @@ -4,7 +4,6 @@ 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"; @@ -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, emailAuthImpl)); - // vm.setEnv("RECOVERY_FACTORY", vm.toString(_factory)); console.log("Deployed Email Recovery Factory at", _factory); } { @@ -59,8 +51,6 @@ contract Deploy7579ControllerScript is Script { 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)); diff --git a/script/Deploy7579TestAccount.s.sol b/script/Deploy7579TestAccount.s.sol index ca1217de..0feacd9a 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"); @@ -114,11 +114,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 +222,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); } }