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

Feat/sync email auth #9

Merged
merged 12 commits into from
Jun 25, 2024
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:

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

test:
needs: ["build"]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Account recovery has traditionally been one of the most complex UX hurdles that

```shell
pnpm install
forge install
```

### Build
Expand Down
14 changes: 4 additions & 10 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ emv_version = "paris"
src = "src"
out = "out"
script = "script"
libs = [
"node_modules",
"lib",
]
libs = ["node_modules", "lib"]
fs_permissions = [
{ access = "read", path = "out-optimized" },
{ access = "read-write", path = "gas_calculations" },
]
allow_paths = [
"*",
"/",
]
allow_paths = ["*", "/"]
ignored_warnings_from = [
"node_modules",
"node_modules/@rhinestone/modulekit/src/**/*.sol",
Expand All @@ -24,8 +18,8 @@ ignored_warnings_from = [
[rpc_endpoints]
sepolia = "${BASE_SEPOLIA_RPC_URL}"

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

[fmt]
bracket_spacing = true
Expand Down
2 changes: 1 addition & 1 deletion lib/ether-email-auth
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
"test:optimized": "pnpm run build:optimized && FOUNDRY_PROFILE=test-optimized forge test"
},
"dependencies": {
"@matterlabs/zksync-contracts": "^0.6.1",
"@openzeppelin/contracts-upgradeable": "v5.0.1",
"@rhinestone/modulekit": "v0.4.2",
"@zk-email/contracts": "v6.0.3",
"erc7579-implementation": "https://github.com/erc7579/erc7579-implementation.git",
"solidity-stringutils": "https://github.com/Arachnid/solidity-stringutils.git"
},
"files": [
Expand Down
833 changes: 380 additions & 453 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ solarray/=node_modules/solarray/src/

ether-email-auth/=lib/ether-email-auth/
@zk-email/contracts/=node_modules/@zk-email/contracts/
solidity-stringutils/=node_modules/solidity-stringutils/
solidity-stringutils/=node_modules/solidity-stringutils/
@matterlabs/=node_modules/@matterlabs
erc7579-implementation/=node_modules/erc7579-implementation/
60 changes: 25 additions & 35 deletions script/Deploy7579Controller.s.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// 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 {EmailRecoveryManager} from "src/EmailRecoveryManager.sol";
import {EmailRecoveryModule} from "src/modules/EmailRecoveryModule.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 { Script } from "forge-std/Script.sol";
import { console } from "forge-std/console.sol";
import { EmailRecoverySubjectHandler } from "src/handlers/EmailRecoverySubjectHandler.sol";
import { EmailRecoveryManager } from "src/EmailRecoveryManager.sol";
import { EmailRecoveryModule } from "src/modules/EmailRecoveryModule.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";

contract Deploy7579ControllerScript is Script {
function run() public {
Expand All @@ -21,53 +22,42 @@ contract Deploy7579ControllerScript is Script {

if (verifier == address(0)) {
verifier = address(new Verifier());
vm.setEnv("VERIFIER", vm.toString(verifier));
// vm.setEnv("VERIFIER", vm.toString(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)
);
vm.setEnv("DKIM_REGISTRY", vm.toString(dkimRegistry));
require(dkimRegistrySigner != address(0), "DKIM_REGISTRY_SIGNER is required");
dkimRegistry = address(new ECDSAOwnedDKIMRegistry(dkimRegistrySigner));
// vm.setEnv("DKIM_REGISTRY", vm.toString(dkimRegistry));
console.log("Deployed DKIM Registry at", dkimRegistry);
}

if (emailAuthImpl == address(0)) {
emailAuthImpl = address(new EmailAuth());
vm.setEnv("EMAIL_AUTH_IMPL", vm.toString(emailAuthImpl));
// vm.setEnv("EMAIL_AUTH_IMPL", vm.toString(emailAuthImpl));
console.log("Deployed Email Auth at", emailAuthImpl);
}

EmailRecoverySubjectHandler emailRecoveryHandler = new EmailRecoverySubjectHandler();
vm.setEnv(
"RECOVERY_HANDLER",
vm.toString(address(emailRecoveryHandler))
);
address _factory = vm.envOr("FACTORY", address(0));
// vm.setEnv(
// "RECOVERY_HANDLER",
// vm.toString(address(emailRecoveryHandler))
// );
address _factory = vm.envOr("RECOVERY_FACTORY", address(0));
if (_factory == address(0)) {
_factory = address(new EmailRecoveryFactory());
vm.setEnv("FACTORY", vm.toString(_factory));
// vm.setEnv("RECOVERY_FACTORY", vm.toString(_factory));
console.log("Deployed Email Recovery Factory at", _factory);
}
EmailRecoveryFactory factory = EmailRecoveryFactory(_factory);
(address manager, address module) = factory.deployModuleAndManager(
verifier,
dkimRegistry,
emailAuthImpl,
address(emailRecoveryHandler)
verifier, dkimRegistry, emailAuthImpl, address(emailRecoveryHandler)
);
vm.setEnv("RECOVERY_MANAGER", vm.toString(manager));
vm.setEnv("RECOVERY_MODULE", vm.toString(module));
// vm.setEnv("RECOVERY_MANAGER", vm.toString(manager));
// vm.setEnv("RECOVERY_MODULE", vm.toString(module));

console.log(
"Deployed Email Recovery Handler at",
address(emailRecoveryHandler)
);
console.log("Deployed Email Recovery Handler at", address(emailRecoveryHandler));
console.log("Deployed Email Recovery Manager at", vm.toString(manager));
console.log("Deployed Email Recovery Module at", vm.toString(module));
vm.stopBroadcast();
Expand Down
Loading