diff --git a/sdk/src/wallet/core/builder.rs b/sdk/src/wallet/core/builder.rs index 8822a62fad..967dc66b83 100644 --- a/sdk/src/wallet/core/builder.rs +++ b/sdk/src/wallet/core/builder.rs @@ -288,9 +288,8 @@ pub(crate) mod dto { use serde::Deserialize; use super::*; - use crate::client::secret::SecretManage; #[cfg(feature = "storage")] - use crate::wallet::storage::StorageOptions; + use crate::{client::secret::SecretManage, wallet::storage::StorageOptions}; #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] diff --git a/sdk/tests/client/addresses.rs b/sdk/tests/client/addresses.rs index 09048a1d6b..1f06942b8f 100644 --- a/sdk/tests/client/addresses.rs +++ b/sdk/tests/client/addresses.rs @@ -1,6 +1,7 @@ // Copyright 2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +#[cfg(feature = "stronghold")] use crypto::keys::bip39::Mnemonic; #[cfg(feature = "stronghold")] use iota_sdk::client::secret::stronghold::StrongholdSecretManager; diff --git a/sdk/tests/wallet/address_generation.rs b/sdk/tests/wallet/address_generation.rs index 8af93166c3..3309a63a60 100644 --- a/sdk/tests/wallet/address_generation.rs +++ b/sdk/tests/wallet/address_generation.rs @@ -1,19 +1,21 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +#[cfg(feature = "ledger_nano")] use std::sync::{Arc, Mutex}; +#[cfg(feature = "stronghold")] use crypto::keys::bip39::Mnemonic; -#[cfg(feature = "ledger_nano")] -use iota_sdk::client::secret::ledger_nano::LedgerSecretManager; #[cfg(feature = "stronghold")] use iota_sdk::client::secret::stronghold::StrongholdSecretManager; +#[cfg(feature = "ledger_nano")] +use iota_sdk::client::secret::{ledger_nano::LedgerSecretManager, GenerateAddressOptions}; #[cfg(feature = "events")] use iota_sdk::wallet::events::{WalletEvent, WalletEventType}; use iota_sdk::{ client::{ constants::IOTA_COIN_TYPE, - secret::{mnemonic::MnemonicSecretManager, GenerateAddressOptions, SecretManager}, + secret::{mnemonic::MnemonicSecretManager, SecretManager}, Error as ClientError, }, types::block::address::ToBech32Ext, diff --git a/sdk/tests/wallet/output_preparation.rs b/sdk/tests/wallet/output_preparation.rs index 91bf6d70ac..4d91794200 100644 --- a/sdk/tests/wallet/output_preparation.rs +++ b/sdk/tests/wallet/output_preparation.rs @@ -99,7 +99,7 @@ async fn output_preparation() -> Result<()> { assets: None, features: Some(Features { metadata: Some(prefix_hex::encode(b"Hello world")), - tag: None, + tag: Some(prefix_hex::encode(b"My Tag")), issuer: None, sender: None, }), @@ -112,8 +112,8 @@ async fn output_preparation() -> Result<()> { assert_eq!(output.amount(), 300000); // only address condition assert_eq!(output.unlock_conditions().unwrap().len(), 1); - // metadata feature - assert_eq!(output.features().unwrap().len(), 1); + // metadata and tag features + assert_eq!(output.features().unwrap().len(), 2); // only send 1 with metadata feature let output = account @@ -124,7 +124,7 @@ async fn output_preparation() -> Result<()> { assets: None, features: Some(Features { metadata: Some(prefix_hex::encode(b"Hello world")), - tag: None, + tag: Some(prefix_hex::encode(b"My Tag")), issuer: None, sender: None, }), @@ -134,15 +134,15 @@ async fn output_preparation() -> Result<()> { None, ) .await?; - assert_eq!(output.amount(), 48200); + assert_eq!(output.amount(), 49000); let unlock_conditions = output.unlock_conditions().unwrap(); // address + sdr assert_eq!(unlock_conditions.len(), 2); let storage_deposit_return = unlock_conditions.storage_deposit_return().unwrap(); // output amount -1 - assert_eq!(storage_deposit_return.amount(), 48199); - // metadata feature - assert_eq!(output.features().unwrap().len(), 1); + assert_eq!(storage_deposit_return.amount(), 48999); + // metadata and tag features + assert_eq!(output.features().unwrap().len(), 2); let output = account .prepare_output( @@ -152,7 +152,7 @@ async fn output_preparation() -> Result<()> { assets: None, features: Some(Features { metadata: Some(prefix_hex::encode(b"Hello world")), - tag: None, + tag: Some(prefix_hex::encode(b"My Tag")), issuer: None, sender: None, }), @@ -166,8 +166,8 @@ async fn output_preparation() -> Result<()> { // address and storage deposit unlock condition, because of the metadata feature block, 12000 is not enough for the // required storage deposit assert_eq!(output.unlock_conditions().unwrap().len(), 2); - // metadata feature - assert_eq!(output.features().unwrap().len(), 1); + // metadata and tag features + assert_eq!(output.features().unwrap().len(), 2); let output = account .prepare_output( @@ -177,7 +177,7 @@ async fn output_preparation() -> Result<()> { assets: None, features: Some(Features { metadata: Some(prefix_hex::encode(b"Hello world")), - tag: None, + tag: Some(prefix_hex::encode(b"My Tag")), issuer: None, sender: None, }), @@ -187,15 +187,15 @@ async fn output_preparation() -> Result<()> { None, ) .await?; - assert_eq!(output.amount(), 48200); + assert_eq!(output.amount(), 49000); let sdr = output.unlock_conditions().unwrap().storage_deposit_return().unwrap(); - assert_eq!(sdr.amount(), 48199); + assert_eq!(sdr.amount(), 48999); // address and storage deposit unlock condition, because of the metadata feature block, 213000 is not enough for the // required storage deposit assert_eq!(output.unlock_conditions().unwrap().len(), 2); - // metadata feature - assert_eq!(output.features().unwrap().len(), 1); + // metadata and tag features + assert_eq!(output.features().unwrap().len(), 2); // Error if this NftId is not in the account let error = account @@ -328,7 +328,10 @@ async fn output_preparation() -> Result<()> { issuer: Some(issuer_and_sender_address), sender: Some(issuer_and_sender_address), }), - unlocks: None, + unlocks: Some(Unlocks { + expiration_unix_time: Some(1), + timelock_unix_time: Some(1), + }), storage_deposit: None, }, None, @@ -346,6 +349,10 @@ async fn output_preparation() -> Result<()> { assert_eq!(issuer_feature.address(), issuer_and_sender_address.inner()); let sender_feature = features.sender().unwrap(); assert_eq!(sender_feature.address(), issuer_and_sender_address.inner()); + // Unlocks + let conditions = output.unlock_conditions().unwrap(); + assert!(conditions.is_time_locked(0)); + assert!(conditions.is_expired(2)); // nft with expiration let output = account