-
Notifications
You must be signed in to change notification settings - Fork 17
Replace ponder.on with addOnchainEventListener
#1839
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
be7bbf1
Create `addOnchainEventListener` function
tk-o 516741e
Replace `ponder.on` with `addOnchainEventListener`
tk-o 272f464
docs(changeset): Replaced `ponder.on` with `addOnchainEventListener`.…
tk-o f27483d
Create `indexing-engines/ponder.ts` file
tk-o 5ed57de
Update `context` param data model
tk-o 54314e9
Update import paths
tk-o 074ac56
Update naming convention used in event handlers
tk-o 9993dae
Apply AI feedback
tk-o dbea54c
Code formatting update
tk-o 1a46168
Replace `"ponder:schema"` import with `@/lib/indexing-engines/ponder`
tk-o 5fca5f5
Apply PR feedback
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 @@ | ||
| --- | ||
| "ensindexer": minor | ||
| --- | ||
|
|
||
| Replaced `ponder.on` with `addOnchainEventListener`. This change enables more granular management of the indexing process. |
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 |
|---|---|---|
| @@ -1,16 +1,20 @@ | ||
| import type { Context } from "ponder:registry"; | ||
| import schema from "ponder:schema"; | ||
| import ensIndexerSchema from "ponder:schema"; | ||
| import type { Address } from "viem"; | ||
|
|
||
| import { interpretAddress } from "@ensnode/ensnode-sdk"; | ||
|
|
||
| import type { IndexingEngineContext } from "@/lib/indexing-engines/ponder"; | ||
|
|
||
| /** | ||
| * Ensures that the account identified by `address` exists. | ||
| * If `address` is the zeroAddress, no-op. | ||
| */ | ||
| export async function ensureAccount(context: Context, address: Address) { | ||
| export async function ensureAccount(context: IndexingEngineContext, address: Address) { | ||
| const interpreted = interpretAddress(address); | ||
| if (interpreted === null) return; | ||
|
|
||
| await context.db.insert(schema.account).values({ id: interpreted }).onConflictDoNothing(); | ||
| await context.ensDb | ||
| .insert(ensIndexerSchema.account) | ||
| .values({ id: interpreted }) | ||
| .onConflictDoNothing(); | ||
| } | ||
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 |
|---|---|---|
| @@ -1,22 +1,24 @@ | ||
| import type { Context } from "ponder:registry"; | ||
| import schema from "ponder:schema"; | ||
| import ensIndexerSchema from "ponder:schema"; | ||
| import type { Address } from "viem"; | ||
|
|
||
| import { type ENSv1DomainId, interpretAddress } from "@ensnode/ensnode-sdk"; | ||
|
|
||
| import { ensureAccount } from "@/lib/ensv2/account-db-helpers"; | ||
| import type { IndexingEngineContext } from "@/lib/indexing-engines/ponder"; | ||
|
|
||
| /** | ||
| * Sets an ENSv1 Domain's effective owner to `owner`. | ||
| */ | ||
| export async function materializeENSv1DomainEffectiveOwner( | ||
| context: Context, | ||
| context: IndexingEngineContext, | ||
| id: ENSv1DomainId, | ||
| owner: Address, | ||
| ) { | ||
| // ensure owner | ||
| await ensureAccount(context, owner); | ||
|
|
||
| // update v1Domain's effective owner | ||
| await context.db.update(schema.v1Domain, { id }).set({ ownerId: interpretAddress(owner) }); | ||
| await context.ensDb | ||
| .update(ensIndexerSchema.v1Domain, { id }) | ||
| .set({ ownerId: interpretAddress(owner) }); | ||
| } |
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
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
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
Oops, something went wrong.
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.
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.
Would it make sense to make it so that
@/lib/indexing-engines/ponderhad an export namedensIndexerSchemaand then all the event handlers would importensIndexerSchemafrom that file too?Goals include: no direct imports from Ponder in our event handlers.