From decc7022ebea5327f557a9553c55a4caf5a20b5f Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 28 Nov 2024 16:46:01 +0100 Subject: [PATCH] fix parsing even-length hex fe256 values --- src/fe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fe.rs b/src/fe.rs index 8fbd6e1..8f5899a 100644 --- a/src/fe.rs +++ b/src/fe.rs @@ -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));