1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
use crate::;
use ecdsa;
use Error;
/// Errors that may occur within wallet operations.
///
/// This enum encompasses a range of errors that can arise when interacting with
/// cryptocurrency wallets, including but not limited to account state issues, cryptographic
/// errors, and IO operations. It is designed to be comprehensive, covering errors
/// from underlying libraries (such as ECDSA operations, hex encoding/decoding) as well
/// as wallet-specific errors like missing key pairs or default accounts.
///
/// # Variants
///
/// - `AccountState`: Represents errors related to an account's state, such as when an account
/// cannot be found or is in an invalid state for the requested operation.
/// - `NoKeyPair`: Indicates that a key pair was expected but none was found.
/// - `EcdsaError`: Wraps errors from the `ecdsa` crate, typically related to signature operations.
/// - `HexError`: Wraps errors from the `hex` crate, often arising during hex encoding or decoding.
/// - `IoError`: Wraps standard IO errors that might occur during file operations.
/// - `NoDefaultAccount`: Signals that a default account was expected but not set.
/// - `InvalidKeyPair`: General error for when a key pair is invalid or fails validation.
/// - `CryptoError`: Wraps cryptographic errors, potentially from operations like hashing or encryption.
/// - `TransactionError`: Encapsulates errors that may occur during transaction creation or processing.
/// - `BuilderError`: Wraps errors that occur during the construction of complex objects, possibly due to invalid parameters.
/// - `DecryptionError`: Indicates an error occurred during account decryption.
/// - `SigningError`: Indicates an error occurred during transaction signing.
/// - `FileError`: Indicates an error occurred during file operations.
/// - `ParseError`: Indicates an error occurred during parsing operations.
/// - `ImportError`: Indicates an error occurred during key import operations.
/// - `InvalidPassword`: Indicates that an invalid password was provided.
/// - `NoAccounts`: Indicates that no accounts were found in the wallet.
/// - `YubiHsmError`: Wraps errors related to YubiHSM operations.
/// - `ProviderError`: Wraps errors from the RPC provider.
///
/// # Examples
///
/// Handling a `WalletError` might look like this:
///
/// ```
/// # use neo3::prelude::*;
/// # fn main() -> Result<(), wallets::WalletError> {
/// let result = some_wallet_operation();
/// match result {
/// Ok(_) => println!("Operation successful"),
/// Err(wallets::WalletError::NoKeyPair) => println!("Key pair missing"),
/// Err(e) => println!("An error occurred: {:?}", e),
/// }
/// # Ok(())
/// # }
/// # fn some_wallet_operation() -> Result<(), wallets::WalletError> {
/// # Err(wallets::WalletError::NoKeyPair)
/// # }
/// ```
///
/// This approach allows for precise error handling and reporting, facilitating debugging and user feedback.