-
Notifications
You must be signed in to change notification settings - Fork 15
refactor(ensnode-sdk): improve Indexing Status data model #1615
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f849779
Refactor ENSIndexer data model for Indexing Status
tk-o 21c5973
Remove usused code
tk-o e5a0bb6
ENSNode SDK: Export validation APIs for Indexing Status API.
tk-o 12a845e
docs(changeset): Introduced `validate*` functions for Indexing Status…
tk-o 520e393
Create schema-layer for Zod schemas
tk-o f02c31c
Fix typos
tk-o File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@ensnode/ensnode-sdk": minor | ||
| --- | ||
|
|
||
| Introduced `validate*` functions for Indexing Status data model. These functions enable new use cases on consumers side. |
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
35 changes: 31 additions & 4 deletions
35
packages/ensnode-sdk/src/api/indexing-status/deserialize.ts
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
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
File renamed without changes.
122 changes: 122 additions & 0 deletions
122
packages/ensnode-sdk/src/ensindexer/indexing-status/chain-indexing-status-snapshot.mocks.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| import { | ||
| earlierBlockRef, | ||
| earliestBlockRef, | ||
| laterBlockRef, | ||
| latestBlockRef, | ||
| } from "./block-refs.mock"; | ||
| import { | ||
| ChainIndexingConfigTypeIds, | ||
| ChainIndexingStatusIds, | ||
| type ChainIndexingStatusSnapshot, | ||
| type ChainIndexingStatusSnapshotBackfill, | ||
| type ChainIndexingStatusSnapshotCompleted, | ||
| type ChainIndexingStatusSnapshotFollowing, | ||
| type ChainIndexingStatusSnapshotQueued, | ||
| } from "./chain-indexing-status-snapshot"; | ||
| import type { ChainIndexingStatusSnapshotForOmnichainIndexingStatusSnapshotBackfill } from "./omnichain-indexing-status-snapshot"; | ||
|
|
||
| export const chainStatusesQueued = [ | ||
| { | ||
| chainStatus: ChainIndexingStatusIds.Queued, | ||
| config: { | ||
| configType: ChainIndexingConfigTypeIds.Definite, | ||
| startBlock: earliestBlockRef, | ||
| endBlock: latestBlockRef, | ||
| }, | ||
| }, | ||
| { | ||
| chainStatus: ChainIndexingStatusIds.Queued, | ||
| config: { | ||
| configType: ChainIndexingConfigTypeIds.Definite, | ||
| startBlock: earliestBlockRef, | ||
| endBlock: laterBlockRef, | ||
| }, | ||
| }, | ||
| ] satisfies ChainIndexingStatusSnapshotQueued[]; | ||
|
|
||
| export const chainStatusesCompleted = [ | ||
| { | ||
| chainStatus: ChainIndexingStatusIds.Completed, | ||
| config: { | ||
| configType: ChainIndexingConfigTypeIds.Definite, | ||
| startBlock: earlierBlockRef, | ||
|
|
||
| endBlock: latestBlockRef, | ||
| }, | ||
| latestIndexedBlock: latestBlockRef, | ||
| }, | ||
|
|
||
| { | ||
| chainStatus: ChainIndexingStatusIds.Completed, | ||
| config: { | ||
| configType: ChainIndexingConfigTypeIds.Definite, | ||
| startBlock: earliestBlockRef, | ||
| endBlock: laterBlockRef, | ||
| }, | ||
| latestIndexedBlock: laterBlockRef, | ||
| }, | ||
| ] satisfies ChainIndexingStatusSnapshotCompleted[]; | ||
|
|
||
| export const chainStatusesBackfillMixed = [ | ||
| { | ||
| chainStatus: ChainIndexingStatusIds.Queued, | ||
| config: { | ||
| configType: ChainIndexingConfigTypeIds.Definite, | ||
| startBlock: earliestBlockRef, | ||
| endBlock: latestBlockRef, | ||
| }, | ||
| } satisfies ChainIndexingStatusSnapshotQueued, | ||
|
|
||
| { | ||
| chainStatus: ChainIndexingStatusIds.Backfill, | ||
| config: { | ||
| configType: ChainIndexingConfigTypeIds.Indefinite, | ||
| startBlock: earliestBlockRef, | ||
| }, | ||
| latestIndexedBlock: laterBlockRef, | ||
| backfillEndBlock: latestBlockRef, | ||
| } satisfies ChainIndexingStatusSnapshotBackfill, | ||
|
|
||
| { | ||
| chainStatus: ChainIndexingStatusIds.Completed, | ||
| config: { | ||
| configType: ChainIndexingConfigTypeIds.Definite, | ||
| startBlock: earliestBlockRef, | ||
| endBlock: laterBlockRef, | ||
| }, | ||
| latestIndexedBlock: laterBlockRef, | ||
| } satisfies ChainIndexingStatusSnapshotCompleted, | ||
| ] satisfies ChainIndexingStatusSnapshotForOmnichainIndexingStatusSnapshotBackfill[]; | ||
|
|
||
| export const chainStatusesFollowingMixed = [ | ||
| { | ||
| chainStatus: ChainIndexingStatusIds.Following, | ||
| config: { | ||
| configType: ChainIndexingConfigTypeIds.Indefinite, | ||
| startBlock: earlierBlockRef, | ||
| }, | ||
| latestIndexedBlock: laterBlockRef, | ||
| latestKnownBlock: latestBlockRef, | ||
| } satisfies ChainIndexingStatusSnapshotFollowing, | ||
|
|
||
| { | ||
| chainStatus: ChainIndexingStatusIds.Backfill, | ||
| config: { | ||
| configType: ChainIndexingConfigTypeIds.Definite, | ||
| startBlock: earliestBlockRef, | ||
| endBlock: latestBlockRef, | ||
| }, | ||
| latestIndexedBlock: laterBlockRef, | ||
| backfillEndBlock: latestBlockRef, | ||
| } satisfies ChainIndexingStatusSnapshotBackfill, | ||
|
|
||
| { | ||
| chainStatus: ChainIndexingStatusIds.Completed, | ||
| config: { | ||
| configType: ChainIndexingConfigTypeIds.Definite, | ||
| startBlock: earliestBlockRef, | ||
| endBlock: laterBlockRef, | ||
| }, | ||
| latestIndexedBlock: laterBlockRef, | ||
| } satisfies ChainIndexingStatusSnapshotCompleted, | ||
| ] satisfies ChainIndexingStatusSnapshot[]; |
44 changes: 44 additions & 0 deletions
44
packages/ensnode-sdk/src/ensindexer/indexing-status/chain-indexing-status-snapshot.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { earlierBlockRef, laterBlockRef } from "./block-refs.mock"; | ||
| import { | ||
| type ChainIndexingConfigDefinite, | ||
| type ChainIndexingConfigIndefinite, | ||
| ChainIndexingConfigTypeIds, | ||
| createIndexingConfig, | ||
| } from "./chain-indexing-status-snapshot"; | ||
|
|
||
| describe("Chain Indexing Status Snapshot", () => { | ||
| describe("createIndexingConfig", () => { | ||
| it("returns 'definite' indexer config if the endBlock exists", () => { | ||
| // arrange | ||
| const startBlock = earlierBlockRef; | ||
| const endBlock = laterBlockRef; | ||
|
|
||
| // act | ||
| const indexingConfig = createIndexingConfig(startBlock, endBlock); | ||
|
|
||
| // assert | ||
| expect(indexingConfig).toStrictEqual({ | ||
| configType: ChainIndexingConfigTypeIds.Definite, | ||
| startBlock: earlierBlockRef, | ||
| endBlock: laterBlockRef, | ||
| } satisfies ChainIndexingConfigDefinite); | ||
| }); | ||
|
|
||
| it("returns 'indefinite' indexer config if the endBlock does not exist", () => { | ||
| // arrange | ||
| const startBlock = earlierBlockRef; | ||
| const endBlock = null; | ||
|
|
||
| // act | ||
| const indexingConfig = createIndexingConfig(startBlock, endBlock); | ||
|
|
||
| // assert | ||
| expect(indexingConfig).toStrictEqual({ | ||
| configType: ChainIndexingConfigTypeIds.Indefinite, | ||
| startBlock: earlierBlockRef, | ||
| } satisfies ChainIndexingConfigIndefinite); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.