diff --git a/script/DeployEmailRecoveryModule.s.sol b/script/7579/EmailRecoveryModule/DeployEmailRecoveryModule.s.sol similarity index 54% rename from script/DeployEmailRecoveryModule.s.sol rename to script/7579/EmailRecoveryModule/DeployEmailRecoveryModule.s.sol index 1032a3fb..8d30ff09 100644 --- a/script/DeployEmailRecoveryModule.s.sol +++ b/script/7579/EmailRecoveryModule/DeployEmailRecoveryModule.s.sol @@ -5,36 +5,39 @@ pragma solidity ^0.8.25; import { console } from "forge-std/console.sol"; import { EmailRecoveryCommandHandler } from "src/handlers/EmailRecoveryCommandHandler.sol"; -import { UserOverrideableDKIMRegistry } from "@zk-email/contracts/UserOverrideableDKIMRegistry.sol"; import { EmailAuth } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol"; import { EmailRecoveryFactory } from "src/factories/EmailRecoveryFactory.sol"; import { OwnableValidator } from "src/test/OwnableValidator.sol"; -import { BaseDeployScript } from "./BaseDeployScript.s.sol"; +import { BaseDeployScript } from "../../BaseDeployScript.s.sol"; contract DeployEmailRecoveryModuleScript is BaseDeployScript { address public verifier; - address public dkimRegistrySigner; + address public dkim; address public emailAuthImpl; - address public validatorAddr; uint256 public minimumDelay; address public killSwitchAuthorizer; + address public validatorAddr; + address public factory; address public initialOwner; + address public dkimRegistrySigner; + uint256 public dkimDelay; uint256 public salt; - UserOverrideableDKIMRegistry public dkim; - function run() public override { super.run(); vm.startBroadcast(vm.envUint("PRIVATE_KEY")); verifier = vm.envOr("VERIFIER", address(0)); - dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); + dkim = vm.envOr("DKIM_REGISTRY", address(0)); emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); - validatorAddr = vm.envOr("VALIDATOR", address(0)); minimumDelay = vm.envOr("MINIMUM_DELAY", uint256(0)); killSwitchAuthorizer = vm.envAddress("KILL_SWITCH_AUTHORIZER"); + validatorAddr = vm.envOr("VALIDATOR", address(0)); + factory = vm.envOr("RECOVERY_FACTORY", address(0)); initialOwner = vm.addr(vm.envUint("PRIVATE_KEY")); + dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); + dkimDelay = vm.envOr("DKIM_DELAY", uint256(0)); salt = vm.envOr("CREATE2_SALT", uint256(0)); if (verifier == address(0)) { @@ -42,48 +45,42 @@ contract DeployEmailRecoveryModuleScript is BaseDeployScript { } // Deploy Useroverridable DKIM registry - dkim = UserOverrideableDKIMRegistry(vm.envOr("DKIM_REGISTRY", address(0))); - uint256 setTimeDelay = vm.envOr("DKIM_DELAY", uint256(0)); - if (address(dkim) == address(0)) { - dkim = UserOverrideableDKIMRegistry( - deployUserOverrideableDKIMRegistry( - initialOwner, dkimRegistrySigner, setTimeDelay, salt - ) + if (dkim == address(0)) { + dkim = deployUserOverrideableDKIMRegistry( + initialOwner, dkimRegistrySigner, dkimDelay, salt ); } if (emailAuthImpl == address(0)) { emailAuthImpl = address(new EmailAuth{ salt: bytes32(salt) }()); - console.log("Deployed Email Auth at", emailAuthImpl); + console.log("EmailAuth implementation deployed at", emailAuthImpl); } if (validatorAddr == address(0)) { validatorAddr = address(new OwnableValidator{ salt: bytes32(salt) }()); - console.log("Deployed Ownable Validator at", validatorAddr); + console.log("OwnableValidator deployed at", validatorAddr); } - address _factory = vm.envOr("RECOVERY_FACTORY", address(0)); - if (_factory == address(0)) { - _factory = + if (factory == address(0)) { + factory = address(new EmailRecoveryFactory{ salt: bytes32(salt) }(verifier, emailAuthImpl)); - console.log("Deployed Email Recovery Factory at", _factory); + console.log("EmailRecoveryFactory deployed at", factory); } - { - EmailRecoveryFactory factory = EmailRecoveryFactory(_factory); - (address module, address commandHandler) = factory.deployEmailRecoveryModule( - bytes32(uint256(0)), - bytes32(uint256(0)), - type(EmailRecoveryCommandHandler).creationCode, - minimumDelay, - killSwitchAuthorizer, - address(dkim), - validatorAddr, - bytes4(keccak256(bytes("changeOwner(address)"))) - ); - console.log("Deployed Email Recovery Module at", vm.toString(module)); - console.log("Deployed Email Recovery Handler at", vm.toString(commandHandler)); - vm.stopBroadcast(); - } + EmailRecoveryFactory emailRecoveryFactory = EmailRecoveryFactory(factory); + (address module, address commandHandler) = emailRecoveryFactory.deployEmailRecoveryModule( + bytes32(uint256(0)), + bytes32(uint256(0)), + type(EmailRecoveryCommandHandler).creationCode, + minimumDelay, + killSwitchAuthorizer, + address(dkim), + validatorAddr, + bytes4(keccak256(bytes("changeOwner(address)"))) + ); + + console.log("EmailRecoveryModule deployed at", vm.toString(module)); + console.log("EmailRecoveryCommandHandler deployed at", vm.toString(commandHandler)); + vm.stopBroadcast(); } } diff --git a/script/7579/EmailRecoveryModule/DeployEmailRecoveryModuleWithAccountHiding.s.sol b/script/7579/EmailRecoveryModule/DeployEmailRecoveryModuleWithAccountHiding.s.sol new file mode 100644 index 00000000..e4d5a4de --- /dev/null +++ b/script/7579/EmailRecoveryModule/DeployEmailRecoveryModuleWithAccountHiding.s.sol @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +/* solhint-disable no-console, gas-custom-errors */ + +import { console } from "forge-std/console.sol"; +import { AccountHidingRecoveryCommandHandler } from + "src/handlers/AccountHidingRecoveryCommandHandler.sol"; +import { EmailAuth } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol"; +import { EmailRecoveryFactory } from "src/factories/EmailRecoveryFactory.sol"; +import { OwnableValidator } from "src/test/OwnableValidator.sol"; +import { BaseDeployScript } from "../../BaseDeployScript.s.sol"; + +contract DeployEmailRecoveryModuleScript is BaseDeployScript { + address public verifier; + address public dkim; + address public emailAuthImpl; + uint256 public minimumDelay; + address public killSwitchAuthorizer; + address public validatorAddr; + address public factory; + + address public initialOwner; + address public dkimRegistrySigner; + uint256 public dkimDelay; + uint256 public salt; + + function run() public override { + super.run(); + vm.startBroadcast(vm.envUint("PRIVATE_KEY")); + verifier = vm.envOr("VERIFIER", address(0)); + dkim = vm.envOr("DKIM_REGISTRY", address(0)); + emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); + minimumDelay = vm.envOr("MINIMUM_DELAY", uint256(0)); + killSwitchAuthorizer = vm.envAddress("KILL_SWITCH_AUTHORIZER"); + validatorAddr = vm.envOr("VALIDATOR", address(0)); + factory = vm.envOr("RECOVERY_FACTORY", address(0)); + + initialOwner = vm.addr(vm.envUint("PRIVATE_KEY")); + dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); + dkimDelay = vm.envOr("DKIM_DELAY", uint256(0)); + salt = vm.envOr("CREATE2_SALT", uint256(0)); + + if (verifier == address(0)) { + verifier = deployVerifier(initialOwner, salt); + } + + if (dkim == address(0)) { + dkim = deployUserOverrideableDKIMRegistry( + initialOwner, dkimRegistrySigner, dkimDelay, salt + ); + } + + if (emailAuthImpl == address(0)) { + emailAuthImpl = address(new EmailAuth{ salt: bytes32(salt) }()); + console.log("EmailAuth implemenation deployed at", emailAuthImpl); + } + + if (validatorAddr == address(0)) { + validatorAddr = address(new OwnableValidator{ salt: bytes32(salt) }()); + console.log("OwnableValidator deployed at", validatorAddr); + } + + if (factory == address(0)) { + factory = + address(new EmailRecoveryFactory{ salt: bytes32(salt) }(verifier, emailAuthImpl)); + console.log("EmailRecoveryFactory deployed at", factory); + } + + EmailRecoveryFactory emailRecoveryFactory = EmailRecoveryFactory(factory); + (address module, address commandHandler) = emailRecoveryFactory.deployEmailRecoveryModule( + bytes32(uint256(0)), + bytes32(uint256(0)), + type(AccountHidingRecoveryCommandHandler).creationCode, + minimumDelay, + killSwitchAuthorizer, + address(dkim), + validatorAddr, + bytes4(keccak256(bytes("changeOwner(address)"))) + ); + + console.log("EmailRecoveryModule deployed at", vm.toString(module)); + console.log("AccountHidingRecoveryCommandHandler deployed at", vm.toString(commandHandler)); + vm.stopBroadcast(); + } +} diff --git a/script/7579/UniversalEmailRecoveryModule/DeployUniversalEmailRecoveryModule.s.sol b/script/7579/UniversalEmailRecoveryModule/DeployUniversalEmailRecoveryModule.s.sol new file mode 100644 index 00000000..66cd7f5f --- /dev/null +++ b/script/7579/UniversalEmailRecoveryModule/DeployUniversalEmailRecoveryModule.s.sol @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +/* solhint-disable no-console, gas-custom-errors */ + +import { console } from "forge-std/console.sol"; +import { EmailRecoveryCommandHandler } from "src/handlers/EmailRecoveryCommandHandler.sol"; +import { EmailAuth } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol"; +import { EmailRecoveryUniversalFactory } from "src/factories/EmailRecoveryUniversalFactory.sol"; +import { BaseDeployScript } from "../../BaseDeployScript.s.sol"; + +contract DeployUniversalEmailRecoveryModuleScript is BaseDeployScript { + address public verifier; + address public dkim; + address public emailAuthImpl; + uint256 public minimumDelay; + address public killSwitchAuthorizer; + address public factory; + + address public initialOwner; + address public dkimRegistrySigner; + uint256 public dkimDelay; + uint256 public salt; + + function run() public override { + super.run(); + vm.startBroadcast(vm.envUint("PRIVATE_KEY")); + verifier = vm.envOr("VERIFIER", address(0)); + dkim = vm.envOr("DKIM_REGISTRY", address(0)); + emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); + minimumDelay = vm.envOr("MINIMUM_DELAY", uint256(0)); + killSwitchAuthorizer = vm.envAddress("KILL_SWITCH_AUTHORIZER"); + factory = vm.envOr("RECOVERY_FACTORY", address(0)); + + initialOwner = vm.addr(vm.envUint("PRIVATE_KEY")); + dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); + dkimDelay = vm.envOr("DKIM_DELAY", uint256(0)); + salt = vm.envOr("CREATE2_SALT", uint256(0)); + + if (verifier == address(0)) { + verifier = deployVerifier(initialOwner, salt); + } + + if (dkim == address(0)) { + dkim = deployUserOverrideableDKIMRegistry( + initialOwner, dkimRegistrySigner, dkimDelay, salt + ); + } + + if (emailAuthImpl == address(0)) { + emailAuthImpl = address(new EmailAuth{ salt: bytes32(salt) }()); + console.log("EmailAuth implemenation deployed at", emailAuthImpl); + } + + if (factory == address(0)) { + factory = address( + new EmailRecoveryUniversalFactory{ salt: bytes32(salt) }(verifier, emailAuthImpl) + ); + console.log("EmailRecoveryUniversalFactory deployed at", factory); + } + + EmailRecoveryUniversalFactory emailRecoveryUniversalFactory = + EmailRecoveryUniversalFactory(factory); + (address module, address commandHandler) = emailRecoveryUniversalFactory + .deployUniversalEmailRecoveryModule( + bytes32(uint256(0)), + bytes32(uint256(0)), + type(EmailRecoveryCommandHandler).creationCode, + minimumDelay, + killSwitchAuthorizer, + address(dkim) + ); + + console.log("UniversalEmailRecoveryModule deployed at", vm.toString(module)); + console.log("EmailRecoveryCommandHandler deployed at", vm.toString(commandHandler)); + vm.stopBroadcast(); + } +} diff --git a/script/7579/UniversalEmailRecoveryModule/DeployUniversalEmailRecoveryModuleWithAccountHiding.s.sol b/script/7579/UniversalEmailRecoveryModule/DeployUniversalEmailRecoveryModuleWithAccountHiding.s.sol new file mode 100644 index 00000000..a13f065c --- /dev/null +++ b/script/7579/UniversalEmailRecoveryModule/DeployUniversalEmailRecoveryModuleWithAccountHiding.s.sol @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +/* solhint-disable no-console, gas-custom-errors */ + +import { console } from "forge-std/console.sol"; +import { AccountHidingRecoveryCommandHandler } from + "src/handlers/AccountHidingRecoveryCommandHandler.sol"; +import { EmailAuth } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol"; +import { EmailRecoveryUniversalFactory } from "src/factories/EmailRecoveryUniversalFactory.sol"; +import { BaseDeployScript } from "../../BaseDeployScript.s.sol"; + +contract DeployUniversalEmailRecoveryModuleScript is BaseDeployScript { + address public verifier; + address public dkim; + address public emailAuthImpl; + uint256 public minimumDelay; + address public killSwitchAuthorizer; + address public factory; + + address public initialOwner; + address public dkimRegistrySigner; + uint256 public dkimDelay; + uint256 public salt; + + function run() public override { + super.run(); + vm.startBroadcast(vm.envUint("PRIVATE_KEY")); + verifier = vm.envOr("VERIFIER", address(0)); + dkim = vm.envOr("DKIM_REGISTRY", address(0)); + emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); + minimumDelay = vm.envOr("MINIMUM_DELAY", uint256(0)); + killSwitchAuthorizer = vm.envAddress("KILL_SWITCH_AUTHORIZER"); + factory = vm.envOr("RECOVERY_FACTORY", address(0)); + + initialOwner = vm.addr(vm.envUint("PRIVATE_KEY")); + dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); + dkimDelay = vm.envOr("DKIM_DELAY", uint256(0)); + salt = vm.envOr("CREATE2_SALT", uint256(0)); + + if (verifier == address(0)) { + verifier = deployVerifier(initialOwner, salt); + } + + if (dkim == address(0)) { + dkim = deployUserOverrideableDKIMRegistry( + initialOwner, dkimRegistrySigner, dkimDelay, salt + ); + } + + if (emailAuthImpl == address(0)) { + emailAuthImpl = address(new EmailAuth{ salt: bytes32(salt) }()); + console.log("EmailAuth implemenation deployed at", emailAuthImpl); + } + + if (factory == address(0)) { + factory = address( + new EmailRecoveryUniversalFactory{ salt: bytes32(salt) }(verifier, emailAuthImpl) + ); + console.log("EmailRecoveryUniversalFactory deployed at", factory); + } + + EmailRecoveryUniversalFactory emailRecoveryUniversalFactory = + EmailRecoveryUniversalFactory(factory); + (address module, address commandHandler) = emailRecoveryUniversalFactory + .deployUniversalEmailRecoveryModule( + bytes32(uint256(0)), + bytes32(uint256(0)), + type(AccountHidingRecoveryCommandHandler).creationCode, + minimumDelay, + killSwitchAuthorizer, + address(dkim) + ); + + console.log("UniversalEmailRecoveryModule deployed at", vm.toString(module)); + console.log("AccountHidingRecoveryCommandHandler deployed at", vm.toString(commandHandler)); + vm.stopBroadcast(); + } +} diff --git a/script/BaseDeployScript.s.sol b/script/BaseDeployScript.s.sol index 1592750a..c5d9857d 100644 --- a/script/BaseDeployScript.s.sol +++ b/script/BaseDeployScript.s.sol @@ -25,7 +25,7 @@ contract BaseDeployScript is Script { abi.encodeCall(verifierImpl.initialize, (initialOwner, address(groth16Verifier))) ); address verifier = address(Verifier(address(verifierProxy))); - console.log("Deployed Verifier at", verifier); + console.log("Verifier proxy deployed at", verifier); return verifier; } @@ -35,7 +35,7 @@ contract BaseDeployScript is Script { function deployUserOverrideableDKIMRegistry( address initialOwner, address dkimRegistrySigner, - uint256 setTimeDelay, + uint256 dkimDelay, uint256 salt ) public @@ -51,11 +51,11 @@ contract BaseDeployScript is Script { ERC1967Proxy dkimProxy = new ERC1967Proxy{ salt: bytes32(salt) }( address(overrideableDkimImpl), abi.encodeCall( - overrideableDkimImpl.initialize, (initialOwner, dkimRegistrySigner, setTimeDelay) + overrideableDkimImpl.initialize, (initialOwner, dkimRegistrySigner, dkimDelay) ) ); address dkim = address(dkimProxy); - console.log("UseroverrideableDKIMRegistry proxy deployed at: %s", dkim); + console.log("UserOverrideableDKIMRegistry proxy deployed at: %s", dkim); return dkim; } } diff --git a/script/DeploySafeNativeRecovery.s.sol b/script/DeploySafeNativeRecovery.s.sol deleted file mode 100644 index 13f5d5ec..00000000 --- a/script/DeploySafeNativeRecovery.s.sol +++ /dev/null @@ -1,72 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.25; - -/* solhint-disable no-console, gas-custom-errors */ - -import { console } from "forge-std/console.sol"; -import { UserOverrideableDKIMRegistry } from "@zk-email/contracts/UserOverrideableDKIMRegistry.sol"; -import { EmailAuth } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol"; -import { SafeRecoveryCommandHandler } from "src/handlers/SafeRecoveryCommandHandler.sol"; -import { SafeEmailRecoveryModule } from "src/modules/SafeEmailRecoveryModule.sol"; -import { BaseDeployScript } from "./BaseDeployScript.s.sol"; - -contract DeploySafeNativeRecovery_Script is BaseDeployScript { - function run() public override { - super.run(); - vm.startBroadcast(vm.envUint("PRIVATE_KEY")); - address verifier = vm.envOr("ZK_VERIFIER", address(0)); - address dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); - address emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); - address commandHandler = vm.envOr("COMMAND_HANDLER", address(0)); - uint256 minimumDelay = vm.envOr("MINIMUM_DELAY", uint256(0)); - address killSwitchAuthorizer = vm.envAddress("KILL_SWITCH_AUTHORIZER"); - - address initialOwner = vm.addr(vm.envUint("PRIVATE_KEY")); - - uint256 salt = vm.envOr("CREATE2_SALT", uint256(0)); - - console.log("verifier %s", verifier); - - UserOverrideableDKIMRegistry dkim; - - if (verifier == address(0)) { - verifier = deployVerifier(initialOwner, salt); - } - - // Deploy Useroverridable DKIM registry - dkim = UserOverrideableDKIMRegistry(vm.envOr("DKIM_REGISTRY", address(0))); - uint256 setTimeDelay = vm.envOr("DKIM_DELAY", uint256(0)); - if (address(dkim) == address(0)) { - dkim = UserOverrideableDKIMRegistry( - deployUserOverrideableDKIMRegistry( - initialOwner, dkimRegistrySigner, setTimeDelay, salt - ) - ); - } - - if (emailAuthImpl == address(0)) { - emailAuthImpl = address(new EmailAuth{ salt: bytes32(salt) }()); - console.log("Deployed Email Auth at", emailAuthImpl); - } - - if (commandHandler == address(0)) { - commandHandler = address(new SafeRecoveryCommandHandler{ salt: bytes32(salt) }()); - console.log("Deployed Command Handler at", commandHandler); - } - - address module = address( - new SafeEmailRecoveryModule{ salt: bytes32(salt) }( - verifier, - address(dkim), - emailAuthImpl, - commandHandler, - minimumDelay, - killSwitchAuthorizer - ) - ); - - console.log("Deployed Email Recovery Module at ", vm.toString(module)); - - vm.stopBroadcast(); - } -} diff --git a/script/DeployUniversalEmailRecoveryModule.s.sol b/script/DeployUniversalEmailRecoveryModule.s.sol deleted file mode 100644 index efc50b20..00000000 --- a/script/DeployUniversalEmailRecoveryModule.s.sol +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.25; - -/* solhint-disable no-console, gas-custom-errors */ - -import { console } from "forge-std/console.sol"; -import { EmailRecoveryCommandHandler } from "src/handlers/EmailRecoveryCommandHandler.sol"; -import { UserOverrideableDKIMRegistry } from "@zk-email/contracts/UserOverrideableDKIMRegistry.sol"; -import { EmailAuth } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol"; -import { EmailRecoveryUniversalFactory } from "src/factories/EmailRecoveryUniversalFactory.sol"; -import { BaseDeployScript } from "./BaseDeployScript.s.sol"; - -contract DeployUniversalEmailRecoveryModuleScript is BaseDeployScript { - function run() public override { - super.run(); - vm.startBroadcast(vm.envUint("PRIVATE_KEY")); - address verifier = vm.envOr("VERIFIER", address(0)); - address dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); - address emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); - uint256 minimumDelay = vm.envOr("MINIMUM_DELAY", uint256(0)); - address killSwitchAuthorizer = vm.envAddress("KILL_SWITCH_AUTHORIZER"); - - address initialOwner = vm.addr(vm.envUint("PRIVATE_KEY")); - uint256 salt = vm.envOr("CREATE2_SALT", uint256(0)); - UserOverrideableDKIMRegistry dkim; - - if (verifier == address(0)) { - verifier = deployVerifier(initialOwner, salt); - } - - // Deploy Useroverridable DKIM registry - dkim = UserOverrideableDKIMRegistry(vm.envOr("DKIM_REGISTRY", address(0))); - uint256 setTimeDelay = vm.envOr("DKIM_DELAY", uint256(0)); - if (address(dkim) == address(0)) { - dkim = UserOverrideableDKIMRegistry( - deployUserOverrideableDKIMRegistry( - initialOwner, dkimRegistrySigner, setTimeDelay, salt - ) - ); - } - - if (emailAuthImpl == address(0)) { - emailAuthImpl = address(new EmailAuth{ salt: bytes32(salt) }()); - console.log("Deployed Email Auth at", emailAuthImpl); - } - - address _factory = vm.envOr("RECOVERY_FACTORY", address(0)); - if (_factory == address(0)) { - _factory = address( - new EmailRecoveryUniversalFactory{ salt: bytes32(salt) }(verifier, emailAuthImpl) - ); - console.log("Deployed Email Recovery Factory at", _factory); - } - { - EmailRecoveryUniversalFactory factory = EmailRecoveryUniversalFactory(_factory); - (address module, address commandHandler) = factory.deployUniversalEmailRecoveryModule( - bytes32(uint256(0)), - bytes32(uint256(0)), - type(EmailRecoveryCommandHandler).creationCode, - minimumDelay, - killSwitchAuthorizer, - address(dkim) - ); - - console.log("Deployed Email Recovery Module at", vm.toString(module)); - console.log("Deployed Email Recovery Handler at", vm.toString(commandHandler)); - vm.stopBroadcast(); - } - } -} diff --git a/script/README.md b/script/README.md new file mode 100644 index 00000000..5b002cbc --- /dev/null +++ b/script/README.md @@ -0,0 +1,59 @@ +# ZK Email Recovery Deployment Scripts + +This directory contains scripts for deploying various ZK Email recovery modules and related contracts. It is possible to combine different command handlers with different modules. Each deployment script directory has an account hiding script. The account hiding feature means that guardians cannot see what account they are recovering in emails. Guardians can still find the address onchain however. + +### `BaseDeployScript.s.sol` + +Base script with helper functions for deploying common contracts like Verifier and DKIM Registry. + +### `ComputeSafeRecoveryCalldata.s.sol` + +Utility script to compute calldata for Safe recovery. Used by 7579 safes and non-7579 Safes. + +## `7579/` + +Contains deployment scripts for 7579-compatible recovery modules. Find more information on 7579 on the [ERC7579 website](https://erc7579.com/) + +## `EmailRecoveryModule/` + +### `DeployEmailRecoveryModule.s.sol` + +Deploys a validator specific recovery module. This module type is coupled to a specific validator address + +### `DeployEmailRecoveryModuleWithAccountHiding.s.sol` + +Deploys a validator specific recovery module with additional account address hiding features for enhanced privacy in emails + +## `UniversalEmailRecoveryModule/` + +### `DeployUniversalEmailRecoveryModule.s.sol` + +Deploys a generic recovery module that can be used with any 7579 validator + +### `DeployUniversalEmailRecoveryModuleWithAccountHiding.s.sol` + +Deploys an generic recovery module with additional account address hiding features for enhanced privacy in emails + +## `Safe/` + +Contains deployment scripts for Safe-specific recovery modules that do not use ERC7579. This is useful for existing Safes that are not 4337 compatible (versions below `v1.4.1`), and also newer Safes that do not want a dependency on ERC7579. + +### `DeploySafeRecovery.s.sol` + +Deploys a [native safe module](https://docs.safe.global/advanced/smart-account-modules) for ZK Email recovery + +### `DeploySafeRecoveryWithAccountHiding.s.sol` + +Deploys a [native safe module](https://docs.safe.global/advanced/smart-account-modules) for ZK Email recovery with additional account address hiding features for enhanced privacy in emails + +## `Safe7579/` + +Contains deployment scripts for Safe 7579-compatible recovery modules using ZK Email. For more information on how Safe's interact with 7579, visit the [Safe7579 project](https://github.com/rhinestonewtf/safe7579). + +### `DeploySafeRecovery.s.sol` + +Deploys a 7579-compatible Safe recovery module + +### `DeploySafeRecoveryWithAccountHiding.s.sol` + +Deploys Safe recovery module with additional account address hiding features for enhanced privacy in emails diff --git a/script/Safe/DeploySafeNativeRecovery.s.sol b/script/Safe/DeploySafeNativeRecovery.s.sol new file mode 100644 index 00000000..367181b7 --- /dev/null +++ b/script/Safe/DeploySafeNativeRecovery.s.sol @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.25; + +/* solhint-disable no-console, gas-custom-errors */ + +import { console } from "forge-std/console.sol"; +import { EmailAuth } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol"; +import { SafeRecoveryCommandHandler } from "src/handlers/SafeRecoveryCommandHandler.sol"; +import { SafeEmailRecoveryModule } from "src/modules/SafeEmailRecoveryModule.sol"; +import { BaseDeployScript } from "../BaseDeployScript.s.sol"; + +contract DeploySafeNativeRecovery_Script is BaseDeployScript { + address public verifier; + address public dkim; + address public emailAuthImpl; + address public commandHandler; + uint256 public minimumDelay; + address public killSwitchAuthorizer; + + address public initialOwner; + address public dkimRegistrySigner; + uint256 public dkimDelay; + uint256 public salt; + + function run() public override { + super.run(); + vm.startBroadcast(vm.envUint("PRIVATE_KEY")); + verifier = vm.envOr("VERIFIER", address(0)); + dkim = vm.envOr("DKIM_REGISTRY", address(0)); + emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); + commandHandler = vm.envOr("COMMAND_HANDLER", address(0)); + minimumDelay = vm.envOr("MINIMUM_DELAY", uint256(0)); + killSwitchAuthorizer = vm.envAddress("KILL_SWITCH_AUTHORIZER"); + + initialOwner = vm.addr(vm.envUint("PRIVATE_KEY")); + dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); + dkimDelay = vm.envOr("DKIM_DELAY", uint256(0)); + salt = vm.envOr("CREATE2_SALT", uint256(0)); + + if (verifier == address(0)) { + verifier = deployVerifier(initialOwner, salt); + } + + if (dkim == address(0)) { + dkim = deployUserOverrideableDKIMRegistry( + initialOwner, dkimRegistrySigner, dkimDelay, salt + ); + } + + if (emailAuthImpl == address(0)) { + emailAuthImpl = address(new EmailAuth{ salt: bytes32(salt) }()); + console.log("EmailAuth implemenation deployed at", emailAuthImpl); + } + + if (commandHandler == address(0)) { + commandHandler = address(new SafeRecoveryCommandHandler{ salt: bytes32(salt) }()); + console.log("SafeRecoveryCommandHandler deployed at", commandHandler); + } + + address module = address( + new SafeEmailRecoveryModule{ salt: bytes32(salt) }( + verifier, + address(dkim), + emailAuthImpl, + commandHandler, + minimumDelay, + killSwitchAuthorizer + ) + ); + + console.log("SafeEmailRecoveryModule deployed at ", vm.toString(module)); + + vm.stopBroadcast(); + } +} diff --git a/script/DeploySafeNativeRecoveryWithAccountHiding.s.sol b/script/Safe/DeploySafeNativeRecoveryWithAccountHiding.s.sol similarity index 54% rename from script/DeploySafeNativeRecoveryWithAccountHiding.s.sol rename to script/Safe/DeploySafeNativeRecoveryWithAccountHiding.s.sol index 2ef58174..5c6db312 100644 --- a/script/DeploySafeNativeRecoveryWithAccountHiding.s.sol +++ b/script/Safe/DeploySafeNativeRecoveryWithAccountHiding.s.sol @@ -4,50 +4,54 @@ pragma solidity ^0.8.25; /* solhint-disable no-console, gas-custom-errors */ import { console } from "forge-std/console.sol"; -import { UserOverrideableDKIMRegistry } from "@zk-email/contracts/UserOverrideableDKIMRegistry.sol"; import { EmailAuth } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol"; import { AccountHidingRecoveryCommandHandler } from "src/handlers/AccountHidingRecoveryCommandHandler.sol"; import { SafeEmailRecoveryModule } from "src/modules/SafeEmailRecoveryModule.sol"; -import { BaseDeployScript } from "./BaseDeployScript.s.sol"; +import { BaseDeployScript } from "../BaseDeployScript.s.sol"; contract DeploySafeNativeRecovery_Script is BaseDeployScript { + address public verifier; + address public dkim; + address public emailAuthImpl; + address public commandHandler; + uint256 public minimumDelay; + address public killSwitchAuthorizer; + + address public initialOwner; + address public dkimRegistrySigner; + uint256 public dkimDelay; + uint256 public salt; + function run() public override { super.run(); vm.startBroadcast(vm.envUint("PRIVATE_KEY")); - address verifier = vm.envOr("VERIFIER", address(0)); - address dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); - address emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); - address commandHandler = vm.envOr("COMMAND_HANDLER", address(0)); - uint256 minimumDelay = vm.envOr("MINIMUM_DELAY", uint256(0)); - address killSwitchAuthorizer = vm.envAddress("KILL_SWITCH_AUTHORIZER"); - - address initialOwner = vm.addr(vm.envUint("PRIVATE_KEY")); - - uint256 salt = vm.envOr("CREATE2_SALT", uint256(0)); - - console.log("verifier %s", verifier); + verifier = vm.envOr("VERIFIER", address(0)); + dkim = vm.envOr("DKIM_REGISTRY", address(0)); + emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); + commandHandler = vm.envOr("COMMAND_HANDLER", address(0)); + minimumDelay = vm.envOr("MINIMUM_DELAY", uint256(0)); + killSwitchAuthorizer = vm.envAddress("KILL_SWITCH_AUTHORIZER"); - UserOverrideableDKIMRegistry dkim; + initialOwner = vm.addr(vm.envUint("PRIVATE_KEY")); + dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); + dkimDelay = vm.envOr("DKIM_DELAY", uint256(0)); + salt = vm.envOr("CREATE2_SALT", uint256(0)); if (verifier == address(0)) { verifier = deployVerifier(initialOwner, salt); } // Deploy Useroverridable DKIM registry - dkim = UserOverrideableDKIMRegistry(vm.envOr("DKIM_REGISTRY", address(0))); - uint256 setTimeDelay = vm.envOr("DKIM_DELAY", uint256(0)); if (address(dkim) == address(0)) { - dkim = UserOverrideableDKIMRegistry( - deployUserOverrideableDKIMRegistry( - initialOwner, dkimRegistrySigner, setTimeDelay, salt - ) + dkim = deployUserOverrideableDKIMRegistry( + initialOwner, dkimRegistrySigner, dkimDelay, salt ); } if (emailAuthImpl == address(0)) { emailAuthImpl = address(new EmailAuth{ salt: bytes32(salt) }()); - console.log("Deployed Email Auth at", emailAuthImpl); + console.log("EmailAuth implemenation deployed at", emailAuthImpl); } if (commandHandler == address(0)) { @@ -67,7 +71,7 @@ contract DeploySafeNativeRecovery_Script is BaseDeployScript { ) ); - console.log("Deployed Email Recovery Module at ", vm.toString(module)); + console.log("SafeEmailRecoveryModule deployed at ", vm.toString(module)); vm.stopBroadcast(); } diff --git a/script/DeploySafeRecovery.s.sol b/script/Safe7579/DeploySafeRecovery.s.sol similarity index 51% rename from script/DeploySafeRecovery.s.sol rename to script/Safe7579/DeploySafeRecovery.s.sol index 9b2884d2..36fb9d58 100644 --- a/script/DeploySafeRecovery.s.sol +++ b/script/Safe7579/DeploySafeRecovery.s.sol @@ -7,65 +7,66 @@ import { console } from "forge-std/console.sol"; import { SafeRecoveryCommandHandler } from "src/handlers/SafeRecoveryCommandHandler.sol"; import { EmailRecoveryUniversalFactory } from "src/factories/EmailRecoveryUniversalFactory.sol"; import { EmailAuth } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol"; -import { UserOverrideableDKIMRegistry } from "@zk-email/contracts/UserOverrideableDKIMRegistry.sol"; - -import { Safe7579 } from "safe7579/Safe7579.sol"; -import { Safe7579Launchpad } from "safe7579/Safe7579Launchpad.sol"; -import { IERC7484 } from "safe7579/interfaces/IERC7484.sol"; -import { BaseDeployScript } from "./BaseDeployScript.s.sol"; +import { BaseDeployScript } from "../BaseDeployScript.s.sol"; // 1. `source .env` // 2. `forge script --chain sepolia script/DeploySafeRecovery.s.sol:DeploySafeRecovery_Script // --rpc-url $BASE_SEPOLIA_RPC_URL --broadcast -vvvv` contract DeploySafeRecovery_Script is BaseDeployScript { address public verifier; - address public dkimRegistrySigner; + address public dkim; address public emailAuthImpl; uint256 public minimumDelay; address public killSwitchAuthorizer; + address public factory; address public initialOwner; + address public dkimRegistrySigner; + uint256 public dkimDelay; uint256 public salt; - UserOverrideableDKIMRegistry public dkim; - function run() public override { super.run(); - address entryPoint = address(0x0000000071727De22E5E9d8BAf0edAc6f37da032); - IERC7484 registry = IERC7484(0xe0cde9239d16bEf05e62Bbf7aA93e420f464c826); vm.startBroadcast(vm.envUint("PRIVATE_KEY")); verifier = vm.envOr("VERIFIER", address(0)); - dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); + dkim = vm.envOr("DKIM_REGISTRY", address(0)); emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); minimumDelay = vm.envOr("MINIMUM_DELAY", uint256(0)); killSwitchAuthorizer = vm.envAddress("KILL_SWITCH_AUTHORIZER"); + factory = vm.envOr("RECOVERY_FACTORY", address(0)); + initialOwner = vm.addr(vm.envUint("PRIVATE_KEY")); + dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); + dkimDelay = vm.envOr("DKIM_DELAY", uint256(0)); salt = vm.envOr("CREATE2_SALT", uint256(0)); if (verifier == address(0)) { verifier = deployVerifier(initialOwner, salt); } - // Deploy Useroverridable DKIM registry - dkim = UserOverrideableDKIMRegistry(vm.envOr("DKIM_REGISTRY", address(0))); - uint256 setTimeDelay = vm.envOr("DKIM_DELAY", uint256(0)); - if (address(dkim) == address(0)) { - dkim = UserOverrideableDKIMRegistry( - deployUserOverrideableDKIMRegistry( - initialOwner, dkimRegistrySigner, setTimeDelay, salt - ) + if (dkim == address(0)) { + dkim = deployUserOverrideableDKIMRegistry( + initialOwner, dkimRegistrySigner, dkimDelay, salt ); } if (emailAuthImpl == address(0)) { emailAuthImpl = address(new EmailAuth{ salt: bytes32(salt) }()); - console.log("Deployed Email Auth at", emailAuthImpl); + console.log("EmailAuth implemenation deployed at", emailAuthImpl); } - EmailRecoveryUniversalFactory factory = - new EmailRecoveryUniversalFactory{ salt: bytes32(salt) }(verifier, emailAuthImpl); - (address module, address commandHandler) = factory.deployUniversalEmailRecoveryModule( + if (factory == address(0)) { + factory = address( + new EmailRecoveryUniversalFactory{ salt: bytes32(salt) }(verifier, emailAuthImpl) + ); + console.log("EmailRecoveryUniversalFactory deployed at", factory); + } + + EmailRecoveryUniversalFactory emailRecoveryUniversalFactory = + EmailRecoveryUniversalFactory(factory); + (address module, address commandHandler) = emailRecoveryUniversalFactory + .deployUniversalEmailRecoveryModule( bytes32(salt), bytes32(salt), type(SafeRecoveryCommandHandler).creationCode, @@ -74,14 +75,8 @@ contract DeploySafeRecovery_Script is BaseDeployScript { address(dkim) ); - address safe7579 = address(new Safe7579{ salt: bytes32(salt) }()); - address safe7579Launchpad = - address(new Safe7579Launchpad{ salt: bytes32(salt) }(entryPoint, registry)); - - console.log("Deployed Email Recovery Module at ", vm.toString(module)); - console.log("Deployed Email Recovery Handler at ", vm.toString(commandHandler)); - console.log("Deployed Safe 7579 at ", vm.toString(safe7579)); - console.log("Deployed Safe 7579 Launchpad at ", vm.toString(safe7579Launchpad)); + console.log("UniversalEmailRecoveryModule deployed at", vm.toString(module)); + console.log("SafeRecoveryCommandHandler deployed at", vm.toString(commandHandler)); vm.stopBroadcast(); } diff --git a/script/DeploySafeRecoveryWithAccountHiding.s.sol b/script/Safe7579/DeploySafeRecoveryWithAccountHiding.s.sol similarity index 53% rename from script/DeploySafeRecoveryWithAccountHiding.s.sol rename to script/Safe7579/DeploySafeRecoveryWithAccountHiding.s.sol index 30888d1b..1245f311 100644 --- a/script/DeploySafeRecoveryWithAccountHiding.s.sol +++ b/script/Safe7579/DeploySafeRecoveryWithAccountHiding.s.sol @@ -8,64 +8,67 @@ import { AccountHidingRecoveryCommandHandler } from "src/handlers/AccountHidingRecoveryCommandHandler.sol"; import { EmailRecoveryUniversalFactory } from "src/factories/EmailRecoveryUniversalFactory.sol"; import { EmailAuth } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol"; - -import { Safe7579 } from "safe7579/Safe7579.sol"; -import { Safe7579Launchpad } from "safe7579/Safe7579Launchpad.sol"; -import { IERC7484 } from "safe7579/interfaces/IERC7484.sol"; -import { BaseDeployScript } from "./BaseDeployScript.s.sol"; +import { BaseDeployScript } from "../BaseDeployScript.s.sol"; // 1. `source .env` // 2. `forge script // script/DeploySafeRecoveryWithAccountHiding.s.sol:DeploySafeRecoveryWithAccountHiding_Script // --rpc-url $RPC_URL --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY -vvvv` contract DeploySafeRecoveryWithAccountHiding_Script is BaseDeployScript { - address verifier; - address dkim; - address dkimRegistrySigner; - address emailAuthImpl; - uint256 minimumDelay; - address killSwitchAuthorizer; + address public verifier; + address public dkim; + address public emailAuthImpl; + uint256 public minimumDelay; + address public killSwitchAuthorizer; + address public factory; - address initialOwner; - uint256 salt; + address public initialOwner; + address public dkimRegistrySigner; + uint256 public dkimDelay; + uint256 public salt; function run() public override { super.run(); - address entryPoint = address(0x0000000071727De22E5E9d8BAf0edAc6f37da032); - IERC7484 registry = IERC7484(0xe0cde9239d16bEf05e62Bbf7aA93e420f464c826); vm.startBroadcast(vm.envUint("PRIVATE_KEY")); verifier = vm.envOr("VERIFIER", address(0)); dkim = vm.envOr("DKIM_REGISTRY", address(0)); - dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); minimumDelay = vm.envOr("MINIMUM_DELAY", uint256(0)); killSwitchAuthorizer = vm.envAddress("KILL_SWITCH_AUTHORIZER"); + factory = vm.envOr("RECOVERY_FACTORY", address(0)); initialOwner = vm.addr(vm.envUint("PRIVATE_KEY")); + dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0)); + dkimDelay = vm.envOr("DKIM_DELAY", uint256(0)); salt = vm.envOr("CREATE2_SALT", uint256(0)); if (verifier == address(0)) { verifier = deployVerifier(initialOwner, salt); } - // Deploy Useroverridable DKIM registry - dkim = vm.envOr("DKIM_REGISTRY", address(0)); - uint256 setTimeDelay = vm.envOr("DKIM_DELAY", uint256(0)); if (dkim == address(0)) { dkim = deployUserOverrideableDKIMRegistry( - initialOwner, dkimRegistrySigner, setTimeDelay, salt + initialOwner, dkimRegistrySigner, dkimDelay, salt ); } if (emailAuthImpl == address(0)) { emailAuthImpl = address(new EmailAuth{ salt: bytes32(salt) }()); - console.log("Deployed Email Auth at", emailAuthImpl); + console.log("EmailAuth implemenation deployed at", emailAuthImpl); } - EmailRecoveryUniversalFactory factory = - new EmailRecoveryUniversalFactory{ salt: bytes32(salt) }(verifier, emailAuthImpl); - (address module, address commandHandler) = factory.deployUniversalEmailRecoveryModule( + if (factory == address(0)) { + factory = address( + new EmailRecoveryUniversalFactory{ salt: bytes32(salt) }(verifier, emailAuthImpl) + ); + console.log("EmailRecoveryUniversalFactory deployed at", factory); + } + + EmailRecoveryUniversalFactory emailRecoveryUniversalFactory = + EmailRecoveryUniversalFactory(factory); + (address module, address commandHandler) = emailRecoveryUniversalFactory + .deployUniversalEmailRecoveryModule( bytes32(uint256(0)), bytes32(uint256(0)), type(AccountHidingRecoveryCommandHandler).creationCode, @@ -74,14 +77,8 @@ contract DeploySafeRecoveryWithAccountHiding_Script is BaseDeployScript { dkim ); - address safe7579 = address(new Safe7579{ salt: bytes32(uint256(0)) }()); - address safe7579Launchpad = - address(new Safe7579Launchpad{ salt: bytes32(uint256(0)) }(entryPoint, registry)); - - console.log("Deployed Email Recovery Module at ", vm.toString(module)); - console.log("Deployed Email Recovery Handler at ", vm.toString(commandHandler)); - console.log("Deployed Safe 7579 at ", vm.toString(safe7579)); - console.log("Deployed Safe 7579 Launchpad at ", vm.toString(safe7579Launchpad)); + console.log("UniversalEmailRecoveryModule deployed at ", vm.toString(module)); + console.log("AccountHidingRecoveryCommandHandler deployed at ", vm.toString(commandHandler)); vm.stopBroadcast(); } diff --git a/script/Compute7579RecoveryDataHash.s.sol b/script/test/Compute7579RecoveryDataHash.s.sol similarity index 100% rename from script/Compute7579RecoveryDataHash.s.sol rename to script/test/Compute7579RecoveryDataHash.s.sol diff --git a/src/test/OwnableValidator.sol b/src/test/OwnableValidator.sol index 8f78521a..02640c78 100644 --- a/src/test/OwnableValidator.sol +++ b/src/test/OwnableValidator.sol @@ -77,12 +77,12 @@ contract OwnableValidator is ERC7579ValidatorBase { } function validateSignatureWithData( - bytes32 hash, - bytes calldata signature, - bytes calldata data + bytes32, /*hash*/ + bytes calldata, /*signature*/ + bytes calldata /*data*/ ) external - view + pure override returns (bool) { diff --git a/test/Base.t.sol b/test/Base.t.sol index e70483e1..095c4285 100644 --- a/test/Base.t.sol +++ b/test/Base.t.sol @@ -127,12 +127,12 @@ abstract contract BaseTest is RhinestoneModuleKit, Test { killSwitchAuthorizer = vm.addr(2); vm.startPrank(zkEmailDeployer); - uint256 setTimeDelay = 0; + uint256 dkimDelay = 0; UserOverrideableDKIMRegistry overrideableDkimImpl = new UserOverrideableDKIMRegistry(); ERC1967Proxy dkimProxy = new ERC1967Proxy( address(overrideableDkimImpl), abi.encodeCall( - overrideableDkimImpl.initialize, (zkEmailDeployer, zkEmailDeployer, setTimeDelay) + overrideableDkimImpl.initialize, (zkEmailDeployer, zkEmailDeployer, dkimDelay) ) ); dkimRegistry = UserOverrideableDKIMRegistry(address(dkimProxy)); diff --git a/test/unit/EmailRecoveryManager/deInitRecoveryModule.t.sol b/test/unit/EmailRecoveryManager/deInitRecoveryModule.t.sol index c13f05ef..d4208e3a 100644 --- a/test/unit/EmailRecoveryManager/deInitRecoveryModule.t.sol +++ b/test/unit/EmailRecoveryManager/deInitRecoveryModule.t.sol @@ -12,7 +12,6 @@ contract EmailRecoveryManager_deInitRecoveryModule_Test is UnitBase { super.setUp(); } - function test_DeInitRecoveryModule_RevertWhen_RecoveryInProcess() public { acceptGuardian(accountAddress1, guardians1[0], emailRecoveryModuleAddress); acceptGuardian(accountAddress1, guardians1[1], emailRecoveryModuleAddress); @@ -89,7 +88,6 @@ contract EmailRecoveryManager_deInitRecoveryModule_Test is UnitBase { assertFalse(isActivated); } - function test_DeInitRecoveryModule_SucceedsWhen_KillSwitchEnabled() public { acceptGuardian(accountAddress1, guardians1[0], emailRecoveryModuleAddress); acceptGuardian(accountAddress1, guardians1[1], emailRecoveryModuleAddress); diff --git a/test/unit/handlers/AccountHidingRecoveryCommandHandler/extractRecoveredAccountFromRecoveryCommand.t.sol b/test/unit/handlers/AccountHidingRecoveryCommandHandler/extractRecoveredAccountFromRecoveryCommand.t.sol index f42ce985..29aeee49 100644 --- a/test/unit/handlers/AccountHidingRecoveryCommandHandler/extractRecoveredAccountFromRecoveryCommand.t.sol +++ b/test/unit/handlers/AccountHidingRecoveryCommandHandler/extractRecoveredAccountFromRecoveryCommand.t.sol @@ -18,7 +18,7 @@ contract AccountHidingRecoveryCommandHandler_extractRecoveredAccountFromRecovery accountHidingRecoveryCommandHandler = new AccountHidingRecoveryCommandHandler(); } - function test_ExtractRecoveredAccountFromRecoveryCommand_FailsWhenHashNotStored() public { + function test_ExtractRecoveredAccountFromRecoveryCommand_FailsWhenHashNotStored() public view { bytes32 accountHash = keccak256(abi.encodePacked(accountAddress1)); string memory accountHashString = uint256(accountHash).toHexString(32); string memory recoveryDataHashString = uint256(recoveryDataHash).toHexString(32); diff --git a/test/unit/modules/EmailRecoveryModule/name.t.sol b/test/unit/modules/EmailRecoveryModule/name.t.sol index 736f020d..f6a69d77 100644 --- a/test/unit/modules/EmailRecoveryModule/name.t.sol +++ b/test/unit/modules/EmailRecoveryModule/name.t.sol @@ -8,7 +8,7 @@ contract EmailRecoveryModule_name_Test is EmailRecoveryModuleBase { super.setUp(); } - function test_Name_ReturnsName() public { + function test_Name_ReturnsName() public view { string memory expectedName = "ZKEmail.EmailRecoveryModule"; string memory actualName = emailRecoveryModule.name(); assertEq(actualName, expectedName, "Module name should match expected value"); diff --git a/test/unit/modules/EmailRecoveryModule/version.t.sol b/test/unit/modules/EmailRecoveryModule/version.t.sol index 617bbe69..4b221cb6 100644 --- a/test/unit/modules/EmailRecoveryModule/version.t.sol +++ b/test/unit/modules/EmailRecoveryModule/version.t.sol @@ -8,7 +8,7 @@ contract EmailRecoveryModule_version_Test is EmailRecoveryModuleBase { super.setUp(); } - function test_Version_ReturnsVersion() public { + function test_Version_ReturnsVersion() public view { string memory expectedVersion = "1.0.0"; string memory actualVersion = emailRecoveryModule.version(); assertEq(actualVersion, expectedVersion, "Module version should match expected value"); diff --git a/test/unit/modules/UniversalEmailRecoveryModule/isModuleType.t.sol b/test/unit/modules/UniversalEmailRecoveryModule/isModuleType.t.sol index bd435c75..8958c65e 100644 --- a/test/unit/modules/UniversalEmailRecoveryModule/isModuleType.t.sol +++ b/test/unit/modules/UniversalEmailRecoveryModule/isModuleType.t.sol @@ -9,7 +9,7 @@ contract UniversalEmailRecoveryModule_isModuleType_Test is UnitBase { super.setUp(); } - function test_IsModuleType_ReturnsModuleType() public { + function test_IsModuleType_ReturnsModuleType() public view { // Verify that the module type is correct bool isExecutor = emailRecoveryModule.isModuleType(MODULE_TYPE_EXECUTOR); assertTrue(isExecutor, "Should be an executor module"); diff --git a/test/unit/modules/UniversalEmailRecoveryModule/name.t.sol b/test/unit/modules/UniversalEmailRecoveryModule/name.t.sol index 8cd8e676..3ebc34da 100644 --- a/test/unit/modules/UniversalEmailRecoveryModule/name.t.sol +++ b/test/unit/modules/UniversalEmailRecoveryModule/name.t.sol @@ -8,7 +8,7 @@ contract UniversalEmailRecoveryModule_name_Test is UnitBase { super.setUp(); } - function test_Name_ReturnsName() public { + function test_Name_ReturnsName() public view { string memory expectedName = "ZKEmail.UniversalEmailRecoveryModule"; string memory actualName = emailRecoveryModule.name(); assertEq(actualName, expectedName, "Module name should match expected value"); diff --git a/test/unit/modules/UniversalEmailRecoveryModule/version.t.sol b/test/unit/modules/UniversalEmailRecoveryModule/version.t.sol index 65e78d5b..f50b0c53 100644 --- a/test/unit/modules/UniversalEmailRecoveryModule/version.t.sol +++ b/test/unit/modules/UniversalEmailRecoveryModule/version.t.sol @@ -8,7 +8,7 @@ contract UniversalEmailRecoveryModule_version_Test is UnitBase { super.setUp(); } - function test_Version_ReturnsVersion() public { + function test_Version_ReturnsVersion() public view { string memory expectedVersion = "1.0.0"; string memory actualVersion = emailRecoveryModule.version(); assertEq(actualVersion, expectedVersion, "Module version should match expected value"); diff --git a/script/test/DeployEmailRecoveryModule.t.sol b/test/unit/script/7579/EmailRecoveryModule/DeployEmailRecoveryModule.t.sol similarity index 91% rename from script/test/DeployEmailRecoveryModule.t.sol rename to test/unit/script/7579/EmailRecoveryModule/DeployEmailRecoveryModule.t.sol index 5bfec904..4201e219 100644 --- a/script/test/DeployEmailRecoveryModule.t.sol +++ b/test/unit/script/7579/EmailRecoveryModule/DeployEmailRecoveryModule.t.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.12; -import { DeployEmailRecoveryModuleScript } from "../DeployEmailRecoveryModule.s.sol"; -import { BaseDeployTest } from "./BaseDeployTest.sol"; +import { DeployEmailRecoveryModuleScript } from + "script/7579/EmailRecoveryModule/DeployEmailRecoveryModule.s.sol"; +import { BaseDeployTest } from "../../BaseDeployTest.sol"; /** * @title DeployEmailRecoveryModule_Test diff --git a/script/test/DeployUniversalEmailRecoveryModule.t.sol b/test/unit/script/7579/UniversalEmailRecoveryModule/DeployUniversalEmailRecoveryModule.t.sol similarity index 92% rename from script/test/DeployUniversalEmailRecoveryModule.t.sol rename to test/unit/script/7579/UniversalEmailRecoveryModule/DeployUniversalEmailRecoveryModule.t.sol index 150928b5..8e6d4be6 100644 --- a/script/test/DeployUniversalEmailRecoveryModule.t.sol +++ b/test/unit/script/7579/UniversalEmailRecoveryModule/DeployUniversalEmailRecoveryModule.t.sol @@ -2,8 +2,8 @@ pragma solidity ^0.8.12; import { DeployUniversalEmailRecoveryModuleScript } from - "../DeployUniversalEmailRecoveryModule.s.sol"; -import { BaseDeployTest } from "./BaseDeployTest.sol"; + "script/7579/UniversalEmailRecoveryModule/DeployUniversalEmailRecoveryModule.s.sol"; +import { BaseDeployTest } from "../../BaseDeployTest.sol"; /// @title DeployUniversalEmailRecoveryModule_Test /// @notice Contains tests for deploying the Universal Email Recovery Module diff --git a/script/test/BaseDeployTest.sol b/test/unit/script/BaseDeployTest.sol similarity index 100% rename from script/test/BaseDeployTest.sol rename to test/unit/script/BaseDeployTest.sol diff --git a/script/test/DeploySafeNativeRecovery.t.sol b/test/unit/script/Safe/DeploySafeNativeRecovery.t.sol similarity index 93% rename from script/test/DeploySafeNativeRecovery.t.sol rename to test/unit/script/Safe/DeploySafeNativeRecovery.t.sol index 9d73e998..905d05de 100644 --- a/script/test/DeploySafeNativeRecovery.t.sol +++ b/test/unit/script/Safe/DeploySafeNativeRecovery.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.12; -import { DeploySafeNativeRecovery_Script } from "../DeploySafeNativeRecovery.s.sol"; -import { BaseDeployTest } from "./BaseDeployTest.sol"; +import { DeploySafeNativeRecovery_Script } from "script/Safe/DeploySafeNativeRecovery.s.sol"; +import { BaseDeployTest } from "../BaseDeployTest.sol"; contract DeploySafeNativeRecovery_Test is BaseDeployTest { /** @@ -26,7 +26,7 @@ contract DeploySafeNativeRecovery_Test is BaseDeployTest { BaseDeployTest.setUp(); // Disable the VERIFIER environment variable - vm.setEnv("ZK_VERIFIER", vm.toString(address(0))); + vm.setEnv("VERIFIER", vm.toString(address(0))); // Instantiate the script and run it DeploySafeNativeRecovery_Script target = new DeploySafeNativeRecovery_Script(); diff --git a/script/test/DeploySafeRecovery.t.sol b/test/unit/script/Safe7579/DeploySafeRecovery.t.sol similarity index 87% rename from script/test/DeploySafeRecovery.t.sol rename to test/unit/script/Safe7579/DeploySafeRecovery.t.sol index 21181469..bc5a6696 100644 --- a/script/test/DeploySafeRecovery.t.sol +++ b/test/unit/script/Safe7579/DeploySafeRecovery.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.12; -import { DeploySafeRecovery_Script } from "../DeploySafeRecovery.s.sol"; -import { BaseDeployTest } from "./BaseDeployTest.sol"; +import { DeploySafeRecovery_Script } from "script/Safe7579/DeploySafeRecovery.s.sol"; +import { BaseDeployTest } from "../BaseDeployTest.sol"; contract DeploySafeRecovery_Test is BaseDeployTest { /** diff --git a/script/test/Compute7579RecoveryDataHash.t.sol b/test/unit/script/test/Compute7579RecoveryDataHash.t.sol similarity index 68% rename from script/test/Compute7579RecoveryDataHash.t.sol rename to test/unit/script/test/Compute7579RecoveryDataHash.t.sol index a440a0a8..f555344f 100644 --- a/script/test/Compute7579RecoveryDataHash.t.sol +++ b/test/unit/script/test/Compute7579RecoveryDataHash.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.12; -import { Compute7579RecoveryDataHash } from "../Compute7579RecoveryDataHash.s.sol"; -import { BaseDeployTest } from "./BaseDeployTest.sol"; +import { Compute7579RecoveryDataHash } from "script/test/Compute7579RecoveryDataHash.s.sol"; +import { BaseDeployTest } from "../BaseDeployTest.sol"; contract Compute7579RecoveryDataHashTest is BaseDeployTest { function setUp() public override {