/// Validates whether a block number is within a specified range.
fn validate_block_number_within_range(
min_oracle_block_numbers: Array<u128,
max_oracle_block_numbers: Array<u128,
block_number: u128
) {
// Initialize a variable indicating whether the block number is within the range.
let is_within_range: bool = false;
// Check if the block is within the range.
for i in 0..min_oracle_block_numbers.len() {
if block_number >= min_oracle_block_numbers[i] && block_number <= max_oracle_block_numbers[i] {
is_within_range = true;
break;
}
}
// If the block is not within the range, you can raise an error or take appropriate actions.
if !is_within_range {
// Raise an error or perform necessary actions.
}
}
/// Validates whether a block number is within a specified range and returns true or false.
fn is_block_number_within_range(
min_oracle_block_numbers: Array<u128,
max_oracle_block_numbers: Array<u128,
block_number: u128
) -> bool {
// Initialize a variable indicating whether the block number is within the range.
let is_within_range: bool = false;
// Check if the block is within the range.
for i in 0..min_oracle_block_numbers.len() {
if block_number >= min_oracle_block_numbers[i] && block_number <= max_oracle_block_numbers[i] {
is_within_range = true;
break;
}
}
return is_within_range;
}
/// Get the uncompacted price at the specified index.
fn get_uncompacted_price(compacted_prices: Array<u128, index: u128) -> u128 {
// Ensure the index is valid.
assert(index < compacted_prices.len(), "Invalid index");
// Return the uncompacted price at the specified index.
return compacted_prices[index];
}
/// Get the uncompacted decimal at the specified index.
fn get_uncompacted_decimal(compacted_decimals: Array<u128, index: u128) -> u128 {
// Ensure the index is valid.
assert(index < compacted_decimals.len(), "Invalid index");
// Return the uncompacted decimal at the specified index.
return compacted_decimals[index];
/// OracleUtils Library
/// Validates whether a block number is within a specified range. fn validate_block_number_within_range( min_oracle_block_numbers: Array<u128, max_oracle_block_numbers: Array<u128, block_number: u128 ) { // Initialize a variable indicating whether the block number is within the range. let is_within_range: bool = false;
}
/// Validates whether a block number is within a specified range and returns true or false. fn is_block_number_within_range( min_oracle_block_numbers: Array<u128, max_oracle_block_numbers: Array<u128, block_number: u128 ) -> bool { // Initialize a variable indicating whether the block number is within the range. let is_within_range: bool = false;
}
/// Get the uncompacted price at the specified index. fn get_uncompacted_price(compacted_prices: Array<u128, index: u128) -> u128 { // Ensure the index is valid. assert(index < compacted_prices.len(), "Invalid index");
}
/// Get the uncompacted decimal at the specified index. fn get_uncompacted_decimal(compacted_decimals: Array<u128, index: u128) -> u128 { // Ensure the index is valid. assert(index < compacted_decimals.len(), "Invalid index");
}