@erc6900/reference-implementation 0.8.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @erc6900/reference-implementation might be problematic. Click here for more details.

Files changed (39) hide show
  1. package/package.json +5 -26
  2. package/preinstall.js +110 -0
  3. package/LICENSE +0 -21
  4. package/README.md +0 -76
  5. package/src/account/AccountExecutor.sol +0 -20
  6. package/src/account/AccountFactory.sol +0 -126
  7. package/src/account/AccountStorage.sol +0 -99
  8. package/src/account/AccountStorageInitializable.sol +0 -67
  9. package/src/account/ModularAccountView.sol +0 -66
  10. package/src/account/ModuleManagerInternals.sol +0 -325
  11. package/src/account/ReferenceModularAccount.sol +0 -769
  12. package/src/account/SemiModularAccount.sol +0 -214
  13. package/src/account/SemiModularAccount7702.sol +0 -38
  14. package/src/helpers/CollectReturnData.sol +0 -14
  15. package/src/helpers/Constants.sol +0 -11
  16. package/src/helpers/EmptyCalldataSlice.sol +0 -12
  17. package/src/helpers/ValidationResHelpers.sol +0 -50
  18. package/src/interfaces/IERC6900Account.sol +0 -127
  19. package/src/interfaces/IERC6900AccountView.sol +0 -52
  20. package/src/interfaces/IERC6900ExecutionHookModule.sol +0 -26
  21. package/src/interfaces/IERC6900ExecutionModule.sol +0 -37
  22. package/src/interfaces/IERC6900Module.sol +0 -24
  23. package/src/interfaces/IERC6900ValidationHookModule.sol +0 -46
  24. package/src/interfaces/IERC6900ValidationModule.sol +0 -53
  25. package/src/libraries/HookConfigLib.sol +0 -135
  26. package/src/libraries/KnownSelectorsLib.sol +0 -65
  27. package/src/libraries/ModuleEntityLib.sol +0 -37
  28. package/src/libraries/ModuleStorageLib.sol +0 -62
  29. package/src/libraries/SparseCalldataSegmentLib.sol +0 -95
  30. package/src/libraries/ValidationConfigLib.sol +0 -119
  31. package/src/modules/BaseModule.sol +0 -54
  32. package/src/modules/ModuleEIP712.sol +0 -29
  33. package/src/modules/ReplaySafeWrapper.sol +0 -38
  34. package/src/modules/TokenReceiverModule.sol +0 -87
  35. package/src/modules/permissions/AllowlistModule.sol +0 -156
  36. package/src/modules/permissions/ERC20TokenLimitModule.sol +0 -145
  37. package/src/modules/permissions/NativeTokenLimitModule.sol +0 -154
  38. package/src/modules/validation/ISingleSignerValidationModule.sol +0 -22
  39. package/src/modules/validation/SingleSignerValidationModule.sol +0 -138
@@ -1,138 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.20;
3
-
4
- import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interfaces/PackedUserOperation.sol";
5
- import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol";
6
- import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
7
- import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
8
-
9
- import {IERC6900Module} from "../../interfaces/IERC6900Module.sol";
10
- import {IERC6900ValidationModule} from "../../interfaces/IERC6900ValidationModule.sol";
11
- import {BaseModule} from "../BaseModule.sol";
12
-
13
- import {ReplaySafeWrapper} from "../ReplaySafeWrapper.sol";
14
- import {ISingleSignerValidationModule} from "./ISingleSignerValidationModule.sol";
15
-
16
- /// @title ECSDA Validation
17
- /// @author ERC-6900 Authors
18
- /// @notice This validation enables any ECDSA (secp256k1 curve) signature validation. It handles installation by
19
- /// each entity (entityId).
20
- /// Note: Uninstallation will NOT disable all installed validation entities. None of the functions are installed on
21
- /// the account. Account states are to be retrieved from this global singleton directly.
22
- ///
23
- /// - This validation supports ERC-1271. The signature is valid if it is signed by the owner's private key
24
- /// (if the owner is an EOA) or if it is a valid ERC-1271 signature from the owner (if the owner is a contract).
25
- ///
26
- /// - This validation supports composition that other validation can relay on entities in this validation
27
- /// to validate partially or fully.
28
- contract SingleSignerValidationModule is ISingleSignerValidationModule, ReplaySafeWrapper, BaseModule {
29
- using MessageHashUtils for bytes32;
30
-
31
- uint256 internal constant _SIG_VALIDATION_PASSED = 0;
32
- uint256 internal constant _SIG_VALIDATION_FAILED = 1;
33
-
34
- // bytes4(keccak256("isValidSignature(bytes32,bytes)"))
35
- bytes4 internal constant _1271_MAGIC_VALUE = 0x1626ba7e;
36
- bytes4 internal constant _1271_INVALID = 0xffffffff;
37
-
38
- mapping(uint32 entityId => mapping(address account => address)) public signers;
39
-
40
- /// @inheritdoc ISingleSignerValidationModule
41
- function transferSigner(uint32 entityId, address newSigner) external {
42
- _transferSigner(entityId, newSigner);
43
- }
44
-
45
- /// @inheritdoc IERC6900Module
46
- function onInstall(bytes calldata data) external override {
47
- (uint32 entityId, address newSigner) = abi.decode(data, (uint32, address));
48
- _transferSigner(entityId, newSigner);
49
- }
50
-
51
- /// @inheritdoc IERC6900Module
52
- function onUninstall(bytes calldata data) external override {
53
- uint32 entityId = abi.decode(data, (uint32));
54
- _transferSigner(entityId, address(0));
55
- }
56
-
57
- /// @inheritdoc IERC6900ValidationModule
58
- function validateUserOp(uint32 entityId, PackedUserOperation calldata userOp, bytes32 userOpHash)
59
- external
60
- view
61
- override
62
- returns (uint256)
63
- {
64
- // Validate the user op signature against the owner.
65
- if (
66
- SignatureChecker.isValidSignatureNow(
67
- signers[entityId][userOp.sender], userOpHash.toEthSignedMessageHash(), userOp.signature
68
- )
69
- ) {
70
- return _SIG_VALIDATION_PASSED;
71
- }
72
- return _SIG_VALIDATION_FAILED;
73
- }
74
-
75
- /// @inheritdoc IERC6900ValidationModule
76
- function validateRuntime(
77
- address account,
78
- uint32 entityId,
79
- address sender,
80
- uint256,
81
- bytes calldata,
82
- bytes calldata
83
- ) external view override {
84
- // Validate that the sender is the owner of the account or self.
85
- if (sender != signers[entityId][account]) {
86
- revert NotAuthorized();
87
- }
88
- return;
89
- }
90
-
91
- /// @inheritdoc IERC6900ValidationModule
92
- /// @dev The signature is valid if it is signed by the owner's private key
93
- /// (if the owner is an EOA) or if it is a valid ERC-1271 signature from the
94
- /// owner (if the owner is a contract).
95
- /// Note that the digest is wrapped in an EIP-712 struct to prevent cross-account replay attacks. The
96
- /// replay-safe hash may be retrieved by calling the public function `replaySafeHash`.
97
- function validateSignature(address account, uint32 entityId, address, bytes32 digest, bytes calldata signature)
98
- external
99
- view
100
- override
101
- returns (bytes4)
102
- {
103
- bytes32 _replaySafeHash = replaySafeHash(account, digest);
104
- if (SignatureChecker.isValidSignatureNow(signers[entityId][account], _replaySafeHash, signature)) {
105
- return _1271_MAGIC_VALUE;
106
- }
107
- return _1271_INVALID;
108
- }
109
-
110
- // ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
111
- // ┃ Module interface functions ┃
112
- // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
113
-
114
- /// @inheritdoc IERC6900Module
115
- function moduleId() external pure returns (string memory) {
116
- return "erc6900.single-signer-validation-module.1.0.0";
117
- }
118
-
119
- function supportsInterface(bytes4 interfaceId)
120
- public
121
- view
122
- virtual
123
- override(BaseModule, IERC165)
124
- returns (bool)
125
- {
126
- return (interfaceId == type(IERC6900ValidationModule).interfaceId || super.supportsInterface(interfaceId));
127
- }
128
-
129
- // ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
130
- // ┃ Internal / Private functions ┃
131
- // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
132
-
133
- function _transferSigner(uint32 entityId, address newSigner) internal {
134
- address previousSigner = signers[entityId][msg.sender];
135
- signers[entityId][msg.sender] = newSigner;
136
- emit SignerTransferred(msg.sender, entityId, newSigner, previousSigner);
137
- }
138
- }