diff --git a/sdk/CHANGELOG.md b/sdk/CHANGELOG.md index 87e1e0030b..4e6a9b49a9 100644 --- a/sdk/CHANGELOG.md +++ b/sdk/CHANGELOG.md @@ -24,7 +24,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Migrated storage types field casing to uniform camelCase; -- Removed inappropriate serde impls from `AccountDetails` and `WalletBuilder`, and added fn impls for conversion; +- Replaced inappropriate serde impls from `AccountDetails` and `WalletBuilder` with fn impls for conversion; + +### Removed + +- `ProtocolParametersDto`, `NetworkInfoDto`, `OutputMetadataDto` in favor of base types; ### Fixed diff --git a/sdk/src/client/builder.rs b/sdk/src/client/builder.rs index 9151575ff6..cf7f06d770 100644 --- a/sdk/src/client/builder.rs +++ b/sdk/src/client/builder.rs @@ -334,6 +334,7 @@ impl ClientBuilder { /// Struct containing network and PoW related information #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct NetworkInfo { /// Protocol parameters. #[serde(default)] diff --git a/sdk/src/wallet/core/builder.rs b/sdk/src/wallet/core/builder.rs index b92082c858..2762af9743 100644 --- a/sdk/src/wallet/core/builder.rs +++ b/sdk/src/wallet/core/builder.rs @@ -9,6 +9,7 @@ use std::sync::{ use std::{collections::HashSet, sync::atomic::Ordering}; use futures::{future::try_join_all, FutureExt}; +use serde::Serialize; use tokio::sync::RwLock; use super::operations::storage::SaveLoadWallet; @@ -27,12 +28,14 @@ use crate::{ }; /// Builder for the wallet. -#[derive(Debug)] +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] pub struct WalletBuilder { pub(crate) client_options: Option, pub(crate) coin_type: Option, #[cfg(feature = "storage")] pub(crate) storage_options: Option, + #[serde(skip)] pub(crate) secret_manager: Option>>, } @@ -282,12 +285,12 @@ fn unlock_unused_inputs(accounts: &mut [AccountDetails]) -> crate::wallet::Resul } pub mod dto { - use serde::{Deserialize, Serialize}; + use serde::Deserialize; use super::*; use crate::{client::secret::SecretManage, wallet::storage::StorageOptions}; - #[derive(Debug, Serialize, Deserialize)] + #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct WalletBuilderDto { pub(crate) client_options: Option, @@ -296,29 +299,6 @@ pub mod dto { pub(crate) storage_options: Option, } - // TODO: This duplication can be streamlined using Borrowed or Owned enum - impl From<&WalletBuilder> for WalletBuilderDto { - fn from(value: &WalletBuilder) -> Self { - Self { - client_options: value.client_options.clone(), - coin_type: value.coin_type, - #[cfg(feature = "storage")] - storage_options: value.storage_options.clone(), - } - } - } - - impl From> for WalletBuilderDto { - fn from(value: WalletBuilder) -> Self { - Self { - client_options: value.client_options, - coin_type: value.coin_type, - #[cfg(feature = "storage")] - storage_options: value.storage_options, - } - } - } - impl WalletBuilderDto { pub(crate) fn into_builder(self, secret_manager: Option) -> WalletBuilder { WalletBuilder { diff --git a/sdk/src/wallet/core/operations/storage.rs b/sdk/src/wallet/core/operations/storage.rs index adf8b98c47..8c1ec6896d 100644 --- a/sdk/src/wallet/core/operations/storage.rs +++ b/sdk/src/wallet/core/operations/storage.rs @@ -36,9 +36,7 @@ mod storage_stub { { async fn save(&self, storage: &impl StorageAdapter) -> crate::wallet::Result<()> { log::debug!("save_wallet_data"); - storage - .set(WALLET_INDEXATION_KEY, &WalletBuilderDto::from(self)) - .await?; + storage.set(WALLET_INDEXATION_KEY, self).await?; if let Some(secret_manager) = &self.secret_manager { let secret_manager = secret_manager.read().await; @@ -73,9 +71,7 @@ mod storage_stub { impl SaveLoadWallet for WalletBuilder { async fn save(&self, storage: &impl StorageAdapter) -> crate::wallet::Result<()> { log::debug!("save_wallet_data"); - storage - .set(WALLET_INDEXATION_KEY, &WalletBuilderDto::from(self)) - .await?; + storage.set(WALLET_INDEXATION_KEY, self).await?; Ok(()) }