From b7a66d561db3d6cc0355f83b998145e668d55219 Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Mon, 11 Mar 2024 15:57:02 -0400 Subject: [PATCH] fix: clippy and fmt --- cmd/soroban-cli/src/commands/config/data.rs | 12 ++++++------ .../src/commands/contract/deploy/asset.rs | 2 +- cmd/soroban-cli/src/commands/contract/deploy/wasm.rs | 2 +- cmd/soroban-cli/src/commands/contract/extend.rs | 2 +- cmd/soroban-cli/src/commands/contract/install.rs | 2 +- cmd/soroban-cli/src/commands/contract/invoke.rs | 4 ++-- cmd/soroban-cli/src/commands/contract/restore.rs | 2 +- docs/soroban-cli-full-docs.md | 4 ++++ 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/cmd/soroban-cli/src/commands/config/data.rs b/cmd/soroban-cli/src/commands/config/data.rs index 9c5b4ec1f7..b8d86eee2f 100644 --- a/cmd/soroban-cli/src/commands/config/data.rs +++ b/cmd/soroban-cli/src/commands/config/data.rs @@ -45,7 +45,7 @@ pub fn spec_dir() -> Result { Ok(dir) } -pub fn write(action: Action, rpc_url: Uri) -> Result { +pub fn write(action: Action, rpc_url: &Uri) -> Result { let data = Data { action, rpc_url: rpc_url.to_string(), @@ -128,14 +128,14 @@ impl TryFrom for Action { fn try_from(res: GetTransactionResponse) -> Result { 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 { +fn to_xdr(data: &impl WriteXdr) -> Result { data.to_xdr_base64(xdr::Limits::none()) } @@ -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) { diff --git a/cmd/soroban-cli/src/commands/contract/deploy/asset.rs b/cmd/soroban-cli/src/commands/contract/deploy/asset.rs index 75f6559402..41e7367dce 100644 --- a/cmd/soroban-cli/src/commands/contract/deploy/asset.rs +++ b/cmd/soroban-cli/src/commands/contract/deploy/asset.rs @@ -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()) diff --git a/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs b/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs index 1bedfc730b..40369b2301 100644 --- a/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs +++ b/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs @@ -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()) } diff --git a/cmd/soroban-cli/src/commands/contract/extend.rs b/cmd/soroban-cli/src/commands/contract/extend.rs index 0c51a88d08..ab7834959b 100644 --- a/cmd/soroban-cli/src/commands/contract/extend.rs +++ b/cmd/soroban-cli/src/commands/contract/extend.rs @@ -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()?; diff --git a/cmd/soroban-cli/src/commands/contract/install.rs b/cmd/soroban-cli/src/commands/contract/install.rs index ec9de88055..d4a0d541fc 100644 --- a/cmd/soroban-cli/src/commands/contract/install.rs +++ b/cmd/soroban-cli/src/commands/contract/install.rs @@ -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 { diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index d7a890334c..2e8414285c 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -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()?) @@ -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()?) }; diff --git a/cmd/soroban-cli/src/commands/contract/restore.rs b/cmd/soroban-cli/src/commands/contract/restore.rs index a335d9860c..8b5921a1a6 100644 --- a/cmd/soroban-cli/src/commands/contract/restore.rs +++ b/cmd/soroban-cli/src/commands/contract/restore.rs @@ -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 diff --git a/docs/soroban-cli-full-docs.md b/docs/soroban-cli-full-docs.md index 6e06debe9c..37d8c30166 100644 --- a/docs/soroban-cli-full-docs.md +++ b/docs/soroban-cli-full-docs.md @@ -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` +