Skip to content

Commit

Permalink
feat: add 7702 compitable semi modular account
Browse files Browse the repository at this point in the history
  • Loading branch information
fangting-alchemy committed Nov 12, 2024
1 parent c23dec6 commit 29f57fe
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/account/SemiModularAccount7702.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.26;

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

import {SemiModularAccountBase} from "./SemiModularAccountBase.sol";

/// @title Semi-Modular Account for EIP-7702 EOAs
/// @author Alchemy
/// @notice An implementation of a semi-modular account which reads the signer as the address(this).
/// @dev Inherits SemiModularAccountBase. This account can be used as the delegate contract of an EOA with
/// EIP-7702, where address(this) (aka the EOA address) is the default fallback signer.
contract SemiModularAccount7702 is SemiModularAccountBase {
constructor(IEntryPoint anEntryPoint) SemiModularAccountBase(anEntryPoint) {}

/// @inheritdoc IModularAccount
function accountId() external pure override returns (string memory) {
return "alchemy.sma-7702.1.0.0";
}

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

return address(this);
}
}

0 comments on commit 29f57fe

Please sign in to comment.