From 7be6fe962ce4ba970bd248c564ec10cebe7b4474 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 20 Nov 2023 14:04:20 +0100 Subject: [PATCH 1/4] Rename --- bindings/core/src/method_handler/client.rs | 2 +- sdk/src/client/node_api/core/mod.rs | 12 ++++++------ sdk/src/wallet/operations/syncing/mod.rs | 2 +- sdk/src/wallet/operations/syncing/outputs.rs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bindings/core/src/method_handler/client.rs b/bindings/core/src/method_handler/client.rs index 53f65631cd..206250670d 100644 --- a/bindings/core/src/method_handler/client.rs +++ b/bindings/core/src/method_handler/client.rs @@ -259,7 +259,7 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM } ClientMethod::GetOutputsIgnoreErrors { output_ids } => { let outputs_response = client - .get_outputs_with_metadata_ignore_errors(&output_ids) + .get_outputs_with_metadata_ignore_not_found(&output_ids) .await? .iter() .map(OutputWithMetadataResponse::from) diff --git a/sdk/src/client/node_api/core/mod.rs b/sdk/src/client/node_api/core/mod.rs index ade26cf22a..dffd4b78da 100644 --- a/sdk/src/client/node_api/core/mod.rs +++ b/sdk/src/client/node_api/core/mod.rs @@ -31,9 +31,9 @@ impl Client { futures::future::try_join_all(output_ids.iter().map(|id| self.get_output(id))).await } - /// Requests outputs by their output ID in parallel, ignoring failed requests. + /// Requests outputs by their output ID in parallel, ignoring outputs not found. /// Useful to get data about spent outputs, that might not be pruned yet. - pub async fn get_outputs_ignore_errors(&self, output_ids: &[OutputId]) -> Result> { + pub async fn get_outputs_ignore_not_found(&self, output_ids: &[OutputId]) -> Result> { Ok( futures::future::join_all(output_ids.iter().map(|id| self.get_output(id))) .await @@ -48,8 +48,8 @@ impl Client { futures::future::try_join_all(output_ids.iter().map(|id| self.get_output_metadata(id))).await } - /// Requests metadata for outputs by their output ID in parallel, ignoring failed requests. - pub async fn get_outputs_metadata_ignore_errors(&self, output_ids: &[OutputId]) -> Result> { + /// Requests metadata for outputs by their output ID in parallel, ignoring outputs not found. + pub async fn get_outputs_metadata_ignore_not_found(&self, output_ids: &[OutputId]) -> Result> { Ok( futures::future::join_all(output_ids.iter().map(|id| self.get_output_metadata(id))) .await @@ -64,9 +64,9 @@ impl Client { futures::future::try_join_all(output_ids.iter().map(|id| self.get_output_with_metadata(id))).await } - /// Requests outputs and their metadata by their output ID in parallel, ignoring failed requests. + /// Requests outputs and their metadata by their output ID in parallel, ignoring outputs not found. /// Useful to get data about spent outputs, that might not be pruned yet. - pub async fn get_outputs_with_metadata_ignore_errors( + pub async fn get_outputs_with_metadata_ignore_not_found( &self, output_ids: &[OutputId], ) -> Result> { diff --git a/sdk/src/wallet/operations/syncing/mod.rs b/sdk/src/wallet/operations/syncing/mod.rs index abbbbb4d4e..f5bab33d1b 100644 --- a/sdk/src/wallet/operations/syncing/mod.rs +++ b/sdk/src/wallet/operations/syncing/mod.rs @@ -119,7 +119,7 @@ where log::debug!("[SYNC] spent_or_not_synced_outputs: {spent_or_not_synced_output_ids:?}"); let spent_or_unsynced_output_metadata_responses = self .client() - .get_outputs_metadata_ignore_errors(&spent_or_not_synced_output_ids) + .get_outputs_metadata_ignore_not_found(&spent_or_not_synced_output_ids) .await?; // Add the output response to the output ids, the output response is optional, because an output could be diff --git a/sdk/src/wallet/operations/syncing/outputs.rs b/sdk/src/wallet/operations/syncing/outputs.rs index 85461ce33d..5b540ffe7d 100644 --- a/sdk/src/wallet/operations/syncing/outputs.rs +++ b/sdk/src/wallet/operations/syncing/outputs.rs @@ -222,7 +222,7 @@ pub(crate) async fn get_inputs_for_transaction_payload( .collect::>(); client - .get_outputs_with_metadata_ignore_errors(&output_ids) + .get_outputs_with_metadata_ignore_not_found(&output_ids) .await .map_err(|e| e.into()) } From aad65c87d73b2913e6f47d64f4d3e38b52e7ced7 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 20 Nov 2023 14:48:31 +0100 Subject: [PATCH 2/4] Ignore not found --- sdk/src/client/node_api/core/mod.rs | 38 ++++++++++++----------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/sdk/src/client/node_api/core/mod.rs b/sdk/src/client/node_api/core/mod.rs index dffd4b78da..7f31339855 100644 --- a/sdk/src/client/node_api/core/mod.rs +++ b/sdk/src/client/node_api/core/mod.rs @@ -8,7 +8,7 @@ pub mod routes; use packable::PackableExt; use crate::{ - client::{Client, Result}, + client::{node_api::error::Error as NodeApiError, Client, Error, Result}, types::block::output::{Output, OutputId, OutputMetadata, OutputWithMetadata}, }; @@ -34,13 +34,11 @@ impl Client { /// Requests outputs by their output ID in parallel, ignoring outputs not found. /// Useful to get data about spent outputs, that might not be pruned yet. pub async fn get_outputs_ignore_not_found(&self, output_ids: &[OutputId]) -> Result> { - Ok( - futures::future::join_all(output_ids.iter().map(|id| self.get_output(id))) - .await - .into_iter() - .filter_map(Result::ok) - .collect(), - ) + futures::future::join_all(output_ids.iter().map(|id| self.get_output(id))) + .await + .into_iter() + .filter(|res| !matches!(res, Err(Error::Node(NodeApiError::NotFound(_))))) + .collect() } /// Requests metadata for outputs by their output ID in parallel. @@ -50,13 +48,11 @@ impl Client { /// Requests metadata for outputs by their output ID in parallel, ignoring outputs not found. pub async fn get_outputs_metadata_ignore_not_found(&self, output_ids: &[OutputId]) -> Result> { - Ok( - futures::future::join_all(output_ids.iter().map(|id| self.get_output_metadata(id))) - .await - .into_iter() - .filter_map(Result::ok) - .collect(), - ) + futures::future::join_all(output_ids.iter().map(|id| self.get_output_metadata(id))) + .await + .into_iter() + .filter(|res| !matches!(res, Err(Error::Node(NodeApiError::NotFound(_))))) + .collect() } /// Requests outputs and their metadata by their output ID in parallel. @@ -70,12 +66,10 @@ impl Client { &self, output_ids: &[OutputId], ) -> Result> { - Ok( - futures::future::join_all(output_ids.iter().map(|id| self.get_output_with_metadata(id))) - .await - .into_iter() - .filter_map(Result::ok) - .collect(), - ) + futures::future::join_all(output_ids.iter().map(|id| self.get_output_with_metadata(id))) + .await + .into_iter() + .filter(|res| !matches!(res, Err(Error::Node(NodeApiError::NotFound(_))))) + .collect() } } From 85df48c8c3842d894a6c8b2d0948b655fd154cbb Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 20 Nov 2023 17:32:32 +0100 Subject: [PATCH 3/4] Missed account rename --- .../operations/syncing/addresses/output_ids/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/src/wallet/operations/syncing/addresses/output_ids/mod.rs b/sdk/src/wallet/operations/syncing/addresses/output_ids/mod.rs index c9ddc7b6cb..994b036752 100644 --- a/sdk/src/wallet/operations/syncing/addresses/output_ids/mod.rs +++ b/sdk/src/wallet/operations/syncing/addresses/output_ids/mod.rs @@ -80,9 +80,9 @@ where tasks.push( async { let bech32_address = address.clone(); - let account = self.clone(); + let wallet = self.clone(); tokio::spawn(async move { - account + wallet .get_basic_output_ids_with_any_unlock_condition(bech32_address) .await }) @@ -108,9 +108,9 @@ where tasks.push( async { let bech32_address = address.clone(); - let account = self.clone(); + let wallet = self.clone(); tokio::spawn(async move { - account + wallet .get_nft_output_ids_with_any_unlock_condition(bech32_address) .await }) @@ -140,9 +140,9 @@ where async { let bech32_address = address.clone(); let sync_options = sync_options.clone(); - let account = self.clone(); + let wallet = self.clone(); tokio::spawn(async move { - account + wallet .get_account_and_foundry_output_ids(bech32_address, &sync_options) .await }) From 8b7c0adfd5f359d02d42d6545ac386206079e583 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 20 Nov 2023 19:33:28 +0100 Subject: [PATCH 4/4] format output list --- cli/src/wallet_cli/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/wallet_cli/mod.rs b/cli/src/wallet_cli/mod.rs index 304b582e76..5715f0dabe 100644 --- a/cli/src/wallet_cli/mod.rs +++ b/cli/src/wallet_cli/mod.rs @@ -1210,7 +1210,7 @@ async fn print_outputs(mut outputs: Vec, title: &str) -> Result<(), }; println_log_info!( - "{:<5}{}\t{}\t{}", + "{:<5}{} {:<16}{}", i, &output_data.output_id, kind_str,