diff --git a/packages/contracts/remappings.txt b/packages/contracts/remappings.txt index 335e802..c22d4aa 100644 --- a/packages/contracts/remappings.txt +++ b/packages/contracts/remappings.txt @@ -8,5 +8,4 @@ ds-test/=../../node_modules/ds-test/src solady/=../../node_modules/solady/src/ accountabstraction/=../../node_modules/accountabstraction/ solidity-stringutils/=../../node_modules/solidity-stringutils/ -openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/ -safe-singleton-deployer/=lib/safe-singleton-deployer-sol/src/ \ No newline at end of file +openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/ \ No newline at end of file diff --git a/packages/contracts/script/DeployRecoveryController.s.sol b/packages/contracts/script/DeployRecoveryController.s.sol index 0ee1f09..40a47b3 100644 --- a/packages/contracts/script/DeployRecoveryController.s.sol +++ b/packages/contracts/script/DeployRecoveryController.s.sol @@ -12,7 +12,6 @@ import {EmailAuth} from "../src/EmailAuth.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {UserOverrideableDKIMRegistry} from "@zk-email/contracts/UserOverrideableDKIMRegistry.sol"; import {BaseDeployScript} from "./BaseDeployScript.sol"; -import {SafeSingletonDeployer} from "safe-singleton-deployer/SafeSingletonDeployer.sol"; contract Deploy is BaseDeployScript { using ECDSA for *; @@ -23,98 +22,54 @@ contract Deploy is BaseDeployScript { address simpleWallet; address recoveryController; - function deploySingleton( - uint256 deployerPrivateKey, - bytes memory creationCode, - bytes memory initData, - bytes32 salt - ) private returns (address) { - return - SafeSingletonDeployer.broadcastDeploy( - deployerPrivateKey, - creationCode, - initData, - salt - ); - } - - function deployDKIMRegistry( - uint256 deployerPrivateKey, - address initialOwner - ) private returns (address) { - address dkimSigner = vm.envAddress("DKIM_SIGNER"); - if (dkimSigner == address(0)) { - revert("DKIM_SIGNER env var not set"); - } - - uint256 timeDelay = vm.envOr("DKIM_DELAY", uint256(0)); - console.log("DKIM_DELAY: %s", timeDelay); - - return - deploySingleton( - deployerPrivateKey, - type(UserOverrideableDKIMRegistry).creationCode, - abi.encode(initialOwner, dkimSigner, timeDelay), - keccak256("DKIM_REGISTRY") - ); - } - - function logDeployment(string memory name, address addr) private view { - console.log("%s: %s", name, addr); - } - function run() public override { super.run(); - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - address initialOwner = vm.envOr("INITIAL_OWNER", address(0)); + vm.startBroadcast(deployerPrivateKey); // Deploy User-overrideable DKIM registry dkim = vm.envOr("DKIM", address(0)); - if (dkim == address(0)) { - dkim = deployDKIMRegistry(deployerPrivateKey, initialOwner); + if (address(dkim) == address(0)) { + address dkimSigner = vm.envAddress("DKIM_SIGNER"); + if (dkimSigner == address(0)) { + console.log("DKIM_SIGNER env var not set"); + return; + } + uint256 timeDelay = vm.envOr("DKIM_DELAY", uint256(0)); + console.log("DKIM_DELAY: %s", timeDelay); + + dkim = deployUserOverrideableDKIMRegistry( + initialOwner, + dkimSigner, + timeDelay + ); } - logDeployment("UserOverrideableDKIMRegistry", dkim); // Deploy Verifier verifier = vm.envOr("VERIFIER", address(0)); - if (verifier == address(0)) { - verifier = deploySingleton( - deployerPrivateKey, - type(Verifier).creationCode, - abi.encode(initialOwner), - keccak256("VERIFIER") - ); + if (address(verifier) == address(0)) { + verifier = deployVerifier(initialOwner); } - logDeployment("Verifier", verifier); // Deploy EmailAuth Implementation emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); if (emailAuthImpl == address(0)) { - emailAuthImpl = deploySingleton( - deployerPrivateKey, - type(EmailAuth).creationCode, - "", - keccak256("EMAIL_AUTH_IMPL") - ); + emailAuthImpl = deployEmailAuthImplementation(); } - logDeployment("EmailAuth", emailAuthImpl); - // Create RecoveryController - recoveryController = deploySingleton( - deployerPrivateKey, - type(RecoveryController).creationCode, - abi.encode(initialOwner, verifier, dkim, emailAuthImpl), - keccak256("RECOVERY_CONTROLLER") + // Create RecoveryController as EmailAccountRecovery implementation + recoveryController = deployRecoveryController( + initialOwner, + address(verifier), + address(dkim), + address(emailAuthImpl) ); - logDeployment("RecoveryController", recoveryController); // Deploy SimpleWallet Implementation - simpleWallet = deploySingleton( - deployerPrivateKey, - type(SimpleWallet).creationCode, - abi.encode(initialOwner, recoveryController), - keccak256("SIMPLE_WALLET") + simpleWallet = deploySimpleWallet( + initialOwner, + address(recoveryController) ); - logDeployment("SimpleWallet", simpleWallet); + + vm.stopBroadcast(); } }