1use near_account_id::AccountId;
2
3#[derive(Debug, Clone, thiserror::Error)]
4pub enum ParseKeyTypeError {
5 #[error("unknown key type '{unknown_key_type}'")]
6 UnknownKeyType { unknown_key_type: String },
7}
8
9#[derive(Debug, Clone, thiserror::Error)]
10pub enum ParseKeyError {
11 #[error("unknown key type '{unknown_key_type}'")]
12 UnknownKeyType { unknown_key_type: String },
13 #[error("invalid key length: expected the input of {expected_length} bytes, but {received_length} was given")]
14 InvalidLength { expected_length: usize, received_length: usize },
15 #[error("invalid key data: {error_message}")]
16 InvalidData { error_message: String },
17}
18
19impl From<ParseKeyTypeError> for ParseKeyError {
20 fn from(err: ParseKeyTypeError) -> Self {
21 match err {
22 ParseKeyTypeError::UnknownKeyType { unknown_key_type } => {
23 Self::UnknownKeyType { unknown_key_type }
24 }
25 }
26 }
27}
28
29#[derive(Debug, Clone, thiserror::Error)]
30pub enum ParseSignatureError {
31 #[error("unknown key type '{unknown_key_type}'")]
32 UnknownKeyType { unknown_key_type: String },
33 #[error("invalid signature length: expected the input of {expected_length} bytes, but {received_length} was given")]
34 InvalidLength { expected_length: usize, received_length: usize },
35 #[error("invalid signature data: {error_message}")]
36 InvalidData { error_message: String },
37}
38
39impl From<ParseKeyTypeError> for ParseSignatureError {
40 fn from(err: ParseKeyTypeError) -> Self {
41 match err {
42 ParseKeyTypeError::UnknownKeyType { unknown_key_type } => {
43 Self::UnknownKeyType { unknown_key_type }
44 }
45 }
46 }
47}
48
49#[derive(Debug, Clone, thiserror::Error)]
50pub enum ImplicitPublicKeyError {
51 #[error("'{account_id}' is not a NEAR-implicit account")]
52 AccountIsNotNearImplicit { account_id: AccountId },
53}