Skip to content

Commit 1bc6af2

Browse files
committed
refactor: supportsAVS
1 parent 77aa23f commit 1bc6af2

File tree

6 files changed

+18
-23
lines changed

6 files changed

+18
-23
lines changed

script/tasks/register_operator_to_operatorSet.s.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ contract AVSRegistrar is IAVSRegistrar {
1818
bytes calldata data
1919
) external {}
2020
function deregisterOperator(address operator, address avsIdentifier, uint32[] calldata operatorSetIds) external {}
21-
function avs() external view returns (address) {}
21+
function supportsAVS(address /*avs*/) external pure returns (bool) {
22+
return true;
23+
}
2224
fallback() external {}
2325
}
2426

src/contracts/core/AllocationManager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ contract AllocationManager is
321321
function setAVSRegistrar(address avs, IAVSRegistrar registrar) external checkCanCall(avs) {
322322
// Check that the registrar is correctly configured to prevent an AVSRegistrar contract
323323
// from being used with the wrong AVS
324-
require(registrar.avs() == avs, InvalidAVSRegistrar());
324+
require(registrar.supportsAVS(avs), InvalidAVSRegistrar());
325325
_avsRegistrar[avs] = registrar;
326326
emit AVSRegistrarSet(avs, getAVSRegistrar(avs));
327327
}

src/contracts/interfaces/IAVSRegistrar.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ interface IAVSRegistrar {
77
* for one or more operator sets. This method should revert if registration
88
* is unsuccessful.
99
* @param operator the registering operator
10-
* @param avsIdentifier the AVS the operator is registering for. This should be the same as IAVSRegistrar.avs()
10+
* @param avs the AVS the operator is registering for. This should be the same as IAVSRegistrar.avs()
1111
* @param operatorSetIds the list of operator set ids being registered for
1212
* @param data arbitrary data the operator can provide as part of registration
1313
*/
1414
function registerOperator(
1515
address operator,
16-
address avsIdentifier,
16+
address avs,
1717
uint32[] calldata operatorSetIds,
1818
bytes calldata data
1919
) external;
@@ -22,15 +22,15 @@ interface IAVSRegistrar {
2222
* @notice Called by the AllocationManager when an operator is deregistered from
2323
* one or more operator sets. If this method reverts, it is ignored.
2424
* @param operator the deregistering operator
25-
* @param avsIdentifier the AVS the operator is deregistering from. This should be the same as IAVSRegistrar.avs()
25+
* @param avs the AVS the operator is deregistering from. This should be the same as IAVSRegistrar.avs()
2626
* @param operatorSetIds the list of operator set ids being deregistered from
2727
*/
28-
function deregisterOperator(address operator, address avsIdentifier, uint32[] calldata operatorSetIds) external;
28+
function deregisterOperator(address operator, address avs, uint32[] calldata operatorSetIds) external;
2929

3030
/**
31-
* @notice Returns the account identifier address of the AVS. This should be the
32-
* the same address as the AVS's UAM account identifier address.
33-
* @return address of the AVS
31+
* @notice Returns true if the AVS is supported by the registrar
32+
* @param avs the AVS to check
33+
* @return true if the AVS is supported, false otherwise
3434
*/
35-
function avs() external view returns (address);
35+
function supportsAVS(address avs) external view returns (bool);
3636
}

src/test/integration/users/AVS.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ contract AVS is Logger, IAllocationManagerTypes, IAVSRegistrar {
6363
return _NAME;
6464
}
6565

66-
function avs() external view override returns (address) {
67-
return address(this);
66+
function supportsAVS(address) external pure override returns (bool) {
67+
return true;
6868
}
6969

7070
/// -----------------------------------------------------------------------

src/test/mocks/MockAVSRegistrar.sol

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22
pragma solidity ^0.8.27;
33

44
contract MockAVSRegistrar {
5-
address _avs;
6-
7-
function avs() external view returns (address) {
8-
return _avs;
9-
}
10-
11-
function setAvs(
12-
address newAvs
13-
) external {
14-
_avs = newAvs;
5+
function supportsAVS(
6+
address /*avs*/
7+
) external pure returns (bool) {
8+
return true;
159
}
1610

1711
fallback() external {}

src/test/unit/AllocationManagerUnit.t.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3663,7 +3663,6 @@ contract AllocationManagerUnitTests_setAVSRegistrar is AllocationManagerUnitTest
36633663
Randomness r
36643664
) public rand(r) {
36653665
address avs = r.Address();
3666-
MockAVSRegistrar(defaultAVS).setAvs(avs);
36673666
IAVSRegistrar avsRegistrar = IAVSRegistrar(defaultAVS);
36683667

36693668
cheats.expectEmit(true, true, true, true, address(allocationManager));

0 commit comments

Comments
 (0)