Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
codeesura committed Dec 21, 2023
1 parent 6e23eff commit e130143
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/starknet-types-rpc/src/custom_serde/num_as_hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,14 @@ impl<'de> NumAsHex<'de> for u64 {
// Because we already checked the size of the string earlier, we know that
// the following code will never overflow.
let hex_bytes = &bytes[2..];

// Trim leading zeros from the hexadecimal part for efficient processing
let trimmed_hex = hex_bytes
.iter()
.skip_while(|&&b| b == b'0')
.collect::<Vec<_>>();

// Check if the significant part of the hexadecimal string is too long for a 64-bit number
if trimmed_hex.len() > 16 {
return Err(E::custom("hexadecimal string too long for a 64-bit number"));
}
Expand Down

0 comments on commit e130143

Please sign in to comment.