fix(solc): skip 0x prefix for deserialize bytes decoding (#671)

This commit is contained in:
Matthias Seitz 2021-12-10 19:20:30 +01:00 committed by GitHub
parent 991cda3f33
commit f48fd88a97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -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<Option<Bytes>, D::Error>