From f86e0886631a98b0638fe09e6fcbe5458d47adc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Thu, 26 Sep 2024 16:30:57 +0100 Subject: [PATCH] bugfix: correctly paginate through 'search_tx' endpoint --- .../nyxd/cosmwasm_client/client_traits/query_client.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/client-libs/validator-client/src/nyxd/cosmwasm_client/client_traits/query_client.rs b/common/client-libs/validator-client/src/nyxd/cosmwasm_client/client_traits/query_client.rs index f63399ce18..47859ea0d1 100644 --- a/common/client-libs/validator-client/src/nyxd/cosmwasm_client/client_traits/query_client.rs +++ b/common/client-libs/validator-client/src/nyxd/cosmwasm_client/client_traits/query_client.rs @@ -218,17 +218,19 @@ pub trait CosmWasmClient: TendermintRpcClient { loop { let mut res = self - .tx_search(query.clone(), false, page, 100, Order::Ascending) + .tx_search(query.clone(), false, page, per_page, Order::Ascending) .await?; - results.append(&mut res.txs); // sanity check for if tendermint's maximum per_page was modified - // we don't want to accidentally be stuck in an infinite loop - if res.total_count == 0 || res.txs.is_empty() { + let early_break = res.total_count == 0 || res.txs.is_empty(); + results.append(&mut res.txs); + + if early_break { break; } - if res.total_count >= per_page { + if res.total_count > results.len() as u32 { page += 1 } else { break;