1use super::{Fee, SignerInfo};
4use crate::{
5 proto::{self, traits::MessageExt},
6 Error, ErrorReport, Result,
7};
8
9#[derive(Clone, Debug, Eq, PartialEq)]
12pub struct AuthInfo {
13 pub signer_infos: Vec<SignerInfo>,
19
20 pub fee: Fee,
26}
27
28impl AuthInfo {
29 pub fn into_proto(self) -> proto::cosmos::tx::v1beta1::AuthInfo {
31 self.into()
32 }
33
34 pub fn into_bytes(self) -> Result<Vec<u8>> {
36 Ok(self.into_proto().to_bytes()?)
37 }
38}
39
40impl TryFrom<proto::cosmos::tx::v1beta1::AuthInfo> for AuthInfo {
41 type Error = ErrorReport;
42
43 fn try_from(proto: proto::cosmos::tx::v1beta1::AuthInfo) -> Result<AuthInfo> {
44 Ok(AuthInfo {
45 signer_infos: proto
46 .signer_infos
47 .into_iter()
48 .map(TryFrom::try_from)
49 .collect::<Result<_, _>>()?,
50 fee: proto
51 .fee
52 .ok_or(Error::MissingField { name: "fee" })?
53 .try_into()?,
54 })
55 }
56}
57
58impl From<AuthInfo> for proto::cosmos::tx::v1beta1::AuthInfo {
59 fn from(auth_info: AuthInfo) -> proto::cosmos::tx::v1beta1::AuthInfo {
60 #[allow(deprecated)] proto::cosmos::tx::v1beta1::AuthInfo {
62 signer_infos: auth_info.signer_infos.into_iter().map(Into::into).collect(),
63 fee: Some(auth_info.fee.into()),
64 tip: None,
65 }
66 }
67}