Skip to content

Commit

Permalink
fix: accountId() is now based off safe's version string
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroknots committed Mar 29, 2024
1 parent e962895 commit d94c097
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions accounts/safe7579/src/SafeERC7579.sol
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,11 @@ contract SafeERC7579 is ISafeOp, IERC7579Account, AccessControl, IMSA, HookManag
/**
* @inheritdoc IERC7579Account
*/
function accountId() external pure override returns (string memory accountImplementationId) {
return "safe-erc7579.v0.0.0";
function accountId() external view override returns (string memory accountImplementationId) {
string memory version = ISafe(msg.sender).VERSION();

accountImplementationId =
string(abi.encodePacked("safe", abi.encodePacked(version), ".erc7579.v0.0.1"));
}

/**
Expand Down
2 changes: 2 additions & 0 deletions accounts/safe7579/src/interfaces/ISafe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ interface ISafe {
*/
function domainSeparator() external view returns (bytes32);

function VERSION() external pure returns (string memory);

function getStorageAt(uint256 offset, uint256 length) external view returns (bytes memory);

/**
Expand Down
8 changes: 8 additions & 0 deletions accounts/safe7579/test/SafeERC7579.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "erc7579/lib/ModeLib.sol";
import "erc7579/lib/ExecutionLib.sol";
import { TestBaseUtil, MockTarget, MockFallback } from "./Base.t.sol";

import "forge-std/console2.sol";

contract MSATest is TestBaseUtil {
function setUp() public override {
super.setUp();
Expand Down Expand Up @@ -117,4 +119,10 @@ contract MSATest is TestBaseUtil {
assertEq(erc2771Sender, address(this));
assertEq(msgSender, address(safe));
}

function test_accountId() public {
string memory id = IERC7579Account(address(safe)).accountId();

assertEq(id, "safe1.4.1.erc7579.v0.0.1");
}
}

0 comments on commit d94c097

Please sign in to comment.