Skip to content

Commit

Permalink
Merge pull request #26 from zkemail/feat/consolidate-module-and-manager
Browse files Browse the repository at this point in the history
Consolidate module & manager into single contract
  • Loading branch information
JohnGuilding authored Aug 1, 2024
2 parents f2ab698 + 07400ad commit 32809e8
Show file tree
Hide file tree
Showing 78 changed files with 1,066 additions and 1,685 deletions.
23 changes: 11 additions & 12 deletions script/Deploy7579TestAccount.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Script } from "forge-std/Script.sol";
import { console } from "forge-std/console.sol";
import { EmailAccountRecovery } from
"ether-email-auth/packages/contracts/src/EmailAccountRecovery.sol";
import { IEmailRecoveryManager } from "../src/interfaces/IEmailRecoveryManager.sol";
import { IGuardianManager } from "src/interfaces/IGuardianManager.sol";
import { RhinestoneModuleKit } from "modulekit/ModuleKit.sol";
import { OwnableValidator } from "src/test/OwnableValidator.sol";
import { ModuleKitHelpers, ModuleKitUserOp } from "modulekit/ModuleKit.sol";
Expand Down Expand Up @@ -38,7 +38,6 @@ contract Deploy7579TestAccountScript is RhinestoneModuleKit, Script {
bytes32 accountSalt;
address validatorAddr;
address recoveryModuleAddr;
address managerAddr;
address[] guardians = new address[](0);
uint256[] guardianWeights = new uint256[](0);

Expand Down Expand Up @@ -111,8 +110,6 @@ contract Deploy7579TestAccountScript is RhinestoneModuleKit, Script {
});

BootstrapConfig[] memory executors = new BootstrapConfig[](1);
managerAddr = vm.envAddress("RECOVERY_MANAGER");
require(managerAddr != address(0), "RECOVERY_MANAGER is required");

bytes memory recoveryModuleInstallData = abi.encode(
validatorAddr,
Expand Down Expand Up @@ -140,17 +137,18 @@ contract Deploy7579TestAccountScript is RhinestoneModuleKit, Script {

{
// Add an EmailAuth guardian
address guardianAddr =
EmailAccountRecovery(managerAddr).computeEmailAuthAddress(account, accountSalt);
address guardianAddr = EmailAccountRecovery(recoveryModuleAddr).computeEmailAuthAddress(
account, accountSalt
);
console.log("Guardian's EmailAuth address", guardianAddr);
userOpCalldata = abi.encodeCall(
IERC7579Account.execute,
(
ModeLib.encodeSimpleSingle(),
ExecutionLib.encodeSingle(
address(managerAddr),
address(recoveryModuleAddr),
uint256(0),
abi.encodeCall(IEmailRecoveryManager.addGuardian, (guardianAddr, 1))
abi.encodeCall(IGuardianManager.addGuardian, (guardianAddr, 1))
)
)
);
Expand Down Expand Up @@ -183,17 +181,18 @@ contract Deploy7579TestAccountScript is RhinestoneModuleKit, Script {
// set threshold to 1.
{
// Add an EmailAuth guardian
address guardianAddr =
EmailAccountRecovery(managerAddr).computeEmailAuthAddress(account, accountSalt);
address guardianAddr = EmailAccountRecovery(recoveryModuleAddr).computeEmailAuthAddress(
account, accountSalt
);
console.log("Guardian's EmailAuth address", guardianAddr);
userOpCalldata = abi.encodeCall(
IERC7579Account.execute,
(
ModeLib.encodeSimpleSingle(),
ExecutionLib.encodeSingle(
address(managerAddr),
address(recoveryModuleAddr),
uint256(0),
abi.encodeCall(IEmailRecoveryManager.changeThreshold, 1)
abi.encodeCall(IGuardianManager.changeThreshold, 1)
)
)
);
Expand Down
5 changes: 1 addition & 4 deletions script/DeployEmailRecoveryModule.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ contract DeployEmailRecoveryModuleScript is Script {
}
{
EmailRecoveryFactory factory = EmailRecoveryFactory(_factory);
(address module, address manager, address subjectHandler) = factory
.deployEmailRecoveryModule(
bytes32(uint256(0)),
(address module, address subjectHandler) = factory.deployEmailRecoveryModule(
bytes32(uint256(0)),
bytes32(uint256(0)),
type(EmailRecoverySubjectHandler).creationCode,
Expand All @@ -62,7 +60,6 @@ contract DeployEmailRecoveryModuleScript is Script {
);

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();
}
Expand Down
5 changes: 1 addition & 4 deletions script/DeploySafeRecovery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ contract DeploySafeRecovery_Script is Script {

EmailRecoveryUniversalFactory factory =
new EmailRecoveryUniversalFactory(verifier, emailAuthImpl);
(address module, address manager, address subjectHandler) = factory
.deployUniversalEmailRecoveryModule(
bytes32(uint256(0)),
(address module, address subjectHandler) = factory.deployUniversalEmailRecoveryModule(
bytes32(uint256(0)),
bytes32(uint256(0)),
type(SafeRecoverySubjectHandler).creationCode,
Expand All @@ -61,7 +59,6 @@ contract DeploySafeRecovery_Script is Script {
address(new Safe7579Launchpad{ salt: bytes32(uint256(0)) }(entryPoint, registry));

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));
console.log("Deployed Safe 7579 at ", vm.toString(safe7579));
console.log("Deployed Safe 7579 Launchpad at ", vm.toString(safe7579Launchpad));
Expand Down
5 changes: 1 addition & 4 deletions script/DeployUniversalEmailRecoveryModule.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,14 @@ contract DeployUniversalEmailRecoveryModuleScript is Script {
}
{
EmailRecoveryUniversalFactory factory = EmailRecoveryUniversalFactory(_factory);
(address module, address manager, address subjectHandler) = factory
.deployUniversalEmailRecoveryModule(
bytes32(uint256(0)),
(address module, address subjectHandler) = factory.deployUniversalEmailRecoveryModule(
bytes32(uint256(0)),
bytes32(uint256(0)),
type(EmailRecoverySubjectHandler).creationCode,
dkimRegistry
);

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();
}
Expand Down
Loading

0 comments on commit 32809e8

Please sign in to comment.