Skip to content

Commit

Permalink
Use recovery subject handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGuilding committed Jun 11, 2024
1 parent 531a49a commit 6aac792
Show file tree
Hide file tree
Showing 56 changed files with 1,612 additions and 2,182 deletions.
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ ignored_warnings_from = [
]

[rpc_endpoints]
baseSepolia = "${BASE_SEPOLIA_RPC_URL}"
sepolia = "${BASE_SEPOLIA_RPC_URL}"

[etherscan]
baseSepolia = { key = "${BASE_SCAN_API_KEY}" }
sepolia = { key = "${BASE_SCAN_API_KEY}" }

[fmt]
bracket_spacing = true
Expand Down
14 changes: 11 additions & 3 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@
pragma solidity ^0.8.25;

import { Script } from "forge-std/Script.sol";
import { ZkEmailRecovery } from "src/ZkEmailRecovery.sol";
import { EmailRecoverySubjectHandler } from "src/handlers/EmailRecoverySubjectHandler.sol";
import { EmailRecoveryManager } from "src/EmailRecoveryManager.sol";
import { EmailRecoveryModule } from "src/modules/EmailRecoveryModule.sol";

contract DeployScript is Script {
function run() public {
bytes32 salt = bytes32(uint256(0));

address verifier = 0xEdC642bbaD91E21cCE6cd436Fdc6F040FD0fF998;
address ecdsaOwnedDkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78;
address dkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78;
address emailAuthImpl = 0x1C76Aa365c17B40c7E944DcCdE4dC6e6D2A7b748;

vm.startBroadcast(vm.envUint("PRIVATE_KEY"));

new ZkEmailRecovery{ salt: salt }(verifier, ecdsaOwnedDkimRegistry, emailAuthImpl);
EmailRecoverySubjectHandler emailRecoveryHandler = new EmailRecoverySubjectHandler();

EmailRecoveryManager emailRecoveryManager = new EmailRecoveryManager{ salt: salt }(
verifier, dkimRegistry, emailAuthImpl, address(emailRecoveryHandler)
);

new EmailRecoveryModule(address(emailRecoveryManager));

vm.stopBroadcast();
}
Expand Down
17 changes: 11 additions & 6 deletions script/DeploySafeRecovery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@
pragma solidity ^0.8.25;

import { Script } from "forge-std/Script.sol";
import { SafeZkEmailRecovery } from "src/SafeZkEmailRecovery.sol";
import { SafeRecoveryModule } from "src/modules/SafeRecoveryModule.sol";
import { SafeRecoverySubjectHandler } from "src/handlers/SafeRecoverySubjectHandler.sol";
import { EmailRecoveryManager } from "src/EmailRecoveryManager.sol";
import { EmailRecoveryModule } from "src/modules/EmailRecoveryModule.sol";

contract DeploySafeRecoveryScript is Script {
function run() public {
bytes32 salt = bytes32(uint256(0));

address verifier = 0xEdC642bbaD91E21cCE6cd436Fdc6F040FD0fF998;
address ecdsaOwnedDkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78;
address dkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78;
address emailAuthImpl = 0x1C76Aa365c17B40c7E944DcCdE4dC6e6D2A7b748;

vm.startBroadcast(vm.envUint("PRIVATE_KEY"));

SafeZkEmailRecovery safeZkEmailRecovery =
new SafeZkEmailRecovery{ salt: salt }(verifier, ecdsaOwnedDkimRegistry, emailAuthImpl);
new SafeRecoveryModule(address(safeZkEmailRecovery));
SafeRecoverySubjectHandler emailRecoveryHandler = new SafeRecoverySubjectHandler();

EmailRecoveryManager emailRecoveryManager = new EmailRecoveryManager(
verifier, dkimRegistry, emailAuthImpl, address(emailRecoveryHandler)
);

new EmailRecoveryModule(address(emailRecoveryManager));

vm.stopBroadcast();
}
Expand Down
67 changes: 0 additions & 67 deletions src/EmailAccountRecoveryRouter.sol

This file was deleted.

53 changes: 53 additions & 0 deletions src/EmailRecoveryFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { EmailRecoveryManager } from "./EmailRecoveryManager.sol";
import { EmailRecoveryModule } from "./modules/EmailRecoveryModule.sol";
import { EmailRecoverySubjectHandler } from "./handlers/EmailRecoverySubjectHandler.sol";

contract EmailRecoveryFactory {
function deployModuleAndManager(
address verifier,
address dkimRegistry,
address emailAuthImpl,
address emailRecoveryHandler
)
external
returns (address, address)
{
EmailRecoveryManager emailRecoveryManager =
new EmailRecoveryManager(verifier, dkimRegistry, emailAuthImpl, emailRecoveryHandler);
EmailRecoveryModule emailRecoveryModule =
new EmailRecoveryModule(address(emailRecoveryManager));

return (address(emailRecoveryManager), address(emailRecoveryModule));
}

function deployHandler(address emailRecoveryManager) external returns (address) {
EmailRecoverySubjectHandler emailRecoveryHandler = new EmailRecoverySubjectHandler();

return (address(emailRecoveryHandler));
}

function deployAll(
address verifier,
address dkimRegistry,
address emailAuthImpl
)
external
returns (address, address, address)
{
EmailRecoverySubjectHandler emailRecoveryHandler = new EmailRecoverySubjectHandler();
EmailRecoveryManager emailRecoveryManager = new EmailRecoveryManager(
verifier, dkimRegistry, emailAuthImpl, address(emailRecoveryHandler)
);
EmailRecoveryModule emailRecoveryModule =
new EmailRecoveryModule(address(emailRecoveryManager));

return (
address(emailRecoveryManager),
address(emailRecoveryModule),
address(emailRecoveryHandler)
);
}
}
Loading

0 comments on commit 6aac792

Please sign in to comment.