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