tendermint/abci/response/
check_tx.rs1use bytes::Bytes;
2use serde::{Deserialize, Serialize};
3
4use crate::abci::{Code, Event};
5use crate::prelude::*;
6use crate::serializers;
7
8#[doc = include_str!("../doc/response-checktx.md")]
9#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize)]
10pub struct CheckTx {
11 pub code: Code,
17 #[serde(with = "serializers::nullable")]
19 pub data: Bytes,
20 pub log: String,
24 pub info: String,
28 #[serde(with = "serializers::from_str")]
30 pub gas_wanted: i64,
31 #[serde(with = "serializers::from_str")]
33 pub gas_used: i64,
34 pub events: Vec<Event>,
36 pub codespace: String,
38 #[serde(default)]
40 pub sender: String,
41 #[serde(default)]
43 #[serde(with = "serializers::from_str")]
44 pub priority: i64,
45 #[serde(default)]
47 pub mempool_error: String,
48}
49
50mod v0_34 {
55 use super::CheckTx;
56 use tendermint_proto::v0_34 as pb;
57 use tendermint_proto::Protobuf;
58
59 impl From<CheckTx> for pb::abci::ResponseCheckTx {
60 fn from(check_tx: CheckTx) -> Self {
61 Self {
62 code: check_tx.code.into(),
63 data: check_tx.data,
64 log: check_tx.log,
65 info: check_tx.info,
66 gas_wanted: check_tx.gas_wanted,
67 gas_used: check_tx.gas_used,
68 events: check_tx.events.into_iter().map(Into::into).collect(),
69 codespace: check_tx.codespace,
70 sender: check_tx.sender,
71 priority: check_tx.priority,
72 mempool_error: check_tx.mempool_error,
73 }
74 }
75 }
76
77 impl TryFrom<pb::abci::ResponseCheckTx> for CheckTx {
78 type Error = crate::Error;
79
80 fn try_from(check_tx: pb::abci::ResponseCheckTx) -> Result<Self, Self::Error> {
81 Ok(Self {
82 code: check_tx.code.into(),
83 data: check_tx.data,
84 log: check_tx.log,
85 info: check_tx.info,
86 gas_wanted: check_tx.gas_wanted,
87 gas_used: check_tx.gas_used,
88 events: check_tx
89 .events
90 .into_iter()
91 .map(TryInto::try_into)
92 .collect::<Result<_, _>>()?,
93 codespace: check_tx.codespace,
94 sender: check_tx.sender,
95 priority: check_tx.priority,
96 mempool_error: check_tx.mempool_error,
97 })
98 }
99 }
100
101 impl Protobuf<pb::abci::ResponseCheckTx> for CheckTx {}
102}
103
104mod v0_37 {
105 use super::CheckTx;
106 use tendermint_proto::v0_37 as pb;
107 use tendermint_proto::Protobuf;
108
109 impl From<CheckTx> for pb::abci::ResponseCheckTx {
110 fn from(check_tx: CheckTx) -> Self {
111 Self {
112 code: check_tx.code.into(),
113 data: check_tx.data,
114 log: check_tx.log,
115 info: check_tx.info,
116 gas_wanted: check_tx.gas_wanted,
117 gas_used: check_tx.gas_used,
118 events: check_tx.events.into_iter().map(Into::into).collect(),
119 codespace: check_tx.codespace,
120 sender: check_tx.sender,
121 priority: check_tx.priority,
122 mempool_error: check_tx.mempool_error,
123 }
124 }
125 }
126
127 impl TryFrom<pb::abci::ResponseCheckTx> for CheckTx {
128 type Error = crate::Error;
129
130 fn try_from(check_tx: pb::abci::ResponseCheckTx) -> Result<Self, Self::Error> {
131 Ok(Self {
132 code: check_tx.code.into(),
133 data: check_tx.data,
134 log: check_tx.log,
135 info: check_tx.info,
136 gas_wanted: check_tx.gas_wanted,
137 gas_used: check_tx.gas_used,
138 events: check_tx
139 .events
140 .into_iter()
141 .map(TryInto::try_into)
142 .collect::<Result<_, _>>()?,
143 codespace: check_tx.codespace,
144 sender: check_tx.sender,
145 priority: check_tx.priority,
146 mempool_error: check_tx.mempool_error,
147 })
148 }
149 }
150
151 impl Protobuf<pb::abci::ResponseCheckTx> for CheckTx {}
152}
153
154mod v0_38 {
155 use super::CheckTx;
156 use tendermint_proto::v0_38 as pb;
157 use tendermint_proto::Protobuf;
158
159 impl From<CheckTx> for pb::abci::ResponseCheckTx {
160 fn from(check_tx: CheckTx) -> Self {
161 Self {
162 code: check_tx.code.into(),
163 data: check_tx.data,
164 log: check_tx.log,
165 info: check_tx.info,
166 gas_wanted: check_tx.gas_wanted,
167 gas_used: check_tx.gas_used,
168 events: check_tx.events.into_iter().map(Into::into).collect(),
169 codespace: check_tx.codespace,
170 }
171 }
172 }
173
174 impl TryFrom<pb::abci::ResponseCheckTx> for CheckTx {
175 type Error = crate::Error;
176
177 fn try_from(check_tx: pb::abci::ResponseCheckTx) -> Result<Self, Self::Error> {
178 Ok(Self {
179 code: check_tx.code.into(),
180 data: check_tx.data,
181 log: check_tx.log,
182 info: check_tx.info,
183 gas_wanted: check_tx.gas_wanted,
184 gas_used: check_tx.gas_used,
185 events: check_tx
186 .events
187 .into_iter()
188 .map(TryInto::try_into)
189 .collect::<Result<_, _>>()?,
190 codespace: check_tx.codespace,
191 sender: Default::default(),
192 priority: Default::default(),
193 mempool_error: Default::default(),
194 })
195 }
196 }
197
198 impl Protobuf<pb::abci::ResponseCheckTx> for CheckTx {}
199}