Skip to content

Commit

Permalink
fix compile warnings & format
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGuilding committed Sep 17, 2024
1 parent 041a882 commit 8562b75
Show file tree
Hide file tree
Showing 99 changed files with 106 additions and 197 deletions.
46 changes: 31 additions & 15 deletions README.md

Large diffs are not rendered by default.

14 changes: 3 additions & 11 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 @@ -36,6 +30,4 @@ number_underscore = "thousands"
quote_style = "double"
tab_width = 4
wrap_comments = true
ignore = [
"./src/libraries/L2ContractHelper.sol",
]
ignore = ["./src/libraries/L2ContractHelper.sol"]
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@
"scripts": {
"build": "forge build",
"build:optimized": "FOUNDRY_PROFILE=optimized forge build",
"build:smt": "FOUNDRY_PROFILE=smt forge build",
"clean": "rm -rf artifacts broadcast cache docs out out-optimized out-svg",
"gas:report": "forge test --gas-report --mp \"./test/integration/**/*.sol\" --nmt \"test(Fuzz)?_RevertWhen_\\w{1,}?\"",
"gas:snapshot": "forge snapshot --mp \"./test/integration/**/*.sol\" --nmt \"test(Fuzz)?_RevertWhen_\\w{1,}?\"",
"gas:snapshot:optimized": "pnpm run build:optimized && FOUNDRY_PROFILE=test-optimized forge snapshot --mp \"./test/integration/**/*.sol\" --nmt \"test(Fork)?(Fuzz)?_RevertWhen_\\w{1,}?\"",
"lint": "pnpm run lint:sol && bun run prettier:check",
"lint:sol": "forge fmt --check && pnpm solhint \"{script,src,test}/**/*.sol\"",
"gas:report": "forge test --gas-report --mp \"./test/integration/**/*.sol\"",
"gas:snapshot": "forge snapshot --mp \"./test/integration/**/*.sol\"",
"gas:snapshot:optimized": "pnpm run build:optimized && FOUNDRY_PROFILE=test-optimized forge snapshot --mp \"./test/integration/**/*.sol\"",
"lint": "forge fmt --check && pnpm solhint \"{script,src,test}/**/*.sol\"",
"prepack": "pnpm install",
"prettier:check": "prettier --check \"**/*.{json,md,svg,yml}\"",
"prettier:write": "prettier --write \"**/*.{json,md,svg,yml}\"",
"test": "forge test",
"test:lite": "FOUNDRY_PROFILE=lite forge test",
"test:optimized": "pnpm run build:optimized && FOUNDRY_PROFILE=test-optimized forge test"
Expand Down Expand Up @@ -58,4 +54,4 @@
"publishConfig": {
"access": "public"
}
}
}
2 changes: 1 addition & 1 deletion script/Compute7579RecoveryDataHash.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";

contract Compute7579RecoveryDataHash is Script {
function run() public {
function run() public view {
bytes4 functionSelector = bytes4(keccak256(bytes("changeOwner(address)")));
address newOwner = vm.envAddress("NEW_OWNER");
address validator = vm.envAddress("VALIDATOR");
Expand Down
2 changes: 1 addition & 1 deletion script/ComputeSafeRecoveryCalldata.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";

contract ComputeSafeRecoveryCalldataScript is Script {
function run() public {
function run() public view {
address oldOwner = vm.envAddress("OLD_OWNER");
address newOwner = vm.envAddress("NEW_OWNER");
address previousOwnerInLinkedList = address(1);
Expand Down
12 changes: 9 additions & 3 deletions script/Deploy7579TestAccount.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ contract Deploy7579TestAccountScript is RhinestoneModuleKit, Script {
validatorAddr = address(new OwnableValidator());
console.log("Deployed Ownable Validator at", validatorAddr);
}
OwnableValidator validator = OwnableValidator(validatorAddr);

// Create initcode to be sent to Factory
BootstrapConfig[] memory validators = new BootstrapConfig[](1);
Expand Down Expand Up @@ -223,8 +222,15 @@ contract Deploy7579TestAccountScript is RhinestoneModuleKit, Script {
vm.stopBroadcast();
}

function getNonce(address account, address validator) internal returns (uint256 nonce) {
function getNonce(
address smartAccount,
address validator
)
internal
view
returns (uint256 nonce)
{
uint192 key = uint192(bytes24(bytes20(address(validator))));
nonce = IEntryPoint(ENTRYPOINT_ADDR).getNonce(address(account), key);
nonce = IEntryPoint(ENTRYPOINT_ADDR).getNonce(address(smartAccount), key);
}
}
2 changes: 0 additions & 2 deletions script/DeployEmailRecoveryModule.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ contract DeployEmailRecoveryModuleScript is Script {
console.log("Deployed Ownable Validator at", validatorAddr);
}

EmailRecoveryCommandHandler emailRecoveryHandler = new EmailRecoveryCommandHandler();

address _factory = vm.envOr("RECOVERY_FACTORY", address(0));
if (_factory == address(0)) {
_factory = address(new EmailRecoveryFactory(verifier, emailAuthImpl));
Expand Down
2 changes: 0 additions & 2 deletions script/DeployUniversalEmailRecoveryModule.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ contract DeployUniversalEmailRecoveryModuleScript is Script {
console.log("Deployed Email Auth at", emailAuthImpl);
}

EmailRecoveryCommandHandler emailRecoveryHandler = new EmailRecoveryCommandHandler();

address _factory = vm.envOr("RECOVERY_FACTORY", address(0));
if (_factory == address(0)) {
_factory = address(new EmailRecoveryUniversalFactory(verifier, emailAuthImpl));
Expand Down
6 changes: 1 addition & 5 deletions src/interfaces/IGuardianManager.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import {
EnumerableGuardianMap,
GuardianStorage,
GuardianStatus
} from "../libraries/EnumerableGuardianMap.sol";
import { GuardianStorage, GuardianStatus } from "../libraries/EnumerableGuardianMap.sol";

interface IGuardianManager {
/**
Expand Down
9 changes: 9 additions & 0 deletions test/Base.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

/* solhint-disable no-console, no-unused-import */

import { Test } from "forge-std/Test.sol";
import { console2 } from "forge-std/console2.sol";

abstract contract BaseTest is Test { }
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { ModuleKitHelpers, ModuleKitUserOp } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR, MODULE_TYPE_VALIDATOR } from "modulekit/external/ERC7579.sol";
import { EmailAuthMsg } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol";
Expand Down
6 changes: 2 additions & 4 deletions test/integration/IntegrationBase.t.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { Test } from "forge-std/Test.sol";
import { console2 } from "forge-std/console2.sol";

import { RhinestoneModuleKit, AccountInstance } from "modulekit/ModuleKit.sol";
import { ECDSAOwnedDKIMRegistry } from
"@zk-email/ether-email-auth-contracts/src/utils/ECDSAOwnedDKIMRegistry.sol";
import { EmailAuth } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol";
import { ECDSA } from "solady/utils/ECDSA.sol";

import { BaseTest } from "test/Base.t.sol";
import { MockGroth16Verifier } from "src/test/MockGroth16Verifier.sol";
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

abstract contract IntegrationBase is RhinestoneModuleKit, Test {
abstract contract IntegrationBase is RhinestoneModuleKit, BaseTest {
// ZK Email contracts and variables
address zkEmailDeployer = vm.addr(1);
ECDSAOwnedDKIMRegistry dkimRegistry;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { ModuleKitHelpers, ModuleKitUserOp } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR, MODULE_TYPE_VALIDATOR } from "modulekit/external/ERC7579.sol";
import { EmailAuthMsg } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { ModuleKitHelpers, ModuleKitUserOp } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR, MODULE_TYPE_VALIDATOR } from "modulekit/external/ERC7579.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
Expand Down Expand Up @@ -170,6 +169,7 @@ abstract contract OwnableValidatorRecovery_EmailRecoveryModule_Base is Integrati
address guardian
)
public
view
returns (bytes32)
{
address[] memory guardians;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { ModuleKitHelpers, ModuleKitUserOp } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR, MODULE_TYPE_VALIDATOR } from "modulekit/external/ERC7579.sol";
import { EmailAuthMsg } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { ModuleKitHelpers, ModuleKitUserOp } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR, MODULE_TYPE_VALIDATOR } from "modulekit/external/ERC7579.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
Expand Down Expand Up @@ -53,9 +52,6 @@ abstract contract OwnableValidatorRecovery_UniversalEmailRecoveryModule_Base is
emailRecoveryHandler = new EmailRecoveryCommandHandler();

// Deploy EmailRecoveryManager & UniversalEmailRecoveryModule
bytes32 commandHandlerSalt = bytes32(uint256(0));
bytes32 recoveryModuleSalt = bytes32(uint256(0));
bytes memory commandHandlerBytecode = type(EmailRecoveryCommandHandler).creationCode;
emailRecoveryModule = new UniversalEmailRecoveryModuleHarness(
address(verifier),
address(dkimRegistry),
Expand Down Expand Up @@ -194,6 +190,7 @@ abstract contract OwnableValidatorRecovery_UniversalEmailRecoveryModule_Base is
address guardian
)
public
view
returns (bytes32)
{
address[] memory guardians;
Expand Down
6 changes: 2 additions & 4 deletions test/integration/SafeRecovery/SafeIntegrationBase.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

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

import { ModuleKitHelpers } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR } from "modulekit/external/ERC7579.sol";
import { EmailAuthMsg, EmailProof } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol";
Expand Down Expand Up @@ -31,7 +29,7 @@ abstract contract SafeIntegrationBase is IntegrationBase {
/**
* Helper function to return if current account type is safe or not
*/
function isAccountTypeSafe() public returns (bool) {
function isAccountTypeSafe() public view returns (bool) {
string memory currentAccountType = vm.envOr("ACCOUNT_TYPE", string(""));
if (Strings.equal(currentAccountType, "SAFE")) {
return true;
Expand Down Expand Up @@ -118,7 +116,7 @@ abstract contract SafeIntegrationBase is IntegrationBase {
return emailProof;
}

function getAccountSaltForGuardian(address guardian) public returns (bytes32) {
function getAccountSaltForGuardian(address guardian) public view returns (bytes32) {
if (guardian == guardians1[0]) {
return accountSalt1;
}
Expand Down
6 changes: 2 additions & 4 deletions test/integration/SafeRecovery/SafeNativeIntegrationBase.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

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

import { ModuleKitHelpers } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR } from "modulekit/external/ERC7579.sol";
import { EmailAuthMsg, EmailProof } from "@zk-email/ether-email-auth-contracts/src/EmailAuth.sol";
Expand Down Expand Up @@ -35,7 +33,7 @@ abstract contract SafeNativeIntegrationBase is IntegrationBase {
/**
* Helper function to return if current account type is safe or not
*/
function isAccountTypeSafe() public returns (bool) {
function isAccountTypeSafe() public view returns (bool) {
string memory currentAccountType = vm.envOr("ACCOUNT_TYPE", string(""));
if (Strings.equal(currentAccountType, "SAFE")) {
return true;
Expand Down Expand Up @@ -120,7 +118,7 @@ abstract contract SafeNativeIntegrationBase is IntegrationBase {
return emailProof;
}

function getAccountSaltForGuardian(address guardian) public returns (bytes32) {
function getAccountSaltForGuardian(address guardian) public view returns (bytes32) {
if (guardian == guardians1[0]) {
return accountSalt1;
}
Expand Down
2 changes: 0 additions & 2 deletions test/integration/SafeRecovery/SafeRecovery.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { ModuleKitHelpers, ModuleKitUserOp } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR } from "erc7579/interfaces/IERC7579Module.sol";
import { IERC7579Account } from "erc7579/interfaces/IERC7579Account.sol";
Expand Down Expand Up @@ -29,7 +28,6 @@ contract SafeRecovery_Integration_Test is SafeIntegrationBase {
"swapOwner(address,address,address)", address(1), owner1, newOwner1
);
bytes memory recoveryData = abi.encode(accountAddress1, swapOwnerCalldata);
bytes32 recoveryDataHash = keccak256(recoveryData);

bytes[] memory commandParamsForRecovery = new bytes[](3);
commandParamsForRecovery[0] = abi.encode(accountAddress1);
Expand Down
3 changes: 0 additions & 3 deletions test/integration/SafeRecovery/SafeRecoveryNativeModule.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { ModuleKitHelpers, ModuleKitUserOp } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR } from "erc7579/interfaces/IERC7579Module.sol";
import { IERC7579Account } from "erc7579/interfaces/IERC7579Account.sol";
Expand Down Expand Up @@ -38,8 +37,6 @@ contract SafeRecoveryNativeModule_Integration_Test is SafeNativeIntegrationBase
bytes memory recoveryData = abi.encode(safeAddress, recoveryCalldata);
bytes32 recoveryDataHash = keccak256(recoveryData);

bytes32 accountHash = keccak256(abi.encodePacked(safeAddress));

AccountHidingRecoveryCommandHandler(commandHandler).storeAccountHash(safeAddress);

// Accept guardian
Expand Down
1 change: 0 additions & 1 deletion test/unit/EmailRecoveryManager/acceptGuardian.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { ModuleKitHelpers, ModuleKitUserOp } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR } from "modulekit/external/ERC7579.sol";
import { IEmailRecoveryManager } from "src/interfaces/IEmailRecoveryManager.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { UnitBase } from "../UnitBase.t.sol";

contract EmailRecoveryManager_acceptanceCommandTemplates_Test is UnitBase {
Expand Down
1 change: 0 additions & 1 deletion test/unit/EmailRecoveryManager/cancelExpiredRecovery.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { UnitBase } from "../UnitBase.t.sol";
import { IEmailRecoveryManager } from "src/interfaces/IEmailRecoveryManager.sol";
Expand Down
1 change: 0 additions & 1 deletion test/unit/EmailRecoveryManager/cancelRecovery.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { UnitBase } from "../UnitBase.t.sol";
import { IEmailRecoveryManager } from "src/interfaces/IEmailRecoveryManager.sol";
Expand Down
1 change: 0 additions & 1 deletion test/unit/EmailRecoveryManager/completeRecovery.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { UnitBase } from "../UnitBase.t.sol";
import { IEmailRecoveryManager } from "src/interfaces/IEmailRecoveryManager.sol";

Expand Down
1 change: 0 additions & 1 deletion test/unit/EmailRecoveryManager/configureRecovery.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { ModuleKitHelpers } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR } from "modulekit/external/ERC7579.sol";
import { IEmailRecoveryManager } from "src/interfaces/IEmailRecoveryManager.sol";
Expand Down
1 change: 0 additions & 1 deletion test/unit/EmailRecoveryManager/constructor.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { UnitBase } from "../UnitBase.t.sol";
import { IEmailRecoveryManager } from "src/interfaces/IEmailRecoveryManager.sol";
import { UniversalEmailRecoveryModule } from "src/modules/UniversalEmailRecoveryModule.sol";
Expand Down
1 change: 0 additions & 1 deletion test/unit/EmailRecoveryManager/deInitRecoveryModule.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { UnitBase } from "../UnitBase.t.sol";
import { IEmailRecoveryManager } from "src/interfaces/IEmailRecoveryManager.sol";
import { GuardianManager } from "src/GuardianManager.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { UnitBase } from "../UnitBase.t.sol";
import { IEmailRecoveryManager } from "src/interfaces/IEmailRecoveryManager.sol";
import { GuardianManager } from "src/GuardianManager.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { console2 } from "forge-std/console2.sol";
import { UnitBase } from "../UnitBase.t.sol";

contract EmailRecoveryManager_extractRecoveredAccountFromAcceptanceSubject_Test is UnitBase {
Expand Down
Loading

0 comments on commit 8562b75

Please sign in to comment.