diff --git a/CHANGELOG.md b/CHANGELOG.md index be90c928..8c88bab8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/ethers-solc/src/compile/output.rs b/ethers-solc/src/compile/output.rs index 3cd0a9dc..c3bed6dd 100644 --- a/ethers-solc/src/compile/output.rs +++ b/ethers-solc/src/compile/output.rs @@ -141,6 +141,22 @@ impl ProjectCompileOutput { pub fn compiled_artifacts(&self) -> &Artifacts { &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> { + 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 ProjectCompileOutput