feat: add GET /grantees/:address/users endpoint#730
Merged
raymondjacobson merged 3 commits intomainfrom Mar 21, 2026
Merged
Conversation
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>
rickyrombo
reviewed
Mar 19, 2026
| AND (@is_approved::boolean IS NULL OR g.is_approved = @is_approved) | ||
| ORDER BY g.created_at DESC | ||
| LIMIT @limit | ||
| OFFSET @offset |
Contributor
There was a problem hiding this comment.
@copilot what indexes do we have on this table? is this fast?
Contributor
|
@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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /v1/grantees/:address/usersendpoint that returns all users who have authorized a given grantee wallet address via the grants tableis_approved(optional) andis_revoked(defaultfalse) query filterslimit/offsetpagination; returns the full user modelTest plan
TestGetGranteeUsersNoParams— default params return non-revoked grants across all approval statusesTestGetGranteeUsersApproved—is_approved=truefilters to only approved grantsTestGetGranteeUsersNotApproved—is_approved=falsefilters to only unapproved grantsTestGetGranteeUsersRevoked—is_revoked=truereturns revoked grantsTestGetGranteeUsersNotFound— unknown address returns empty list with 200TestGetGranteeUsersPagination—limit=1returns a single resultTestGetGranteeUsersInvalidParams— invalid param values return 400🤖 Generated with Claude Code