Skip to content

feat: add GET /grantees/:address/users endpoint#730

Merged
raymondjacobson merged 3 commits intomainfrom
rj-grantee
Mar 21, 2026
Merged

feat: add GET /grantees/:address/users endpoint#730
raymondjacobson merged 3 commits intomainfrom
rj-grantee

Conversation

@raymondjacobson
Copy link
Member

Summary

  • Adds GET /v1/grantees/:address/users endpoint that returns all users who have authorized a given grantee wallet address via the grants table
  • Supports is_approved (optional) and is_revoked (default false) query filters
  • Supports limit/offset pagination; returns the full user model

Test plan

  • TestGetGranteeUsersNoParams — default params return non-revoked grants across all approval statuses
  • TestGetGranteeUsersApprovedis_approved=true filters to only approved grants
  • TestGetGranteeUsersNotApprovedis_approved=false filters to only unapproved grants
  • TestGetGranteeUsersRevokedis_revoked=true returns revoked grants
  • TestGetGranteeUsersNotFound — unknown address returns empty list with 200
  • TestGetGranteeUsersPaginationlimit=1 returns a single result
  • TestGetGranteeUsersInvalidParams — invalid param values return 400

🤖 Generated with Claude Code

raymondjacobson and others added 2 commits March 18, 2026 17:33
Returns paginated full user models for all users who have authorized a
given grantee wallet address via the grants table. Supports is_approved
and is_revoked filters, and limit/offset pagination.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Allows callers to pass the address with or without the 0x prefix.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
AND (@is_approved::boolean IS NULL OR g.is_approved = @is_approved)
ORDER BY g.created_at DESC
LIMIT @limit
OFFSET @offset
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot what indexes do we have on this table? is this fast?

Copy link
Contributor

Copilot AI commented Mar 19, 2026

@rickyrombo I've opened a new pull request, #731, to work on those changes. Once the pull request is ready, I'll request review from you.

The `GET /grantees/:address/users` endpoint was doing a full table scan
on `grants` — the table only had a primary key on `(user_id, txhash,
grantee_address)` with no usable index for lookups by `grantee_address`.

## Changes

- **`ddl/migrations/0191_grants_grantee_address_idx.sql`** — adds a
partial index covering the query's filter and sort columns:
  ```sql
  CREATE INDEX IF NOT EXISTS idx_grants_grantee_address
  ON grants(grantee_address, is_revoked, created_at DESC)
  WHERE is_current = true;
  ```
The `WHERE is_current = true` predicate keeps the index small;
`is_revoked` covers the boolean filter; `created_at DESC` supports
`ORDER BY … LIMIT … OFFSET` pagination without a sort step.

- **`sql/01_schema.sql`** — schema snapshot updated to reflect the new
index.

<!-- START COPILOT CODING AGENT TIPS -->
---

📍 Connect Copilot coding agent with [Jira](https://gh.io/cca-jira-docs),
[Azure Boards](https://gh.io/cca-azure-boards-docs) or
[Linear](https://gh.io/cca-linear-docs) to delegate work to Copilot in
one click without leaving your project management tool.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rickyrombo <3690498+rickyrombo@users.noreply.github.com>
@raymondjacobson raymondjacobson merged commit 2f195b2 into main Mar 21, 2026
5 checks passed
@raymondjacobson raymondjacobson deleted the rj-grantee branch March 21, 2026 00:49
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.

3 participants