Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

fix(solc): when compiler-out metadata is empty and there's no internalType #1182

Merged
merged 2 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ethers-solc/src/artifacts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ pub struct SolcAbi {
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Item {
#[serde(rename = "internalType")]
pub internal_type: String,
pub internal_type: Option<String>,
pub name: String,
#[serde(rename = "type")]
pub put_type: String,
Expand Down Expand Up @@ -1081,7 +1081,13 @@ pub struct UserDoc {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub kind: Option<String>,
#[serde(default, skip_serializing_if = "::std::collections::BTreeMap::is_empty")]
pub methods: BTreeMap<String, BTreeMap<String, String>>,
pub methods: BTreeMap<String, MethodNotice>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub notice: Option<String>,
}

#[derive(Clone, Debug, Default, Serialize, Deserialize, Eq, PartialEq)]
pub struct MethodNotice {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub notice: Option<String>,
}
Expand Down
4 changes: 4 additions & 0 deletions ethers-solc/src/artifacts/serde_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ pub mod json_string_opt {
T: DeserializeOwned,
{
if let Some(s) = Option::<String>::deserialize(deserializer)? {
if s.is_empty() {
return Ok(None)
}

serde_json::from_str(&s).map_err(de::Error::custom).map(Some)
} else {
Ok(None)
Expand Down
Loading