Skip to content

Changed accurateAsOf in Registrar Actions from optional to required#1907

Merged
Goader merged 3 commits intomainfrom
task/registrar-actions-accurateasof-required
Apr 10, 2026
Merged

Changed accurateAsOf in Registrar Actions from optional to required#1907
Goader merged 3 commits intomainfrom
task/registrar-actions-accurateasof-required

Conversation

@Goader
Copy link
Copy Markdown
Contributor

@Goader Goader commented Apr 9, 2026

Registrar Actions: accurateAsOf

closes: #1497

Summary

  • accurateAsOf is now required in RegistrarActionsResponseOk (type + zod schema).
  • Restored accurateAsOf on the GET /api/registrar-actions handler.

Why


Testing

  • Automatic, CI testing
  • Introduced some new tests
  • Manual validation

Notes for Reviewer (Optional)

  • The unfiltered GET /api/registrar-actions endpoint stopped returning accurateAsOf after refactor: use zod-openapi for registrar-actions-api #1673 split the original single /:parentNode? handler into two, keeping the logic only in the by-parent-node one. This PR restores it, but the older versions of ENSApi will not return it, and therefore newer client will throw.

Pre-Review Checklist (Blocking)

  • This PR does not introduce significant changes and is low-risk to review quickly.
  • Relevant changesets are included (or are not required)

@Goader Goader self-assigned this Apr 9, 2026
@Goader Goader requested a review from a team as a code owner April 9, 2026 15:27
Copilot AI review requested due to automatic review settings April 9, 2026 15:27
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

🦋 Changeset detected

Latest commit: c17c8c9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@ensnode/ensnode-sdk Major
ensapi Major
ensadmin Major
ensindexer Major
ensrainbow Major
fallback-ensapi Major
@namehash/ens-referrals Major
@ensnode/ensdb-sdk Major
@ensnode/ensnode-react Major
@ensnode/ensrainbow-sdk Major
@ensnode/integration-test-env Patch
@namehash/namehash-ui Major
@docs/ensnode Major
@docs/ensrainbow Major
enssdk Major
enscli Major
enskit Major
ensskills Major
@ensnode/datasources Major
@ensnode/ponder-sdk Major
@ensnode/ponder-subgraph Major
@ensnode/shared-configs Major
@docs/mintlify Major
@ensnode/enskit-react-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: daffcf13-0fde-46c2-9465-143e0f00ecd2

📥 Commits

Reviewing files that changed from the base of the PR and between 5c120d8 and c17c8c9.

📒 Files selected for processing (2)
  • apps/ensapi/src/handlers/api/explore/registrar-actions-api.ts
  • packages/ensnode-sdk/src/ensapi/api/registrar-actions/response.ts

📝 Walkthrough

Walkthrough

Makes accurateAsOf required on Registrar Actions responses; API handlers now read accurateAsOf from the omnichain indexing cursor and defensively guard for indexingStatus errors. SDK types and Zod schemas enforce the field; tests and a changeset are added.

Changes

Cohort / File(s) Summary
Changeset Documentation
.changeset/shy-rabbits-drum.md
Adds a changeset bumping @ensnode/ensnode-sdk and ensapi to minor versions and documents that accurateAsOf is now required.
API Handler
apps/ensapi/src/handlers/api/explore/registrar-actions-api.ts
Adds runtime guards that throw if c.var.indexingStatus is an Error and includes accurateAsOf (sourced from indexingStatus.snapshot.omnichainSnapshot.omnichainIndexingCursor) in successful responses.
Response Type & Validation
packages/ensnode-sdk/src/ensapi/api/registrar-actions/response.ts, packages/ensnode-sdk/src/ensapi/api/registrar-actions/zod-schemas.ts
Changes RegistrarActionsResponseOk.accurateAsOf from optional to required and updates the Zod schema to make accurateAsOf mandatory; docs note omnichain cursor as the source.
Tests
packages/ensnode-sdk/src/ensapi/api/registrar-actions/zod-schemas.test.ts
Adds a Vitest case that omits accurateAsOf from a fixture and asserts schema parsing fails.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

javascript

Poem

🐇 I nibbled docs and hopped through lines,
Found a timestamp tucked in vines,
Now every call must plainly show,
AccurateAsOf — let it flow,
Hooray for tidy, timely signs!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: making accurateAsOf required in Registrar Actions.
Description check ✅ Passed The description includes all required sections with clear details on what changed, why, testing approach, and notes for reviewers.
Linked Issues check ✅ Passed All coding requirements from issue #1497 are met: accurateAsOf is required in type and schema, and the unfiltered endpoint now returns it.
Out of Scope Changes check ✅ Passed All changes directly address the objective to make accurateAsOf required; no unrelated modifications are present in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/registrar-actions-accurateasof-required

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
admin.ensnode.io Ready Ready Preview, Comment Apr 10, 2026 2:05pm
ensnode.io Ready Ready Preview, Comment Apr 10, 2026 2:05pm
ensrainbow.io Ready Ready Preview, Comment Apr 10, 2026 2:05pm

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 9, 2026

Greptile Summary

This PR promotes accurateAsOf from optional to required in RegistrarActionsResponseOk (both the TypeScript type and the Zod schema), and restores the field in the previously-broken unfiltered GET /api/registrar-actions handler (which lost it in #1673 when the single route was split into two).

Confidence Score: 5/5

Safe to merge — all changes are consistent, well-tested, and the breaking-change implications are documented and intentional.

No P0 or P1 issues found. The type/schema change is correct, the previously-missing accurateAsOf field is properly restored in the unfiltered handler using the same well-established pattern as the by-parent-node handler, and a targeted test validates the new required behavior. The changeset version bumps are appropriate.

No files require special attention.

Vulnerabilities

No security concerns identified.

Important Files Changed

Filename Overview
apps/ensapi/src/handlers/api/explore/registrar-actions-api.ts Adds accurateAsOf (from indexingStatus.snapshot.slowestChainIndexingCursor) to the unfiltered handler, mirroring the already-correct by-parent-node handler; no logic issues.
packages/ensnode-sdk/src/ensapi/api/registrar-actions/response.ts Removes the ? optional modifier and associated backward-compat comment from accurateAsOf in RegistrarActionsResponseOk; straightforward and correct.
packages/ensnode-sdk/src/ensapi/api/registrar-actions/zod-schemas.ts Removes .optional() from the accurateAsOf Zod field, keeping the schema aligned with the updated TypeScript type.
packages/ensnode-sdk/src/ensapi/api/registrar-actions/zod-schemas.test.ts Adds a test asserting that a response missing accurateAsOf is rejected; adequate coverage for the new requirement.
.changeset/shy-rabbits-drum.md Correctly bumps both @ensnode/ensnode-sdk and ensapi as minor for the breaking schema change.

Sequence Diagram

sequenceDiagram
    participant Client
    participant indexingStatusMiddleware
    participant registrarActionsApiMiddleware
    participant getRegistrarActionsHandler

    Client->>indexingStatusMiddleware: GET /api/registrar-actions
    indexingStatusMiddleware->>indexingStatusMiddleware: set c.var.indexingStatus (RealtimeIndexingStatusProjection | Error)
    indexingStatusMiddleware->>registrarActionsApiMiddleware: next()
    registrarActionsApiMiddleware->>registrarActionsApiMiddleware: check indexingStatus instanceof Error → 503
    registrarActionsApiMiddleware->>registrarActionsApiMiddleware: check config/indexing support → 503
    registrarActionsApiMiddleware->>getRegistrarActionsHandler: next()
    getRegistrarActionsHandler->>getRegistrarActionsHandler: read indexingStatus.snapshot.slowestChainIndexingCursor (accurateAsOf)
    getRegistrarActionsHandler->>getRegistrarActionsHandler: fetchRegistrarActions(undefined, query)
    getRegistrarActionsHandler-->>Client: 200 { responseCode, registrarActions, pageContext, accurateAsOf }
Loading

Reviews (1): Last reviewed commit: "accurateasof made required" | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Makes accurateAsOf mandatory again in the Registrar Actions API contract and restores it on the unfiltered GET /api/registrar-actions endpoint so clients can reliably use indexing “accurate as of” metadata.

Changes:

  • Require accurateAsOf in RegistrarActionsResponseOk (TypeScript type + Zod schema).
  • Add a schema test ensuring responses missing accurateAsOf are rejected.
  • Restore accurateAsOf in the unfiltered registrar-actions handler response.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/ensnode-sdk/src/ensapi/api/registrar-actions/zod-schemas.ts Makes accurateAsOf required in the response OK schema.
packages/ensnode-sdk/src/ensapi/api/registrar-actions/zod-schemas.test.ts Adds a regression test rejecting OK responses without accurateAsOf.
packages/ensnode-sdk/src/ensapi/api/registrar-actions/response.ts Makes accurateAsOf required in the public response type and removes the temporary-optional note.
apps/ensapi/src/handlers/api/explore/registrar-actions-api.ts Restores returning accurateAsOf for the unfiltered endpoint using indexing status snapshot data.
.changeset/shy-rabbits-drum.md Declares release notes + version bumps for the contract change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/ensapi/src/handlers/api/explore/registrar-actions-api.ts`:
- Around line 104-106: Replace the throw in the indexing-status check with the
same serialized 503 response used elsewhere: when c.var.indexingStatus
instanceof Error, call serializeRegistrarActionsResponse(...) with responseCode
set to 503 and the appropriate body (preserving existing shape) instead of
throwing; update the handler that calls serializeRegistrarActionsResponse (the
registrar-actions-api request/handler) so this branch returns that serialized
result directly, preserving the prior API contract and avoiding a caught throw
that yields a generic 500.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f4c961c2-d1a2-46a7-afd5-33a48a9e31dc

📥 Commits

Reviewing files that changed from the base of the PR and between b781245 and 79c11fc.

📒 Files selected for processing (5)
  • .changeset/shy-rabbits-drum.md
  • apps/ensapi/src/handlers/api/explore/registrar-actions-api.ts
  • packages/ensnode-sdk/src/ensapi/api/registrar-actions/response.ts
  • packages/ensnode-sdk/src/ensapi/api/registrar-actions/zod-schemas.test.ts
  • packages/ensnode-sdk/src/ensapi/api/registrar-actions/zod-schemas.ts

*/
app.openapi(getRegistrarActionsRoute, async (c) => {
try {
if (c.var.indexingStatus instanceof Error) {
Copy link
Copy Markdown
Contributor

@vercel vercel bot Apr 9, 2026

Choose a reason for hiding this comment

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

Handler throws a generic Error when indexingStatus is unavailable, causing a 500 response inside try-catch instead of returning correct 503 response

Fix on Vercel

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The registrar-actions handlers' if (c.var.indexingStatus instanceof Error) throw … branches are unreachable defensive code for TypeScript narrowing - registrarActionsApiMiddleware already short-circuits that case with a serialized 503 before the handler runs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Goader Thanks. Agreed with your conclusion here but it will be good to add a comment in the code here how this case is unreachable based on the registrarActionsApiMiddleware (which would return a HTTP 503 error) but we add this logic here just as a formality for type narrowing.

@Goader Goader requested a review from lightwalker-eth April 9, 2026 16:54
Copy link
Copy Markdown
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@Goader Thanks for this. Reviewed and shared feedback. Please take the lead to merge when ready 👍

*/
app.openapi(getRegistrarActionsRoute, async (c) => {
try {
if (c.var.indexingStatus instanceof Error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Goader Thanks. Agreed with your conclusion here but it will be good to add a comment in the code here how this case is unreachable based on the registrarActionsApiMiddleware (which would return a HTTP 503 error) but we add this logic here just as a formality for type narrowing.

const { registrarActions, pageContext } = await fetchRegistrarActions(undefined, query);

// Get the accurateAsOf timestamp from the slowest chain indexing cursor
const accurateAsOf = c.var.indexingStatus.snapshot.slowestChainIndexingCursor;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's not use this field for this idea. Instead, let's set accurateAsOf to be equal to the omnichainIndexingCursor field which you should be able to access as as a field somewhere in the indexingStatus object.

if (c.var.indexingStatus instanceof Error) {
throw new Error("Indexing status has not been loaded yet");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggest we move the operation that builds accurateAsOf here, before the call to fetchRegistrarActions. We want to error on the side of accurateAsOf being older, rather than newer than the data being returned.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Goader Goader merged commit b2481d6 into main Apr 10, 2026
21 of 22 checks passed
@Goader Goader deleted the task/registrar-actions-accurateasof-required branch April 10, 2026 14:11
@github-actions github-actions bot mentioned this pull request Apr 9, 2026
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.

Change accurateAsOf in Registrar Actions from optional to required

3 participants