cometbft_rpc/endpoint/
tx.rs1use cometbft::{abci, block, tx, Hash};
4use serde::{Deserialize, Serialize};
5
6use crate::dialect::{self, Dialect};
7use crate::{prelude::*, request::RequestMessage, serializers, Method};
8
9#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
11pub struct Request {
12 #[serde(with = "serializers::tx_hash_base64")]
17 pub hash: Hash,
18 pub prove: bool,
21}
22
23impl Request {
24 pub fn new(hash: Hash, prove: bool) -> Self {
26 Self { hash, prove }
27 }
28}
29
30impl RequestMessage for Request {
31 fn method(&self) -> Method {
32 Method::Tx
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)]
53pub struct Response {
54 pub hash: Hash,
60 pub height: block::Height,
61 pub index: u32,
62 pub tx_result: abci::types::ExecTxResult,
63 #[serde(with = "serializers::bytes::base64string")]
64 pub tx: Vec<u8>,
65 #[serde(skip_serializing_if = "Option::is_none")]
66 pub proof: Option<tx::Proof>,
67}
68
69impl crate::Response for Response {}
70
71pub mod v0_34 {
73 use super::Response;
74 use crate::dialect::v0_34::Event;
75 use crate::prelude::*;
76 use crate::{dialect, serializers};
77 use cometbft::{block, tx, Hash};
78 use serde::{Deserialize, Serialize};
79
80 #[derive(Debug, Deserialize, Serialize)]
82 pub struct DialectResponse {
83 pub hash: Hash,
89 pub height: block::Height,
90 pub index: u32,
91 pub tx_result: dialect::DeliverTx<Event>,
92 #[serde(with = "serializers::bytes::base64string")]
93 pub tx: Vec<u8>,
94 #[serde(skip_serializing_if = "Option::is_none")]
95 pub proof: Option<tx::Proof>,
96 }
97
98 impl crate::Response for DialectResponse {}
99
100 impl From<DialectResponse> for Response {
101 fn from(msg: DialectResponse) -> Self {
102 Self {
103 hash: msg.hash,
104 height: msg.height,
105 index: msg.index,
106 tx_result: msg.tx_result.into(),
107 tx: msg.tx,
108 proof: msg.proof,
109 }
110 }
111 }
112}