Skip to content

Commit

Permalink
chore: rename file
Browse files Browse the repository at this point in the history
  • Loading branch information
highskore committed Nov 28, 2024
1 parent 48d4028 commit 49c7e8c
Show file tree
Hide file tree
Showing 27 changed files with 160 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Modules.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
IExecutor as IERC7579Executor,
IFallback as IERC7579Fallback,
IHook as IERC7579Hook
} from "src/accounts/common/interfaces/IERC7579Modules.sol";
} from "src/accounts/common/interfaces/IERC7579Module.sol";
import { ERC7484RegistryAdapter } from "src/module-bases/ERC7484RegistryAdapter.sol";
import { ERC7579ModuleBase } from "src/module-bases/ERC7579ModuleBase.sol";
import { TrustedForwarder } from "src/module-bases/utils/TrustedForwarder.sol";
Expand Down
134 changes: 134 additions & 0 deletions src/accounts/erc7579/helpers/ExecutionHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import { Execution } from "../../common/interfaces/IERC7579Account.sol";

/**
* @title Execution
* @dev This contract executes calls in the context of this contract.
* @author zeroknots.eth | rhinestone.wtf
* shoutout to solady (vectorized, ross) for this code
* https://github.com/Vectorized/solady/blob/main/src/accounts/ERC4337.sol
*/
contract ExecutionHelper {
error ExecutionFailed();

event TryExecuteUnsuccessful(uint256 batchExecutionindex, bytes result);

function _execute(Execution[] calldata executions) internal returns (bytes[] memory result) {
uint256 length = executions.length;
result = new bytes[](length);

for (uint256 i; i < length; i++) {
Execution calldata _exec = executions[i];
result[i] = _execute(_exec.target, _exec.value, _exec.callData);
}
}

function _tryExecute(Execution[] calldata executions)
internal
returns (bytes[] memory result)
{
uint256 length = executions.length;
result = new bytes[](length);

for (uint256 i; i < length; i++) {
Execution calldata _exec = executions[i];
bool success;
(success, result[i]) = _tryExecute(_exec.target, _exec.value, _exec.callData);
if (!success) emit TryExecuteUnsuccessful(i, result[i]);
}
}

function _execute(
address target,
uint256 value,
bytes calldata callData
)
internal
virtual
returns (bytes memory result)
{
/// @solidity memory-safe-assembly
assembly {

Check warning on line 53 in src/accounts/erc7579/helpers/ExecutionHelper.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Avoid to use inline assembly. It is acceptable only in rare cases
result := mload(0x40)
calldatacopy(result, callData.offset, callData.length)
if iszero(call(gas(), target, value, result, callData.length, codesize(), 0x00)) {
// Bubble up the revert if the call reverts.
returndatacopy(result, 0x00, returndatasize())
revert(result, returndatasize())
}
mstore(result, returndatasize()) // Store the length.
let o := add(result, 0x20)
returndatacopy(o, 0x00, returndatasize()) // Copy the returndata.
mstore(0x40, add(o, returndatasize())) // Allocate the memory.
}
}

function _tryExecute(
address target,
uint256 value,
bytes calldata callData
)
internal
virtual
returns (bool success, bytes memory result)
{
/// @solidity memory-safe-assembly
assembly {

Check warning on line 78 in src/accounts/erc7579/helpers/ExecutionHelper.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Avoid to use inline assembly. It is acceptable only in rare cases
result := mload(0x40)
calldatacopy(result, callData.offset, callData.length)
success := call(gas(), target, value, result, callData.length, codesize(), 0x00)
mstore(result, returndatasize()) // Store the length.
let o := add(result, 0x20)
returndatacopy(o, 0x00, returndatasize()) // Copy the returndata.
mstore(0x40, add(o, returndatasize())) // Allocate the memory.
}
}

/// @dev Execute a delegatecall with `delegate` on this account.
function _executeDelegatecall(
address delegate,
bytes calldata callData
)
internal
returns (bytes memory result)
{
/// @solidity memory-safe-assembly
assembly {

Check warning on line 98 in src/accounts/erc7579/helpers/ExecutionHelper.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Avoid to use inline assembly. It is acceptable only in rare cases
result := mload(0x40)
calldatacopy(result, callData.offset, callData.length)
// Forwards the `data` to `delegate` via delegatecall.
if iszero(delegatecall(gas(), delegate, result, callData.length, codesize(), 0x00)) {
// Bubble up the revert if the call reverts.
returndatacopy(result, 0x00, returndatasize())
revert(result, returndatasize())
}
mstore(result, returndatasize()) // Store the length.
let o := add(result, 0x20)
returndatacopy(o, 0x00, returndatasize()) // Copy the returndata.
mstore(0x40, add(o, returndatasize())) // Allocate the memory.
}
}

/// @dev Execute a delegatecall with `delegate` on this account and catch reverts.
function _tryExecuteDelegatecall(
address delegate,
bytes calldata callData
)
internal
returns (bool success, bytes memory result)
{
/// @solidity memory-safe-assembly
assembly {

Check warning on line 123 in src/accounts/erc7579/helpers/ExecutionHelper.sol

View workflow job for this annotation

GitHub Actions / lint / forge-lint

Avoid to use inline assembly. It is acceptable only in rare cases
result := mload(0x40)
calldatacopy(result, callData.offset, callData.length)
// Forwards the `data` to `delegate` via delegatecall.
success := delegatecall(gas(), delegate, result, callData.length, codesize(), 0x00)
mstore(result, returndatasize()) // Store the length.
let o := add(result, 0x20)
returndatacopy(o, 0x00, returndatasize()) // Copy the returndata.
mstore(0x40, add(o, returndatasize())) // Allocate the memory.
}
}
}
2 changes: 1 addition & 1 deletion src/accounts/erc7579/interfaces/IERC7579Bootstrap.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.23 <0.9.0;

import { IModule } from "../../common/interfaces/IERC7579Modules.sol";
import { IModule } from "../../common/interfaces/IERC7579Module.sol";

struct BootstrapConfig {
address module;
Expand Down
4 changes: 2 additions & 2 deletions src/accounts/kernel/KernelFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { IEntryPoint } from "@ERC4337/account-abstraction/contracts/interfaces/I
import { ENTRYPOINT_ADDR } from "../../test/predeploy/EntryPoint.sol";
import { ValidatorLib } from "src/accounts/kernel/lib/ValidationTypeLib.sol";
import { ValidationId } from "src/accounts/kernel/types/Types.sol";
import { IValidator } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { IHook } from "src/accounts/kernel/interfaces/IERC7579Modules.sol";
import { IValidator } from "src/accounts/common/interfaces/IERC7579Module.sol";
import { IHook } from "src/accounts/kernel/interfaces/IERC7579Module.sol";
import { IAccountFactory } from "src/accounts/interface/IAccountFactory.sol";
import { MockHookMultiPlexer } from "src/Mocks.sol";
import { KernelPrecompiles } from "src/test/precompiles/KernelPrecompiles.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/accounts/kernel/interfaces/IKernel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IERC7579Account } from "./IERC7579Account.sol";
import { IAccount, ValidationData } from "./IAccount.sol";
import { IAccountExecute } from "./IAccountExecute.sol";
import { ValidationId, ValidationConfig } from "../lib/ValidationTypeLib.sol";
import { IHook } from "./IERC7579Modules.sol";
import { IHook } from "./IERC7579Module.sol";
import { PackedUserOperation } from
"@ERC4337/account-abstraction/contracts/core/UserOperationLib.sol";
import { ExecMode } from "../lib/ExecLib.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/accounts/kernel/interfaces/IValidationManager.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.23 <0.9.0;

import { IHook, ISigner } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { IHook, ISigner } from "src/accounts/common/interfaces/IERC7579Module.sol";
import { PassFlag, PolicyData, ValidationId, PermissionId } from "../lib/ValidationTypeLib.sol";

// erc7579 plugins
Expand Down
2 changes: 1 addition & 1 deletion src/accounts/kernel/lib/ValidationTypeLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.23 <0.9.0;

import {
IValidator, IPolicy, IHook, ISigner
} from "src/accounts/common/interfaces/IERC7579Modules.sol";
} from "src/accounts/common/interfaces/IERC7579Module.sol";
import {
PassFlag,
ValidationType,
Expand Down
2 changes: 1 addition & 1 deletion src/accounts/kernel/mock/MockFallback.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.8.23 <0.9.0;

import { IERC7579Account } from "../interfaces/IERC7579Account.sol";
import { IFallback } from "../interfaces/IERC7579Modules.sol";
import { IFallback } from "../interfaces/IERC7579Module.sol";
import { CallType, ExecType, ExecMode, ExecLib } from "../lib/ExecLib.sol";
import { EXEC_MODE_DEFAULT } from "../types/Constants.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/accounts/nexus/interfaces/INexusBootstrap.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.23 <0.9.0;

import { IModule as IERC7579Module } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { IModule as IERC7579Module } from "src/accounts/common/interfaces/IERC7579Module.sol";
import { IERC7484 } from "src/Interfaces.sol";

struct BootstrapConfig {
Expand Down
2 changes: 1 addition & 1 deletion src/integrations/registry/ExampleFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.8.23 <0.9.0;
import { IMSA } from "src/accounts/erc7579/interfaces/IMSA.sol";
import { FactoryBase } from "./FactoryBase.sol";
import { IERC7579Bootstrap } from "src/accounts/erc7579/interfaces/IERC7579Bootstrap.sol";
import { IModule as IERC7579Module } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { IModule as IERC7579Module } from "src/accounts/common/interfaces/IERC7579Module.sol";
import { ERC7579Precompiles } from "src/test/precompiles/ERC7579Precompiles.sol";

contract ExampleFactory is FactoryBase, ERC7579Precompiles {
Expand Down
2 changes: 1 addition & 1 deletion src/module-bases/ERC7579ExecutorBase.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0 <0.9.0;

import { IExecutor as IERC7579Executor } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { IExecutor as IERC7579Executor } from "src/accounts/common/interfaces/IERC7579Module.sol";
import { IERC7579Account } from "src/accounts/common/interfaces/IERC7579Account.sol";
import {
Execution,
Expand Down
2 changes: 1 addition & 1 deletion src/module-bases/ERC7579FallbackBase.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0 <0.9.0;

import { IFallback as IERC7579Fallback } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { IFallback as IERC7579Fallback } from "src/accounts/common/interfaces/IERC7579Module.sol";
import { ERC7579ModuleBase } from "./ERC7579ModuleBase.sol";

abstract contract ERC7579FallbackBase is IERC7579Fallback, ERC7579ModuleBase {
Expand Down
2 changes: 1 addition & 1 deletion src/module-bases/ERC7579HookBase.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0 <0.9.0;

import { IHook as IERC7579Hook } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { IHook as IERC7579Hook } from "src/accounts/common/interfaces/IERC7579Module.sol";
import { ERC7579ModuleBase } from "./ERC7579ModuleBase.sol";
import { TrustedForwarder } from "./utils/TrustedForwarder.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/module-bases/ERC7579HookDestruct.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.8.0 <0.9.0;

import { IERC7579Account } from "src/accounts/common/interfaces/IERC7579Account.sol";
import { IHook as IERC7579Hook } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { IHook as IERC7579Hook } from "src/accounts/common/interfaces/IERC7579Module.sol";
import { ExecutionLib, Execution } from "src/accounts/erc7579/lib/ExecutionLib.sol";
import {
ModeLib,
Expand Down
2 changes: 1 addition & 1 deletion src/module-bases/ERC7579ModuleBase.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0 <0.9.0;

import { IModule as IERC7579Module } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { IModule as IERC7579Module } from "src/accounts/common/interfaces/IERC7579Module.sol";

abstract contract ERC7579ModuleBase is IERC7579Module {
uint256 internal constant TYPE_VALIDATOR = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/module-bases/interfaces/IPolicy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
IModule as IERC7579Module,
VALIDATION_SUCCESS,
VALIDATION_FAILED
} from "src/accounts/common/interfaces/IERC7579Modules.sol";
} from "src/accounts/common/interfaces/IERC7579Module.sol";
import { IERC165 } from "forge-std/interfaces/IERC165.sol";

type ConfigId is bytes32;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ModuleKitHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { PackedUserOperation } from "../external/ERC4337.sol";
import { ERC4337Helpers } from "./utils/ERC4337Helpers.sol";
import { HelperBase } from "./helpers/HelperBase.sol";
import { MODULE_TYPE_HOOK } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { MODULE_TYPE_HOOK } from "src/accounts/common/interfaces/IERC7579Module.sol";
import { Execution } from "src/accounts/erc7579/lib/ExecutionLib.sol";
import {
prank,
Expand Down
2 changes: 1 addition & 1 deletion src/test/RhinestoneModuleKit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { PackedUserOperation, IStakeManager, IEntryPoint } from "../external/ERC
import { ENTRYPOINT_ADDR } from "./predeploy/EntryPoint.sol";
import { SMARTSESSION_ADDR } from "./precompiles/SmartSessions.sol";
import { ISmartSession, ISessionValidator } from "src/test/helpers/interfaces/ISmartSession.sol";
import { IValidator as IERC7579Validator } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { IValidator as IERC7579Validator } from "src/accounts/common/interfaces/IERC7579Module.sol";
import { MockValidator, MockStatelessValidator } from "../Mocks.sol";
import {
getAccountEnv,
Expand Down
2 changes: 1 addition & 1 deletion src/test/helpers/HelperBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
MODULE_TYPE_EXECUTOR,
MODULE_TYPE_HOOK,
MODULE_TYPE_FALLBACK
} from "src/accounts/common/interfaces/IERC7579Modules.sol";
} from "src/accounts/common/interfaces/IERC7579Module.sol";
import { PackedUserOperation } from "../../external/ERC4337.sol";
import { AccountInstance } from "../RhinestoneModuleKit.sol";
import "../utils/Vm.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/test/helpers/KernelHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { MockFallback } from "src/accounts/kernel/mock/MockFallback.sol";
import { HelperBase } from "./HelperBase.sol";
import { IKernel } from "src/accounts/kernel/interfaces/IKernel.sol";
import { etch } from "../utils/Vm.sol";
import { IValidator, IModule } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { IValidator, IModule } from "src/accounts/common/interfaces/IERC7579Module.sol";
import { IERC1271, EIP1271_MAGIC_VALUE } from "src/Interfaces.sol";
import { CallType } from "src/accounts/common/lib/ModeLib.sol";
import { Execution } from "src/accounts/erc7579/lib/ExecutionLib.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/test/helpers/SafeHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
MODULE_TYPE_VALIDATOR,
MODULE_TYPE_EXECUTOR,
MODULE_TYPE_FALLBACK
} from "src/accounts/common/interfaces/IERC7579Modules.sol";
} from "src/accounts/common/interfaces/IERC7579Module.sol";
import { IERC7579Account } from "src/accounts/common/interfaces/IERC7579Account.sol";
import { HookType } from "src/accounts/safe/types/DataTypes.sol";
import { IAccountFactory } from "src/accounts/interface/IAccountFactory.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/test/helpers/interfaces/ISmartSession.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.0 <0.9.0;

import { IModule } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { IModule } from "src/accounts/common/interfaces/IERC7579Module.sol";

import { PackedUserOperation } from "src/external/ERC4337.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/Diff.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
MODULE_TYPE_FALLBACK,
VALIDATION_SUCCESS,
VALIDATION_FAILED
} from "src/accounts/common/interfaces/IERC7579Modules.sol";
} from "src/accounts/common/interfaces/IERC7579Module.sol";
import { CALLTYPE_SINGLE } from "src/accounts/common/lib/ModeLib.sol";
import { getAccountType, InstalledModule } from "src/test/utils/Storage.sol";
import { toString } from "src/test/utils/Vm.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/integrations/SmartSession.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.8.23 <0.9.0;

// Constants
import { MODULE_TYPE_VALIDATOR } from "src/accounts/common/interfaces/IERC7579Modules.sol";
import { MODULE_TYPE_VALIDATOR } from "src/accounts/common/interfaces/IERC7579Module.sol";

// Libraries
import { ModuleKitHelpers, AccountInstance } from "src/ModuleKit.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/MockK1Validator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
VALIDATION_SUCCESS,
VALIDATION_FAILED,
MODULE_TYPE_VALIDATOR
} from "src/accounts/common/interfaces/IERC7579Modules.sol";
} from "src/accounts/common/interfaces/IERC7579Module.sol";
import { PackedUserOperation } from "src/external/ERC4337.sol";
import { ECDSA } from "solady/utils/ECDSA.sol";
import { SignatureCheckerLib } from "solady/utils/SignatureCheckerLib.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/MockK1ValidatorUncompliantUninstall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
VALIDATION_SUCCESS,
VALIDATION_FAILED,
MODULE_TYPE_VALIDATOR
} from "src/accounts/common/interfaces/IERC7579Modules.sol";
} from "src/accounts/common/interfaces/IERC7579Module.sol";
import { PackedUserOperation } from "src/external/ERC4337.sol";
import { ECDSA } from "solady/utils/ECDSA.sol";
import { SignatureCheckerLib } from "solady/utils/SignatureCheckerLib.sol";
Expand Down

0 comments on commit 49c7e8c

Please sign in to comment.