diff --git a/sdk/src/wallet/operations/balance.rs b/sdk/src/wallet/operations/balance.rs index 1bd8e93d95..374e74cc90 100644 --- a/sdk/src/wallet/operations/balance.rs +++ b/sdk/src/wallet/operations/balance.rs @@ -73,8 +73,6 @@ where if !wallet_data.locked_outputs.contains(output_id) { total_storage_cost += storage_cost; } - // Add native tokens - total_native_tokens.add_native_tokens(output.native_tokens().clone())?; let account_id = output.account_id_non_null(output_id); balance.accounts.push(account_id); @@ -87,8 +85,11 @@ where if !wallet_data.locked_outputs.contains(output_id) { total_storage_cost += storage_cost; } - // Add native tokens - total_native_tokens.add_native_tokens(output.native_tokens().clone())?; + + // Add native token + if let Some(native_token) = output.native_token() { + total_native_tokens.add_native_token(native_token.clone())?; + } balance.foundries.push(output.id()); } @@ -112,12 +113,7 @@ where // Add storage deposit if output.is_basic() { balance.required_storage_deposit.basic += storage_cost; - if output - .native_tokens() - .map(|native_tokens| !native_tokens.is_empty()) - .unwrap_or(false) - && !wallet_data.locked_outputs.contains(output_id) - { + if output.native_token().is_some() && !wallet_data.locked_outputs.contains(output_id) { total_storage_cost += storage_cost; } } else if output.is_nft() { @@ -127,9 +123,9 @@ where } } - // Add native tokens - if let Some(native_tokens) = output.native_tokens() { - total_native_tokens.add_native_tokens(native_tokens.clone())?; + // Add native token + if let Some(native_token) = output.native_token() { + total_native_tokens.add_native_token(native_token.clone())?; } } else { // if we have multiple unlock conditions for basic or nft outputs, then we can't @@ -187,13 +183,9 @@ where // Add storage deposit if output.is_basic() { balance.required_storage_deposit.basic += storage_cost; - // Amount for basic outputs isn't added to total storage cost if there aren't - // native tokens, since we can - // spend it without burning. - if output - .native_tokens() - .map(|native_tokens| !native_tokens.is_empty()) - .unwrap_or(false) + // Amount for basic outputs isn't added to total storage cost if there aren't native + // tokens, since we can spend it without burning. + if output.native_token().is_some() && !wallet_data.locked_outputs.contains(output_id) { total_storage_cost += storage_cost; @@ -205,9 +197,9 @@ where } } - // Add native tokens - if let Some(native_tokens) = output.native_tokens() { - total_native_tokens.add_native_tokens(native_tokens.clone())?; + // Add native token + if let Some(native_token) = output.native_token() { + total_native_tokens.add_native_token(native_token.clone())?; } } else { // only add outputs that can't be locked now and at any point in the future @@ -267,8 +259,8 @@ where // Only check outputs that are in this network if output_data.network_id == network_id { locked_amount += output_data.output.amount(); - if let Some(native_tokens) = output_data.output.native_tokens() { - locked_native_tokens.add_native_tokens(native_tokens.clone())?; + if let Some(native_token) = output_data.output.native_token() { + locked_native_tokens.add_native_token(native_token.clone())?; } } } diff --git a/sdk/src/wallet/operations/transaction/prepare_transaction.rs b/sdk/src/wallet/operations/transaction/prepare_transaction.rs index fcf9a1f96d..be6ef8b7bd 100644 --- a/sdk/src/wallet/operations/transaction/prepare_transaction.rs +++ b/sdk/src/wallet/operations/transaction/prepare_transaction.rs @@ -7,6 +7,7 @@ use instant::Instant; use packable::bounded::TryIntoBoundedU16Error; #[cfg(feature = "events")] +// TODO why is this not used anymore? Are we not triggering an event anymore? use crate::wallet::events::types::{AddressData, TransactionProgressEvent, WalletEvent}; use crate::{ client::{api::PreparedTransactionData, secret::SecretManage},