tendermint_rpc/endpoint/broadcast/
tx_commit.rs1use serde::{Deserialize, Serialize};
5
6use tendermint::{abci, block, Hash};
7
8use crate::dialect::{self, Dialect};
9use crate::{prelude::*, request::RequestMessage, serializers};
10
11#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
17pub struct Request {
18 #[serde(with = "serializers::bytes::base64string")]
20 pub tx: Vec<u8>,
21}
22
23impl Request {
24 pub fn new(tx: impl Into<Vec<u8>>) -> Request {
26 Request { tx: tx.into() }
27 }
28}
29
30impl RequestMessage for Request {
31 fn method(&self) -> crate::Method {
32 crate::Method::BroadcastTxCommit
33 }
34}
35
36impl crate::Request<dialect::v0_34::Dialect> for Request {
37 type Response = self::v0_34::DialectResponse;
38}
39
40impl crate::Request<dialect::v0_37::Dialect> for Request {
41 type Response = Response;
42}
43
44impl crate::Request<dialect::v0_38::Dialect> for Request {
45 type Response = Response;
46}
47
48impl<S: Dialect> crate::SimpleRequest<S> for Request
49where
50 Self: crate::Request<S>,
51 Response: From<Self::Response>,
52{
53 type Output = Response;
54}
55
56#[derive(Clone, Debug, Serialize, Deserialize)]
58pub struct Response {
59 pub check_tx: abci::response::CheckTx,
61
62 #[serde(alias = "deliver_tx")]
67 pub tx_result: abci::types::ExecTxResult,
68
69 pub hash: Hash,
71
72 pub height: block::Height,
74}
75
76impl crate::Response for Response {}
77
78pub mod v0_34 {
80 use super::Response;
81 use crate::dialect;
82 use crate::dialect::v0_34::Event;
83 use serde::{Deserialize, Serialize};
84 use tendermint::{block, Hash};
85
86 #[derive(Debug, Deserialize, Serialize)]
88 pub struct DialectResponse {
89 pub check_tx: dialect::CheckTx<Event>,
91
92 pub deliver_tx: dialect::DeliverTx<Event>,
94
95 pub hash: Hash,
97
98 pub height: block::Height,
100 }
101
102 impl crate::Response for DialectResponse {}
103
104 impl From<DialectResponse> for Response {
105 fn from(msg: DialectResponse) -> Self {
106 Self {
107 check_tx: msg.check_tx.into(),
108 tx_result: msg.deliver_tx.into(),
109 hash: msg.hash,
110 height: msg.height,
111 }
112 }
113 }
114}
115
116pub mod v0_37 {
118 use super::Response;
119 use crate::dialect;
120 use serde::{Deserialize, Serialize};
121 use tendermint::{abci::Event, block, Hash};
122
123 #[derive(Debug, Deserialize, Serialize)]
125 pub struct DialectResponse {
126 pub check_tx: dialect::CheckTx<Event>,
128
129 pub deliver_tx: dialect::DeliverTx<Event>,
131
132 pub hash: Hash,
134
135 pub height: block::Height,
137 }
138
139 impl crate::Response for DialectResponse {}
140
141 impl From<DialectResponse> for Response {
142 fn from(msg: DialectResponse) -> Self {
143 Self {
144 check_tx: msg.check_tx.into(),
145 tx_result: msg.deliver_tx.into(),
146 hash: msg.hash,
147 height: msg.height,
148 }
149 }
150 }
151}