inline value search for setLotSizes
No need to have an external function here
@@ -98,9 +98,14 @@ contract TBTCSystem is Ownable, ITBTCSystem, DepositLog {
/// @dev Lot sizes should be
/// @param _lotSizes Array of allowed lot sizes.
function setLotSizes(uint256[] calldata _lotSizes) external onlyOwner {
- require(arrayContains(_lotSizes, 10**8), "Lot size array must always contain 1BTC");
+ for( uint i = 0; i < _lotSizes.length; i++){
+ if (_lotSizes[i] == 10**8){
lotSizesSatoshis = _lotSizes;
emit LotSizesUpdated(_lotSizes);
+ return;
+ }
+ }
+ revert("Lot size array must always contain 1BTC");
}
/// @notice Gets the allowed lot sizes
@@ -109,17 +114,6 @@ contract TBTCSystem is Ownable, ITBTCSystem, DepositLog {
return lotSizesSatoshis;
}
- /// @notice Checks if a uint256 value exists in a unt256 array
- /// @return true if it exists, false otherwise.
- function arrayContains(uint256[] memory _array, uint256 _value) internal pure returns (bool){
- for( uint i = 0; i < _array.length; i++){
- if (_array[i] == _value){
- return true;
- }
- }
- return false;
- }
-
/// @notice Check if a lot size is allowed.
/// @param _lotSize Lot size to check.
/// @return True if lot size is allowed, false otherwise.
