Skip to content

Commit

Permalink
fix parsing even-length hex fe256 values
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Nov 28, 2024
1 parent 84b0a0d commit decc702
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/fe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl FromStr for fe256 {
let s = s
.strip_suffix(".fe")
.ok_or_else(|| ParseFeError::NoSuffix(s.to_owned()))?;
let bytes = Bytes32::from_str(s)?;
let bytes = if s.len() % 2 == 1 { Bytes32::from_str(&format!("0{s}"))? } else { Bytes32::from_str(s)? };
let val = u256::from_le_bytes(bytes.into_inner());
if !Self::test_value(val) {
return Err(ParseFeError::Overflow(val));
Expand Down

0 comments on commit decc702

Please sign in to comment.