Add offset and limit to ContractsKey and V2ContractsKey#305
Merged
ChrisSchinnerl merged 4 commits intomasterfrom Feb 4, 2026
Merged
Add offset and limit to ContractsKey and V2ContractsKey#305ChrisSchinnerl merged 4 commits intomasterfrom
ContractsKey and V2ContractsKey#305ChrisSchinnerl merged 4 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds pagination support (offset and limit) to the ContractsKey and V2ContractsKey paths across the storage, explorer, API server, client, and OpenAPI spec to address performance and payload size issues when querying contracts by public key.
Changes:
- Extend
ContractsKeyandV2ContractsKeyin the store, explorer, and API layers to acceptoffsetandlimitparameters, and update associated SQL queries to support ordering and pagination. - Update HTTP handlers and the Go API client to parse/query
offsetandlimitfor/pubkey/{key}/contractsand/v2/pubkey/{key}/contracts, with server-side defaults and max-limit enforcement. - Extend tests to call the new paginated signatures and update the OpenAPI specification to document the new query parameters using existing
OffsetParamandLimitParamcomponents.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
persist/sqlite/v2contracts_test.go |
Adjusts TestV2FileContractsKey to call V2ContractsKey with explicit offset and limit, ensuring tests compile with the new signature and still validate DB-level behavior. |
persist/sqlite/v2contracts.go |
Adds offset and limit parameters to V2ContractsKey and applies ORDER BY rev.confirmation_height ASC LIMIT ? OFFSET ? in the SQL query for paginated v2 contracts-by-key retrieval. |
persist/sqlite/contracts_test.go |
Updates TestFileContractsKey to call ContractsKey with explicit offset and limit while preserving its existing behavioral assertions. |
persist/sqlite/contracts.go |
Extends ContractsKey to accept offset and limit, adding explicit ordering by confirmation height and SQL-level pagination for v1 contracts-by-key. |
openapi.yml |
Documents offset and limit as optional query parameters for /v2/pubkey/{key}/contracts and /pubkey/{key}/contracts using the shared OffsetParam and LimitParam components. |
explorer/explorer.go |
Updates the Store interface and Explorer methods so ContractsKey/V2ContractsKey now require offset and limit, propagating pagination into the explorer abstraction. |
api/server.go |
Adds pagination handling (default and max limit, offset parsing) to the pubkey contracts handlers and wires offset/limit through to Explorer.ContractsKey and Explorer.V2ContractsKey. |
api/client.go |
Changes Client.ContractsKey and Client.V2ContractsKey to accept offset and limit and include them in the request URLs to the corresponding endpoints. |
api/api_test.go |
Updates the ContractsKey API test to use the new client signature, verifying the endpoint still returns the expected contract for the renter key. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c876c46 to
3ea435a
Compare
peterjan
reviewed
Feb 3, 2026
.changeset/add_offset_and_limit_to_contractskey_and_v2contractskey.md
Outdated
Show resolved
Hide resolved
peterjan
previously approved these changes
Feb 3, 2026
ChrisSchinnerl
approved these changes
Feb 4, 2026
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.
Close #304