etopay_sdk/wallet/
error.rs1use super::{kdbx::KdbxStorageError, share::ShareError};
2use crate::{backend::error::ApiError, types::error::TypeError, user::error::UserKvStorageError};
3use iota_sdk::types::block;
4use serde::Serialize;
5
6pub type Result<T> = core::result::Result<T, WalletError>;
8
9#[derive(Debug, Serialize, PartialEq, Clone, Copy)]
10pub enum ErrorKind {
12 MissingPassword,
14 SetRecoveryShare,
16 UseMnemonic,
18}
19
20#[derive(thiserror::Error, Debug)]
22pub enum WalletError {
23 #[error("IotaClient error: {0}")]
25 IotaClient(#[from] iota_sdk::client::Error),
26
27 #[error("Password is missing")]
29 MissingPassword,
30
31 #[error("Pin or password incorrect.")]
33 WrongPinOrPassword,
34
35 #[error("Wallet init error: {0:?}")]
37 WalletNotInitialized(ErrorKind),
38
39 #[error("Wallet feature is not implemented")]
41 WalletFeatureNotImplemented,
42
43 #[error("Unauthorized: Missing Access Token")]
45 MissingAccessToken,
46
47 #[error("Wallet address is empty")]
49 EmptyWalletAddress,
50
51 #[error("ParseError: {0}")]
53 Parse(String),
54
55 #[error("Alloy RPC error: {0}")]
57 Rpc(String),
58
59 #[error("InvalidTransactionAmount: {0}")]
61 InvalidTransactionAmount(String),
62
63 #[error("InvalidTransaction: {0}")]
65 InvalidTransaction(String),
66
67 #[error("InsufficientBalanceError: {0}")]
69 InsufficientBalance(String),
70
71 #[error("Decimal error: {0}")]
73 Decimal(rust_decimal::Error),
74
75 #[error("Block error: {0}")]
77 Block(#[from] block::Error),
78
79 #[error("IotaWallet error: {0}")]
81 IotaWallet(#[from] iota_sdk::wallet::Error),
82
83 #[error("KdbxStorage error: {0}")]
85 KdbxStorage(#[from] KdbxStorageError),
86
87 #[error("Type errors: {0}")]
89 Type(#[from] TypeError),
90
91 #[error("User repository error: {0}")]
93 UserRepository(#[from] UserKvStorageError),
94
95 #[error("Share error: {0}")]
97 Share(#[from] ShareError),
98
99 #[error("Bip39 error: {0:?}")]
101 Bip39(iota_sdk::crypto::keys::bip39::Error),
102
103 #[error("BackendApi errors: {0}")]
105 BackendApi(#[from] ApiError),
106
107 #[error("LocalSignerError: {0}")]
109 LocalSignerError(#[from] alloy::signers::local::LocalSignerError),
110
111 #[error("PendingTransactionError: {0}")]
113 PendingTransactionError(#[from] alloy::providers::PendingTransactionError),
114
115 #[error("Invalid hex value: {0}")]
117 FromHexError(#[from] alloy_primitives::hex::FromHexError),
118
119 #[error("Alloy transport RPC error: {0}")]
121 AlloyTransportRpcError(#[from] alloy_json_rpc::RpcError<alloy_transport::TransportErrorKind>),
122
123 #[error("TransactionNotFound")]
125 TransactionNotFound,
126
127 #[error("Unable to convert: {0}")]
129 ConversionError(String),
130
131 #[error("Contract error: {0}")]
133 Contract(#[from] alloy::contract::Error),
134
135 #[error("SolidityError error: {0}")]
137 SolidityError(#[from] alloy::sol_types::Error),
138}
139
140impl From<iota_sdk::crypto::keys::bip39::Error> for WalletError {
141 fn from(value: iota_sdk::crypto::keys::bip39::Error) -> Self {
142 Self::Bip39(value)
143 }
144}
145
146impl From<rust_decimal::Error> for WalletError {
147 fn from(value: rust_decimal::Error) -> Self {
148 Self::Decimal(value)
149 }
150}