Skip to content

Commit

Permalink
refactor: simplify state-reader iteration (#453)
Browse files Browse the repository at this point in the history
`prepare_compiled_contract_classes` shouldn't know about stuff it
isn't using.

Co-Authored-By: Gilad Chase <[email protected]>
  • Loading branch information
giladchase and Gilad Chase authored Jul 14, 2024
1 parent fdb417f commit 7cf243c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/tests-integration/src/state_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ fn initialize_papyrus_test_state(
fund_additional_accounts,
);

let contracts = contract_instances.iter().map(|(contract, _n_instances_of_contract)| *contract);
let (cairo0_contract_classes, cairo1_contract_classes) =
prepare_compiled_contract_classes(contract_instances);
prepare_compiled_contract_classes(contracts);

write_state_to_papyrus_storage(state_diff, &cairo0_contract_classes, &cairo1_contract_classes)
}
Expand Down Expand Up @@ -152,11 +153,11 @@ fn prepare_state_diff(
}

fn prepare_compiled_contract_classes(
contract_instances: &[(FeatureContract, usize)],
contract_instances: impl Iterator<Item = FeatureContract>,
) -> ContractClassesMap {
let mut cairo0_contract_classes = Vec::new();
let mut cairo1_contract_classes = Vec::new();
for (contract, _) in contract_instances.iter() {
for contract in contract_instances {
match contract.cairo_version() {
CairoVersion::Cairo0 => {
cairo0_contract_classes.push((
Expand Down

0 comments on commit 7cf243c

Please sign in to comment.