Skip to content

Commit

Permalink
conditionally deploy factory & linting/formating
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGuilding committed Nov 11, 2024
1 parent 93344c7 commit 1db7a8a
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 137 deletions.
36 changes: 17 additions & 19 deletions script/7579/EmailRecoveryModule/DeployEmailRecoveryModule.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,35 @@ 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";

contract DeployEmailRecoveryModuleScript is BaseDeployScript {
address verifier;
address dkim;
address emailAuthImpl;
address commandHandler;
uint256 minimumDelay;
address killSwitchAuthorizer;
address validatorAddr;
address public verifier;
address public dkim;
address public emailAuthImpl;
uint256 public minimumDelay;
address public killSwitchAuthorizer;
address public validatorAddr;
address public factory;

address initialOwner;
address dkimRegistrySigner;
uint256 dkimDelay;
uint256 salt;
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");
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));
Expand Down Expand Up @@ -62,15 +61,14 @@ contract DeployEmailRecoveryModuleScript is BaseDeployScript {
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("EmailRecoveryFactory deployed at", _factory);
console.log("EmailRecoveryFactory deployed at", factory);
}

EmailRecoveryFactory factory = EmailRecoveryFactory(_factory);
(address module, address commandHandler) = factory.deployEmailRecoveryModule(
EmailRecoveryFactory emailRecoveryFactory = EmailRecoveryFactory(factory);
(address module, address commandHandler) = emailRecoveryFactory.deployEmailRecoveryModule(
bytes32(uint256(0)),
bytes32(uint256(0)),
type(EmailRecoveryCommandHandler).creationCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,35 @@ pragma solidity ^0.8.25;
import { console } from "forge-std/console.sol";
import { AccountHidingRecoveryCommandHandler } from
"src/handlers/AccountHidingRecoveryCommandHandler.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";

contract DeployEmailRecoveryModuleScript is BaseDeployScript {
address verifier;
address dkim;
address emailAuthImpl;
address commandHandler;
uint256 minimumDelay;
address killSwitchAuthorizer;
address validatorAddr;
address public verifier;
address public dkim;
address public emailAuthImpl;
uint256 public minimumDelay;
address public killSwitchAuthorizer;
address public validatorAddr;
address public factory;

address initialOwner;
address dkimRegistrySigner;
uint256 dkimDelay;
uint256 salt;
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");
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));
Expand All @@ -62,15 +61,14 @@ contract DeployEmailRecoveryModuleScript is BaseDeployScript {
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("EmailRecoveryFactory deployed at", _factory);
console.log("EmailRecoveryFactory deployed at", factory);
}

EmailRecoveryFactory factory = EmailRecoveryFactory(_factory);
(address module, address commandHandler) = factory.deployEmailRecoveryModule(
EmailRecoveryFactory emailRecoveryFactory = EmailRecoveryFactory(factory);
(address module, address commandHandler) = emailRecoveryFactory.deployEmailRecoveryModule(
bytes32(uint256(0)),
bytes32(uint256(0)),
type(AccountHidingRecoveryCommandHandler).creationCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,32 @@ 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 { EmailRecoveryUniversalFactory } from "src/factories/EmailRecoveryUniversalFactory.sol";
import { BaseDeployScript } from "../../BaseDeployScript.s.sol";

contract DeployUniversalEmailRecoveryModuleScript is BaseDeployScript {
address verifier;
address dkim;
address emailAuthImpl;
address commandHandler;
uint256 minimumDelay;
address killSwitchAuthorizer;
address public verifier;
address public dkim;
address public emailAuthImpl;
uint256 public minimumDelay;
address public killSwitchAuthorizer;
address public factory;

address initialOwner;
address dkimRegistrySigner;
uint256 dkimDelay;
uint256 salt;
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");
factory = vm.envOr("RECOVERY_FACTORY", address(0));

initialOwner = vm.addr(vm.envUint("PRIVATE_KEY"));
dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0));
Expand All @@ -53,16 +52,17 @@ contract DeployUniversalEmailRecoveryModuleScript is BaseDeployScript {
console.log("EmailAuth implemenation deployed at", emailAuthImpl);
}

address _factory = vm.envOr("RECOVERY_FACTORY", address(0));
if (_factory == address(0)) {
_factory = address(
if (factory == address(0)) {
factory = address(
new EmailRecoveryUniversalFactory{ salt: bytes32(salt) }(verifier, emailAuthImpl)
);
console.log("EmailRecoveryUniversalFactory deployed at", _factory);
console.log("EmailRecoveryUniversalFactory deployed at", factory);
}

EmailRecoveryUniversalFactory factory = EmailRecoveryUniversalFactory(_factory);
(address module, address commandHandler) = factory.deployUniversalEmailRecoveryModule(
EmailRecoveryUniversalFactory emailRecoveryUniversalFactory =
EmailRecoveryUniversalFactory(factory);
(address module, address commandHandler) = emailRecoveryUniversalFactory
.deployUniversalEmailRecoveryModule(
bytes32(uint256(0)),
bytes32(uint256(0)),
type(EmailRecoveryCommandHandler).creationCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,32 @@ pragma solidity ^0.8.25;
import { console } from "forge-std/console.sol";
import { AccountHidingRecoveryCommandHandler } from
"src/handlers/AccountHidingRecoveryCommandHandler.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 {
address verifier;
address dkim;
address emailAuthImpl;
address commandHandler;
uint256 minimumDelay;
address killSwitchAuthorizer;
address public verifier;
address public dkim;
address public emailAuthImpl;
uint256 public minimumDelay;
address public killSwitchAuthorizer;
address public factory;

address initialOwner;
address dkimRegistrySigner;
uint256 dkimDelay;
uint256 salt;
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");
factory = vm.envOr("RECOVERY_FACTORY", address(0));

initialOwner = vm.addr(vm.envUint("PRIVATE_KEY"));
dkimRegistrySigner = vm.envOr("DKIM_SIGNER", address(0));
Expand All @@ -54,16 +53,17 @@ contract DeployUniversalEmailRecoveryModuleScript is BaseDeployScript {
console.log("EmailAuth implemenation deployed at", emailAuthImpl);
}

address _factory = vm.envOr("RECOVERY_FACTORY", address(0));
if (_factory == address(0)) {
_factory = address(
if (factory == address(0)) {
factory = address(
new EmailRecoveryUniversalFactory{ salt: bytes32(salt) }(verifier, emailAuthImpl)
);
console.log("EmailRecoveryUniversalFactory deployed at", _factory);
console.log("EmailRecoveryUniversalFactory deployed at", factory);
}

EmailRecoveryUniversalFactory factory = EmailRecoveryUniversalFactory(_factory);
(address module, address commandHandler) = factory.deployUniversalEmailRecoveryModule(
EmailRecoveryUniversalFactory emailRecoveryUniversalFactory =
EmailRecoveryUniversalFactory(factory);
(address module, address commandHandler) = emailRecoveryUniversalFactory
.deployUniversalEmailRecoveryModule(
bytes32(uint256(0)),
bytes32(uint256(0)),
type(AccountHidingRecoveryCommandHandler).creationCode,
Expand Down
21 changes: 10 additions & 11 deletions script/Safe/DeploySafeNativeRecovery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@ 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 {
address verifier;
address dkim;
address emailAuthImpl;
address commandHandler;
uint256 minimumDelay;
address killSwitchAuthorizer;
address public verifier;
address public dkim;
address public emailAuthImpl;
address public commandHandler;
uint256 public minimumDelay;
address public killSwitchAuthorizer;

address initialOwner;
address dkimRegistrySigner;
uint256 dkimDelay;
uint256 salt;
address public initialOwner;
address public dkimRegistrySigner;
uint256 public dkimDelay;
uint256 public salt;

function run() public override {
super.run();
Expand Down
21 changes: 10 additions & 11 deletions script/Safe/DeploySafeNativeRecoveryWithAccountHiding.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@ 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";

contract DeploySafeNativeRecovery_Script is BaseDeployScript {
address verifier;
address dkim;
address emailAuthImpl;
address commandHandler;
uint256 minimumDelay;
address killSwitchAuthorizer;
address public verifier;
address public dkim;
address public emailAuthImpl;
address public commandHandler;
uint256 public minimumDelay;
address public killSwitchAuthorizer;

address initialOwner;
address dkimRegistrySigner;
uint256 dkimDelay;
uint256 salt;
address public initialOwner;
address public dkimRegistrySigner;
uint256 public dkimDelay;
uint256 public salt;

function run() public override {
super.run();
Expand Down
Loading

0 comments on commit 1db7a8a

Please sign in to comment.