cometbft_rpc/endpoint/broadcast/
tx_commit.rs1use serde::{Deserialize, Serialize};
5
6use cometbft::{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::v1::Dialect> for Request {
41 type Response = Response;
42}
43
44impl<S: Dialect> crate::SimpleRequest<S> for Request
45where
46 Self: crate::Request<S>,
47 Response: From<Self::Response>,
48{
49 type Output = Response;
50}
51
52#[derive(Clone, Debug, Serialize, Deserialize)]
54pub struct Response {
55 pub check_tx: abci::response::CheckTx,
57
58 #[serde(alias = "deliver_tx")]
63 pub tx_result: abci::types::ExecTxResult,
64
65 pub hash: Hash,
67
68 pub height: block::Height,
70}
71
72impl crate::Response for Response {}
73
74pub mod v0_34 {
76 use super::Response;
77 use crate::dialect;
78 use crate::dialect::v0_34::Event;
79 use cometbft::{block, Hash};
80 use serde::{Deserialize, Serialize};
81
82 #[derive(Debug, Deserialize, Serialize)]
84 pub struct DialectResponse {
85 pub check_tx: dialect::CheckTx<Event>,
87
88 pub deliver_tx: dialect::DeliverTx<Event>,
90
91 pub hash: Hash,
93
94 pub height: block::Height,
96 }
97
98 impl crate::Response for DialectResponse {}
99
100 impl From<DialectResponse> for Response {
101 fn from(msg: DialectResponse) -> Self {
102 Self {
103 check_tx: msg.check_tx.into(),
104 tx_result: msg.deliver_tx.into(),
105 hash: msg.hash,
106 height: msg.height,
107 }
108 }
109 }
110}