Skip to content
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
22 changes: 16 additions & 6 deletions crates/common/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,22 @@ impl<'a> ContractsByArtifactBuilder<'a> {
Self { artifacts: artifacts.into_iter().collect(), storage_layouts: BTreeMap::new() }
}

/// Adds storage layouts from `ProjectCompileOutput` to known artifacts.
pub fn with_storage_layouts(mut self, output: ProjectCompileOutput) -> Self {
self.storage_layouts = output
.into_artifacts()
.filter_map(|(id, artifact)| artifact.storage_layout.map(|layout| (id, layout)))
.collect();
/// Add storage layouts from the given `ProjectCompileOutput` to known artifacts.
pub fn with_output(self, output: &ProjectCompileOutput, base: &Path) -> Self {
self.with_storage_layouts(output.artifact_ids().filter_map(|(id, artifact)| {
artifact
.storage_layout
.as_ref()
.map(|layout| (id.with_stripped_file_prefixes(base), layout.clone()))
}))
}

/// Add storage layouts.
pub fn with_storage_layouts(
mut self,
layouts: impl IntoIterator<Item = (ArtifactId, StorageLayout)>,
) -> Self {
self.storage_layouts.extend(layouts);
self
}

Expand Down
5 changes: 2 additions & 3 deletions crates/forge/src/multi_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,8 @@ impl MultiContractRunnerBuilder {
}

// Create known contracts from linked contracts and storage layout information (if any).
let known_contracts = ContractsByArtifactBuilder::new(linked_contracts)
.with_storage_layouts(output.clone().with_stripped_file_prefixes(root))
.build();
let known_contracts =
ContractsByArtifactBuilder::new(linked_contracts).with_output(output, root).build();

Ok(MultiContractRunner {
contracts: deployable_contracts,
Expand Down
Loading