Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add contract file awareness #21

Merged
merged 1 commit into from
May 17, 2024
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
2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ serde.workspace = true
smol_str.workspace = true
thiserror.workspace = true
toml.workspace = true
reqwest = { version = "0.11", features = ["blocking", "json", "multipart"] }
reqwest = { version = "=0.11", features = ["blocking", "json", "multipart"] }
tokio = { version = "1.28.2", features = ["full"] }
url = "2.2.2"
dialoguer = { version = "0.10.4", features = ["fuzzy-select"] }
Expand Down
5 changes: 3 additions & 2 deletions crates/cli/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub struct VerificationJob {
created_timestamp: Option<f64>,
updated_timestamp: Option<f64>,
address: Option<String>,
contract_name: Option<String>,
contract_file: Option<String>,
name: Option<String>,
version: Option<String>,
license: Option<String>,
Expand Down Expand Up @@ -246,6 +246,7 @@ pub struct ProjectMetadataInfo {
pub cairo_version: SupportedCairoVersions,
pub scarb_version: SupportedScarbVersions,
pub project_dir_path: String,
pub contract_file: String,
}

pub fn dispatch_class_verification_job(
Expand All @@ -269,7 +270,7 @@ pub fn dispatch_class_verification_job(
.text("license", license.to_string())
.text("account_contract", is_account.to_string())
.text("name", name.to_string())
.text("contract_name", address.to_string())
.text("contract_file", project_metadata.contract_file)
.text("project_dir_path", project_metadata.project_dir_path);

for file in files.iter() {
Expand Down
10 changes: 9 additions & 1 deletion crates/cli/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub fn verify_project(

// The compiler compiles into the original scarb package name
// As such we have to craft the correct path to the main package
let project_dir_path = extracted_files_dir.join(scarb_metadata_package_name);
let project_dir_path = extracted_files_dir.join(scarb_metadata_package_name.clone());
let project_dir_path = project_dir_path
.strip_prefix(extracted_files_dir.clone())
.unwrap();
Expand Down Expand Up @@ -203,6 +203,13 @@ pub fn verify_project(
})
.collect::<Vec<FileInfo>>();

// We already know the contract file specified in Scarb.toml is relative to src/
let contract_file = format!(
"{}/src/{}",
scarb_metadata_package_name.clone(),
contract_paths[0].as_str()
);

let dispatch_response = dispatch_class_verification_job(
args.api_key.as_str(),
network_enum.clone(),
Expand All @@ -213,6 +220,7 @@ pub fn verify_project(
ProjectMetadataInfo {
cairo_version,
scarb_version,
contract_file,
project_dir_path: project_dir_path.as_str().to_owned(),
},
project_files,
Expand Down
4 changes: 2 additions & 2 deletions crates/voyager-resolver-cairo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ cairo-lang-sierra-generator = "=2.4.3"
cairo-lang-starknet = "=2.4.3"
cairo-lang-syntax = "=2.4.3"
cairo-lang-utils = "=2.4.3"
scarb = { git = "https://github.com/software-mansion/scarb", version = "2.4.3", rev = "5dbab1f" }
scarb-ui = { git = "https://github.com/software-mansion/scarb", version = "0.1.2", rev = "5dbab1f" }
scarb = { git = "https://github.com/software-mansion/scarb", version = "=2.4.3", rev = "5dbab1f" }
scarb-ui = { git = "https://github.com/software-mansion/scarb", version = "=0.1.2", rev = "5dbab1f" }

[dev-dependencies]
env_logger.workspace = true
Expand Down