penumbra_sdk_transaction/
auth_data.rs1use decaf377_rdsa::{Signature, SpendAuth};
2
3use penumbra_sdk_proto::{core::transaction::v1 as pb, DomainType};
4use penumbra_sdk_txhash::EffectHash;
5
6#[derive(Clone, Debug, Default)]
9pub struct AuthorizationData {
10 pub effect_hash: Option<EffectHash>,
12 pub spend_auths: Vec<Signature<SpendAuth>>,
15 pub delegator_vote_auths: Vec<Signature<SpendAuth>>,
18 pub lqt_vote_auths: Vec<Signature<SpendAuth>>,
21}
22
23impl DomainType for AuthorizationData {
24 type Proto = pb::AuthorizationData;
25}
26
27impl From<AuthorizationData> for pb::AuthorizationData {
28 fn from(msg: AuthorizationData) -> Self {
29 Self {
30 effect_hash: msg.effect_hash.map(Into::into),
31 spend_auths: msg.spend_auths.into_iter().map(Into::into).collect(),
32 delegator_vote_auths: msg
33 .delegator_vote_auths
34 .into_iter()
35 .map(Into::into)
36 .collect(),
37 lqt_vote_auths: msg.lqt_vote_auths.into_iter().map(Into::into).collect(),
38 }
39 }
40}
41
42impl TryFrom<pb::AuthorizationData> for AuthorizationData {
43 type Error = anyhow::Error;
44 fn try_from(value: pb::AuthorizationData) -> Result<Self, Self::Error> {
45 Ok(Self {
46 effect_hash: value.effect_hash.map(TryInto::try_into).transpose()?,
47 spend_auths: value
48 .spend_auths
49 .into_iter()
50 .map(TryInto::try_into)
51 .collect::<Result<_, _>>()?,
52 delegator_vote_auths: value
53 .delegator_vote_auths
54 .into_iter()
55 .map(TryInto::try_into)
56 .collect::<Result<_, _>>()?,
57 lqt_vote_auths: value
58 .lqt_vote_auths
59 .into_iter()
60 .map(TryInto::try_into)
61 .collect::<Result<_, _>>()?,
62 })
63 }
64}