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

Consolidate module & manager into single contract #26

Merged
merged 4 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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