Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(solc): improve contract metadata bindings #1326

Merged
merged 1 commit into from
May 31, 2022
Merged
Changes from all commits
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
24 changes: 19 additions & 5 deletions ethers-solc/src/artifacts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -859,12 +859,18 @@ pub struct Metadata {
/// Compiler settings
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct MetadataSettings {
#[serde(default)]
pub remappings: Vec<Remapping>,
pub optimizer: Optimizer,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<SettingsMetadata>,
/// Required for Solidity: File and name of the contract or library this metadata is created
/// for.
#[serde(default, rename = "compilationTarget")]
pub compilation_target: BTreeMap<String, String>,
#[serde(flatten)]
pub inner: Settings,
/// Metadata settings
#[serde(default)]
pub libraries: Libraries,
}

/// Compilation source files/source units, keys are file names
Expand Down Expand Up @@ -1010,16 +1016,19 @@ 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<Item>,
#[serde(rename = "stateMutability")]
#[serde(rename = "stateMutability", skip_serializing_if = "Option::is_none")]
pub state_mutability: Option<String>,
#[serde(rename = "type")]
pub abi_type: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub outputs: Vec<Item>,
// required to satisfy solidity events
#[serde(default, skip_serializing_if = "Option::is_none")]
pub anonymous: Option<bool>,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
Expand All @@ -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<Item>,
/// Indexed flag. for solidity events
#[serde(default, skip_serializing_if = "Option::is_none")]
pub indexed: Option<bool>,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
Expand Down