Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feat: add getter to ProjectCompileOutput #908

Merged
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
so that the receipt can be returned to the called when deploying
a contract [#865](https://github.com/gakonst/ethers-rs/pull/865)
- Add Arbitrum mainnet and testnet to the list of known chains
- Add a getter to `ProjectCompileOutput` that returns a mapping of compiler
versions to a vector of name + contract struct tuples
[#908](https://github.com/gakonst/ethers-rs/pull/908)

## ethers-contract-abigen

Expand Down
16 changes: 16 additions & 0 deletions ethers-solc/src/compile/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ impl<T: ArtifactOutput> ProjectCompileOutput<T> {
pub fn compiled_artifacts(&self) -> &Artifacts<T::Artifact> {
&self.compiled_artifacts
}

/// Returns a `BTreeMap` that maps the compiler version used during [`Project::compile()`]
/// to a Vector of tuples containing the contract name and the `Contract`
pub fn compiled_contracts_by_compiler_version(
&self,
) -> BTreeMap<Version, Vec<(String, Contract)>> {
let mut contracts = BTreeMap::new();
let versioned_contracts = &self.compiler_output.contracts;
for (_, name, contract, version) in versioned_contracts.contracts_with_files_and_version() {
contracts
.entry(version.to_owned())
.or_insert(Vec::<(String, Contract)>::new())
.push((name.to_string(), contract.clone()));
}
contracts
}
}

impl<T: ArtifactOutput> ProjectCompileOutput<T>
Expand Down