Skip to content

Commit c2072a1

Browse files
authored
feat: add accountId (#152)
1 parent bd33993 commit c2072a1

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

src/account/SemiModularAccount.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interface
77

88
import {ModuleEntityLib} from "../helpers/ModuleEntityLib.sol";
99

10-
import {ModuleEntity, ValidationConfig} from "../interfaces/IModularAccount.sol";
10+
import {IModularAccount, ModuleEntity, ValidationConfig} from "../interfaces/IModularAccount.sol";
1111

1212
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
1313
import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
@@ -83,6 +83,11 @@ contract SemiModularAccount is UpgradeableModularAccount {
8383
revert InitializerDisabled();
8484
}
8585

86+
/// @inheritdoc IModularAccount
87+
function accountId() external pure override returns (string memory) {
88+
return "erc6900/reference-semi-modular-account/0.8.0";
89+
}
90+
8691
function _execUserOpValidation(
8792
ModuleEntity userOpValidationFunction,
8893
PackedUserOperation memory userOp,

src/account/UpgradeableModularAccount.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ contract UpgradeableModularAccount is
276276
return getAccountStorage().supportedIfaces[interfaceId] > 0;
277277
}
278278

279+
/// @inheritdoc IModularAccount
280+
function accountId() external pure virtual returns (string memory) {
281+
return "erc6900/reference-modular-account/0.8.0";
282+
}
283+
279284
/// @inheritdoc UUPSUpgradeable
280285
/// @notice May be validated by a global validation.
281286
function upgradeToAndCall(address newImplementation, bytes memory data)

src/helpers/KnownSelectors.sol

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,20 @@ library KnownSelectors {
2222
return
2323
// check against IAccount methods
2424
selector == IAccount.validateUserOp.selector
25-
// check against module manager methods
25+
// check against IModularAccount methods
2626
|| selector == IModularAccount.installExecution.selector
2727
|| selector == IModularAccount.uninstallExecution.selector
28+
|| selector == IModularAccount.installValidation.selector
29+
|| selector == IModularAccount.uninstallValidation.selector || selector == IModularAccount.execute.selector
30+
|| selector == IModularAccount.executeBatch.selector
31+
|| selector == IModularAccount.executeWithAuthorization.selector
32+
|| selector == IModularAccount.accountId.selector
2833
// check against IERC165 methods
2934
|| selector == IERC165.supportsInterface.selector
3035
// check against UUPSUpgradeable methods
3136
|| selector == UUPSUpgradeable.proxiableUUID.selector
3237
|| selector == UUPSUpgradeable.upgradeToAndCall.selector
33-
// check against IModularAccount methods
34-
|| selector == IModularAccount.execute.selector || selector == IModularAccount.executeBatch.selector
35-
|| selector == IModularAccount.executeWithAuthorization.selector
36-
// check against account loupe methods
38+
// check against IAccountLoupe methods
3739
|| selector == IAccountLoupe.getExecutionData.selector
3840
|| selector == IAccountLoupe.getValidationData.selector;
3941
}

src/interfaces/IModularAccount.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,9 @@ interface IModularAccount {
9797
ExecutionManifest calldata manifest,
9898
bytes calldata moduleUninstallData
9999
) external;
100+
101+
/// @notice Return a unique identifier for the account implementation.
102+
/// @dev This function MUST return a string in the format "vendor/account/semver".
103+
/// @return The account ID.
104+
function accountId() external view returns (string memory);
100105
}

test/account/UpgradeableModularAccount.t.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ contract UpgradeableModularAccountTest is AccountTestBase {
184184
_printStorageReadsAndWrites(address(account2));
185185
}
186186

187+
function test_accountId() public {
188+
string memory accountId = account1.accountId();
189+
assertEq(
190+
accountId,
191+
vm.envOr("SMA_TEST", false)
192+
? "erc6900/reference-semi-modular-account/0.8.0"
193+
: "erc6900/reference-modular-account/0.8.0"
194+
);
195+
}
196+
187197
function test_contractInteraction() public {
188198
PackedUserOperation memory userOp = PackedUserOperation({
189199
sender: address(account1),

0 commit comments

Comments
 (0)