Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deployment scripts with more combinations #63

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,85 +5,82 @@ 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)) {
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 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();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
8 changes: 4 additions & 4 deletions script/BaseDeployScript.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -35,7 +35,7 @@ contract BaseDeployScript is Script {
function deployUserOverrideableDKIMRegistry(
address initialOwner,
address dkimRegistrySigner,
uint256 setTimeDelay,
uint256 dkimDelay,
uint256 salt
)
public
Expand All @@ -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;
}
}
Loading