Skip to content

rename topic0 to selector in schema and API#1760

Open
shrugs wants to merge 1 commit intomainfrom
feat/rename-topic0-to-selector
Open

rename topic0 to selector in schema and API#1760
shrugs wants to merge 1 commit intomainfrom
feat/rename-topic0-to-selector

Conversation

@shrugs
Copy link
Collaborator

@shrugs shrugs commented Mar 12, 2026

Summary

  • renamed topic0 column to selector in the ensv2 event schema (including DB index byTopic0bySelector)
  • renamed topic0_in filter to selector_in in all GraphQL EventsWhereInput / AccountEventsWhereInput types and the underlying resolver logic
  • updated changeset description to reflect the new name

Why

  • selector more accurately describes what topic0 represents (the event signature / selector), aligning the API terminology with its semantic meaning

Testing

  • pnpm typecheck — all packages pass
  • pnpm lint — clean
  • no runtime behavior change; purely a naming refactor across 5 files

Checklist

  • This PR does not change runtime behavior or semantics
  • This PR is low-risk and safe to review quickly

Closes #1759

🤖 Generated with Claude Code

Renames the `topic0` column/concept to `selector` across the DB schema,
indexer, GraphQL API inputs, and resolver logic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@shrugs shrugs requested a review from a team as a code owner March 12, 2026 22:14
Copilot AI review requested due to automatic review settings March 12, 2026 22:14
@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2026

⚠️ No Changeset found

Latest commit: f39f7df

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

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

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link
Contributor

vercel bot commented Mar 12, 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 Mar 12, 2026 10:15pm
ensnode.io Ready Ready Preview, Comment Mar 12, 2026 10:15pm
ensrainbow.io Ready Ready Preview, Comment Mar 12, 2026 10:15pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 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: b4d11cae-8a19-4c0d-b920-3f28b29eea85

📥 Commits

Reviewing files that changed from the base of the PR and between 9429530 and f39f7df.

📒 Files selected for processing (5)
  • .changeset/shy-wolves-judge.md
  • apps/ensapi/src/graphql-api/lib/find-events/find-events-resolver.ts
  • apps/ensapi/src/graphql-api/schema/event.ts
  • apps/ensindexer/src/lib/ensv2/event-db-helpers.ts
  • packages/ensnode-schema/src/schemas/ensv2.schema.ts

📝 Walkthrough

Walkthrough

This PR renames the event signature field from topic0 to selector across the ENS event model, including the database schema, indexer event storage, GraphQL schema definitions, resolver logic, and accompanying documentation. The renaming improves semantic clarity while preserving all underlying data and behavior.

Changes

Cohort / File(s) Summary
GraphQL Schema & Resolver
apps/ensapi/src/graphql-api/schema/event.ts, apps/ensapi/src/graphql-api/lib/find-events/find-events-resolver.ts
Renamed filter field from topic0_in to selector_in in EventsWhereInput and AccountEventsWhereInput GraphQL types. Updated resolver to query against schema.event.selector instead of topic0.
Database Schema
packages/ensnode-schema/src/schemas/ensv2.schema.ts
Renamed on-chain event field from topic0 to selector in the events table, and updated corresponding index from byTopic0 to bySelector.
Indexer Event Storage
apps/ensindexer/src/lib/ensv2/event-db-helpers.ts
Changed property name from topic0 to selector when persisting the first element of the topics array in ensureEvent.
Documentation
.changeset/shy-wolves-judge.md
Updated changeset documenting the filter field change from topic0_in to selector_in in event connections documentation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A topic renamed to selector bright,
From schema deep to API's light,
Each field now speaks what it will do,
The naming clearer, the code renewed! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'rename topic0 to selector in schema and API' accurately and concisely summarizes the main change—a naming refactor across the codebase.
Description check ✅ Passed The pull request description follows the template structure with clear Summary, Why, Testing, and Checklist sections; all required information is present and complete.
Linked Issues check ✅ Passed The PR successfully implements the objective from issue #1759 to rename topic0 to selector across the schema and API, improving naming clarity.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the renaming objective; no out-of-scope modifications are present outside the five modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/rename-topic0-to-selector
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 12, 2026

Greptile Summary

This PR performs a clean, purely cosmetic rename of topic0selector across the ENSNode codebase, touching the Ponder DB schema, the indexer's insert helper, and the GraphQL API's input types and resolver logic. All five changed files are mutually consistent and no occurrences of the old name remain anywhere in the repository.

Key changes:

  • ensv2.schema.ts: event.topic0 column → event.selector; index byTopic0bySelector
  • event-db-helpers.ts: Insert field topic0: topics[0]selector: topics[0]
  • find-events-resolver.ts: Internal EventsWhere.topic0_inselector_in; inArray(schema.event.topic0, …)inArray(schema.event.selector, …)
  • event.ts: Both EventsWhereInput and AccountEventsWhereInput GraphQL inputs expose selector_in instead of topic0_in
  • .changeset/shy-wolves-judge.md: Description updated to match

Note: this is a breaking change for any existing API clients that pass topic0_in in their GraphQL where filter — they will need to migrate to selector_in. The changeset is correctly marked minor.

Confidence Score: 5/5

  • This PR is safe to merge — it is a consistent rename with no logic changes and no residual references to the old name.
  • All five files have been updated in lock-step, a full-repository grep confirms zero remaining topic0 references, and the change carries no runtime logic alterations.
  • No files require special attention.

Important Files Changed

Filename Overview
packages/ensnode-schema/src/schemas/ensv2.schema.ts Column renamed from topic0 to selector and index from byTopic0 to bySelector; all changes are self-contained and correct.
apps/ensindexer/src/lib/ensv2/event-db-helpers.ts Single insert-field rename from topic0 to selector matching the updated schema; no logic changes.
apps/ensapi/src/graphql-api/lib/find-events/find-events-resolver.ts Internal EventsWhere interface and eventsWhereConditions helper updated to use selector_in; correctly references the renamed schema.event.selector column.
apps/ensapi/src/graphql-api/schema/event.ts Both EventsWhereInput and AccountEventsWhereInput GraphQL input types updated to expose selector_in instead of topic0_in; this is a breaking API rename for existing consumers.
.changeset/shy-wolves-judge.md Changeset description updated to reference selector_in; bump level remains minor which is appropriate for a public API rename.

Sequence Diagram

sequenceDiagram
    participant Client as GraphQL Client
    participant GQL as GraphQL Schema (event.ts)
    participant Resolver as find-events-resolver.ts
    participant DB as Database (ensv2.schema.ts)

    Client->>GQL: query { domain { events(where: { selector_in: [...] }) } }
    Note over GQL: EventsWhereInput.selector_in<br/>(was topic0_in)
    GQL->>Resolver: resolveFindEvents({ where: { selector_in } })
    Note over Resolver: eventsWhereConditions()<br/>reads where.selector_in
    Resolver->>DB: SELECT ... FROM events WHERE selector IN (...)
    Note over DB: events.selector column<br/>(was topic0) + bySelector index
    DB-->>Resolver: event rows
    Resolver-->>Client: paginated EventConnection
Loading

Last reviewed commit: f39f7df

Copy link
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

Renames the ENSv2 event “topic0” field to “selector” across the shared schema, indexer write-path, and ENSApi GraphQL filter inputs, aligning naming with the semantic meaning of the first log topic (event signature/selector).

Changes:

  • Renamed events.topic0events.selector in the ENSv2 onchain schema (and byTopic0bySelector index).
  • Renamed GraphQL filter input topic0_inselector_in and updated resolver filtering logic.
  • Updated the pending changeset description to reference selector_in.

Reviewed changes

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

Show a summary per file
File Description
packages/ensnode-schema/src/schemas/ensv2.schema.ts Renames the persisted events column and its index.
apps/ensindexer/src/lib/ensv2/event-db-helpers.ts Writes selector instead of topic0 when persisting events.
apps/ensapi/src/graphql-api/schema/event.ts Renames the public GraphQL filter field to selector_in (and updates descriptions).
apps/ensapi/src/graphql-api/lib/find-events/find-events-resolver.ts Updates SQL filtering to use schema.event.selector and the new selector_in key.
.changeset/shy-wolves-judge.md Updates release-note text to mention selector_in.

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

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 118 to 126
address: t.hex().notNull().$type<Address>(),
logIndex: t.integer().notNull().$type<number>(),
topic0: t.hex().notNull().$type<Hash>(),
selector: t.hex().notNull().$type<Hash>(),
topics: t.hex().array().notNull().$type<[Hash, ...Hash[]]>(),
data: t.hex().notNull(),
}),
(t) => ({
byTopic0: index().on(t.topic0),
bySelector: index().on(t.selector),
byFrom: index().on(t.from),
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

Renaming the persisted events table column from topic0 to selector (and index rename) will break existing Postgres/Ponder databases that already have topic0 (queries/inserts will fail unless the DB is rebuilt or migrated). Please add an explicit migration/upgrade path (e.g., SQL ALTER TABLE ... RENAME COLUMN, index rename) or clearly document that a full re-index / DB reset is required for this change.

Copilot uses AI. Check for mistakes.
Comment on lines +168 to 172
selector_in: t.field({
type: ["Hex"],
description: "Filter to events whose topic0 (event signature) is one of the provided values.",
description:
"Filter to events whose selector (event signature) is one of the provided values.",
}),
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

This removes the topic0_in input field and replaces it with selector_in. If topic0_in has been part of any released/used GraphQL schema, this is a breaking API change for clients. Consider keeping topic0_in as a deprecated alias (with a deprecation reason pointing to selector_in) for at least one release cycle, or otherwise document the breaking change prominently.

Copilot uses AI. Check for mistakes.
Comment on lines 37 to 45
function eventsWhereConditions(where?: EventsWhere | null): SQL | undefined {
if (!where) return undefined;

return and(
where.topic0_in
? where.topic0_in.length
? inArray(schema.event.topic0, where.topic0_in)
where.selector_in
? where.selector_in.length
? inArray(schema.event.selector, where.selector_in)
: sql`false`
: undefined,
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

There are integration tests for events pagination, but none appear to cover the where.selector_in filter path. Since this PR renames a public filter field and changes the SQL condition to use schema.event.selector, it would be easy for a regression to slip through without a targeted test. Please add at least one integration test that queries a connection with where: { selector_in: [...] } and asserts results are filtered correctly.

Copilot uses AI. Check for mistakes.
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.

rename topic0 to selector in schema/api

2 participants