Skip to content

Commit

Permalink
feat(registry): add getallregistrants
Browse files Browse the repository at this point in the history
  • Loading branch information
namn-grg committed Jul 23, 2024
1 parent 95a64f8 commit 3d0adaf
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion bolt-contracts/src/contracts/BoltRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ contract BoltRegistry is IBoltRegistry {
// Mapping to hold the registrants
mapping(address => Registrant) public registrants;

// Array to hold operator addresses
address[] public operators;

// Mapping that holds the relationship between validator index and operator address
mapping(uint64 => address) public delegations;

Expand Down Expand Up @@ -106,7 +109,7 @@ contract BoltRegistry is IBoltRegistry {
/// @notice Check if an address is a based proposer opted into the protocol
/// @param _operator The address to check
/// @return True if the address is an active based proposer, false otherwise
function isActiveOperator(address _operator) external view returns (bool) {
function isActiveOperator(address _operator) public view returns (bool) {
return registrants[_operator].status == Status.ACTIVE;
}

Expand All @@ -129,4 +132,16 @@ contract BoltRegistry is IBoltRegistry {

revert NotFound();
}

function getAllRegistrants() external view returns (Registrant[] memory) {
Registrant[] memory _registrants = new Registrant[](operators.length);

for (uint256 i = 0; i < operators.length; i++) {
if (isActiveOperator(operators[i])) {
_registrants[i] = registrants[operators[i]];
}
}

return _registrants;
}
}

0 comments on commit 3d0adaf

Please sign in to comment.