Skip to content
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: 7 additions & 0 deletions src/core/TxAuthManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ contract TxAuthManager is Initializable, TxAuthManagerBase, CrossStore, ITxAuthM
}

function _accountKey(Account.Data memory a) internal pure returns (bytes32) {
if (a.auth_type.mode == AuthType.AuthMode.AUTH_MODE_EXTENSION) {
return keccak256(abi.encode(
a.id,
a.auth_type.mode,
a.auth_type.option.type_url
));
}
return keccak256(abi.encode(a.id, a.auth_type));
}
}
21 changes: 21 additions & 0 deletions test/TxAuthManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,27 @@ contract TxAuthManagerTest is Test, ICrossError {
assertEq(keyA, keyACopy, "Identical accounts should produce the same key");
}

function test_accountKey_ExtensionModeIgnoresOptionValue() public {
bytes memory id = bytes("user1");
string memory typeUrl = URL_VALID;

GoogleProtobufAny.Data memory optionA = GoogleProtobufAny.Data({type_url: typeUrl, value: hex"aaaa"});
GoogleProtobufAny.Data memory optionB = GoogleProtobufAny.Data({type_url: typeUrl, value: hex"bbbb"});

AuthAccount.Data memory accA = AuthAccount.Data({
id: id, auth_type: AuthType.Data({mode: AuthType.AuthMode.AUTH_MODE_EXTENSION, option: optionA})
});

AuthAccount.Data memory accB = AuthAccount.Data({
id: id, auth_type: AuthType.Data({mode: AuthType.AuthMode.AUTH_MODE_EXTENSION, option: optionB})
});

bytes32 keyA = harness.exposed_accountKey(accA);
bytes32 keyB = harness.exposed_accountKey(accB);

assertEq(keyA, keyB, "Extension mode should ignore option.value in accountKey generation");
}

function test_setStateFromRemainingList_HandlesDuplicatesAndReturnsRemains() public {
AuthAccount.Data[] memory signers = new AuthAccount.Data[](3);
signers[0] = signerA;
Expand Down
Loading