Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
22 changes: 22 additions & 0 deletions src/avs/task/TaskAVSRegistrarBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {AVSRegistrarWithSocket} from
"../../middlewareV2/registrar/presets/AVSRegistrarWithSocket.sol";
import {ITaskAVSRegistrarBase} from "../../interfaces/ITaskAVSRegistrarBase.sol";
import {TaskAVSRegistrarBaseStorage} from "./TaskAVSRegistrarBaseStorage.sol";
import {Allowlist} from "../../middlewareV2/registrar/modules/Allowlist.sol";
import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol";

/**
* @title TaskAVSRegistrarBase
Expand All @@ -22,6 +24,7 @@ abstract contract TaskAVSRegistrarBase is
Initializable,
OwnableUpgradeable,
AVSRegistrarWithSocket,
Allowlist,
TaskAVSRegistrarBaseStorage
{
/**
Expand Down Expand Up @@ -53,6 +56,7 @@ abstract contract TaskAVSRegistrarBase is
__Ownable_init();
_transferOwnership(_owner);
_setAvsConfig(_initialConfig);
__Allowlist_init(_owner);
}

/// @inheritdoc ITaskAVSRegistrarBase
Expand Down Expand Up @@ -93,4 +97,22 @@ abstract contract TaskAVSRegistrarBase is
avsConfig = config;
emit AvsConfigSet(config.aggregatorOperatorSetId, config.executorOperatorSetIds);
}

/// @notice Before registering operator, check if the operator is in the allowlist
/// @dev Reverts for:
/// - OperatorNotInAllowlist: The operator is not in the allowlist
function _beforeRegisterOperator(
address operator,
uint32[] calldata operatorSetIds,
bytes calldata data
) internal override {
super._beforeRegisterOperator(operator, operatorSetIds, data);

for (uint32 i; i < operatorSetIds.length; ++i) {
require(
isOperatorAllowed(OperatorSet({avs: avs, id: operatorSetIds[i]}), operator),
OperatorNotInAllowlist()
);
}
}
}
14 changes: 14 additions & 0 deletions test/mocks/AllocationManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,18 @@ contract AllocationManagerMock is AllocationManagerIntermediate {

return minimumSlashableStake;
}

/**
* @notice Register an operator to an AVS through the AVS registrar
* @dev This function delegates to the appropriate AVS registrar
*/
function registerOperator(
address avs,
address operator,
uint32[] calldata operatorSetIds,
bytes calldata data
) external {
IAVSRegistrar avsRegistrar = IAVSRegistrar(_avsRegistrar[avs]);
avsRegistrar.registerOperator(operator, avs, operatorSetIds, data);
}
}
Loading
Loading