Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed Sep 30, 2024
1 parent 5febc73 commit ec4b7d4
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/deploy/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl NetworkRunnable for Cmd {
let asset = parse_asset(&self.asset)?;

let network = config.get_network()?;
let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(&network)?;
client
.verify_network_passphrase(Some(&network.network_passphrase))
.await?;
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/deploy/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl NetworkRunnable for Cmd {
None => rand::thread_rng().gen::<[u8; 32]>(),
};

let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(&network)?;
client
.verify_network_passphrase(Some(&network.network_passphrase))
.await?;
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl NetworkRunnable for Cmd {
let network = config.get_network()?;
tracing::trace!(?network);
let keys = self.key.parse_keys(&config.locator, &network)?;
let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(&network)?;
let key = config.source_account()?;
let extend_to = self.ledgers_to_extend();

Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/info/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub async fn fetch_wasm(args: &Args) -> Result<Option<Vec<u8>>, Error> {

let hash = xdr::Hash(hash);

let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(network)?;

client
.verify_network_passphrase(Some(&network.network_passphrase))
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl NetworkRunnable for Cmd {
let config = config.unwrap_or(&self.config);
let contract = self.wasm.read()?;
let network = config.get_network()?;
let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(&network)?;
client
.verify_network_passphrase(Some(&network.network_passphrase))
.await?;
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl NetworkRunnable for Cmd {
// For testing wasm arg parsing
let _ = build_host_function_parameters(&contract_id, &self.slop, spec_entries, config)?;
}
let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(&network)?;
let account_details = if self.is_view {
default_account_entry()
} else {
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl NetworkRunnable for Cmd {
let config = config.unwrap_or(&self.config);
let network = config.get_network()?;
tracing::trace!(?network);
let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(&network)?;
let keys = self.key.parse_keys(&config.locator, &network)?;
Ok(client.get_full_ledger_entries(&keys).await?)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl NetworkRunnable for Cmd {
let network = config.get_network()?;
tracing::trace!(?network);
let entry_keys = self.key.parse_keys(&config.locator, &network)?;
let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(&network)?;
let key = config.source_account()?;

// Get the account sequence number
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl NetworkRunnable for Cmd {
self.network.get(&self.locator)
}?;

let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(&network)?;
client
.verify_network_passphrase(Some(&network.network_passphrase))
.await?;
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/tx/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl NetworkRunnable for Cmd {
} else {
self.network.get(&self.locator)?
};
let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(&network)?;
let tx_env = super::xdr::tx_envelope_from_stdin()?;
Ok(client.send_transaction_polling(&tx_env).await?)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/tx/simulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl NetworkRunnable for Cmd {
) -> Result<Self::Result, Self::Error> {
let config = config.unwrap_or(&self.config);
let network = config.get_network()?;
let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(&network)?;
let tx = super::xdr::unwrap_envelope_v1(super::xdr::tx_envelope_from_stdin()?)?;
Ok(client.simulate_and_assemble_transaction(&tx).await?)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl Args {
) -> Result<Option<Transaction>, Error> {
let network = self.get_network()?;
let source_key = self.key_pair()?;
let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(&network)?;
let latest_ledger = client.get_latest_ledger().await?.sequence;
let seq_num = latest_ledger + 60; // ~ 5 min
Ok(signer::sign_soroban_authorizations(
Expand Down
14 changes: 7 additions & 7 deletions cmd/soroban-cli/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ pub struct RpcClient {
}

impl RpcClient {
pub fn new(network: Network) -> Result<Self, Error> {
pub fn new(network: &Network) -> Result<Self, Error> {
let mut additional_headers = HeaderMap::new();
for header in network.rpc_headers.iter() {
for header in &network.rpc_headers {
let header_name = HeaderName::from_bytes(header.0.as_bytes())?;
let header_value = HeaderValue::from_str(&header.1)?;

Expand Down Expand Up @@ -64,7 +64,7 @@ mod tests {
rpc_headers: [("api key".to_string(), "Bearer".to_string())].to_vec(),
};

let result = RpcClient::new(network);
let result = RpcClient::new(&network);

assert!(result.is_err());
assert_eq!(
Expand All @@ -81,7 +81,7 @@ mod tests {
rpc_headers: [("Authorization".to_string(), "Bearer 1234".to_string())].to_vec(),
};

let result = RpcClient::new(network);
let result = RpcClient::new(&network);

assert!(result.is_ok());
}
Expand All @@ -94,7 +94,7 @@ mod tests {
rpc_headers: [("authorization".to_string(), "bearer 1234".to_string())].to_vec(),
};

let result = RpcClient::new(network);
let result = RpcClient::new(&network);

assert!(result.is_ok());
}
Expand All @@ -107,7 +107,7 @@ mod tests {
rpc_headers: [].to_vec(),
};

let result = RpcClient::new(network);
let result = RpcClient::new(&network);

assert!(result.is_ok());
}
Expand All @@ -124,7 +124,7 @@ mod tests {
.to_vec(),
};

let result = RpcClient::new(network);
let result = RpcClient::new(&network);

assert!(result.is_ok());
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub async fn fetch_from_contract(
.resolve_contract_id(contract_id, &network.network_passphrase)?
.0;

let client = RpcClient::new(network.clone())?;
let client = RpcClient::new(network)?;
client
.verify_network_passphrase(Some(&network.network_passphrase))
.await?;
Expand Down

0 comments on commit ec4b7d4

Please sign in to comment.