Skip to content

feat(api): add token filter query param to transfers endpoint#53

Open
ezedike-evan wants to merge 1 commit intoMiracle656:mainfrom
ezedike-evan:feat/transfers-filter-by-token
Open

feat(api): add token filter query param to transfers endpoint#53
ezedike-evan wants to merge 1 commit intoMiracle656:mainfrom
ezedike-evan:feat/transfers-filter-by-token

Conversation

@ezedike-evan
Copy link
Copy Markdown
Collaborator

  • Read ?token= from GET /transfers/address/:address
  • Validate: must start with C and be 56 characters (Stellar SAC contract address)
  • Invalid value returns 400 with a descriptive error message
  • Valid value forwarded to queryAllTransfers as field
  • Absent param preserves existing behaviour (no filtering)
  • Add four tests: valid filter, wrong prefix, wrong length, absent param

Closes #35

- Read ?token= from GET /transfers/address/:address
- Validate: must start with C and be 56 characters (Stellar SAC contract address)
- Invalid value returns 400 with a descriptive error message
- Valid value forwarded to queryAllTransfers as  field
- Absent param preserves existing behaviour (no filtering)
- Add four tests: valid filter, wrong prefix, wrong length, absent param

Closes Miracle656#35
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 28, 2026

@ezedike-evan Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Copy link
Copy Markdown
Owner

@Miracle656 Miracle656 left a comment

Choose a reason for hiding this comment

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

Good structure and solid tests — two things to fix before this can merge:

1. token is not wired into the DB query (critical)

queryAllTransfers in src/db.ts has AllTransfersQueryParams which doesn't include token. TypeScript will error on the call in api.ts, and even if it didn't, the filter would be silently ignored — no actual filtering would happen in the DB.

Fix in src/db.ts:

// In AllTransfersQueryParams:
token?: string;

// In the where clause:
...(token ? { contractId: token } : {}),

(Token IS a contract ID — it's just a more semantic query param name, so mapping it to contractId in the where clause is correct.)

2. Remove leftover draft comment

Line ~305 in src/api.ts:

// ── PASTE THIS to replace the GET /transfers/address/:address handler in src/api.ts ──

This is a work note that snuck into the final code — please remove it.

Everything else (validation, test coverage, response format) looks great. Once these two are fixed this is ready to merge.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add filtering by token contract address

2 participants