Skip to content

Commit

Permalink
fix: clippy and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal authored and gitbutler-client committed Mar 11, 2024
1 parent df57e3b commit b7a66d5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
12 changes: 6 additions & 6 deletions cmd/soroban-cli/src/commands/config/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn spec_dir() -> Result<std::path::PathBuf, Error> {
Ok(dir)
}

pub fn write(action: Action, rpc_url: Uri) -> Result<ulid::Ulid, Error> {
pub fn write(action: Action, rpc_url: &Uri) -> Result<ulid::Ulid, Error> {
let data = Data {
action,
rpc_url: rpc_url.to_string(),
Expand Down Expand Up @@ -128,14 +128,14 @@ impl TryFrom<GetTransactionResponse> for Action {
fn try_from(res: GetTransactionResponse) -> Result<Self, Self::Error> {
Ok(Self::Transaction(GetTransactionResponseRaw {
status: res.status,
envelope_xdr: res.envelope.map(to_xdr).transpose()?,
result_xdr: res.result.map(to_xdr).transpose()?,
result_meta_xdr: res.result_meta.map(to_xdr).transpose()?,
envelope_xdr: res.envelope.as_ref().map(to_xdr).transpose()?,
result_xdr: res.result.as_ref().map(to_xdr).transpose()?,
result_meta_xdr: res.result_meta.as_ref().map(to_xdr).transpose()?,
}))
}
}

fn to_xdr(data: impl WriteXdr) -> Result<String, xdr::Error> {
fn to_xdr(data: &impl WriteXdr) -> Result<String, xdr::Error> {
data.to_xdr_base64(xdr::Limits::none())
}

Expand All @@ -151,7 +151,7 @@ mod test {
let sim = SimulateTransactionResponse::default();
let original_action: Action = sim.into();

let id = write(original_action.clone(), rpc_uri.clone()).unwrap();
let id = write(original_action.clone(), &rpc_uri.clone()).unwrap();
let (action, new_rpc_uri) = read(&id).unwrap();
assert_eq!(rpc_uri, new_rpc_uri);
match (action, original_action) {
Expand Down
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 @@ -115,7 +115,7 @@ impl NetworkRunnable for Cmd {
.await?
.try_into()?;
if args.map_or(true, |a| !a.no_cache) {
data::write(get_txn_resp, network.rpc_uri()?)?;
data::write(get_txn_resp, &network.rpc_uri()?)?;
}

Ok(stellar_strkey::Contract(contract_id.0).to_string())
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 @@ -176,7 +176,7 @@ impl NetworkRunnable for Cmd {
.await?
.try_into()?;
if global_args.map_or(true, |a| !a.no_cache) {
data::write(get_txn_resp, network.rpc_uri()?)?;
data::write(get_txn_resp, &network.rpc_uri()?)?;
}
Ok(stellar_strkey::Contract(contract_id.0).to_string())
}
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 @@ -166,7 +166,7 @@ impl NetworkRunnable for Cmd {
.prepare_and_send_transaction(&tx, &key, &[], &network.network_passphrase, None, None)
.await?;
if args.map_or(true, |a| !a.no_cache) {
data::write(res.clone().try_into()?, network.rpc_uri()?)?;
data::write(res.clone().try_into()?, &network.rpc_uri()?)?;
}

let events = res.events()?;
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 @@ -139,7 +139,7 @@ impl NetworkRunnable for Cmd {
.send_assembled_transaction(txn, &key, &[], &network.network_passphrase, None, None)
.await?;
if args.map_or(true, |a| !a.no_cache) {
data::write(txn_resp.clone().try_into().unwrap(), network.rpc_uri()?)?;
data::write(txn_resp.clone().try_into().unwrap(), &network.rpc_uri()?)?;
}
// Currently internal errors are not returned if the contract code is expired
if let Some(TransactionResult {
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/contract/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl NetworkRunnable for Cmd {
let txn = self.fee.apply_to_assembled_txn(txn);
let sim_res = txn.sim_response();
if global_args.map_or(true, |a| !a.no_cache) {
data::write(sim_res.clone().into(), network.rpc_uri()?)?;
data::write(sim_res.clone().into(), &network.rpc_uri()?)?;
}
let (return_value, events) = if self.is_view() {
(sim_res.results()?[0].xdr.clone(), sim_res.events()?)
Expand All @@ -390,7 +390,7 @@ impl NetworkRunnable for Cmd {
)
.await?;
if !no_cache {
data::write(res.clone().try_into()?, network.rpc_uri()?)?;
data::write(res.clone().try_into()?, &network.rpc_uri()?)?;
}
(res.return_value()?, res.contract_events()?)
};
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 @@ -167,7 +167,7 @@ impl NetworkRunnable for Cmd {
.prepare_and_send_transaction(&tx, &key, &[], &network.network_passphrase, None, None)
.await?;
if args.map_or(true, |a| !a.no_cache) {
data::write(res.clone().try_into()?, network.rpc_uri()?)?;
data::write(res.clone().try_into()?, &network.rpc_uri()?)?;
}
let meta = res
.result_meta
Expand Down
4 changes: 4 additions & 0 deletions docs/soroban-cli-full-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ Full CLI reference: https://github.com/stellar/soroban-tools/tree/main/docs/soro

Possible values: `true`, `false`

* `--no-cache` — Do not cache your simulations and transactions

Possible values: `true`, `false`




Expand Down

0 comments on commit b7a66d5

Please sign in to comment.