penumbra_transaction/
auth_data.rsuse decaf377_rdsa::{Signature, SpendAuth};
use penumbra_proto::{core::transaction::v1 as pb, DomainType};
use penumbra_txhash::EffectHash;
#[derive(Clone, Debug)]
pub struct AuthorizationData {
pub effect_hash: Option<EffectHash>,
pub spend_auths: Vec<Signature<SpendAuth>>,
pub delegator_vote_auths: Vec<Signature<SpendAuth>>,
}
impl DomainType for AuthorizationData {
type Proto = pb::AuthorizationData;
}
impl From<AuthorizationData> for pb::AuthorizationData {
fn from(msg: AuthorizationData) -> Self {
Self {
effect_hash: msg.effect_hash.map(Into::into),
spend_auths: msg.spend_auths.into_iter().map(Into::into).collect(),
delegator_vote_auths: msg
.delegator_vote_auths
.into_iter()
.map(Into::into)
.collect(),
}
}
}
impl TryFrom<pb::AuthorizationData> for AuthorizationData {
type Error = anyhow::Error;
fn try_from(value: pb::AuthorizationData) -> Result<Self, Self::Error> {
Ok(Self {
effect_hash: value.effect_hash.map(TryInto::try_into).transpose()?,
spend_auths: value
.spend_auths
.into_iter()
.map(TryInto::try_into)
.collect::<Result<_, _>>()?,
delegator_vote_auths: value
.delegator_vote_auths
.into_iter()
.map(TryInto::try_into)
.collect::<Result<_, _>>()?,
})
}
}