-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tx_search endpoint for RPC client (#701)
* Add tx_search endpoint for RPC client Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update CHANGELOG Signed-off-by: Thane Thomson <connect@thanethomson.com> * Fix tx_search Request docs Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update proto/src/serializers/bytes.rs Co-authored-by: Greg Szabo <16846635+greg-szabo@users.noreply.github.com> * Replace sleep with Tokio 0.2.x-compatible method call Signed-off-by: Thane Thomson <connect@thanethomson.com> * Supply full tx to broadcast_tx helper method Signed-off-by: Thane Thomson <connect@thanethomson.com> * Fix tx_search query for integration test Signed-off-by: Thane Thomson <connect@thanethomson.com> Co-authored-by: Greg Szabo <16846635+greg-szabo@users.noreply.github.com>
- Loading branch information
1 parent
e334fb7
commit 25f7ba5
Showing
19 changed files
with
1,110 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//! `/tx_search` endpoint JSON-RPC wrapper | ||
|
||
use crate::{Method, Order}; | ||
use serde::{Deserialize, Serialize}; | ||
use tendermint::{abci, block}; | ||
use tendermint_proto::types::TxProof; | ||
|
||
/// Request for searching for transactions with their results. | ||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] | ||
pub struct Request { | ||
pub query: String, | ||
pub prove: bool, | ||
#[serde(with = "tendermint_proto::serializers::from_str")] | ||
pub page: u32, | ||
#[serde(with = "tendermint_proto::serializers::from_str")] | ||
pub per_page: u8, | ||
pub order_by: Order, | ||
} | ||
|
||
impl Request { | ||
/// Constructor. | ||
pub fn new( | ||
query: impl ToString, | ||
prove: bool, | ||
page: u32, | ||
per_page: u8, | ||
order_by: Order, | ||
) -> Self { | ||
Self { | ||
query: query.to_string(), | ||
prove, | ||
page, | ||
per_page, | ||
order_by, | ||
} | ||
} | ||
} | ||
|
||
impl crate::Request for Request { | ||
type Response = Response; | ||
|
||
fn method(&self) -> Method { | ||
Method::TxSearch | ||
} | ||
} | ||
|
||
impl crate::SimpleRequest for Request {} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct Response { | ||
pub txs: Vec<ResultTx>, | ||
#[serde(with = "tendermint_proto::serializers::from_str")] | ||
pub total_count: u32, | ||
} | ||
|
||
impl crate::Response for Response {} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct ResultTx { | ||
pub hash: abci::transaction::Hash, | ||
pub height: block::Height, | ||
pub index: u32, | ||
pub tx_result: abci::DeliverTx, | ||
pub tx: abci::Transaction, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub proof: Option<TxProof>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! Ordering of paginated RPC responses. | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Ordering of paginated RPC responses. | ||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] | ||
pub enum Order { | ||
/// Ascending order | ||
#[serde(rename = "asc")] | ||
Ascending, | ||
|
||
/// Descending order | ||
#[serde(rename = "desc")] | ||
Descending, | ||
} |
Oops, something went wrong.