-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathKnownSelectorsLib.sol
More file actions
60 lines (56 loc) · 3.47 KB
/
KnownSelectorsLib.sol
File metadata and controls
60 lines (56 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// This file is part of Modular Account.
//
// Copyright 2024 Alchemy Insights, Inc.
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General
// Public License as published by the Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with this program. If not, see
// <https://www.gnu.org/licenses/>.
pragma solidity ^0.8.28;
import {IExecutionHookModule} from "@erc6900/reference-implementation/interfaces/IExecutionHookModule.sol";
import {IExecutionModule} from "@erc6900/reference-implementation/interfaces/IExecutionModule.sol";
import {IModule} from "@erc6900/reference-implementation/interfaces/IModule.sol";
import {IValidationHookModule} from "@erc6900/reference-implementation/interfaces/IValidationHookModule.sol";
import {IValidationModule} from "@erc6900/reference-implementation/interfaces/IValidationModule.sol";
import {IAggregator} from "@eth-infinitism/account-abstraction/interfaces/IAggregator.sol";
import {IPaymaster} from "@eth-infinitism/account-abstraction/interfaces/IPaymaster.sol";
/// @title Known Selectors Library
/// @author Alchemy
/// @notice Library to help to check if a selector is an ERC-6900 module function or a an ERC-4337 contract
/// function.
library KnownSelectorsLib {
/// @notice Check if a selector is an ERC-4337 function.
/// @param selector The selector to check.
/// @return True if the selector is an ERC-4337 function, false otherwise.
function isERC4337Function(uint32 selector) internal pure returns (bool) {
return selector == uint32(IAggregator.validateSignatures.selector)
|| selector == uint32(IAggregator.validateUserOpSignature.selector)
|| selector == uint32(IAggregator.aggregateSignatures.selector)
|| selector == uint32(IPaymaster.validatePaymasterUserOp.selector)
|| selector == uint32(IPaymaster.postOp.selector);
}
/// @notice Check if a selector is an ERC-6900 module function.
/// @param selector The selector to check.
/// @return True if the selector is an ERC-6900 module function, false otherwise.
function isIModuleFunction(uint32 selector) internal pure returns (bool) {
return selector == uint32(IModule.onInstall.selector) || selector == uint32(IModule.onUninstall.selector)
|| selector == uint32(IModule.moduleId.selector)
|| selector == uint32(IExecutionModule.executionManifest.selector)
|| selector == uint32(IExecutionHookModule.preExecutionHook.selector)
|| selector == uint32(IExecutionHookModule.postExecutionHook.selector)
|| selector == uint32(IValidationModule.validateUserOp.selector)
|| selector == uint32(IValidationModule.validateRuntime.selector)
|| selector == uint32(IValidationModule.validateSignature.selector)
|| selector == uint32(IValidationHookModule.preUserOpValidationHook.selector)
|| selector == uint32(IValidationHookModule.preRuntimeValidationHook.selector)
|| selector == uint32(IValidationHookModule.preSignatureValidationHook.selector);
}
}