Skip to content

Commit

Permalink
cargo clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ngundotra committed Dec 18, 2024
1 parent 6734e00 commit 88e2231
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
12 changes: 4 additions & 8 deletions src/api/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use reqwest::{Client, Response};
use serde_json::json;
use solana_client::rpc_client::RpcClient;
use solana_sdk::pubkey::Pubkey;
use std::sync::atomic::{Ordering};
use std::sync::atomic::Ordering;
use std::thread;
use std::time::{Duration, Instant};

Expand Down Expand Up @@ -190,7 +190,7 @@ pub async fn handle_submission_response(
break; // Exit the loop and continue with normal error handling
}

let status = check_job_status(&client, &request_id).await?;
let status = check_job_status(client, &request_id).await?;
match status.status {
JobStatus::InProgress => {
if SIGNAL_RECEIVED.load(Ordering::Relaxed) {
Expand Down Expand Up @@ -266,7 +266,7 @@ pub async fn handle_submission_response(
async fn check_job_status(client: &Client, request_id: &str) -> anyhow::Result<JobResponse> {
// Get /job/:id
let response = client
.get(&format!("{}/job/{}", REMOTE_SERVER_URL, request_id))
.get(format!("{}/job/{}", REMOTE_SERVER_URL, request_id))
.send()
.await
.unwrap();
Expand Down Expand Up @@ -309,11 +309,7 @@ pub async fn get_remote_status(program_id: Pubkey) -> anyhow::Result<()> {
.build()?;

let response = client
.get(format!(
"{}/status-all/{}",
REMOTE_SERVER_URL,
program_id.to_string()
))
.get(format!("{}/status-all/{}", REMOTE_SERVER_URL, program_id,))
.send()
.await?;

Expand Down
26 changes: 13 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ fn build_args(
args.push(relative_mount_path.to_string());
}
// Get the absolute build path to the solana program directory to build inside docker
let mount_path = PathBuf::from(verify_tmp_root_path).join(&relative_mount_path);
let mount_path = PathBuf::from(verify_tmp_root_path).join(relative_mount_path);

args.push("--library-name".to_string());
let library_name = match library_name_opt.clone() {
Expand Down Expand Up @@ -1139,7 +1139,7 @@ fn clone_repo_and_checkout(
println!("Cloning repo into: {}", verify_tmp_root_path);

std::process::Command::new("git")
.args(["clone", &repo_url, &verify_tmp_root_path])
.args(["clone", repo_url, &verify_tmp_root_path])
.stdout(Stdio::inherit())
.output()?;

Expand All @@ -1164,7 +1164,7 @@ fn clone_repo_and_checkout(

fn get_basename(repo_url: &str) -> anyhow::Result<String> {
let base_name = std::process::Command::new("basename")
.arg(&repo_url)
.arg(repo_url)
.output()
.map_err(|e| anyhow!("Failed to get basename of repo_url: {:?}", e))
.and_then(|output| parse_output(output.stdout))?;
Expand Down Expand Up @@ -1404,7 +1404,7 @@ pub fn print_build_params(pubkey: &Pubkey, build_params: &OtterBuildParams) {
}

pub async fn list_program_pdas(program_id: Pubkey, client: &RpcClient) -> anyhow::Result<()> {
let pdas = get_all_pdas_available(&client, &program_id).await?;
let pdas = get_all_pdas_available(client, &program_id).await?;
for (pda, build_params) in pdas {
print_build_params(&pda, &build_params);
}
Expand All @@ -1416,7 +1416,7 @@ pub async fn print_program_pda(
signer: Option<String>,
client: &RpcClient,
) -> anyhow::Result<()> {
let (pda, build_params) = get_program_pda(&client, &program_id, signer).await?;
let (pda, build_params) = get_program_pda(client, &program_id, signer).await?;
print_build_params(&pda, &build_params);
Ok(())
}
Expand All @@ -1426,7 +1426,7 @@ pub fn get_commit_hash(sub_m: &ArgMatches, repo_url: &str) -> anyhow::Result<Str
.value_of("commit-hash")
.map(String::from)
.or_else(|| {
get_commit_hash_from_remote(&repo_url).ok() // Dynamically determine commit hash from remote
get_commit_hash_from_remote(repo_url).ok() // Dynamically determine commit hash from remote
})
.ok_or_else(|| {
anyhow::anyhow!("Commit hash must be provided or inferred from the remote repository")
Expand All @@ -1436,6 +1436,7 @@ pub fn get_commit_hash(sub_m: &ArgMatches, repo_url: &str) -> anyhow::Result<Str
Ok(commit_hash)
}

#[allow(clippy::too_many_arguments)]
async fn export_pda_tx(
connection: &RpcClient,
program_id: Pubkey,
Expand All @@ -1451,7 +1452,7 @@ async fn export_pda_tx(
cargo_args: Vec<String>,
compute_unit_price: u64,
) -> anyhow::Result<()> {
let last_deployed_slot = get_last_deployed_slot(&connection, &program_id.to_string())
let last_deployed_slot = get_last_deployed_slot(connection, &program_id.to_string())
.await
.map_err(|err| anyhow!("Unable to get last deployed slot: {}", err))?;

Expand All @@ -1472,7 +1473,7 @@ async fn export_pda_tx(
library_name.clone(),
&temp_root_path,
base_image.clone(),
bpf_flag.clone(),
bpf_flag,
cargo_args,
)?
.0,
Expand All @@ -1483,13 +1484,12 @@ async fn export_pda_tx(
.args(["-rf", &verify_dir])
.output()?;

let (pda, _) =
find_build_params_pda(&Pubkey::try_from(program_id)?, &Pubkey::try_from(uploader)?);
let (pda, _) = find_build_params_pda(&program_id, &uploader);

// check if account already exists
let instruction = match connection.get_account(&pda) {
Ok(account_info) => {
if account_info.data.len() > 0 {
if !account_info.data.is_empty() {
println!("PDA already exists, creating update transaction");
OtterVerifyInstructions::Update
} else {
Expand All @@ -1502,9 +1502,9 @@ async fn export_pda_tx(

let tx = compose_transaction(
&input_params,
Pubkey::try_from(uploader)?,
uploader,
pda,
Pubkey::try_from(program_id)?,
program_id,
instruction,
compute_unit_price,
);
Expand Down
9 changes: 5 additions & 4 deletions src/solana_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn create_ix_data(params: &InputParams, ix: &OtterVerifyInstructions) -> Vec<u8>
}

fn get_keypair_from_path(path: &str) -> anyhow::Result<Keypair> {
solana_clap_utils::keypair::keypair_from_path(&Default::default(), &path, "keypair", false)
solana_clap_utils::keypair::keypair_from_path(&Default::default(), path, "keypair", false)
.map_err(|err| anyhow!("Unable to get signer from path: {}", err))
}

Expand Down Expand Up @@ -208,6 +208,7 @@ pub fn resolve_rpc_url(url: Option<String>) -> anyhow::Result<RpcClient> {
Ok(connection)
}

#[allow(clippy::too_many_arguments)]
pub async fn upload_program_verification_data(
git_url: String,
commit: &Option<String>,
Expand All @@ -228,15 +229,15 @@ pub async fn upload_program_verification_data(
let cli_config = get_user_config()?;

let signer_pubkey: Pubkey = if let Some(ref path_to_keypair) = path_to_keypair {
get_keypair_from_path(&path_to_keypair)?.pubkey()
get_keypair_from_path(path_to_keypair)?.pubkey()
} else {
cli_config.0.pubkey()
};

// let rpc_url = connection.url();
println!("Using connection url: {}", connection.url());

let last_deployed_slot = get_last_deployed_slot(&connection, &program_address.to_string())
let last_deployed_slot = get_last_deployed_slot(connection, &program_address.to_string())
.await
.map_err(|err| anyhow!("Unable to get last deployed slot: {}", err))?;

Expand Down Expand Up @@ -315,7 +316,7 @@ pub async fn process_close(
let signer = user_config.0;
let signer_pubkey = signer.pubkey();

let last_deployed_slot = get_last_deployed_slot(&connection, &program_address.to_string())
let last_deployed_slot = get_last_deployed_slot(connection, &program_address.to_string())
.await
.map_err(|err| anyhow!("Unable to get last deployed slot: {}", err))?;

Expand Down

0 comments on commit 88e2231

Please sign in to comment.