diff --git a/cosmrs/src/dev.rs b/cosmrs/src/dev.rs index a473cea4..d30c43e6 100644 --- a/cosmrs/src/dev.rs +++ b/cosmrs/src/dev.rs @@ -99,7 +99,7 @@ pub async fn poll_for_first_block(rpc_client: &rpc::HttpClient) { } /// Wait for a transaction with the given hash to appear in the blockchain -pub async fn poll_for_tx(rpc_client: &rpc::HttpClient, tx_hash: &tx::Hash) -> Tx { +pub async fn poll_for_tx(rpc_client: &rpc::HttpClient, tx_hash: tx::Hash) -> Tx { let attempts = 5; for _ in 0..attempts { diff --git a/cosmrs/src/tx.rs b/cosmrs/src/tx.rs index eb2f570d..349dac9f 100644 --- a/cosmrs/src/tx.rs +++ b/cosmrs/src/tx.rs @@ -162,22 +162,12 @@ impl Tx { /// Use RPC to find a transaction by its hash. #[cfg(feature = "rpc")] #[cfg_attr(docsrs, doc(cfg(feature = "rpc")))] - pub async fn find_by_hash(rpc_client: &C, tx_hash: &Hash) -> Result + pub async fn find_by_hash(rpc_client: &C, tx_hash: Hash) -> Result where C: rpc::Client + Send + Sync, { - let query = rpc::query::Query::from(rpc::query::EventType::Tx) - .and_eq("tx.hash", tx_hash.to_string()); - - let response = rpc_client - .tx_search(query, false, 1, 1, rpc::Order::Ascending) - .await?; - - if response.total_count == 1 { - Tx::from_bytes(response.txs[0].tx.as_bytes()) - } else { - Err(Error::TxNotFound { hash: *tx_hash }.into()) - } + let response = rpc_client.tx(tx_hash, false).await?; + Tx::from_bytes(response.tx.as_bytes()) } } diff --git a/cosmrs/tests/integration.rs b/cosmrs/tests/integration.rs index 748ec4f6..26d368f7 100644 --- a/cosmrs/tests/integration.rs +++ b/cosmrs/tests/integration.rs @@ -93,7 +93,7 @@ fn msg_send() { panic!("deliver_tx failed: {:?}", tx_commit_response.deliver_tx); } - let tx = dev::poll_for_tx(&rpc_client, &tx_commit_response.hash).await; + let tx = dev::poll_for_tx(&rpc_client, tx_commit_response.hash).await; assert_eq!(&tx_body, &tx.body); assert_eq!(&auth_info, &tx.auth_info); })