1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use super::{Fee, SignerInfo};
use crate::{prost_ext::MessageExt, proto, Error, ErrorReport, Result};
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AuthInfo {
pub signer_infos: Vec<SignerInfo>,
pub fee: Fee,
}
impl AuthInfo {
pub fn into_proto(self) -> proto::cosmos::tx::v1beta1::AuthInfo {
self.into()
}
pub fn into_bytes(self) -> Result<Vec<u8>> {
self.into_proto().to_bytes()
}
}
impl TryFrom<proto::cosmos::tx::v1beta1::AuthInfo> for AuthInfo {
type Error = ErrorReport;
fn try_from(proto: proto::cosmos::tx::v1beta1::AuthInfo) -> Result<AuthInfo> {
Ok(AuthInfo {
signer_infos: proto
.signer_infos
.into_iter()
.map(TryFrom::try_from)
.collect::<Result<_, _>>()?,
fee: proto
.fee
.ok_or(Error::MissingField { name: "fee" })?
.try_into()?,
})
}
}
impl From<AuthInfo> for proto::cosmos::tx::v1beta1::AuthInfo {
fn from(auth_info: AuthInfo) -> proto::cosmos::tx::v1beta1::AuthInfo {
proto::cosmos::tx::v1beta1::AuthInfo {
signer_infos: auth_info.signer_infos.into_iter().map(Into::into).collect(),
fee: Some(auth_info.fee.into()),
}
}
}