Skip to content

Commit

Permalink
refactor(contracts): core contracts optimization, reflect on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjei committed Jan 17, 2025
1 parent 0bd434c commit fd66efc
Show file tree
Hide file tree
Showing 11 changed files with 589 additions and 450 deletions.
14 changes: 8 additions & 6 deletions packages/contracts/contracts/src/Checker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ abstract contract Checker is IChecker {
verifiers = _verifiers;
}

/// @notice Retrieves the list of third-party verifiers' addresses.
/// @return Array of addresses for the necessary verification contracts.
function getVerifiers() internal view returns (address[] memory) {
return verifiers;
/// @notice Retrieves the verifier address at a specific index.
/// @param index The index of the verifier in the array.
/// @return The address of the verifier at the specified index.
/// @custom:throws VerifierNotFound if no address have been specified at given index.
function getVerifierAtIndex(uint256 index) external view returns (address) {
return _getVerifierAtIndex(index);
}

/// @notice Retrieves the verifier address at a specific index.
/// @notice Internal implementation of verifier address retrieval at a specific index.
/// @param index The index of the verifier in the array.
/// @return The address of the verifier at the specified index.
/// @custom:throws VerifierNotFound if no address have been specified at given index.
function getVerifierAtIndex(uint256 index) internal view returns (address) {
function _getVerifierAtIndex(uint256 index) internal view returns (address) {
if (index >= verifiers.length) revert VerifierNotFound();

return verifiers[index];
Expand Down
6 changes: 6 additions & 0 deletions packages/contracts/contracts/src/interfaces/IChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ pragma solidity ^0.8.20;
interface IChecker {
/// @notice Core error conditions.
error VerifierNotFound();

/// @notice Retrieves the verifier address at a specific index.
/// @param index The index of the verifier in the array.
/// @return The address of the verifier at the specified index.
/// @custom:throws VerifierNotFound if no address have been specified at given index.
function getVerifierAtIndex(uint256 index) external view returns (address);
}
Loading

0 comments on commit fd66efc

Please sign in to comment.