From 919a570237b0d92cfa34737d8803514caaa62612 Mon Sep 17 00:00:00 2001 From: Bjerg Date: Sun, 27 Mar 2022 16:44:23 +0200 Subject: [PATCH] feat: ability to get artifacts + sources (#1080) --- ethers-solc/src/compile/output.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ethers-solc/src/compile/output.rs b/ethers-solc/src/compile/output.rs index a05b16f2..2ff3e08c 100644 --- a/ethers-solc/src/compile/output.rs +++ b/ethers-solc/src/compile/output.rs @@ -68,6 +68,19 @@ impl ProjectCompileOutput { .chain(compiled_artifacts.into_artifacts_with_files()) } + /// All artifacts together with their ID and the sources of the project. + pub fn into_artifacts_with_sources(self) -> (BTreeMap, SourceFiles) { + let Self { cached_artifacts, compiled_artifacts, compiler_output, .. } = self; + + ( + cached_artifacts + .into_artifacts::() + .chain(compiled_artifacts.into_artifacts::()) + .collect(), + SourceFiles(compiler_output.sources), + ) + } + /// Strips the given prefix from all artifact file paths to make them relative to the given /// `base` argument ///