Skip to content

Commit

Permalink
run solhint
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGuilding committed May 31, 2024
1 parent d7b7e33 commit 170185f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 29 deletions.
17 changes: 9 additions & 8 deletions src/ZkEmailRecovery.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
GuardianStorage,
GuardianStatus
} from "./libraries/EnumerableGuardianMap.sol";
import "forge-std/console2.sol";
// import "forge-std/console2.sol";

/**
* @title ZkEmailRecovery
Expand Down Expand Up @@ -66,39 +66,40 @@ contract ZkEmailRecovery is EmailAccountRecovery, IZkEmailRecovery {
* Minimum required time window between when a recovery attempt becomes valid and when it
* becomes invalid
*/
uint256 constant MINIMUM_RECOVERY_WINDOW = 1 days;
uint256 public constant MINIMUM_RECOVERY_WINDOW = 1 days;

/**
* Account address to recovery config
*/
mapping(address => RecoveryConfig) internal recoveryConfigs;
mapping(address account => RecoveryConfig recoveryConfig) internal recoveryConfigs;

/**
* Account address to recovery request
*/
mapping(address => RecoveryRequest) internal recoveryRequests;
mapping(address account => RecoveryRequest recoveryRequest) internal recoveryRequests;

/**
* Account address to guardian address to guardian storage
*/
mapping(address => EnumerableGuardianMap.AddressToGuardianMap) internal guardiansStorage;
mapping(address account => EnumerableGuardianMap.AddressToGuardianMap guardian) internal
guardiansStorage;

/**
* Account to guardian config
*/
mapping(address => GuardianConfig) internal guardianConfigs;
mapping(address account => GuardianConfig guardianConfig) internal guardianConfigs;

/**
* Email account recovery router address to account address
*/
mapping(address => address) internal routerToAccount;
mapping(address router => address account) internal routerToAccount;

/**
* Account address to email account recovery router address.
* These are stored for frontends to easily find the router contract address from the given
* account account address
*/
mapping(address => address) internal accountToRouter;
mapping(address account => address router) internal accountToRouter;

/*//////////////////////////////////////////////////////////////////////////
MODIFIERS
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/EnumerableGuardianMap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ library EnumerableGuardianMap {
/**
* Maximum number of guardians that can be added
*/
uint256 constant MAX_NUMBER_OF_GUARDIANS = 32;
uint256 public constant MAX_NUMBER_OF_GUARDIANS = 32;

error MaxNumberOfGuardiansReached();
error TooManyValuesToRemove();
Expand Down
16 changes: 8 additions & 8 deletions src/modules/OwnableValidatorRecoveryModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import { ERC7579ExecutorBase } from "@rhinestone/modulekit/src/Modules.sol";

import { IRecoveryModule } from "../interfaces/IRecoveryModule.sol";
import { IZkEmailRecovery } from "../interfaces/IZkEmailRecovery.sol";
import "forge-std/console2.sol";
// import "forge-std/console2.sol";

contract OwnableValidatorRecoveryModule is ERC7579ExecutorBase, IRecoveryModule {
/*//////////////////////////////////////////////////////////////////////////
CONSTANTS
//////////////////////////////////////////////////////////////////////////*/

address public immutable zkEmailRecovery;
address public immutable ZK_EMAIL_RECOVERY;

mapping(address => address) public validators;
mapping(address account => address validator) public validators;

error InvalidNewOwner();
error NotTrustedRecoveryContract();

constructor(address _zkEmailRecovery) {
zkEmailRecovery = _zkEmailRecovery;
ZK_EMAIL_RECOVERY = _zkEmailRecovery;
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -53,7 +53,7 @@ contract OwnableValidatorRecoveryModule is ERC7579ExecutorBase, IRecoveryModule
expiry
);

_execute(msg.sender, zkEmailRecovery, 0, encodedCall);
_execute(msg.sender, ZK_EMAIL_RECOVERY, 0, encodedCall);
}

/**
Expand All @@ -62,7 +62,7 @@ contract OwnableValidatorRecoveryModule is ERC7579ExecutorBase, IRecoveryModule
*/
function onUninstall(bytes calldata /* data */ ) external {
delete validators[msg.sender];
IZkEmailRecovery(zkEmailRecovery).deInitRecoveryFromModule(msg.sender);
IZkEmailRecovery(ZK_EMAIL_RECOVERY).deInitRecoveryFromModule(msg.sender);
}

/**
Expand All @@ -79,7 +79,7 @@ contract OwnableValidatorRecoveryModule is ERC7579ExecutorBase, IRecoveryModule
//////////////////////////////////////////////////////////////////////////*/

function recover(address account, bytes[] memory subjectParams) external {
if (msg.sender != zkEmailRecovery) {
if (msg.sender != ZK_EMAIL_RECOVERY) {
revert NotTrustedRecoveryContract();
}

Expand All @@ -95,7 +95,7 @@ contract OwnableValidatorRecoveryModule is ERC7579ExecutorBase, IRecoveryModule
}

function getTrustedContract() external view returns (address) {
return zkEmailRecovery;
return ZK_EMAIL_RECOVERY;
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down
19 changes: 8 additions & 11 deletions src/modules/SafeRecoveryModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,26 @@
pragma solidity ^0.8.25;

import { ERC7579ExecutorBase } from "@rhinestone/modulekit/src/Modules.sol";
import { IERC7579Account } from "erc7579/interfaces/IERC7579Account.sol";
import { ExecutionLib } from "erc7579/lib/ExecutionLib.sol";
import { ModeLib } from "erc7579/lib/ModeLib.sol";

import { IRecoveryModule } from "../interfaces/IRecoveryModule.sol";
import { IZkEmailRecovery } from "../interfaces/IZkEmailRecovery.sol";
import { ISafe } from "../interfaces/ISafe.sol";
import "forge-std/console2.sol";
// import "forge-std/console2.sol";

contract SafeRecoveryModule is ERC7579ExecutorBase, IRecoveryModule {
/*//////////////////////////////////////////////////////////////////////////
CONSTANTS
//////////////////////////////////////////////////////////////////////////*/

address public immutable zkEmailRecovery;
address public immutable ZK_EMAIL_RECOVERY;

error NotTrustedRecoveryContract();
error InvalidSubjectParams();
error InvalidOldOwner();
error InvalidNewOwner();

constructor(address _zkEmailRecovery) {
zkEmailRecovery = _zkEmailRecovery;
ZK_EMAIL_RECOVERY = _zkEmailRecovery;
}

/*//////////////////////////////////////////////////////////////////////////
Expand All @@ -45,7 +42,7 @@ contract SafeRecoveryModule is ERC7579ExecutorBase, IRecoveryModule {
) = abi.decode(data, (address[], uint256[], uint256, uint256, uint256));

_execute({
to: zkEmailRecovery,
to: ZK_EMAIL_RECOVERY,
value: 0,
data: abi.encodeCall(
IZkEmailRecovery.configureRecovery,
Expand All @@ -59,7 +56,7 @@ contract SafeRecoveryModule is ERC7579ExecutorBase, IRecoveryModule {
* @custom:unusedparam data - the data to de-initialize the module with
*/
function onUninstall(bytes calldata /* data */ ) external {
IZkEmailRecovery(zkEmailRecovery).deInitRecoveryFromModule(msg.sender);
IZkEmailRecovery(ZK_EMAIL_RECOVERY).deInitRecoveryFromModule(msg.sender);
}

/**
Expand All @@ -68,15 +65,15 @@ contract SafeRecoveryModule is ERC7579ExecutorBase, IRecoveryModule {
* @return true if the module is initialized, false otherwise
*/
function isInitialized(address smartAccount) external view returns (bool) {
return IZkEmailRecovery(zkEmailRecovery).getGuardianConfig(smartAccount).threshold != 0;
return IZkEmailRecovery(ZK_EMAIL_RECOVERY).getGuardianConfig(smartAccount).threshold != 0;
}

/*//////////////////////////////////////////////////////////////////////////
MODULE LOGIC
//////////////////////////////////////////////////////////////////////////*/

function recover(address account, bytes[] memory subjectParams) external {
if (msg.sender != zkEmailRecovery) {
if (msg.sender != ZK_EMAIL_RECOVERY) {
revert NotTrustedRecoveryContract();
}

Expand Down Expand Up @@ -134,7 +131,7 @@ contract SafeRecoveryModule is ERC7579ExecutorBase, IRecoveryModule {
}

function getTrustedContract() external view returns (address) {
return zkEmailRecovery;
return ZK_EMAIL_RECOVERY;
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion test/unit/UnitBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ abstract contract UnitBase is RhinestoneModuleKit, Test {

address router = zkEmailRecovery.getRouterForAccount(accountAddress);
string memory subject =
"Recover account 0x50Bc6f1F08ff752F7F5d687F35a0fA25Ab20EF52 to new owner 0x7240b687730BE024bcfD084621f794C2e4F8408f using recovery module 0x8Db2C2e0026E39A5f1Ec12fab63eaBE0687132Ac";
"Recover account 0x50Bc6f1F08ff752F7F5d687F35a0fA25Ab20EF52 to new owner 0x7240b687730BE024bcfD084621f794C2e4F8408f using recovery module 0x52d76593519b17d28Df0b33cd9842D2542d96C87";
bytes32 nullifier = keccak256(abi.encode("nullifier 2"));
EmailProof memory emailProof = generateMockEmailProof(subject, nullifier, accountSalt);

Expand Down

0 comments on commit 170185f

Please sign in to comment.