Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

Commit

Permalink
data encapsulation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gitofdeepanshu committed Jun 26, 2023
1 parent 6038c63 commit 60bcbb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 1 addition & 2 deletions precompiles/utils/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ impl<K: Kind, S: Get<u32>> EvmData for BoundedBytesString<K, S> {
let range = inner_reader.move_cursor(array_size)?;

let data = inner_reader
.input
.get(range)
.get_input_from_range(range)
.ok_or_else(|| revert(K::signature()))?;

let bytes = Self {
Expand Down
7 changes: 6 additions & 1 deletion precompiles/utils/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl From<Bytes> for Vec<u8> {
/// Provide functions to parse common types.
#[derive(Clone, Copy, Debug)]
pub struct EvmDataReader<'a> {
pub(crate) input: &'a [u8],
input: &'a [u8],
cursor: usize,
}

Expand Down Expand Up @@ -175,6 +175,11 @@ impl<'a> EvmDataReader<'a> {
})
}

/// Return Option<&[u8]> from a given range for EvmDataReader
pub fn get_input_from_range(&self, range: Range<usize>) -> Option<&[u8]> {
self.input.get(range)
}

/// Read remaining bytes
pub fn read_till_end(&mut self) -> EvmResult<&[u8]> {
let range = self.move_cursor(self.input.len() - self.cursor)?;
Expand Down

0 comments on commit 60bcbb6

Please sign in to comment.