feat(solc): include id in artifact (#1284)
This commit is contained in:
parent
fb39d36697
commit
809ccbc9ad
|
@ -55,6 +55,9 @@ pub struct ConfigurableContractArtifact {
|
||||||
pub ewasm: Option<Ewasm>,
|
pub ewasm: Option<Ewasm>,
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub ast: Option<Ast>,
|
pub ast: Option<Ast>,
|
||||||
|
/// The identifier of the source file
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub id: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfigurableContractArtifact {
|
impl ConfigurableContractArtifact {
|
||||||
|
@ -77,6 +80,11 @@ impl ConfigurableContractArtifact {
|
||||||
}
|
}
|
||||||
links
|
links
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the source file of this artifact's contract
|
||||||
|
pub fn source_file(&self) -> Option<SourceFile> {
|
||||||
|
self.id.map(|id| SourceFile { id, ast: self.ast.clone() })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ConfigurableContractArtifact> for CompactContractBytecode {
|
impl From<ConfigurableContractArtifact> for CompactContractBytecode {
|
||||||
|
@ -316,6 +324,7 @@ impl ArtifactOutput for ConfigurableArtifacts {
|
||||||
ir: artifact_ir,
|
ir: artifact_ir,
|
||||||
ir_optimized: artifact_ir_optimized,
|
ir_optimized: artifact_ir_optimized,
|
||||||
ewasm: artifact_ewasm,
|
ewasm: artifact_ewasm,
|
||||||
|
id: source_file.as_ref().map(|s| s.id),
|
||||||
ast: source_file.and_then(|s| s.ast.clone()),
|
ast: source_file.and_then(|s| s.ast.clone()),
|
||||||
generated_sources: generated_sources.unwrap_or_default(),
|
generated_sources: generated_sources.unwrap_or_default(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,11 @@ impl<T: ArtifactOutput> ProjectCompileOutput<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All artifacts together with their ID and the sources of the project.
|
/// All artifacts together with their ID and the sources of the project.
|
||||||
|
///
|
||||||
|
/// Note: this only returns the `SourceFiles` for freshly compiled contracts because, if not
|
||||||
|
/// included in the `Artifact` itself (see
|
||||||
|
/// [`crate::ConfigurableContractArtifact::source_file()`]), is only available via the solc
|
||||||
|
/// `CompilerOutput`
|
||||||
pub fn into_artifacts_with_sources(
|
pub fn into_artifacts_with_sources(
|
||||||
self,
|
self,
|
||||||
) -> (BTreeMap<ArtifactId, T::Artifact>, VersionedSourceFiles) {
|
) -> (BTreeMap<ArtifactId, T::Artifact>, VersionedSourceFiles) {
|
||||||
|
|
Loading…
Reference in New Issue