Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
maciektr committed Sep 18, 2024
1 parent 9619404 commit e9efe0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions scarb/src/compiler/compilers/starknet_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl Compiler for StarknetContractCompiler {

let compiler_config = build_compiler_config(db, &unit, &main_crate_ids, ws);

let Compiled {
let CompiledContracts {
contract_paths,
contracts,
classes,
Expand Down Expand Up @@ -353,7 +353,7 @@ impl ArtifactsWriter {
}
}

pub struct Compiled {
pub struct CompiledContracts {
pub contract_paths: Vec<String>,
pub contracts: Vec<ContractDeclaration>,
pub classes: Vec<ContractClass>,
Expand All @@ -365,7 +365,7 @@ pub fn get_compiled_contracts(
compiler_config: CompilerConfig<'_>,
db: &mut RootDatabase,
ws: &Workspace<'_>,
) -> Result<Compiled> {
) -> Result<CompiledContracts> {
let contracts = find_project_contracts(
db.upcast_mut(),
ws.config().ui(),
Expand All @@ -383,7 +383,7 @@ pub fn get_compiled_contracts(
let _ = trace_span!("compile_starknet").enter();
compile_prepared_db(db, &contracts.iter().collect::<Vec<_>>(), compiler_config)?
};
Ok(Compiled {
Ok(CompiledContracts {
contract_paths,
contracts,
classes,
Expand Down
7 changes: 5 additions & 2 deletions scarb/src/compiler/compilers/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use tracing::trace_span;

use crate::compiler::compilers::starknet_contract::Props as StarknetContractProps;
use crate::compiler::compilers::{
ensure_gas_enabled, get_compiled_contracts, ArtifactsWriter, Compiled, ContractSelector,
ensure_gas_enabled, get_compiled_contracts, ArtifactsWriter, CompiledContracts,
ContractSelector,
};
use crate::compiler::helpers::{
build_compiler_config, collect_all_crate_ids, collect_main_crate_ids, write_json,
Expand Down Expand Up @@ -83,6 +84,8 @@ impl Compiler for TestCompiler {
}

if starknet {
// Note: this will only search for contracts in the main CU component and
// `build-external-contracts`. It will not collect contracts from all dependencies.
compile_contracts(test_crate_ids, target_dir, unit, db, ws)?;
}

Expand All @@ -108,7 +111,7 @@ fn compile_contracts(
..StarknetContractProps::default()
};
let compiler_config = build_compiler_config(db, &unit, &main_crate_ids, ws);
let Compiled {
let CompiledContracts {
contract_paths,
contracts,
classes,
Expand Down

0 comments on commit e9efe0c

Please sign in to comment.