feat(solc): add more contract iter helper functions (#1438)
This commit is contained in:
parent
9892756ee4
commit
ca34d0c049
|
@ -166,6 +166,28 @@ impl VersionedContracts {
|
|||
})
|
||||
}
|
||||
|
||||
/// Returns an iterator over (`file`, `name`, `Contract`)
|
||||
pub fn into_contracts_with_files(self) -> impl Iterator<Item = (String, String, Contract)> {
|
||||
self.0.into_iter().flat_map(|(file, contracts)| {
|
||||
contracts.into_iter().flat_map(move |(name, c)| {
|
||||
let file = file.clone();
|
||||
c.into_iter().map(move |c| (file.clone(), name.clone(), c.contract))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns an iterator over (`file`, `name`, `Contract`, `Version`)
|
||||
pub fn into_contracts_with_files_and_version(
|
||||
self,
|
||||
) -> impl Iterator<Item = (String, String, Contract, Version)> {
|
||||
self.0.into_iter().flat_map(|(file, contracts)| {
|
||||
contracts.into_iter().flat_map(move |(name, c)| {
|
||||
let file = file.clone();
|
||||
c.into_iter().map(move |c| (file.clone(), name.clone(), c.contract, c.version))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Sets the contract's file paths to `root` adjoined to `self.file`.
|
||||
pub fn join_all(&mut self, root: impl AsRef<Path>) -> &mut Self {
|
||||
let root = root.as_ref();
|
||||
|
|
|
@ -388,6 +388,32 @@ impl AggregatedCompilerOutput {
|
|||
self.contracts.into_contracts()
|
||||
}
|
||||
|
||||
/// Returns an iterator over (`file`, `name`, `Contract`)
|
||||
pub fn contracts_with_files_iter(&self) -> impl Iterator<Item = (&String, &String, &Contract)> {
|
||||
self.contracts.contracts_with_files()
|
||||
}
|
||||
|
||||
/// Returns an iterator over (`file`, `name`, `Contract`)
|
||||
pub fn contracts_with_files_into_iter(
|
||||
self,
|
||||
) -> impl Iterator<Item = (String, String, Contract)> {
|
||||
self.contracts.into_contracts_with_files()
|
||||
}
|
||||
|
||||
/// Returns an iterator over (`file`, `name`, `Contract`, `Version`)
|
||||
pub fn contracts_with_files_and_version_iter(
|
||||
&self,
|
||||
) -> impl Iterator<Item = (&String, &String, &Contract, &Version)> {
|
||||
self.contracts.contracts_with_files_and_version()
|
||||
}
|
||||
|
||||
/// Returns an iterator over (`file`, `name`, `Contract`, `Version`)
|
||||
pub fn contracts_with_files_and_version_into_iter(
|
||||
self,
|
||||
) -> impl Iterator<Item = (String, String, Contract, Version)> {
|
||||
self.contracts.into_contracts_with_files_and_version()
|
||||
}
|
||||
|
||||
/// Given the contract file's path and the contract's name, tries to return the contract's
|
||||
/// bytecode, runtime bytecode, and abi
|
||||
/// # Example
|
||||
|
|
Loading…
Reference in New Issue