Skip to content

Commit

Permalink
feat: batch operator id conversions (#248)
Browse files Browse the repository at this point in the history
* feat: batch operator id conversions

* docs: natspec
  • Loading branch information
0x0aa0 authored Apr 29, 2024
1 parent deebd4b commit 1feb6ae
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/OperatorStateRetriever.sol
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,37 @@ contract OperatorStateRetriever {
}
return quorumBitmaps;
}

/**
* @notice This function returns the operatorIds for each of the operators in the operators array
* @param registryCoordinator is the AVS registry coordinator to fetch the operator information from
* @param operators is the array of operator address to get corresponding operatorIds for
* @dev if an operator is not registered, the operatorId will be 0
*/
function getBatchOperatorId(
IRegistryCoordinator registryCoordinator,
address[] memory operators
) external view returns (bytes32[] memory operatorIds) {
operatorIds = new bytes32[](operators.length);
for (uint256 i = 0; i < operators.length; ++i) {
operatorIds[i] = registryCoordinator.getOperatorId(operators[i]);
}
}

/**
* @notice This function returns the operator addresses for each of the operators in the operatorIds array
* @param registryCoordinator is the AVS registry coordinator to fetch the operator information from
* @param operators is the array of operatorIds to get corresponding operator addresses for
* @dev if an operator is not registered, the operator address will be 0
*/
function getBatchOperatorFromId(
IRegistryCoordinator registryCoordinator,
bytes32[] memory operatorIds
) external view returns (address[] memory operators) {
operators = new address[](operatorIds.length);
for (uint256 i = 0; i < operatorIds.length; ++i) {
operators[i] = registryCoordinator.getOperatorFromId(operatorIds[i]);
}
}

}

0 comments on commit 1feb6ae

Please sign in to comment.