Skip to content

Commit

Permalink
fix: ensure input arrays have the same length
Browse files Browse the repository at this point in the history
  • Loading branch information
xorsal committed Dec 10, 2024
1 parent 3e1078a commit f223864
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion solidity/contracts/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ contract Oracle is IOracle, OracleAccessController {
AccessControl[] calldata _accessControl
) external returns (bytes32[] memory _batchRequestsIds) {
uint256 _requestsAmount = _requestsData.length;
_batchRequestsIds = new bytes32[](_requestsAmount);

if (_requestsAmount != _ipfsHashes.length || _requestsAmount != _accessControl.length) {
revert Oracle_ArrayMismatchLength();
}

_batchRequestsIds = new bytes32[](_requestsAmount);
for (uint256 _i; _i < _requestsAmount;) {
_batchRequestsIds[_i] = _createRequest(_requestsData[_i], _ipfsHashes[_i], _accessControl[_i]);
unchecked {
Expand Down
5 changes: 5 additions & 0 deletions solidity/interfaces/IOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ interface IOracle is IOracleAccessController {
*/
error Oracle_InvalidDisputer();

/**
* @notice Thrown when the input arrays have different lengths
*/
error Oracle_ArrayMismatchLength();

/*///////////////////////////////////////////////////////////////
ENUMS
//////////////////////////////////////////////////////////////*/
Expand Down

0 comments on commit f223864

Please sign in to comment.