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)]
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}
19
20impl DomainType for AuthorizationData {
21 type Proto = pb::AuthorizationData;
22}
23
24impl From<AuthorizationData> for pb::AuthorizationData {
25 fn from(msg: AuthorizationData) -> Self {
26 Self {
27 effect_hash: msg.effect_hash.map(Into::into),
28 spend_auths: msg.spend_auths.into_iter().map(Into::into).collect(),
29 delegator_vote_auths: msg
30 .delegator_vote_auths
31 .into_iter()
32 .map(Into::into)
33 .collect(),
34 }
35 }
36}
37
38impl TryFrom<pb::AuthorizationData> for AuthorizationData {
39 type Error = anyhow::Error;
40 fn try_from(value: pb::AuthorizationData) -> Result<Self, Self::Error> {
41 Ok(Self {
42 effect_hash: value.effect_hash.map(TryInto::try_into).transpose()?,
43 spend_auths: value
44 .spend_auths
45 .into_iter()
46 .map(TryInto::try_into)
47 .collect::<Result<_, _>>()?,
48 delegator_vote_auths: value
49 .delegator_vote_auths
50 .into_iter()
51 .map(TryInto::try_into)
52 .collect::<Result<_, _>>()?,
53 })
54 }
55}