diff --git a/bindings/core/src/method_handler/client.rs b/bindings/core/src/method_handler/client.rs index d68fea59b3..753c897297 100644 --- a/bindings/core/src/method_handler/client.rs +++ b/bindings/core/src/method_handler/client.rs @@ -251,7 +251,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/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, diff --git a/sdk/src/client/node_api/core/mod.rs b/sdk/src/client/node_api/core/mod.rs index ade26cf22a..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}, }; @@ -31,16 +31,14 @@ 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> { - Ok( - futures::future::join_all(output_ids.iter().map(|id| self.get_output(id))) - .await - .into_iter() - .filter_map(Result::ok) - .collect(), - ) + pub async fn get_outputs_ignore_not_found(&self, output_ids: &[OutputId]) -> Result> { + 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. @@ -48,15 +46,13 @@ 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> { - Ok( - futures::future::join_all(output_ids.iter().map(|id| self.get_output_metadata(id))) - .await - .into_iter() - .filter_map(Result::ok) - .collect(), - ) + /// 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> { + 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. @@ -64,18 +60,16 @@ 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> { - 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() } } 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 }) diff --git a/sdk/src/wallet/operations/syncing/mod.rs b/sdk/src/wallet/operations/syncing/mod.rs index 4ec2ac0045..a19b66b265 100644 --- a/sdk/src/wallet/operations/syncing/mod.rs +++ b/sdk/src/wallet/operations/syncing/mod.rs @@ -127,7 +127,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 dfa73891c5..bc048e8350 100644 --- a/sdk/src/wallet/operations/syncing/outputs.rs +++ b/sdk/src/wallet/operations/syncing/outputs.rs @@ -220,7 +220,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()) }