Skip to content

Commit

Permalink
Add module_path to ContractArtifacts (#1082)
Browse files Browse the repository at this point in the history
Closes #1048

---------

Signed-off-by: Marek Kaput <[email protected]>
Co-authored-by: Marek Kaput <[email protected]>
  • Loading branch information
tomek0123456789 and mkaput authored Jan 24, 2024
1 parent 1d35b4c commit e7fc484
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scarb/src/compiler/compilers/starknet_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,22 @@ struct ContractArtifacts {
id: String,
package_name: PackageName,
contract_name: String,
module_path: String,
artifacts: ContractArtifact,
}

impl ContractArtifacts {
fn new(package_name: &PackageName, contract_name: &str, contract_path: &str) -> Self {
fn new(
package_name: &PackageName,
contract_name: &str,
contract_path: &str,
module_path: &str,
) -> Self {
Self {
id: short_hash((&package_name, &contract_path)),
package_name: package_name.clone(),
contract_name: contract_name.to_owned(),
module_path: module_path.to_owned(),
artifacts: ContractArtifact::default(),
}
}
Expand Down Expand Up @@ -275,6 +282,7 @@ impl Compiler for StarknetContractCompiler {
&package_name,
&contract_name,
contract_selector.full_path().as_str(),
&decl.module_id().full_path(db.upcast_mut()),
);

if props.sierra {
Expand Down
4 changes: 4 additions & 0 deletions scarb/tests/build_starknet_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ fn compile_starknet_contract() {

t.child("target/dev/hello_Balance.contract_class.json")
.assert_is_json::<ContractClass>();
t.child("target/dev/hello.starknet_artifacts.json")
.assert(predicates::str::contains(
r#""module_path":"hello::Balance""#,
));
}

#[test]
Expand Down

0 comments on commit e7fc484

Please sign in to comment.