diff --git a/cli/src/wallet_cli/mod.rs b/cli/src/wallet_cli/mod.rs index 62dfbaec12..f534b2e41b 100644 --- a/cli/src/wallet_cli/mod.rs +++ b/cli/src/wallet_cli/mod.rs @@ -19,9 +19,9 @@ use iota_sdk::{ }, payload::signed_transaction::TransactionId, slot::SlotIndex, - ConvertTo, }, }, + utils::ConvertTo, wallet::{ types::{OutputData, TransactionWithMetadata}, ConsolidationParams, CreateNativeTokenParams, MintNftParams, OutputsToClaim, SendNativeTokensParams, diff --git a/sdk/src/client/api/address.rs b/sdk/src/client/api/address.rs index 173de7289f..6d5501d4d7 100644 --- a/sdk/src/client/api/address.rs +++ b/sdk/src/client/api/address.rs @@ -12,10 +12,8 @@ use crate::{ secret::{GenerateAddressOptions, SecretManage, SecretManager}, Client, Result, }, - types::block::{ - address::{Address, Bech32Address, Hrp, ToBech32Ext}, - ConvertTo, - }, + types::block::address::{Address, Bech32Address, Hrp, ToBech32Ext}, + utils::ConvertTo, }; #[derive(Clone, Debug, Serialize, Deserialize)] diff --git a/sdk/src/client/node_api/participation.rs b/sdk/src/client/node_api/participation.rs index 68c721fa2f..5f9dddc4a4 100644 --- a/sdk/src/client/node_api/participation.rs +++ b/sdk/src/client/node_api/participation.rs @@ -15,8 +15,9 @@ use crate::{ ParticipationEventType, }, }, - block::{address::Bech32Address, output::OutputId, ConvertTo}, + block::{address::Bech32Address, output::OutputId}, }, + utils::ConvertTo, }; impl ClientInner { diff --git a/sdk/src/client/utils.rs b/sdk/src/client/utils.rs index da07957425..ba2f0056aa 100644 --- a/sdk/src/client/utils.rs +++ b/sdk/src/client/utils.rs @@ -21,8 +21,9 @@ use crate::{ address::{Address, Bech32Address, Ed25519Address, Hrp, ToBech32Ext}, output::{AccountId, NftId}, payload::TaggedDataPayload, - BlockId, ConvertTo, SignedBlock, + BlockId, SignedBlock, }, + utils::ConvertTo, }; /// Transforms bech32 to hex diff --git a/sdk/src/types/block/address/bech32.rs b/sdk/src/types/block/address/bech32.rs index cbc8d26d5b..36cbe7bbea 100644 --- a/sdk/src/types/block/address/bech32.rs +++ b/sdk/src/types/block/address/bech32.rs @@ -16,9 +16,12 @@ use packable::{ Packable, PackableExt, }; -use crate::types::block::{ - address::{Address, MultiAddress}, - ConvertTo, Error, +use crate::{ + types::block::{ + address::{Address, MultiAddress}, + Error, + }, + utils::ConvertTo, }; #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deref, Display)] diff --git a/sdk/src/types/block/address/mod.rs b/sdk/src/types/block/address/mod.rs index 4857bf4093..4a8021ad8e 100644 --- a/sdk/src/types/block/address/mod.rs +++ b/sdk/src/types/block/address/mod.rs @@ -26,12 +26,15 @@ pub use self::{ nft::NftAddress, restricted::{AddressCapabilities, AddressCapabilityFlag, RestrictedAddress}, }; -use crate::types::block::{ - output::Output, - semantic::{SemanticValidationContext, TransactionFailureReason}, - signature::Signature, - unlock::Unlock, - ConvertTo, Error, +use crate::{ + types::block::{ + output::Output, + semantic::{SemanticValidationContext, TransactionFailureReason}, + signature::Signature, + unlock::Unlock, + Error, + }, + utils::ConvertTo, }; /// A generic address supporting different address kinds. diff --git a/sdk/src/types/block/macro.rs b/sdk/src/types/block/macro.rs index d4783a93cd..b7a5b6695a 100644 --- a/sdk/src/types/block/macro.rs +++ b/sdk/src/types/block/macro.rs @@ -75,13 +75,13 @@ macro_rules! impl_id { } } - impl $crate::types::block::ConvertTo<$hash_name> for &alloc::string::String { + impl $crate::utils::ConvertTo<$hash_name> for &alloc::string::String { fn convert(self) -> Result<$hash_name, $crate::types::block::Error> { self.try_into() } } - impl $crate::types::block::ConvertTo<$hash_name> for &str { + impl $crate::utils::ConvertTo<$hash_name> for &str { fn convert(self) -> Result<$hash_name, $crate::types::block::Error> { self.try_into() } @@ -205,13 +205,13 @@ macro_rules! impl_id { } } - impl $crate::types::block::ConvertTo<$id_name> for &alloc::string::String { + impl $crate::utils::ConvertTo<$id_name> for &alloc::string::String { fn convert(self) -> Result<$id_name, $crate::types::block::Error> { self.try_into() } } - impl $crate::types::block::ConvertTo<$id_name> for &str { + impl $crate::utils::ConvertTo<$id_name> for &str { fn convert(self) -> Result<$id_name, $crate::types::block::Error> { self.try_into() } diff --git a/sdk/src/types/block/mod.rs b/sdk/src/types/block/mod.rs index d010281bab..df210e8224 100644 --- a/sdk/src/types/block/mod.rs +++ b/sdk/src/types/block/mod.rs @@ -4,7 +4,6 @@ //! Core data types for blocks in the tangle. mod block_id; -mod convert; mod error; mod issuer_id; mod r#macro; @@ -46,7 +45,6 @@ pub use self::core::dto::{BlockDto, SignedBlockDto, UnsignedBlockDto}; pub(crate) use self::r#macro::*; pub use self::{ block_id::{BlockHash, BlockId}, - convert::ConvertTo, core::{Block, SignedBlock, UnsignedBlock}, error::Error, issuer_id::IssuerId, diff --git a/sdk/src/types/block/protocol.rs b/sdk/src/types/block/protocol.rs index 25556c4fd2..30ecf8e94f 100644 --- a/sdk/src/types/block/protocol.rs +++ b/sdk/src/types/block/protocol.rs @@ -13,7 +13,10 @@ use super::{ mana::{ManaParameters, RewardsParameters}, slot::{EpochIndex, SlotIndex}, }; -use crate::types::block::{helper::network_name_to_id, output::RentStructure, ConvertTo, Error, PROTOCOL_VERSION}; +use crate::{ + types::block::{helper::network_name_to_id, output::RentStructure, Error, PROTOCOL_VERSION}, + utils::ConvertTo, +}; /// Defines the parameters of the protocol at a particular version. #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Packable, Getters, CopyGetters)] diff --git a/sdk/src/types/block/convert.rs b/sdk/src/utils/convert.rs similarity index 100% rename from sdk/src/types/block/convert.rs rename to sdk/src/utils/convert.rs diff --git a/sdk/src/utils/mod.rs b/sdk/src/utils/mod.rs index 9671dfe13d..1341ced35a 100644 --- a/sdk/src/utils/mod.rs +++ b/sdk/src/utils/mod.rs @@ -1,6 +1,10 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +mod convert; + pub mod merkle_hasher; #[cfg(feature = "serde")] pub mod serde; + +pub use convert::ConvertTo; diff --git a/sdk/src/wallet/operations/syncing/addresses/output_ids/account_foundry.rs b/sdk/src/wallet/operations/syncing/addresses/output_ids/account_foundry.rs index 76246b9b14..779227f649 100644 --- a/sdk/src/wallet/operations/syncing/addresses/output_ids/account_foundry.rs +++ b/sdk/src/wallet/operations/syncing/addresses/output_ids/account_foundry.rs @@ -13,9 +13,9 @@ use crate::{ block::{ address::{AccountAddress, Bech32Address, ToBech32Ext}, output::{Output, OutputId}, - ConvertTo, }, }, + utils::ConvertTo, wallet::{operations::syncing::SyncOptions, task, Wallet}, }; diff --git a/sdk/src/wallet/operations/syncing/addresses/output_ids/basic.rs b/sdk/src/wallet/operations/syncing/addresses/output_ids/basic.rs index d709c49a22..4374d0c859 100644 --- a/sdk/src/wallet/operations/syncing/addresses/output_ids/basic.rs +++ b/sdk/src/wallet/operations/syncing/addresses/output_ids/basic.rs @@ -3,7 +3,8 @@ use crate::{ client::{node_api::indexer::query_parameters::BasicOutputQueryParameters, secret::SecretManage}, - types::block::{address::Bech32Address, output::OutputId, ConvertTo}, + types::block::{address::Bech32Address, output::OutputId}, + utils::ConvertTo, wallet::Wallet, }; diff --git a/sdk/src/wallet/operations/syncing/addresses/output_ids/nft.rs b/sdk/src/wallet/operations/syncing/addresses/output_ids/nft.rs index b445d4dfd1..5430bcb009 100644 --- a/sdk/src/wallet/operations/syncing/addresses/output_ids/nft.rs +++ b/sdk/src/wallet/operations/syncing/addresses/output_ids/nft.rs @@ -3,7 +3,8 @@ use crate::{ client::{node_api::indexer::query_parameters::NftOutputQueryParameters, secret::SecretManage}, - types::block::{address::Bech32Address, output::OutputId, ConvertTo}, + types::block::{address::Bech32Address, output::OutputId}, + utils::ConvertTo, wallet::Wallet, }; diff --git a/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs b/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs index c9c4400023..b5eb4a945e 100644 --- a/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs +++ b/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs @@ -13,8 +13,8 @@ use crate::{ unlock_condition::AddressUnlockCondition, NftId, NftOutputBuilder, }, - ConvertTo, }, + utils::ConvertTo, wallet::{ operations::transaction::{TransactionOptions, TransactionWithMetadata}, Wallet, diff --git a/sdk/src/wallet/operations/transaction/high_level/send.rs b/sdk/src/wallet/operations/transaction/high_level/send.rs index 235572f0e7..dadc527e4b 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send.rs @@ -15,9 +15,8 @@ use crate::{ BasicOutputBuilder, MinimumStorageDepositBasicOutput, }, slot::SlotIndex, - ConvertTo, }, - utils::serde::string, + utils::{serde::string, ConvertTo}, wallet::{ constants::DEFAULT_EXPIRATION_SLOTS, operations::transaction::{TransactionOptions, TransactionWithMetadata}, diff --git a/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs b/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs index bf02fd7797..3f77ad9e19 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs @@ -16,8 +16,8 @@ use crate::{ BasicOutputBuilder, MinimumStorageDepositBasicOutput, NativeToken, NativeTokens, TokenId, }, slot::SlotIndex, - ConvertTo, }, + utils::ConvertTo, wallet::{ constants::DEFAULT_EXPIRATION_SLOTS, operations::transaction::{TransactionOptions, TransactionWithMetadata}, diff --git a/sdk/src/wallet/operations/transaction/high_level/send_nft.rs b/sdk/src/wallet/operations/transaction/high_level/send_nft.rs index 1eb3dc31f6..33212d22a5 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send_nft.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send_nft.rs @@ -9,8 +9,8 @@ use crate::{ types::block::{ address::Bech32Address, output::{unlock_condition::AddressUnlockCondition, NftId, NftOutputBuilder, Output}, - ConvertTo, }, + utils::ConvertTo, wallet::{ operations::transaction::{TransactionOptions, TransactionWithMetadata}, Wallet, diff --git a/sdk/src/wallet/types/address.rs b/sdk/src/wallet/types/address.rs index a1539ad157..2eced539d4 100644 --- a/sdk/src/wallet/types/address.rs +++ b/sdk/src/wallet/types/address.rs @@ -6,9 +6,12 @@ use std::hash::Hash; use getset::{Getters, Setters}; use serde::{Deserialize, Serialize}; -use crate::types::{ - self, - block::{address::Bech32Address, output::OutputId, ConvertTo}, +use crate::{ + types::{ + self, + block::{address::Bech32Address, output::OutputId}, + }, + utils::ConvertTo, }; /// A BIP44 address.