diff --git a/bindings/core/src/lib.rs b/bindings/core/src/lib.rs index 0d88cd4fbe..6aeb8d3f30 100644 --- a/bindings/core/src/lib.rs +++ b/bindings/core/src/lib.rs @@ -17,6 +17,7 @@ use fern_logger::{logger_init, LoggerConfig, LoggerOutputConfigBuilder}; pub use iota_sdk; use iota_sdk::{ client::secret::{SecretManager, SecretManagerDto}, + types::block::address::Bech32Address, wallet::{ClientOptions, Wallet}, }; use serde::Deserialize; @@ -42,21 +43,23 @@ pub fn init_logger(config: String) -> std::result::Result<(), fern_logger::Error #[derivative(Debug)] #[serde(rename_all = "camelCase")] pub struct WalletOptions { - pub storage_path: Option, - pub client_options: Option, + pub address: Option, + pub alias: Option, pub bip_path: Option, + pub client_options: Option, #[derivative(Debug(format_with = "OmittedDebug::omitted_fmt"))] pub secret_manager: Option, + pub storage_path: Option, } impl WalletOptions { - pub fn with_storage_path(mut self, storage_path: impl Into>) -> Self { - self.storage_path = storage_path.into(); + pub fn with_address(mut self, address: impl Into>) -> Self { + self.address = address.into(); self } - pub fn with_client_options(mut self, client_options: impl Into>) -> Self { - self.client_options = client_options.into(); + pub fn with_alias(mut self, alias: impl Into>) -> Self { + self.alias = alias.into(); self } @@ -65,16 +68,28 @@ impl WalletOptions { self } + pub fn with_client_options(mut self, client_options: impl Into>) -> Self { + self.client_options = client_options.into(); + self + } + pub fn with_secret_manager(mut self, secret_manager: impl Into>) -> Self { self.secret_manager = secret_manager.into(); self } + pub fn with_storage_path(mut self, storage_path: impl Into>) -> Self { + self.storage_path = storage_path.into(); + self + } + pub async fn build(self) -> iota_sdk::wallet::Result { log::debug!("wallet options: {self:?}"); let mut builder = Wallet::builder() - .with_client_options(self.client_options) - .with_bip_path(self.bip_path); + .with_address(self.address) + .with_alias(self.alias) + .with_bip_path(self.bip_path) + .with_client_options(self.client_options); #[cfg(feature = "storage")] if let Some(storage_path) = &self.storage_path { diff --git a/bindings/core/tests/secrets_debug.rs b/bindings/core/tests/secrets_debug.rs index 25fdc1438c..6f57d1eba5 100644 --- a/bindings/core/tests/secrets_debug.rs +++ b/bindings/core/tests/secrets_debug.rs @@ -26,6 +26,6 @@ fn method_interface_secrets_debug() { let wallet_options = WalletOptions::default().with_secret_manager(SecretManagerDto::Placeholder); assert_eq!( format!("{:?}", wallet_options), - "WalletOptions { storage_path: None, client_options: None, bip_path: None, secret_manager: Some() }" + "WalletOptions { address: None, alias: None, bip_path: None, client_options: None, secret_manager: Some(), storage_path: None }" ); } diff --git a/sdk/src/types/block/output/delegation.rs b/sdk/src/types/block/output/delegation.rs index bee2915709..93550da76a 100644 --- a/sdk/src/types/block/output/delegation.rs +++ b/sdk/src/types/block/output/delegation.rs @@ -411,7 +411,7 @@ impl StateTransitionVerifier for DelegationOutput { fn verify_validator_address(validator_address: &AccountAddress) -> Result<(), Error> { if VERIFY && validator_address.is_null() { - return Err(Error::NullDelegationValidatorId); + Err(Error::NullDelegationValidatorId) } else { Ok(()) } diff --git a/sdk/src/wallet/core/mod.rs b/sdk/src/wallet/core/mod.rs index f8a83acea3..00ae19d59c 100644 --- a/sdk/src/wallet/core/mod.rs +++ b/sdk/src/wallet/core/mod.rs @@ -265,7 +265,7 @@ where ImplicitAccountCreationAddress::from(address.clone()), )) } else { - return Err(Error::NonEd25519Address); + Err(Error::NonEd25519Address) } } diff --git a/sdk/src/wallet/operations/helpers/time.rs b/sdk/src/wallet/operations/helpers/time.rs index 3321adfa83..ebd3675688 100644 --- a/sdk/src/wallet/operations/helpers/time.rs +++ b/sdk/src/wallet/operations/helpers/time.rs @@ -3,7 +3,7 @@ use crate::{ types::block::{address::Address, output::Output, slot::SlotIndex}, - wallet::types::{AddressWithUnspentOutputs, OutputData}, + wallet::types::OutputData, }; // Check if an output can be unlocked by the wallet address at the current time diff --git a/sdk/src/wallet/operations/reissue.rs b/sdk/src/wallet/operations/reissue.rs index d5ef412e1e..ec1c120f36 100644 --- a/sdk/src/wallet/operations/reissue.rs +++ b/sdk/src/wallet/operations/reissue.rs @@ -1,8 +1,6 @@ // Copyright 2022 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use crypto::keys::bip44::Bip44; - use crate::{ client::{ secret::{SecretManage, SignBlock}, diff --git a/sdk/src/wallet/operations/transaction/submit_transaction.rs b/sdk/src/wallet/operations/transaction/submit_transaction.rs index bf93b3d298..4ce30c6a8f 100644 --- a/sdk/src/wallet/operations/transaction/submit_transaction.rs +++ b/sdk/src/wallet/operations/transaction/submit_transaction.rs @@ -1,8 +1,6 @@ // Copyright 2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use crypto::keys::bip44::Bip44; - #[cfg(feature = "events")] use crate::wallet::events::types::{TransactionProgressEvent, WalletEvent}; use crate::{ diff --git a/sdk/src/wallet/storage/participation.rs b/sdk/src/wallet/storage/participation.rs index 1bd07332a1..0691874a91 100644 --- a/sdk/src/wallet/storage/participation.rs +++ b/sdk/src/wallet/storage/participation.rs @@ -25,13 +25,13 @@ impl StorageManager { let mut events = self .storage - .get::>(&format!("{PARTICIPATION_EVENTS}")) + .get::>(PARTICIPATION_EVENTS) .await? .unwrap_or_default(); events.insert(event_with_nodes.id, event_with_nodes); - self.storage.set(&format!("{PARTICIPATION_EVENTS}"), &events).await?; + self.storage.set(PARTICIPATION_EVENTS, &events).await?; Ok(()) } @@ -41,7 +41,7 @@ impl StorageManager { let mut events = match self .storage - .get::>(&format!("{PARTICIPATION_EVENTS}")) + .get::>(PARTICIPATION_EVENTS) .await? { Some(events) => events, @@ -50,7 +50,7 @@ impl StorageManager { events.remove(id); - self.storage.set(&format!("{PARTICIPATION_EVENTS}"), &events).await?; + self.storage.set(PARTICIPATION_EVENTS, &events).await?; Ok(()) } @@ -60,11 +60,7 @@ impl StorageManager { ) -> crate::wallet::Result> { log::debug!("get_participation_events"); - Ok(self - .storage - .get(&format!("{PARTICIPATION_EVENTS}")) - .await? - .unwrap_or_default()) + Ok(self.storage.get(PARTICIPATION_EVENTS).await?.unwrap_or_default()) } pub(crate) async fn set_cached_participation_output_status( @@ -74,7 +70,7 @@ impl StorageManager { log::debug!("set_cached_participation"); self.storage - .set(&format!("{PARTICIPATION_CACHED_OUTPUTS}"), outputs_participation) + .set(PARTICIPATION_CACHED_OUTPUTS, outputs_participation) .await?; Ok(()) @@ -87,7 +83,7 @@ impl StorageManager { Ok(self .storage - .get(&format!("{PARTICIPATION_CACHED_OUTPUTS}")) + .get(PARTICIPATION_CACHED_OUTPUTS) .await? .unwrap_or_default()) }