Skip to content

Add ?minAmount=/?maxAmount= range filtering to GET /api/v1/settlements #139

Description

@Jagadeeshftw

📌 Description

routes/settlements.ts's GET / supports filtering by ?anchor= and ?asset= only. An operator investigating settlements above/below a certain size (e.g. auditing unusually large settlements) currently has to fetch everything and filter client-side.

🧩 Requirements and context

  • Accept optional ?minAmount=/?maxAmount= query params, validated as non-negative numbers via utils/validation.ts.
  • Apply the range filter in SettlementService.list (extend its filters parameter) rather than in the route handler, consistent with the existing anchor/asset filtering pattern.
  • Combine correctly with existing ?anchor=/?asset= filters, sorting, and pagination.

🛠️ Suggested execution

  • Extend src/services/settlementService.ts's list(filters) signature to accept minAmount/maxAmount and filter accordingly.
  • Modify src/routes/settlements.ts's GET / handler to parse and pass the new query params through.
  • Update src/openapi.ts's /api/v1/settlements GET parameters.
  • Add tests in src/services/settlementService.test.ts and src/routes/settlements.test.ts.

✅ Acceptance criteria

  • GET /api/v1/settlements?minAmount=100&maxAmount=500 returns only settlements within that range.
  • Range filters combine correctly with ?anchor=, ?asset=, sorting, and pagination.
  • Invalid (non-numeric or negative) range values return 400.

🔒 Security notes

N/A — read-path filter over already-exposed settlement data.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issueapiHTTP/WebSocket APIenhancementNew feature or improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions