penumbra_sdk_stake/
current_consensus_keys.rs1use anyhow::Result;
2use penumbra_sdk_proto::{penumbra::core::component::stake::v1 as pb, DomainType};
3use serde::{Deserialize, Serialize};
4use tendermint::PublicKey;
5
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
9#[serde(
10 try_from = "pb::CurrentConsensusKeys",
11 into = "pb::CurrentConsensusKeys"
12)]
13pub struct CurrentConsensusKeys {
14 pub consensus_keys: Vec<PublicKey>,
15}
16
17impl DomainType for CurrentConsensusKeys {
18 type Proto = pb::CurrentConsensusKeys;
19}
20
21impl From<CurrentConsensusKeys> for pb::CurrentConsensusKeys {
22 fn from(value: CurrentConsensusKeys) -> pb::CurrentConsensusKeys {
23 pb::CurrentConsensusKeys {
24 consensus_keys: value.consensus_keys.into_iter().map(Into::into).collect(),
25 }
26 }
27}
28
29impl TryFrom<pb::CurrentConsensusKeys> for CurrentConsensusKeys {
30 type Error = anyhow::Error;
31 fn try_from(value: pb::CurrentConsensusKeys) -> Result<CurrentConsensusKeys> {
32 Ok(CurrentConsensusKeys {
33 consensus_keys: value
34 .consensus_keys
35 .into_iter()
36 .map(TryInto::try_into)
37 .collect::<Result<_>>()?,
38 })
39 }
40}