-
Notifications
You must be signed in to change notification settings - Fork 15
refactor(ensnode-sdk): improve of OmnichainIndexingStatusSnapshot data model
#1627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(ensnode-sdk): improve of OmnichainIndexingStatusSnapshot data model
#1627
Conversation
Replace `./types` with `./omnichain-indexing-status-snapshot`
Replace `./helpers` with `./omnichain-indexing-status-snapshot`
…c serialized-types.ts file
Replace `./serialized-types` with `./serialize/omnichain-indexing-status-snapshot`
Replace `./serialize` with `./serialize/omnichain-indexing-status-snapshot`
Replace `./zod-schemas` with `./zod-schema/omnichain-indexing-status-snapshot`
Replace `./deserialize` with `./deserialize/omnichain-indexing-status-snapshot`
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
📝 WalkthroughWalkthroughThis pull request refactors the indexing-status module by extracting omnichain indexing snapshot types, serialization/deserialization, and validation logic into dedicated, focused modules. Previously scattered logic is consolidated into dedicated files for types, serializers, deserializers, and Zod schemas, while simplifying helpers and updating import paths across the codebase. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
packages/ensnode-sdk/src/ensindexer/indexing-status/zod-schemas.ts
Dismissed
Show dismissed
Hide dismissed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Refactors the ENSNode SDK’s ENSIndexer indexing-status area to split the OmnichainIndexingStatusSnapshot model/serialization/deserialization/Zod schema into dedicated modules, paving the way for an independent validation layer.
Changes:
- Moved the
OmnichainIndexingStatusSnapshotdata model + helper logic into a newomnichain-indexing-status-snapshot.tsmodule. - Extracted omnichain snapshot Zod schema + invariants into
zod-schema/omnichain-indexing-status-snapshot.tsand wired it into the existing zod-schemas entrypoint. - Extracted omnichain snapshot serialization/deserialization types + functions into
serialize/omnichain-indexing-status-snapshot.tsanddeserialize/omnichain-indexing-status-snapshot.ts.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ensnode-sdk/src/ensindexer/indexing-status/zod-schemas.ts | Switched omnichain snapshot schema import to the new dedicated zod-schema module. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/zod-schema/omnichain-indexing-status-snapshot.ts | New: omnichain snapshot Zod schema + related invariants and chain-map transform. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/validations.ts | Removed omnichain snapshot invariants from the shared validations module. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/types.ts | Removed omnichain snapshot types from types.ts; now references the new omnichain model module. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/serialized-types.ts | Redirected omnichain snapshot serialized type usage to the new serialize module. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/serialize/omnichain-indexing-status-snapshot.ts | New: omnichain snapshot serialization + serialized type definitions. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/serialize.ts | Delegates omnichain snapshot serialization to the new serialize module. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/projection.test.ts | Updated imports to reference the new omnichain model module. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/omnichain-indexing-status-snapshot.ts | New: omnichain snapshot data model + helper functions (status/cursor derivation, checks). |
| packages/ensnode-sdk/src/ensindexer/indexing-status/omnichain-indexing-status-snapshot.test.ts | Updated imports to reference the new omnichain model module. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/index.ts | Barrel exports updated to include new omnichain serialize/deserialize/model modules. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/helpers.ts | Removed omnichain helper logic now housed in the omnichain model module. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/deserialize/omnichain-indexing-status-snapshot.ts | New: omnichain snapshot deserialization helper using the new schema module. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/deserialize.ts | Removed omnichain snapshot deserializer from the shared deserialize module. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/conversions.test.ts | Updated imports to use the new omnichain serialize/deserialize modules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In
`@packages/ensnode-sdk/src/ensindexer/indexing-status/omnichain-indexing-status-snapshot.ts`:
- Around line 264-272: The local variable allChainsHaveValidStatuses in function
checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotFollowing is
misleading because it uses chains.some(...) (checks at least one Following);
rename it to reflect that behavior (e.g., anyChainFollowing or
hasFollowingChain) and update the return to use the new name so the code and
identifier semantics match (referencing ChainIndexingStatusIds.Following).
- Around line 329-331: Add an explicit type guard to narrow
ChainIndexingStatusSnapshot at compile time: implement a function named
isChainIndexedOrBetter(chain: ChainIndexingStatusSnapshot): chain is
Exclude<ChainIndexingStatusSnapshot, ChainIndexingStatusSnapshotQueued> that
returns chain.chainStatus !== ChainIndexingStatusIds.Queued, then use
chains.filter(isChainIndexedOrBetter).map(chain =>
chain.latestIndexedBlock.timestamp) to populate latestIndexedBlockTimestamps so
TypeScript knows latestIndexedBlock is present.
In
`@packages/ensnode-sdk/src/ensindexer/indexing-status/serialize/omnichain-indexing-status-snapshot.ts`:
- Around line 65-98: The switch in serializeOmnichainIndexingStatusSnapshot
repeats identical runtime logic for every OmnichainIndexingStatusIds branch;
extract the common object creation into one shared value and return it once
(e.g., build a const base = { omnichainStatus: indexingStatus.omnichainStatus,
chains: serializeChainIndexingSnapshots(indexingStatus.chains),
omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor }), then perform
a single type assertion or conditional satisfies for the specific
SerializedOmnichainIndexingStatusSnapshot* variant if needed; update references
to OmnichainIndexingStatusIds and serializeChainIndexingSnapshots accordingly
and remove the duplicated case bodies in
serializeOmnichainIndexingStatusSnapshot.
In
`@packages/ensnode-sdk/src/ensindexer/indexing-status/zod-schema/omnichain-indexing-status-snapshot.ts`:
- Around line 313-318: The Following variant schema produced by
makeOmnichainIndexingStatusSnapshotFollowingSchema is missing the object-level
invariant that enforces chain invariants; update
makeOmnichainIndexingStatusSnapshotFollowingSchema to call
.check(invariant_omnichainStatusSnapshotFollowingHasValidChains as (v:
ParsePayload<OmnichainIndexingStatusSnapshotFollowing>) => boolean, ...) on the
returned z.strictObject so the specific invariant
invariant_omnichainStatusSnapshotFollowingHasValidChains is applied at the
snapshot (object) level rather than on the chains field; ensure you use the
ParsePayload<OmnichainIndexingStatusSnapshotFollowing> typing when casting the
predicate to satisfy the invariant's expected input type.
packages/ensnode-sdk/src/ensindexer/indexing-status/omnichain-indexing-status-snapshot.ts
Show resolved
Hide resolved
packages/ensnode-sdk/src/ensindexer/indexing-status/omnichain-indexing-status-snapshot.ts
Show resolved
Hide resolved
...s/ensnode-sdk/src/ensindexer/indexing-status/serialize/omnichain-indexing-status-snapshot.ts
Show resolved
Hide resolved
.../ensnode-sdk/src/ensindexer/indexing-status/zod-schema/omnichain-indexing-status-snapshot.ts
Show resolved
Hide resolved
.../ensnode-sdk/src/ensindexer/indexing-status/zod-schema/omnichain-indexing-status-snapshot.ts
Show resolved
Hide resolved
Greptile OverviewGreptile SummaryThis PR refactors the ENSNode SDK indexing-status model by extracting One merge-blocking issue: Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Consumer as SDK Consumer
participant Deserialize as deserialize*()
participant Zod as Zod Schemas
participant Validate as invariants/checks
participant Model as OmnichainIndexingStatusSnapshot
participant Serialize as serialize*()
Consumer->>Deserialize: deserializeOmnichainIndexingStatusSnapshot(serialized)
Deserialize->>Zod: makeOmnichainIndexingStatusSnapshotSchema().safeParse(serialized)
Zod->>Validate: .check(invariants...)
Validate-->>Zod: issues[] (if invariant fails)
Zod-->>Deserialize: parsed.data or error
Deserialize-->>Consumer: OmnichainIndexingStatusSnapshot
Consumer->>Serialize: serializeOmnichainIndexingStatusSnapshot(model)
Serialize->>Model: read omnichainStatus/chains/cursor
Serialize-->>Consumer: SerializedOmnichainIndexingStatusSnapshot
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
15 files reviewed, 2 comments
packages/ensnode-sdk/src/ensindexer/indexing-status/omnichain-indexing-status-snapshot.ts
Show resolved
Hide resolved
Additional Comments (1)
This test name is missing the closing |
|
No AI agents feedback requires action in this PR. |
|
@greptile review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
15 files reviewed, 1 comment
Additional Comments (1)
|
lightwalker-eth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tk-o Looks good. Thanks
Lite PR
Tip: Review docs on the ENSNode PR process
Summary
OmnichainIndexingStatusSnapshotdata model.Why
Unvalidated<OmnichainIndexingStatusSnapshot>and have it validated withvalidateOmnichainIndexingStatusSnapshot.Testing
/api/indexing-statuson local ENSIndexer instance./api/indexing-statuson local ENSApi instance connected to ENSIndexer Alpha in the Green env.Notes for Reviewer (Optional)
CrossChainIndexingStatusSnapshotRealtimeIndexingStatusProjectionPre-Review Checklist (Blocking)