Skip to content

Commit 2b2c061

Browse files
authored
feat: Add 7702 Semi-Modular Account Support (#213)
1 parent c9b256c commit 2b2c061

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

src/account/ReferenceModularAccount.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ contract ReferenceModularAccount is
305305
function upgradeToAndCall(address newImplementation, bytes memory data)
306306
public
307307
payable
308+
virtual
308309
override
309310
onlyProxy
310311
wrapNativeFunction

src/account/SemiModularAccount.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ contract SemiModularAccount is ReferenceModularAccount {
9292
}
9393

9494
/// @inheritdoc IModularAccount
95-
function accountId() external pure override returns (string memory) {
95+
function accountId() external pure virtual override returns (string memory) {
9696
return "erc6900.reference-semi-modular-account.0.8.0";
9797
}
9898

@@ -177,6 +177,7 @@ contract SemiModularAccount is ReferenceModularAccount {
177177
function _retrieveFallbackSignerUnchecked(SemiModularAccountStorage storage _storage)
178178
internal
179179
view
180+
virtual
180181
returns (address)
181182
{
182183
address storageFallbackSigner = _storage.fallbackSigner;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: GPL-3.0
2+
pragma solidity ^0.8.20;
3+
4+
import {IModularAccount} from "../interfaces/IModularAccount.sol";
5+
import {SemiModularAccount} from "./SemiModularAccount.sol";
6+
import {IEntryPoint} from "@eth-infinitism/account-abstraction/interfaces/IEntryPoint.sol";
7+
8+
contract SemiModularAccount7702 is SemiModularAccount {
9+
error UpgradeNotAllowed();
10+
11+
constructor(IEntryPoint anEntryPoint) SemiModularAccount(anEntryPoint) {}
12+
13+
/// @inheritdoc IModularAccount
14+
function accountId() external pure virtual override returns (string memory) {
15+
return "erc6900.reference-semi-modular-account-7702.0.8.0";
16+
}
17+
18+
/// @dev To prevent accidental self-calls, upgrades are disabled in 7702 accounts.
19+
function upgradeToAndCall(address, bytes memory) public payable override {
20+
revert UpgradeNotAllowed();
21+
}
22+
23+
/// @dev If the fallback signer is set in storage, ignore the 7702 signer.
24+
function _retrieveFallbackSignerUnchecked(SemiModularAccountStorage storage _storage)
25+
internal
26+
view
27+
override
28+
returns (address)
29+
{
30+
address storageFallbackSigner = _storage.fallbackSigner;
31+
if (storageFallbackSigner != address(0)) {
32+
return storageFallbackSigner;
33+
}
34+
35+
// To support 7702, we default to address(this) as the fallback signer.
36+
return address(this);
37+
}
38+
}

0 commit comments

Comments
 (0)