diff --git a/ethers-solc/src/artifacts.rs b/ethers-solc/src/artifacts.rs index 8a154da9..5977b43c 100644 --- a/ethers-solc/src/artifacts.rs +++ b/ethers-solc/src/artifacts.rs @@ -752,6 +752,7 @@ impl<'a> fmt::Display for OutputDiagnostics<'a> { /// Represents a compiled solidity contract #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "camelCase")] pub struct Contract { /// The Ethereum Contract Metadata. /// See https://docs.soliditylang.org/en/develop/metadata.html @@ -764,7 +765,7 @@ pub struct Contract { pub devdoc: DevDoc, #[serde(default, skip_serializing_if = "Option::is_none")] pub ir: Option, - #[serde(default, rename = "storageLayout", skip_serializing_if = "StorageLayout::is_empty")] + #[serde(default, skip_serializing_if = "StorageLayout::is_empty")] pub storage_layout: StorageLayout, /// EVM-related outputs #[serde(default, skip_serializing_if = "Option::is_none")] @@ -772,6 +773,8 @@ pub struct Contract { /// Ewasm related outputs #[serde(default, skip_serializing_if = "Option::is_none")] pub ewasm: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub ir_optimized: Option, } /// Minimal representation of a contract with a present abi and bytecode. diff --git a/ethers-solc/src/config.rs b/ethers-solc/src/config.rs index 93cad0de..80208792 100644 --- a/ethers-solc/src/config.rs +++ b/ethers-solc/src/config.rs @@ -653,6 +653,29 @@ impl ArtifactOutput for MinimalCombinedArtifacts { )) })?; } + + if let Some(iropt) = &contract.ir_optimized { + fs::write(&file.with_extension("iropt"), iropt) + .map_err(|err| SolcError::io(err, file.with_extension("iropt")))? + } + + if let Some(ir) = &contract.ir { + fs::write(&file.with_extension("ir"), ir) + .map_err(|err| SolcError::io(err, file.with_extension("ir")))? + } + + if let Some(ewasm) = &contract.ewasm { + fs::write(&file.with_extension("ewasm"), serde_json::to_vec_pretty(&ewasm)?) + .map_err(|err| SolcError::io(err, file.with_extension("ewasm")))?; + } + + if let Some(evm) = &contract.evm { + if let Some(asm) = &evm.assembly { + fs::write(&file.with_extension("asm"), asm) + .map_err(|err| SolcError::io(err, file.with_extension("asm")))? + } + } + let min = CompactContractBytecode::from(contract.clone()); fs::write(&file, serde_json::to_vec_pretty(&min)?) .map_err(|err| SolcError::io(err, file))?