tendermint_rpc/endpoint/
tx.rs1use serde::{Deserialize, Serialize};
4use tendermint::{abci, block, tx, Hash};
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::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)]
57pub struct Response {
58 pub hash: Hash,
64 pub height: block::Height,
65 pub index: u32,
66 pub tx_result: abci::types::ExecTxResult,
67 #[serde(with = "serializers::bytes::base64string")]
68 pub tx: Vec<u8>,
69 #[serde(skip_serializing_if = "Option::is_none")]
70 pub proof: Option<tx::Proof>,
71}
72
73impl crate::Response for Response {}
74
75pub mod v0_34 {
77 use super::Response;
78 use crate::dialect::v0_34::Event;
79 use crate::prelude::*;
80 use crate::{dialect, serializers};
81 use serde::{Deserialize, Serialize};
82 use tendermint::{block, tx, Hash};
83
84 #[derive(Debug, Deserialize, Serialize)]
86 pub struct DialectResponse {
87 pub hash: Hash,
93 pub height: block::Height,
94 pub index: u32,
95 pub tx_result: dialect::DeliverTx<Event>,
96 #[serde(with = "serializers::bytes::base64string")]
97 pub tx: Vec<u8>,
98 #[serde(skip_serializing_if = "Option::is_none")]
99 pub proof: Option<tx::Proof>,
100 }
101
102 impl crate::Response for DialectResponse {}
103
104 impl From<DialectResponse> for Response {
105 fn from(msg: DialectResponse) -> Self {
106 Self {
107 hash: msg.hash,
108 height: msg.height,
109 index: msg.index,
110 tx_result: msg.tx_result.into(),
111 tx: msg.tx,
112 proof: msg.proof,
113 }
114 }
115 }
116}