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

Update safe integration test #11

Merged
merged 9 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 12 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@ env:

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

test:
test-multi-account:
needs: ["build"]
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test.yaml@main"
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test-multi-account.yaml@main"
with:
foundry-fuzz-runs: 5000
foundry-profile: "test"
match-path: "test/**/*.sol"

test-simulate:
needs: ["build"]
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test-simulate.yaml@main"

with:
foundry-fuzz-runs: 5000
foundry-profile: "test"
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
"prettier:check": "prettier --check \"**/*.{json,md,svg,yml}\"",
"prettier:write": "prettier --write \"**/*.{json,md,svg,yml}\"",
"test": "forge test",
"test:safe": "ACCOUNT_TYPE=SAFE forge test",
"test:kernel": "ACCOUNT_TYPE=KERNEL forge test",
"test:lite": "FOUNDRY_PROFILE=lite forge test",
"test:optimized": "pnpm run build:optimized && FOUNDRY_PROFILE=test-optimized forge test"
},
"dependencies": {
"@openzeppelin/contracts-upgradeable": "v5.0.1",
"@zk-email/contracts": "v6.0.3",
"@matterlabs": "github:matter-labs/era-contracts",
"@rhinestone/modulekit": "github:rhinestonewtf/modulekit",
"@rhinestone/modulekit": "github:rhinestonewtf/modulekit#test/safe-latest",
"erc7579-implementation": "https://github.com/erc7579/erc7579-implementation.git",
"solidity-stringutils": "https://github.com/Arachnid/solidity-stringutils.git"
},
Expand Down
102 changes: 68 additions & 34 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

62 changes: 52 additions & 10 deletions script/DeploySafeRecovery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,67 @@
pragma solidity ^0.8.25;

import { Script } from "forge-std/Script.sol";
import { console } from "forge-std/console.sol";
import { SafeRecoverySubjectHandler } from "src/handlers/SafeRecoverySubjectHandler.sol";
import { EmailRecoveryManager } from "src/EmailRecoveryManager.sol";
import { UniversalEmailRecoveryModule } from "src/modules/UniversalEmailRecoveryModule.sol";
import { EmailRecoveryFactory } from "src/EmailRecoveryFactory.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";

contract DeploySafeRecoveryScript is Script {
import { Safe7579 } from "safe7579/Safe7579.sol";
import { Safe7579Launchpad } from "safe7579/Safe7579Launchpad.sol";
import { IERC7484 } from "safe7579/interfaces/IERC7484.sol";

// 1. `source .env`
// 2. `forge script --chain sepolia script/DeploySafeRecovery.s.sol:DeploySafeRecovery_Script
// --rpc-url $BASE_SEPOLIA_RPC_URL --broadcast -vvvv`
contract DeploySafeRecovery_Script is Script {
function run() public {
address verifier = 0xEdC642bbaD91E21cCE6cd436Fdc6F040FD0fF998;
address dkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78;
address emailAuthImpl = 0x1C76Aa365c17B40c7E944DcCdE4dC6e6D2A7b748;
address entryPoint = address(0x0000000071727De22E5E9d8BAf0edAc6f37da032);
IERC7484 registry = IERC7484(0xe0cde9239d16bEf05e62Bbf7aA93e420f464c826);

vm.startBroadcast(vm.envUint("PRIVATE_KEY"));
address verifier = vm.envOr("VERIFIER", address(0));
address dkimRegistry = vm.envOr("DKIM_REGISTRY", address(0));
address dkimRegistrySigner = vm.envOr("SIGNER", address(0));
address emailAuthImpl = vm.envOr("EMAIL_AUTH_IMPL", address(0));

if (verifier == address(0)) {
verifier = address(new Verifier());
console.log("Deployed Verifier at", verifier);
}

SafeRecoverySubjectHandler emailRecoveryHandler = new SafeRecoverySubjectHandler();
if (dkimRegistry == address(0)) {
require(dkimRegistrySigner != address(0), "DKIM_REGISTRY_SIGNER is required");
dkimRegistry = address(new ECDSAOwnedDKIMRegistry(dkimRegistrySigner));
console.log("Deployed DKIM Registry at", dkimRegistry);
}

EmailRecoveryManager emailRecoveryManager = new EmailRecoveryManager(
verifier, dkimRegistry, emailAuthImpl, address(emailRecoveryHandler)
if (emailAuthImpl == address(0)) {
emailAuthImpl = address(new EmailAuth());
console.log("Deployed Email Auth at", emailAuthImpl);
}

EmailRecoveryFactory factory = new EmailRecoveryFactory(verifier, emailAuthImpl);
(address module, address manager, address subjectHandler) = factory
.deployUniversalEmailRecoveryModule(
bytes32(uint256(0)),
bytes32(uint256(0)),
bytes32(uint256(0)),
type(SafeRecoverySubjectHandler).creationCode,
dkimRegistry
);

new UniversalEmailRecoveryModule(address(emailRecoveryManager));
address safe7579 = address(new Safe7579{ salt: bytes32(uint256(0)) }());
address safe7579Launchpad =
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));

vm.stopBroadcast();
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/MockRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract MockRegistry is IERC7484 {
{ }

function trustAttesters(uint8, /* threshold */ address[] calldata /* attesters */ ) external {
emit Log(msg.sender);
emit NewTrustedAttesters();
// emit Log(msg.sender);
// emit NewTrustedAttesters();
}
}
Loading