feat: add getter to `ProjectCompileOutput` (#908)

* feat: add getter to `ProjectCompileOutput`

Add a function `compiled_contracts_by_compiler_version`
to the `ProjectCompileOutput` that returns a `BTreeMap`
that maps the compiler version to a vector of the contract
names and contract structs.

* changelog: update

* chore(solc): remove &mut

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
Mark Tyneway 2022-02-13 11:47:00 -08:00 committed by GitHub
parent 27a4454ac0
commit faba6e014d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -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

View File

@ -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>