-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from zkemail/feat/factory-and-script-updates
Feat/factory and script updates
- Loading branch information
Showing
15 changed files
with
124 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.25; | ||
|
||
import { Script } from "forge-std/Script.sol"; | ||
import { console } from "forge-std/console.sol"; | ||
import { EmailRecoverySubjectHandler } from "src/handlers/EmailRecoverySubjectHandler.sol"; | ||
import { Verifier } from "ether-email-auth/packages/contracts/src/utils/Verifier.sol"; | ||
import { ECDSAOwnedDKIMRegistry } from | ||
"ether-email-auth/packages/contracts/src/utils/ECDSAOwnedDKIMRegistry.sol"; | ||
import { EmailAuth } from "ether-email-auth/packages/contracts/src/EmailAuth.sol"; | ||
import { EmailRecoveryFactory } from "src/EmailRecoveryFactory.sol"; | ||
import { OwnableValidator } from "src/test/OwnableValidator.sol"; | ||
|
||
contract DeployEmailRecoveryModuleScript is Script { | ||
function run() public { | ||
vm.startBroadcast(vm.envUint("PRIVATE_KEY")); | ||
address verifier = vm.envOr("VERIFIER", address(0)); | ||
address dkimRegistry = vm.envOr("DKIM_REGISTRY", address(0)); | ||
address dkimRegistrySigner = vm.envOr("SIGNER", address(0)); | ||
address emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0)); | ||
address validatorAddr = vm.envOr("VALIDATOR", address(0)); | ||
|
||
if (verifier == address(0)) { | ||
verifier = address(new Verifier()); | ||
console.log("Deployed Verifier at", verifier); | ||
} | ||
|
||
if (dkimRegistry == address(0)) { | ||
require(dkimRegistrySigner != address(0), "DKIM_REGISTRY_SIGNER is required"); | ||
dkimRegistry = address(new ECDSAOwnedDKIMRegistry(dkimRegistrySigner)); | ||
console.log("Deployed DKIM Registry at", dkimRegistry); | ||
} | ||
|
||
if (emailAuthImpl == address(0)) { | ||
emailAuthImpl = address(new EmailAuth()); | ||
console.log("Deployed Email Auth at", emailAuthImpl); | ||
} | ||
|
||
if (validatorAddr == address(0)) { | ||
validatorAddr = address(new OwnableValidator()); | ||
console.log("Deployed Ownable Validator at", validatorAddr); | ||
} | ||
|
||
EmailRecoverySubjectHandler emailRecoveryHandler = new EmailRecoverySubjectHandler(); | ||
|
||
address _factory = vm.envOr("RECOVERY_FACTORY", address(0)); | ||
if (_factory == address(0)) { | ||
_factory = address(new EmailRecoveryFactory(verifier, emailAuthImpl)); | ||
console.log("Deployed Email Recovery Factory at", _factory); | ||
} | ||
{ | ||
EmailRecoveryFactory factory = EmailRecoveryFactory(_factory); | ||
(address module, address manager, address subjectHandler) = factory | ||
.deployEmailRecoveryModule( | ||
bytes32(uint256(0)), | ||
bytes32(uint256(0)), | ||
bytes32(uint256(0)), | ||
type(EmailRecoverySubjectHandler).creationCode, | ||
dkimRegistry, | ||
validatorAddr, | ||
bytes4(keccak256(bytes("changeOwner(address)"))) | ||
); | ||
|
||
console.log("Deployed Email Recovery Module at", vm.toString(module)); | ||
console.log("Deployed Email Recovery Manager at", vm.toString(manager)); | ||
console.log("Deployed Email Recovery Handler at", vm.toString(subjectHandler)); | ||
vm.stopBroadcast(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.