Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add 7702 Semi-Modular Account Support #213

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/account/ReferenceModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ contract ReferenceModularAccount is
function upgradeToAndCall(address newImplementation, bytes memory data)
public
payable
virtual
override
onlyProxy
wrapNativeFunction
Expand Down
3 changes: 2 additions & 1 deletion src/account/SemiModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ contract SemiModularAccount is ReferenceModularAccount {
}

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

Expand Down Expand Up @@ -177,6 +177,7 @@ contract SemiModularAccount is ReferenceModularAccount {
function _retrieveFallbackSignerUnchecked(SemiModularAccountStorage storage _storage)
internal
view
virtual
returns (address)
{
address storageFallbackSigner = _storage.fallbackSigner;
Expand Down
38 changes: 38 additions & 0 deletions src/account/SemiModularAccount7702.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;

import {IModularAccount} from "../interfaces/IModularAccount.sol";
import {SemiModularAccount} from "./SemiModularAccount.sol";
import {IEntryPoint} from "@eth-infinitism/account-abstraction/interfaces/IEntryPoint.sol";

contract SemiModularAccount7702 is SemiModularAccount {
error UpgradeNotAllowed();

constructor(IEntryPoint anEntryPoint) SemiModularAccount(anEntryPoint) {}

/// @inheritdoc IModularAccount
function accountId() external pure virtual override returns (string memory) {
return "erc6900.reference-semi-modular-account-7702.0.8.0";
}

/// @dev To prevent accidental self-calls, upgrades are disabled in 7702 accounts.
function upgradeToAndCall(address, bytes memory) public payable override {
revert UpgradeNotAllowed();
}

/// @dev If the fallback signer is set in storage, ignore the 7702 signer.
function _retrieveFallbackSignerUnchecked(SemiModularAccountStorage storage _storage)
internal
view
override
returns (address)
{
address storageFallbackSigner = _storage.fallbackSigner;
if (storageFallbackSigner != address(0)) {
return storageFallbackSigner;
}

// To support 7702, we default to address(this) as the fallback signer.
return address(this);
}
}