Skip to content

Commit

Permalink
Merge pull request #2 from zkemail/generic-validator-module
Browse files Browse the repository at this point in the history
Add generic validator recovery module and update zk email contracts to use it
  • Loading branch information
JohnGuilding authored Jun 14, 2024
2 parents 164dc76 + f13e93c commit 5a7a993
Show file tree
Hide file tree
Showing 57 changed files with 3,648 additions and 3,914 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ env:

jobs:
build:
uses: "./.github/workflows/forge-build.yml"
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-build.yaml@main"

test:
needs: ["build"]
uses: "./.github/workflows/forge-test.yml"
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test.yaml@main"
with:
foundry-fuzz-runs: 5000
foundry-profile: "test"
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ It is strongly recommended that configureRecovery is called during the installat

```ts
function configureRecovery(
address recoveryModule,
address[] memory guardians,
uint256[] memory weights,
uint256 threshold,
Expand Down
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.

29 changes: 29 additions & 0 deletions src/EmailRecoveryFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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);
address manager = address(emailRecoveryManager);

EmailRecoveryModule emailRecoveryModule = new EmailRecoveryModule(manager);
address module = address(emailRecoveryModule);

emailRecoveryManager.initialize(module);

return (manager, module);
}
}
Loading

0 comments on commit 5a7a993

Please sign in to comment.