diff --git a/sdk/examples/wallet/logger.rs b/sdk/examples/wallet/logger.rs index 907a75120d..37390bd4f6 100644 --- a/sdk/examples/wallet/logger.rs +++ b/sdk/examples/wallet/logger.rs @@ -10,7 +10,6 @@ use iota_sdk::{ client::{ - api::GetAddressesOptions, constants::SHIMMER_COIN_TYPE, secret::{mnemonic::MnemonicSecretManager, SecretManager}, }, diff --git a/sdk/examples/wallet/spammer.rs b/sdk/examples/wallet/spammer.rs index 52786a6f73..70fc0aaf88 100644 --- a/sdk/examples/wallet/spammer.rs +++ b/sdk/examples/wallet/spammer.rs @@ -12,14 +12,10 @@ use iota_sdk::{ client::{ constants::SHIMMER_COIN_TYPE, request_funds_from_faucet, - secret::{mnemonic::MnemonicSecretManager, SecretManage, SecretManager}, + secret::{mnemonic::MnemonicSecretManager, SecretManager}, }, crypto::keys::bip44::Bip44, - types::block::{ - address::{Address, Bech32Address, Hrp}, - output::BasicOutput, - payload::signed_transaction::TransactionId, - }, + types::block::{address::Bech32Address, output::BasicOutput, payload::signed_transaction::TransactionId}, wallet::{ClientOptions, FilterOptions, SendParams, Wallet}, }; diff --git a/sdk/src/client/api/block_builder/transaction_builder/requirement/mana.rs b/sdk/src/client/api/block_builder/transaction_builder/requirement/mana.rs index 58a0b8989f..e7cfc405dd 100644 --- a/sdk/src/client/api/block_builder/transaction_builder/requirement/mana.rs +++ b/sdk/src/client/api/block_builder/transaction_builder/requirement/mana.rs @@ -256,6 +256,15 @@ impl TransactionBuilder { let Some(input) = priority_map.next(required_mana - selected_mana) else { break; }; + // Don't select input with 0 available mana + if input.output.available_mana( + &self.protocol_parameters, + input.output_id().transaction_id().slot_index(), + self.creation_slot, + )? == 0 + { + continue; + } selected_mana += self.total_mana(&input, include_generated)?; if let Some(output) = self.select_input(input)? { required_mana += output.mana(); diff --git a/sdk/tests/wallet/burn_outputs.rs b/sdk/tests/wallet/burn_outputs.rs index 5514340a75..796bf4e38a 100644 --- a/sdk/tests/wallet/burn_outputs.rs +++ b/sdk/tests/wallet/burn_outputs.rs @@ -111,6 +111,7 @@ async fn create_and_melt_native_token() -> Result<(), Box // First create an account output, this needs to be done only once, because an account can have many foundry outputs let transaction = wallet.create_account_output(None, None).await?; + let account_id = AccountId::from(&OutputId::new(transaction.transaction_id, 0)); wallet .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; @@ -118,7 +119,7 @@ async fn create_and_melt_native_token() -> Result<(), Box let circulating_supply = U256::from(60i32); let params = CreateNativeTokenParams { - account_id: None, + account_id: Some(account_id), circulating_supply, maximum_supply: U256::from(100i32), foundry_metadata: None, @@ -175,7 +176,7 @@ async fn create_and_melt_native_token() -> Result<(), Box // Call to run tests in sequence destroy_foundry(&wallet).await?; - destroy_account(&wallet).await?; + destroy_account(&wallet, account_id).await?; tear_down(storage_path) } @@ -203,12 +204,10 @@ async fn destroy_foundry(wallet: &Wallet) -> Result<(), Box Result<(), Box> { +async fn destroy_account(wallet: &Wallet, account_id: AccountId) -> Result<(), Box> { let balance = wallet.sync(None).await.unwrap(); println!("account balance -> {}", serde_json::to_string(&balance).unwrap()); - // Let's destroy the first account we can find - let account_id = *balance.accounts().first().unwrap(); println!("account_id -> {account_id}"); let transaction = wallet.burn(account_id, None).await.unwrap(); wallet @@ -228,6 +227,16 @@ async fn destroy_account(wallet: &Wallet) -> Result<(), Box Result<(), Box> { + let logger_output_config = fern_logger::LoggerOutputConfigBuilder::new() + .name("client.log") + .target_exclusions(&["h2", "hyper", "rustls"]) + .level_filter(log::LevelFilter::Debug); + + let config = fern_logger::LoggerConfig::build() + .with_output(logger_output_config) + .finish(); + + fern_logger::logger_init(config).unwrap(); let storage_path = "test-storage/create_and_burn_native_tokens"; setup(storage_path)?; diff --git a/sdk/tests/wallet/claim_outputs.rs b/sdk/tests/wallet/claim_outputs.rs index 9ab3c25e73..d6d0bda2fa 100644 --- a/sdk/tests/wallet/claim_outputs.rs +++ b/sdk/tests/wallet/claim_outputs.rs @@ -133,9 +133,9 @@ async fn claim_1_of_2_basic_outputs() -> Result<(), Box> #[ignore] #[tokio::test] -async fn claim_2_basic_outputs_no_outputs_in_claim_account() -> Result<(), Box> { - let storage_path_0 = "test-storage/claim_2_basic_outputs_no_outputs_in_claim_account_0"; - let storage_path_1 = "test-storage/claim_2_basic_outputs_no_outputs_in_claim_account_1"; +async fn claim_2_basic_outputs_no_available_in_claim_account() -> Result<(), Box> { + let storage_path_0 = "test-storage/claim_2_basic_outputs_no_available_in_claim_account_0"; + let storage_path_1 = "test-storage/claim_2_basic_outputs_no_available_in_claim_account_1"; setup(storage_path_0)?; setup(storage_path_1)?; @@ -143,10 +143,31 @@ async fn claim_2_basic_outputs_no_outputs_in_claim_account() -> Result<(), Box Result<(), Box> { #[ignore] #[tokio::test] -async fn claim_2_native_tokens_no_outputs_in_claim_account() -> Result<(), Box> { - let storage_path_0 = "test-storage/claim_2_native_tokens_no_outputs_in_claim_account_0"; - let storage_path_1 = "test-storage/claim_2_native_tokens_no_outputs_in_claim_account_1"; +async fn claim_2_native_tokens_no_available_balance_in_claim_account() -> Result<(), Box> { + let storage_path_0 = "test-storage/claim_2_native_tokens_no_available_balance_in_claim_account_0"; + let storage_path_1 = "test-storage/claim_2_native_tokens_no_available_balance_in_claim_account_1"; setup(storage_path_0)?; setup(storage_path_1)?; @@ -291,6 +312,22 @@ async fn claim_2_native_tokens_no_outputs_in_claim_account() -> Result<(), Box Result<(), Box> { let storage_path_1 = "test-storage/send_amount_1"; setup(storage_path_1)?; - let wallet_0 = make_wallet(storage_path_0, Some(generate_mnemonic()?), None).await?; + let wallet_0 = make_wallet(storage_path_0, None, None).await?; request_funds(&wallet_0).await?; let wallet_1 = make_wallet(storage_path_1, None, None).await?;