Skip to content

Commit

Permalink
fix(solc): when compiler-out metadata is empty and there's no `intern…
Browse files Browse the repository at this point in the history
…alType` (gakonst#1182)

* add another compiler-out with fixes

* update changelog
  • Loading branch information
joshieDo authored Apr 27, 2022
1 parent 6faceb2 commit a0f41c5
Show file tree
Hide file tree
Showing 4 changed files with 56,279 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
- Add support for library linking and make `Bytecode`'s `object` filed an
`enum BytecodeObject` [#656](https://github.com/gakonst/ethers-rs/pull/656).
- Nit: remove accidentally doubled double-quotes in an error message
- Fix when compiler-out metadata is empty and there's no internalType [#1182](https://github.com/gakonst/ethers-rs/pull/1182)

### 0.6.0

Expand Down
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

0 comments on commit a0f41c5

Please sign in to comment.