Skip to content

fix: honour status query param in list transactions endpoint#792

Open
shaunwackerly wants to merge 1 commit into
OpenZeppelin:mainfrom
shaunwackerly:fix/list-transactions-status-filter
Open

fix: honour status query param in list transactions endpoint#792
shaunwackerly wants to merge 1 commit into
OpenZeppelin:mainfrom
shaunwackerly:fix/list-transactions-status-filter

Conversation

@shaunwackerly

@shaunwackerly shaunwackerly commented Jun 6, 2026

Copy link
Copy Markdown

Summary

  • GET /relayers/{id}/transactions?status=Sent (and any other status value) was silently ignored — the endpoint always returned all transactions for the relayer regardless of the requested status.
  • Root cause: PaginationQuery only had page / per_page fields. The ?status= parameter was unknown to the deserializer and dropped. The controller called find_by_relayer_id, which applies no status filter.

Changes

src/models/pagination.rs

  • Add TransactionListQuery — a copy of PaginationQuery extended with an optional status: Option<TransactionStatus> field.
  • Add From<TransactionListQuery> for PaginationQuery for ergonomic conversion.

src/api/routes/relayer.rs

  • list_transactions route now deserialises TransactionListQuery instead of PaginationQuery.

src/api/controllers/relayer.rs

  • list_transactions accepts TransactionListQuery and branches on the presence of a status filter:
    • status present: delegates to the existing find_by_status_paginated, which uses the per-status sorted sets already maintained by the repository for efficient indexed lookups.
    • status absent: delegates to find_by_relayer_id as before.

No repository changes are required; both methods already exist on TransactionRepository.

Test plan

  • All existing unit tests pass (cargo test --lib).
  • GET /relayers/{id}/transactions?status=Sent returns only Sent transactions.
  • GET /relayers/{id}/transactions (no filter) still returns all transactions.
  • GET /relayers/{id}/transactions?status=Failed returns only Failed transactions.
  • Pagination (page / per_page) works correctly in both filtered and unfiltered modes.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Transaction listing endpoint now supports optional status-based filtering in addition to pagination. Users can filter transactions by status when querying transaction lists through the relayer API, providing improved control over transaction retrieval and more efficient data management.

The GET /relayers/{id}/transactions endpoint accepted a ?status= query
parameter but silently discarded it. PaginationQuery only contained page
and per_page, so every call returned all transactions for the relayer
regardless of the requested status.

Introduce TransactionListQuery (pagination.rs) which adds an optional
status field and a From<TransactionListQuery> impl for PaginationQuery.
Update the route to deserialise TransactionListQuery and the controller
to branch on the presence of a status filter:

- status present: delegate to the existing find_by_status_paginated,
  which uses per-status sorted sets for efficient indexed lookups.
- status absent: delegate to find_by_relayer_id as before.

No repository changes are required; both methods already exist on the
TransactionRepository trait.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shaunwackerly shaunwackerly requested a review from a team as a code owner June 6, 2026 00:09
@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Too much diff to scan? Review this PR in Change Stack to start with the highest-impact changes.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 07a490c0-01cf-48a8-928c-b1fbe54c34b8

📥 Commits

Reviewing files that changed from the base of the PR and between 345b895 and 06c3e76.

📒 Files selected for processing (3)
  • src/api/controllers/relayer.rs
  • src/api/routes/relayer.rs
  • src/models/pagination.rs

Walkthrough

This PR extends the transaction listing endpoint to support optional status filtering. A new TransactionListQuery type is introduced to carry pagination parameters plus an optional transaction status. The controller's list_transactions function now accepts this richer query and conditionally calls either a status-based or relayer-ID-based repository method depending on whether a status filter is provided.

Changes

Transaction List Status Filtering

Layer / File(s) Summary
Transaction list query type definition
src/models/pagination.rs
TransactionListQuery struct extends pagination with optional status: Option<TransactionStatus> filter; From<TransactionListQuery> impl converts it to plain PaginationQuery.
Controller conditional filtering logic
src/api/controllers/relayer.rs
list_transactions signature updated to accept TransactionListQuery; implementation converts to PaginationQuery and branches on query.status presence to call either status-specific or relayer-ID-based repository paginated method.
Route handler query type wiring
src/api/routes/relayer.rs
GET /relayers/{relayer_id}/transactions handler query parameter type changed from PaginationQuery to TransactionListQuery to support optional status filtering.

Sequence Diagram

sequenceDiagram
  participant Client
  participant list_transactions as list_transactions handler
  participant repo as Transaction repository
  Client->>list_transactions: GET with query (page, per_page, status?)
  alt status is Some
    list_transactions->>repo: list_transactions_by_status(status, pagination)
  else status is None
    list_transactions->>repo: list_transactions_by_relayer_id(relayer_id, pagination)
  end
  repo-->>list_transactions: paginated transactions
  list_transactions-->>Client: transaction list response
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

A query now filters with grace,
Status optional, in its place,
Branching paths both lead the way,
To list transactions, come what may! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing the issue where the status query parameter was being ignored in the list transactions endpoint.
Description check ✅ Passed The description is comprehensive and well-structured, covering the problem, root cause, changes made, and a detailed test plan, though the required checklist items are not marked as completed.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution to OpenZeppelin Relayer. Before being able to integrate those changes, we would like you to sign our Contributor License Agreement. You can sign the CLA by just posting a Pull Request Comment with the sentence below. Thanks.


I confirm that I have read and hereby agree to the OpenZeppelin Contributor License Agreement


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the relayer transactions listing endpoint so that the status query parameter is actually honored, enabling clients to retrieve only transactions in a specific TransactionStatus while retaining pagination.

Changes:

  • Introduces TransactionListQuery (pagination + optional status) for query deserialization.
  • Updates the relayer routes/controllers to accept the new query type.
  • Adds branching logic in the controller to call find_by_status_paginated when a status filter is present.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/models/pagination.rs Adds TransactionListQuery and a conversion to PaginationQuery to support optional status filtering alongside pagination.
src/api/routes/relayer.rs Switches the list-transactions route extractor to TransactionListQuery and updates the route docstring to mention status filtering.
src/api/controllers/relayer.rs Implements status-aware branching: filtered queries use find_by_status_paginated, otherwise the existing find_by_relayer_id path is used.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/models/pagination.rs
Comment on lines +18 to +21
#[serde(default = "default_per_page")]
pub per_page: u32,
pub status: Option<TransactionStatus>,
}
Comment on lines +559 to +573
let pagination = PaginationQuery::from(query.clone());
let transactions = match query.status {
Some(status) => {
state
.transaction_repository
.find_by_status_paginated(&relayer_id, &[status], pagination, false)
.await?
}
None => {
state
.transaction_repository
.find_by_relayer_id(&relayer_id, pagination)
.await?
}
};
Comment on lines +560 to +564
let transactions = match query.status {
Some(status) => {
state
.transaction_repository
.find_by_status_paginated(&relayer_id, &[status], pagination, false)
Comment thread src/api/routes/relayer.rs
Comment on lines +118 to +122
/// Lists all transactions for a specific relayer with pagination and optional status filter.
#[get("/relayers/{relayer_id}/transactions")]
async fn list_transactions(
relayer_id: web::Path<String>,
query: web::Query<PaginationQuery>,
query: web::Query<TransactionListQuery>,

@zeljkoX zeljkoX left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

PR looks good!

Few things to wrap it up:

  • Update desc, only lowercase statuses should be accepted(per deserialization)
  • Add tests for newly added logic
  • Update src/api/routes/docs/relayer_docs.rs: docs to include status param for openapi spec generation
  • Accept CLA per #792 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants