From 9cdf2294cdd7f37ded53cd2b6d40673d70bda58f Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Thu, 19 Oct 2023 19:25:48 +0200 Subject: [PATCH] Remove unused API core error (#1469) * Remove unused API core error * Remove comment --- bindings/core/src/method_handler/client.rs | 2 +- bindings/core/src/response.rs | 2 +- .../block/01_block_confirmation_time.rs | 2 +- sdk/src/client/error.rs | 3 -- sdk/src/client/node_api/core/routes.rs | 2 +- sdk/src/client/node_manager/builder.rs | 2 +- sdk/src/client/node_manager/mod.rs | 2 +- sdk/src/client/node_manager/syncing.rs | 2 +- .../types/api/{core/response.rs => core.rs} | 0 sdk/src/types/api/core/error.rs | 28 ------------------- sdk/src/types/api/core/mod.rs | 7 ----- sdk/src/wallet/account/mod.rs | 2 +- sdk/src/wallet/account/operations/reissue.rs | 2 +- .../account/operations/syncing/outputs.rs | 2 +- .../operations/syncing/transactions.rs | 2 +- .../account/operations/transaction/mod.rs | 2 +- sdk/src/wallet/account/types/mod.rs | 2 +- sdk/src/wallet/account/update.rs | 2 +- sdk/src/wallet/events/types.rs | 2 +- sdk/tests/client/node_api/core.rs | 2 +- 20 files changed, 16 insertions(+), 54 deletions(-) rename sdk/src/types/api/{core/response.rs => core.rs} (100%) delete mode 100644 sdk/src/types/api/core/error.rs delete mode 100644 sdk/src/types/api/core/mod.rs diff --git a/bindings/core/src/method_handler/client.rs b/bindings/core/src/method_handler/client.rs index 5c1845d46d..89fab444d6 100644 --- a/bindings/core/src/method_handler/client.rs +++ b/bindings/core/src/method_handler/client.rs @@ -6,7 +6,7 @@ use iota_sdk::client::mqtt::{MqttPayload, Topic}; use iota_sdk::{ client::{request_funds_from_faucet, secret::SecretManager, Client}, types::{ - api::core::response::OutputWithMetadataResponse, + api::core::OutputWithMetadataResponse, block::{ output::{ dto::OutputDto, AccountOutput, BasicOutput, FoundryOutput, NftOutput, Output, OutputBuilderAmount, Rent, diff --git a/bindings/core/src/response.rs b/bindings/core/src/response.rs index 693bee2335..805e07b7a6 100644 --- a/bindings/core/src/response.rs +++ b/bindings/core/src/response.rs @@ -15,7 +15,7 @@ use iota_sdk::{ }, types::{ api::{ - core::response::{ + core::{ BlockMetadataResponse, InfoResponse as NodeInfo, IssuanceBlockHeaderResponse, OutputWithMetadataResponse, PeerResponse, }, diff --git a/sdk/examples/client/block/01_block_confirmation_time.rs b/sdk/examples/client/block/01_block_confirmation_time.rs index 6b6b961dc8..889fe159bc 100644 --- a/sdk/examples/client/block/01_block_confirmation_time.rs +++ b/sdk/examples/client/block/01_block_confirmation_time.rs @@ -11,7 +11,7 @@ use crypto::keys::bip44::Bip44; use iota_sdk::{ client::{constants::IOTA_COIN_TYPE, secret::SecretManager, Client, Result}, - types::api::core::response::BlockState, + types::api::core::BlockState, }; #[tokio::main] diff --git a/sdk/src/client/error.rs b/sdk/src/client/error.rs index d78ed8dc42..0ecf9e91de 100644 --- a/sdk/src/client/error.rs +++ b/sdk/src/client/error.rs @@ -22,9 +22,6 @@ pub type Result = std::result::Result; /// Error type of the iota client crate. #[derive(Debug, thiserror::Error)] pub enum Error { - /// Block dtos error - #[error("{0}")] - ApiTypes(#[from] crate::types::api::core::error::Error), /// Invalid bech32 HRP, should match the one from the used network #[error("invalid bech32 hrp for the connected network: {provided}, expected: {expected}")] Bech32HrpMismatch { diff --git a/sdk/src/client/node_api/core/routes.rs b/sdk/src/client/node_api/core/routes.rs index b19da9631f..57aab9e23d 100644 --- a/sdk/src/client/node_api/core/routes.rs +++ b/sdk/src/client/node_api/core/routes.rs @@ -15,7 +15,7 @@ use crate::{ Client, ClientInner, Result, }, types::{ - api::core::response::{ + api::core::{ BlockMetadataResponse, CommitteeResponse, CongestionResponse, InfoResponse, IssuanceBlockHeaderResponse, ManaRewardsResponse, PeerResponse, RoutesResponse, SubmitBlockResponse, UtxoChangesResponse, ValidatorResponse, ValidatorsResponse, diff --git a/sdk/src/client/node_manager/builder.rs b/sdk/src/client/node_manager/builder.rs index 75857da452..69b1d54b3d 100644 --- a/sdk/src/client/node_manager/builder.rs +++ b/sdk/src/client/node_manager/builder.rs @@ -22,7 +22,7 @@ use crate::{ NodeManager, }, }, - types::api::core::response::InfoResponse, + types::api::core::InfoResponse, }; /// Node manager builder diff --git a/sdk/src/client/node_manager/mod.rs b/sdk/src/client/node_manager/mod.rs index 08c4e364f9..01b1421e27 100644 --- a/sdk/src/client/node_manager/mod.rs +++ b/sdk/src/client/node_manager/mod.rs @@ -28,7 +28,7 @@ use crate::{ error::{Error, Result}, node_manager::builder::NodeManagerBuilder, }, - types::api::core::response::InfoResponse, + types::api::core::InfoResponse, }; // The node manager takes care of selecting node(s) for requests until a result is returned or if quorum is enabled it diff --git a/sdk/src/client/node_manager/syncing.rs b/sdk/src/client/node_manager/syncing.rs index 35cccf6bd7..e57199ad3f 100644 --- a/sdk/src/client/node_manager/syncing.rs +++ b/sdk/src/client/node_manager/syncing.rs @@ -3,7 +3,7 @@ #[cfg(not(target_family = "wasm"))] use { - crate::types::api::core::response::InfoResponse, + crate::types::api::core::InfoResponse, crate::types::block::PROTOCOL_VERSION, std::{collections::HashSet, time::Duration}, tokio::time::sleep, diff --git a/sdk/src/types/api/core/response.rs b/sdk/src/types/api/core.rs similarity index 100% rename from sdk/src/types/api/core/response.rs rename to sdk/src/types/api/core.rs diff --git a/sdk/src/types/api/core/error.rs b/sdk/src/types/api/core/error.rs deleted file mode 100644 index 1954f7d6b7..0000000000 --- a/sdk/src/types/api/core/error.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2020-2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use crate::types::block::Error as BlockError; - -#[derive(Debug)] -pub enum Error { - InvalidField(&'static str), - Block(BlockError), -} - -impl core::fmt::Display for Error { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Self::InvalidField(field) => write!(f, "invalid field \"{field}\""), - Self::Block(error) => write!(f, "{error}"), - } - } -} - -impl From for Error { - fn from(error: BlockError) -> Self { - Self::Block(error) - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error {} diff --git a/sdk/src/types/api/core/mod.rs b/sdk/src/types/api/core/mod.rs deleted file mode 100644 index dea8ed459a..0000000000 --- a/sdk/src/types/api/core/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2020-2023 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -//! Core API-related types like responses and DTOs. - -pub mod error; -pub mod response; diff --git a/sdk/src/wallet/account/mod.rs b/sdk/src/wallet/account/mod.rs index 5da357fcd5..42237b0251 100644 --- a/sdk/src/wallet/account/mod.rs +++ b/sdk/src/wallet/account/mod.rs @@ -60,7 +60,7 @@ use crate::{ Client, }, types::{ - api::core::response::OutputWithMetadataResponse, + api::core::OutputWithMetadataResponse, block::{ address::Bech32Address, output::{dto::FoundryOutputDto, AccountId, FoundryId, FoundryOutput, NftId, Output, OutputId, TokenId}, diff --git a/sdk/src/wallet/account/operations/reissue.rs b/sdk/src/wallet/account/operations/reissue.rs index 54c93a4f42..86d51f4ef4 100644 --- a/sdk/src/wallet/account/operations/reissue.rs +++ b/sdk/src/wallet/account/operations/reissue.rs @@ -6,7 +6,7 @@ use crypto::keys::bip44::Bip44; use crate::{ client::{secret::SecretManage, Error as ClientError}, types::{ - api::core::response::{BlockState, TransactionState}, + api::core::{BlockState, TransactionState}, block::{ payload::{transaction::TransactionId, Payload}, BlockId, diff --git a/sdk/src/wallet/account/operations/syncing/outputs.rs b/sdk/src/wallet/account/operations/syncing/outputs.rs index 74d7ebca9c..a3db4553cb 100644 --- a/sdk/src/wallet/account/operations/syncing/outputs.rs +++ b/sdk/src/wallet/account/operations/syncing/outputs.rs @@ -7,7 +7,7 @@ use instant::Instant; use crate::{ client::{secret::SecretManage, Client, Error as ClientError}, types::{ - api::core::response::OutputWithMetadataResponse, + api::core::OutputWithMetadataResponse, block::{ core::{BasicBlock, Block}, input::Input, diff --git a/sdk/src/wallet/account/operations/syncing/transactions.rs b/sdk/src/wallet/account/operations/syncing/transactions.rs index 028ab8ecf4..f6bcccfc9c 100644 --- a/sdk/src/wallet/account/operations/syncing/transactions.rs +++ b/sdk/src/wallet/account/operations/syncing/transactions.rs @@ -4,7 +4,7 @@ use crate::{ client::{secret::SecretManage, unix_timestamp_now}, types::{ - api::core::response::TransactionState, + api::core::TransactionState, block::{input::Input, output::OutputId, BlockId}, }, wallet::account::{ diff --git a/sdk/src/wallet/account/operations/transaction/mod.rs b/sdk/src/wallet/account/operations/transaction/mod.rs index 4a88d21660..3211e869f5 100644 --- a/sdk/src/wallet/account/operations/transaction/mod.rs +++ b/sdk/src/wallet/account/operations/transaction/mod.rs @@ -18,7 +18,7 @@ use crate::{ Error, }, types::{ - api::core::response::OutputWithMetadataResponse, + api::core::OutputWithMetadataResponse, block::{ output::{dto::OutputDto, Output}, payload::transaction::TransactionPayload, diff --git a/sdk/src/wallet/account/types/mod.rs b/sdk/src/wallet/account/types/mod.rs index da4f52ba0d..5d8dc49664 100644 --- a/sdk/src/wallet/account/types/mod.rs +++ b/sdk/src/wallet/account/types/mod.rs @@ -19,7 +19,7 @@ pub use self::{ use crate::{ client::secret::types::InputSigningData, types::{ - api::core::response::OutputWithMetadataResponse, + api::core::OutputWithMetadataResponse, block::{ address::Address, output::{dto::OutputDto, AccountTransition, Output, OutputId, OutputMetadata}, diff --git a/sdk/src/wallet/account/update.rs b/sdk/src/wallet/account/update.rs index 0e6ac761e8..3e3a58603b 100644 --- a/sdk/src/wallet/account/update.rs +++ b/sdk/src/wallet/account/update.rs @@ -14,7 +14,7 @@ use crate::{ }; #[cfg(feature = "events")] use crate::{ - types::{api::core::response::OutputWithMetadataResponse, block::payload::transaction::dto::TransactionPayloadDto}, + types::{api::core::OutputWithMetadataResponse, block::payload::transaction::dto::TransactionPayloadDto}, wallet::{ account::types::OutputDataDto, events::types::{NewOutputEvent, SpentOutputEvent, TransactionInclusionEvent, WalletEvent}, diff --git a/sdk/src/wallet/events/types.rs b/sdk/src/wallet/events/types.rs index e6239396f3..22307e2220 100644 --- a/sdk/src/wallet/events/types.rs +++ b/sdk/src/wallet/events/types.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize, Serializer}; use crate::{ client::api::PreparedTransactionDataDto, types::{ - api::core::response::OutputWithMetadataResponse, + api::core::OutputWithMetadataResponse, block::{ address::Bech32Address, payload::transaction::{dto::TransactionPayloadDto, TransactionId}, diff --git a/sdk/tests/client/node_api/core.rs b/sdk/tests/client/node_api/core.rs index b44bae435a..7fb51f1271 100644 --- a/sdk/tests/client/node_api/core.rs +++ b/sdk/tests/client/node_api/core.rs @@ -6,7 +6,7 @@ use iota_sdk::{ client::{api::GetAddressesOptions, node_api::indexer::query_parameters::QueryParameter, Client, NodeInfoWrapper}, types::{ - api::core::response::TransactionState, + api::core::TransactionState, block::{ output::{Output, OutputId}, BlockWrapper,