Skip to content

Commit

Permalink
Revert "feat: use SafeSingletonDeployer for deterministic deployments…
Browse files Browse the repository at this point in the history
… in DeployRecoveryController script"

This reverts commit 88631eb.
  • Loading branch information
JohnGuilding committed Dec 27, 2024
1 parent 2f67632 commit 2638682
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 76 deletions.
3 changes: 1 addition & 2 deletions packages/contracts/remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/
openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/
103 changes: 29 additions & 74 deletions packages/contracts/script/DeployRecoveryController.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 *;
Expand All @@ -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();
}
}

0 comments on commit 2638682

Please sign in to comment.