From f48fd88a9715d17f2b87647e5d80032eef4b2367 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 10 Dec 2021 19:20:30 +0100 Subject: [PATCH] fix(solc): skip 0x prefix for deserialize bytes decoding (#671) --- ethers-solc/src/artifacts.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ethers-solc/src/artifacts.rs b/ethers-solc/src/artifacts.rs index 3bb57af8..fce6eb78 100644 --- a/ethers-solc/src/artifacts.rs +++ b/ethers-solc/src/artifacts.rs @@ -1223,7 +1223,13 @@ where D: Deserializer<'de>, { let value = String::deserialize(d)?; - Ok(hex::decode(&value).map_err(|e| serde::de::Error::custom(e.to_string()))?.into()) + if let Some(value) = value.strip_prefix("0x") { + hex::decode(value) + } else { + hex::decode(&value) + } + .map(Into::into) + .map_err(|e| serde::de::Error::custom(e.to_string())) } pub fn deserialize_opt_bytes<'de, D>(d: D) -> std::result::Result, D::Error>