Skip to content

Commit

Permalink
Fixes method access checks (#669)
Browse files Browse the repository at this point in the history
* use .some to find table access type

* chore: changeset

Co-authored-by: mendesfabio <[email protected]>
  • Loading branch information
kyscott18 and mendesfabio authored Feb 29, 2024
1 parent 46816a0 commit 41c72ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-otters-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ponder/core": patch
---

Fixed indexing service event ordering bug.
8 changes: 5 additions & 3 deletions packages/core/src/indexing/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,9 @@ export class IndexingService extends Emittery<IndexingEvents> {

// All tables that this indexing function key reads
const tableReads = this.tableAccess[indexingFunctionKey]
?.filter((t) => storeMethodAccess[t.storeMethod][0] === "read")
?.filter((t) =>
storeMethodAccess[t.storeMethod].some((s) => s === "read"),
)
.map((t) => t.tableName);

// All indexing function keys that write to a table in `tableReads`
Expand All @@ -917,7 +919,7 @@ export class IndexingService extends Emittery<IndexingEvents> {
] ?? []) {
if (
!parentIndexingFunctionKey.includes(":setup") &&
storeMethodAccess[storeMethod][1] === "write" &&
storeMethodAccess[storeMethod].some((s) => s === "write") &&
tableReads.includes(tableName) &&
parentIndexingFunctionKey !== indexingFunctionKey
) {
Expand All @@ -928,7 +930,7 @@ export class IndexingService extends Emittery<IndexingEvents> {

const isSelfDependent = this.tableAccess[indexingFunctionKey]?.some(
(t) =>
storeMethodAccess[t.storeMethod][1] === "write" &&
storeMethodAccess[t.storeMethod].some((s) => s === "write") &&
tableReads.includes(t.tableName),
);

Expand Down

0 comments on commit 41c72ad

Please sign in to comment.