tendermint/public_key/
pub_key_response.rs

1use crate::{privval::RemoteSignerError, PublicKey};
2
3/// PubKeyResponse
4#[derive(Clone, PartialEq, Eq, Debug)]
5// Todo: either pub_key OR error is present
6pub struct PubKeyResponse {
7    /// Public key
8    pub pub_key: Option<PublicKey>,
9
10    /// Error
11    pub error: Option<RemoteSignerError>,
12}
13
14// =============================================================================
15// Protobuf conversions
16// =============================================================================
17
18tendermint_pb_modules! {
19    use super::PubKeyResponse;
20    use pb::privval::PubKeyResponse as RawPubKeyResponse;
21
22    impl Protobuf<RawPubKeyResponse> for PubKeyResponse {}
23
24    impl TryFrom<RawPubKeyResponse> for PubKeyResponse {
25        type Error = crate::Error;
26
27        fn try_from(value: RawPubKeyResponse) -> Result<Self, Self::Error> {
28            Ok(PubKeyResponse {
29                pub_key: value.pub_key.map(TryInto::try_into).transpose()?,
30                error: value.error.map(TryInto::try_into).transpose()?,
31            })
32        }
33    }
34
35    impl From<PubKeyResponse> for RawPubKeyResponse {
36        fn from(value: PubKeyResponse) -> Self {
37            RawPubKeyResponse {
38                pub_key: value.pub_key.map(Into::into),
39                error: value.error.map(Into::into),
40            }
41        }
42    }
43}
44// Todo: write unit test