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 91ec2c3
Show file tree
Hide file tree
Showing 12 changed files with 590 additions and 451 deletions.
2 changes: 1 addition & 1 deletion packages/contracts/contracts/src/AdvancedChecker.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IAdvancedChecker, Check, CheckStatus} from "./interfaces/IAdvancedChecker.sol";
import {IAdvancedChecker, Check} from "./interfaces/IAdvancedChecker.sol";
import {Checker} from "./Checker.sol";

/// @title AdvancedChecker.
Expand Down
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 91ec2c3

Please sign in to comment.