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 accountId #152

Merged
merged 1 commit into from
Aug 22, 2024
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
7 changes: 6 additions & 1 deletion src/account/SemiModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interface

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

import {ModuleEntity, ValidationConfig} from "../interfaces/IModularAccount.sol";
import {IModularAccount, ModuleEntity, ValidationConfig} from "../interfaces/IModularAccount.sol";

import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
Expand Down Expand Up @@ -83,6 +83,11 @@ contract SemiModularAccount is UpgradeableModularAccount {
revert InitializerDisabled();
}

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

function _execUserOpValidation(
ModuleEntity userOpValidationFunction,
PackedUserOperation memory userOp,
Expand Down
5 changes: 5 additions & 0 deletions src/account/UpgradeableModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ contract UpgradeableModularAccount is
return getAccountStorage().supportedIfaces[interfaceId] > 0;
}

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

/// @inheritdoc UUPSUpgradeable
/// @notice May be validated by a global validation.
function upgradeToAndCall(address newImplementation, bytes memory data)
Expand Down
12 changes: 7 additions & 5 deletions src/helpers/KnownSelectors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@ library KnownSelectors {
return
// check against IAccount methods
selector == IAccount.validateUserOp.selector
// check against module manager methods
// check against IModularAccount methods
|| selector == IModularAccount.installExecution.selector
|| selector == IModularAccount.uninstallExecution.selector
|| selector == IModularAccount.installValidation.selector
|| selector == IModularAccount.uninstallValidation.selector || selector == IModularAccount.execute.selector
|| selector == IModularAccount.executeBatch.selector
|| selector == IModularAccount.executeWithAuthorization.selector
|| selector == IModularAccount.accountId.selector
// check against IERC165 methods
|| selector == IERC165.supportsInterface.selector
// check against UUPSUpgradeable methods
|| selector == UUPSUpgradeable.proxiableUUID.selector
|| selector == UUPSUpgradeable.upgradeToAndCall.selector
// check against IModularAccount methods
|| selector == IModularAccount.execute.selector || selector == IModularAccount.executeBatch.selector
|| selector == IModularAccount.executeWithAuthorization.selector
// check against account loupe methods
// check against IAccountLoupe methods
|| selector == IAccountLoupe.getExecutionData.selector
|| selector == IAccountLoupe.getValidationData.selector;
}
Expand Down
5 changes: 5 additions & 0 deletions src/interfaces/IModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,9 @@ interface IModularAccount {
ExecutionManifest calldata manifest,
bytes calldata moduleUninstallData
) external;

/// @notice Return a unique identifier for the account implementation.
/// @dev This function MUST return a string in the format "vendor/account/semver".
/// @return The account ID.
function accountId() external view returns (string memory);
}
10 changes: 10 additions & 0 deletions test/account/UpgradeableModularAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ contract UpgradeableModularAccountTest is AccountTestBase {
_printStorageReadsAndWrites(address(account2));
}

function test_accountId() public {
string memory accountId = account1.accountId();
assertEq(
accountId,
vm.envOr("SMA_TEST", false)
? "erc6900/reference-semi-modular-account/0.8.0"
: "erc6900/reference-modular-account/0.8.0"
);
}

function test_contractInteraction() public {
PackedUserOperation memory userOp = PackedUserOperation({
sender: address(account1),
Expand Down
Loading