From ac0560c252290a167cdde6f1a43df2e6c84119f3 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 31 May 2022 18:28:23 +0200 Subject: [PATCH] fix(solc): improve contract metadata bindings (#1326) --- ethers-solc/src/artifacts/mod.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/ethers-solc/src/artifacts/mod.rs b/ethers-solc/src/artifacts/mod.rs index 732f5956..34efb27c 100644 --- a/ethers-solc/src/artifacts/mod.rs +++ b/ethers-solc/src/artifacts/mod.rs @@ -289,7 +289,7 @@ pub struct Settings { /// If remappings are used, this source file should match the global path /// after remappings were applied. /// If this key is an empty string, that refers to a global level. - #[serde(default, skip_serializing_if = "Libraries::is_empty")] + #[serde(default)] pub libraries: Libraries, } @@ -859,12 +859,18 @@ pub struct Metadata { /// Compiler settings #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct MetadataSettings { + #[serde(default)] + pub remappings: Vec, + pub optimizer: Optimizer, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub metadata: Option, /// Required for Solidity: File and name of the contract or library this metadata is created /// for. #[serde(default, rename = "compilationTarget")] pub compilation_target: BTreeMap, - #[serde(flatten)] - pub inner: Settings, + /// Metadata settings + #[serde(default)] + pub libraries: Libraries, } /// Compilation source files/source units, keys are file names @@ -1010,9 +1016,9 @@ pub struct Output { #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct SolcAbi { - #[serde(default, skip_serializing_if = "Vec::is_empty")] + #[serde(default)] pub inputs: Vec, - #[serde(rename = "stateMutability")] + #[serde(rename = "stateMutability", skip_serializing_if = "Option::is_none")] pub state_mutability: Option, #[serde(rename = "type")] pub abi_type: String, @@ -1020,6 +1026,9 @@ pub struct SolcAbi { pub name: Option, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub outputs: Vec, + // required to satisfy solidity events + #[serde(default, skip_serializing_if = "Option::is_none")] + pub anonymous: Option, } #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] @@ -1029,6 +1038,11 @@ pub struct Item { pub name: String, #[serde(rename = "type")] pub put_type: String, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub components: Vec, + /// Indexed flag. for solidity events + #[serde(default, skip_serializing_if = "Option::is_none")] + pub indexed: Option, } #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]