Repository: ponder-sh/ponder
Pull request #1355 (2024-12-17 17:15:44)

fix get intervals and github ci


Patch:
diff --git a/.changeset/plenty-camels-marry.md b/.changeset/plenty-camels-marry.md
new file mode 100644
index 00000000..e647b974
--- /dev/null
+++ b/.changeset/plenty-camels-marry.md
@@ -0,0 +1,5 @@
+---
+"ponder": patch
+---
+
+Fixed a bug with detecting cached rpc requests.
diff --git a/.changeset/shiny-masks-try.md b/.changeset/shiny-masks-try.md
new file mode 100644
index 00000000..8f758054
--- /dev/null
+++ b/.changeset/shiny-masks-try.md
@@ -0,0 +1,5 @@
+---
+"ponder": patch
+---
+
+Fixed an issue leading to "could not determine data type of parameter" for some postgres versions.
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
deleted file mode 100644
index af48c559..00000000
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ /dev/null
@@ -1,52 +0,0 @@
-name: Bug report
-description: Report bugs or issues.
-body:
-  - type: markdown
-    attributes:
-      value: |
-        Thanks for taking the time to fill out this bug report! The more info you provide, the faster we can help you. Before you proceed, please confirm that there isn't [already an issue](https://github.com/ponder-sh/ponder/issues) for this bug.
-
-  - type: input
-    attributes:
-      label: Version
-      description: What version of `ponder` or `@ponder/core` are you using?
-      placeholder: x.y.z (do not write `latest`)
-    validations:
-      required: true
-
-  - type: textarea
-    attributes:
-      label: Current behavior
-      description: A concise description of what you're experiencing.
-    validations:
-      required: false
-
-  - type: textarea
-    attributes:
-      label: Expected behavior
-      description: A concise description of what you expected to happen.
-    validations:
-      required: false
-
-  - type: textarea
-    attributes:
-      label: Steps to reproduce
-      description: Steps or code snippets to reproduce the behavior (`ponder.config.ts`, `ponder.schema.ts`, indexing functions, ABIs, etc).
-    validations:
-      required: false
-
-  - type: input
-    attributes:
-      label: Link to repository
-      description: The public repository containing your Ponder app.
-      placeholder: https://github.com/...
-    validations:
-      required: false
-
-  - type: textarea
-    attributes:
-      label: Anything else?
-      description: |
-        Logs? Screenshots? Anything that might help us understand or reproduce the issue. Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
-    validations:
-      required: false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 0e915671..e7a5aa4a 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -28,7 +28,7 @@ jobs:
         run: pnpm typecheck
 
       - name: Test (types)
-        run: pnpm --filter core test:typecheck
+        run: pnpm --filter "ponder" test:typecheck
 
       - name: Lint
         run: pnpm lint
@@ -70,7 +70,7 @@ jobs:
         run: cd packages/core/ && pnpm wagmi generate
 
       - name: Test
-        run: pnpm --filter core test
+        run: pnpm --filter "ponder" test
         env:
           DATABASE_URL: ${{ matrix.database == 'Postgres' && steps.postgres.outputs.connection-uri || '' }}
 
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index d2e69d27..d6fd1eba 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -30,7 +30,7 @@ jobs:
         run: cd packages/core/ && pnpm wagmi generate
 
       - name: Test
-        run: pnpm --filter core test:typecheck
+        run: pnpm --filter "ponder" test
         env:
           DATABASE_URL: ${{ matrix.database == 'Postgres' && steps.postgres.outputs.connection-uri || '' }}
 
diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md
index 00e7877e..dd9ec42f 100644
--- a/packages/core/CHANGELOG.md
+++ b/packages/core/CHANGELOG.md
@@ -1,17 +1,5 @@
 # ponder
 
-## 0.8.6
-
-### Patch Changes
-
-- [#1349](https://github.com/ponder-sh/ponder/pull/1349) [`4b18d8d2ab45475eea651e0db5c515b1242031f5`](https://github.com/ponder-sh/ponder/commit/4b18d8d2ab45475eea651e0db5c515b1242031f5) Thanks [@kyscott18](https://github.com/kyscott18)! - Fixed an issue leading to "could not determine data type of parameter" for some postgres versions.
-
-## 0.8.5
-
-### Patch Changes
-
-- [#1345](https://github.com/ponder-sh/ponder/pull/1345) [`7ec278f0fe5d71ebb5386a5f948ef63f158c174c`](https://github.com/ponder-sh/ponder/commit/7ec278f0fe5d71ebb5386a5f948ef63f158c174c) Thanks [@kyscott18](https://github.com/kyscott18)! - Fixed a bug that caused no events to be found in the historical backfill. Affected users should resync their apps to get rid of the incorrect cached data.
-
 ## 0.8.4
 
 ### Patch Changes
diff --git a/packages/core/package.json b/packages/core/package.json
index 200ae24f..fbee7699 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -1,6 +1,6 @@
 {
   "name": "ponder",
-  "version": "0.8.6",
+  "version": "0.8.4",
   "description": "An open-source framework for crypto application backends",
   "license": "MIT",
   "type": "module",
diff --git a/packages/core/src/sync-historical/index.ts b/packages/core/src/sync-historical/index.ts
index 75bed19c..9403ab62 100644
--- a/packages/core/src/sync-historical/index.ts
+++ b/packages/core/src/sync-historical/index.ts
@@ -153,22 +153,6 @@ export const createHistoricalSync = async (
             filter.topic3 ?? null,
           ];
 
-    // Note: the `topics` field is very fragile for many rpc providers, and
-    // cannot handle extra "null" topics
-
-    if (topics[3] === null) {
-      topics.pop();
-      if (topics[2] === null) {
-        topics.pop();
-        if (topics[1] === null) {
-          topics.pop();
-          if (topics[0] === null) {
-            topics.pop();
-          }
-        }
-      }
-    }
-
     // Batch large arrays of addresses, handling arrays that are empty
 
     let addressBatches: (Address | Address[] | undefined)[];
diff --git a/packages/core/src/sync-realtime/index.ts b/packages/core/src/sync-realtime/index.ts
index e08f5e11..b5b7e37b 100644
--- a/packages/core/src/sync-realtime/index.ts
+++ b/packages/core/src/sync-realtime/index.ts
@@ -66,7 +66,6 @@ type CreateRealtimeSyncParameters = {
 
 export type BlockWithEventData = {
   block: SyncBlock;
-  // filters: Set<Filter>;
   logs: SyncLog[];
   factoryLogs: SyncLog[];
   traces: SyncTrace[];
diff --git a/packages/core/src/sync-store/index.ts b/packages/core/src/sync-store/index.ts
index 33efb29f..9b736729 100644
--- a/packages/core/src/sync-store/index.ts
+++ b/packages/core/src/sync-store/index.ts
@@ -25,7 +25,7 @@ import type {
 } from "@/types/sync.js";
 import type { NonNull } from "@/types/utils.js";
 import { type Interval, intervalIntersectionMany } from "@/utils/interval.js";
-import { type Kysely, type SelectQueryBuilder, sql as ksql, sql } from "kysely";
+import { type Kysely, type SelectQueryBuilder, sql as ksql } from "kysely";
 import type { InsertObject } from "kysely";
 import {
   type Address,
@@ -204,13 +204,13 @@ export const createSyncStore = ({
             .selectFrom(
               db
                 .selectFrom("intervals")
-                .select(sql`unnest(blocks)`.as("blocks"))
+                .select(ksql`unnest(blocks)`.as("blocks"))
                 .where("fragment_id", "in", fragment.adjacent)
                 .as("unnested"),
             )
             .select([
-              sql<string>`range_agg(unnested.blocks)`.as("merged_blocks"),
-              sql.raw<string>(`${i}`).as("filter"),
+              ksql<string>`range_agg(unnested.blocks)`.as("merged_blocks"),
+              ksql.raw(`'${i}'`).as("filter"),
             ]);
           // @ts-ignore
           query = query === undefined ? _query : query.unionAll(_query);
@@ -592,7 +592,7 @@ export const createSyncStore = ({
               .where(
                 "transactionReceipts.transactionHash",
                 "=",
-                sql.ref("transactions.hash"),
+                ksql.ref("transactions.hash"),
               ),
             "=",
             "0x1",
@@ -1006,7 +1006,7 @@ export const createSyncStore = ({
         .selectFrom("rpc_request_results")
         .select("result")
 
-        .where("request_hash", "=", sql`MD5(${request})`)
+        .where("request_hash", "=", ksql`MD5(${request})`)
         .where("chain_id", "=", chainId)
         .executeTakeFirst();
 
diff --git a/packages/create-ponder/CHANGELOG.md b/packages/create-ponder/CHANGELOG.md
index 3de1839c..47163941 100644
--- a/packages/create-ponder/CHANGELOG.md
+++ b/packages/create-ponder/CHANGELOG.md
@@ -1,9 +1,5 @@
 # create-ponder
 
-## 0.8.6
-
-## 0.8.5
-
 ## 0.8.4
 
 ## 0.8.3
diff --git a/packages/create-ponder/package.json b/packages/create-ponder/package.json
index ccf7ce5d..d374cce2 100644
--- a/packages/create-ponder/package.json
+++ b/packages/create-ponder/package.json
@@ -1,6 +1,6 @@
 {
   "name": "create-ponder",
-  "version": "0.8.6",
+  "version": "0.8.4",
   "type": "module",
   "description": "A CLI tool to create Ponder apps",
   "license": "MIT",
diff --git a/packages/eslint-config-ponder/CHANGELOG.md b/packages/eslint-config-ponder/CHANGELOG.md
index 378a8855..4ff28b44 100644
--- a/packages/eslint-config-ponder/CHANGELOG.md
+++ b/packages/eslint-config-ponder/CHANGELOG.md
@@ -1,9 +1,5 @@
 # eslint-config-ponder
 
-## 0.8.6
-
-## 0.8.5
-
 ## 0.8.4
 
 ## 0.8.3
diff --git a/packages/eslint-config-ponder/package.json b/packages/eslint-config-ponder/package.json
index 2dc43948..75e30d01 100644
--- a/packages/eslint-config-ponder/package.json
+++ b/packages/eslint-config-ponder/package.json
@@ -1,6 +1,6 @@
 {
   "name": "eslint-config-ponder",
-  "version": "0.8.6",
+  "version": "0.8.4",
   "description": "ESLint config for Ponder apps",
   "license": "MIT",
   "main": "./index.js",


Test patch:
diff --git a/packages/core/src/_test/setup.ts b/packages/core/src/_test/setup.ts
index 1eef0f29..18a7def9 100644
--- a/packages/core/src/_test/setup.ts
+++ b/packages/core/src/_test/setup.ts
@@ -94,48 +94,64 @@ export async function setupIsolatedDatabase(context: TestContext) {
     await instance.exec(`
       DO $$
       DECLARE
-          obj TEXT;
-          schema TEXT;
+        obj TEXT;
+        schema TEXT;
       BEGIN
-          -- Loop over all user-defined schemas
-          FOR schema IN SELECT nspname FROM pg_namespace WHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema'
+        -- Loop over all user-defined schemas
+        FOR schema IN SELECT nspname FROM pg_namespace WHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema'
+        LOOP
+          -- Drop all tables
+          FOR obj IN SELECT table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema = schema
           LOOP
-              -- Drop all tables
-              FOR obj IN SELECT table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema = schema
-              LOOP
-                  EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(schema) || '.' || quote_ident(obj) || ' CASCADE;';
-              END LOOP;
-
-              -- Drop all sequences
-              FOR obj IN SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = schema
-              LOOP
-                  EXECUTE 'DROP SEQUENCE IF EXISTS ' || quote_ident(schema) || '.' || quote_ident(obj) || ' CASCADE;';
-              END LOOP;
-
-              -- Drop all views
-              FOR obj IN SELECT table_name FROM information_schema.views WHERE table_schema = schema
-              LOOP
-                  EXECUTE 'DROP VIEW IF EXISTS ' || quote_ident(schema) || '.' || quote_ident(obj) || ' CASCADE;';
-              END LOOP;
-
-              -- Drop all functions
-              FOR obj IN SELECT routine_name FROM information_schema.routines WHERE routine_type = 'FUNCTION' AND routine_schema = schema
-              LOOP
-                  EXECUTE 'DROP FUNCTION IF EXISTS ' || quote_ident(schema) || '.' || quote_ident(obj) || ' CASCADE;';
-              END LOOP;
-
-              -- Drop all custom types
-              FOR obj IN SELECT typname FROM pg_type WHERE typnamespace = (SELECT oid FROM pg_namespace WHERE nspname = schema)
-              LOOP
-                  EXECUTE 'DROP TYPE IF EXISTS ' || quote_ident(schema) || '.' || quote_ident(obj) || ' CASCADE;';
-              END LOOP;
-
-              -- Drop all extensions (extensions are usually in public, but handling if in other schemas)
-              FOR obj IN SELECT extname FROM pg_extension WHERE extnamespace = (SELECT oid FROM pg_namespace WHERE nspname = schema)
-              LOOP
-                  EXECUTE 'DROP EXTENSION IF EXISTS ' || quote_ident(obj) || ' CASCADE;';
-              END LOOP;
+            EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(schema) || '.' || quote_ident(obj) || ' CASCADE;';
           END LOOP;
+
+          -- Drop all sequences
+          FOR obj IN SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = schema
+          LOOP
+            EXECUTE 'DROP SEQUENCE IF EXISTS ' || quote_ident(schema) || '.' || quote_ident(obj) || ' CASCADE;';
+          END LOOP;
+
+          -- Drop all views
+          FOR obj IN SELECT table_name FROM information_schema.views WHERE table_schema = schema
+          LOOP
+            EXECUTE 'DROP VIEW IF EXISTS ' || quote_ident(schema) || '.' || quote_ident(obj) || ' CASCADE;';
+          END LOOP;
+
+          -- Drop all functions
+          FOR obj IN SELECT routine_name FROM information_schema.routines WHERE routine_type = 'FUNCTION' AND routine_schema = schema
+          LOOP
+            EXECUTE 'DROP FUNCTION IF EXISTS ' || quote_ident(schema) || '.' || quote_ident(obj) || ' CASCADE;';
+          END LOOP;
+
+          -- Drop all enum types first (this will cascade and drop their associated array types)
+          FOR obj IN
+            SELECT typname
+            FROM pg_type
+            JOIN pg_namespace ns ON pg_type.typnamespace = ns.oid
+            WHERE ns.nspname = schema
+              AND typtype = 'e'  -- 'e' stands for enum type
+          LOOP
+            EXECUTE 'DROP TYPE IF EXISTS ' || quote_ident(schema) || '.' || quote_ident(obj) || ' CASCADE;';
+          END LOOP;
+
+          -- Drop all remaining custom types (non-enum)
+          FOR obj IN
+            SELECT typname
+            FROM pg_type
+            JOIN pg_namespace ns ON pg_type.typnamespace = ns.oid
+            WHERE ns.nspname = schema
+              AND typtype <> 'e'
+          LOOP
+            EXECUTE 'DROP TYPE IF EXISTS ' || quote_ident(schema) || '.' || quote_ident(obj) || ' CASCADE;';
+          END LOOP;
+
+          -- Drop all extensions
+          FOR obj IN SELECT extname FROM pg_extension WHERE extnamespace = (SELECT oid FROM pg_namespace WHERE nspname = schema)
+          LOOP
+            EXECUTE 'DROP EXTENSION IF EXISTS ' || quote_ident(obj) || ' CASCADE;';
+          END LOOP;
+        END LOOP;
       END $$;
     `);
 
diff --git a/packages/core/src/sync-realtime/index.test.ts b/packages/core/src/sync-realtime/index.test.ts
index 0c609b5d..02d3a027 100644
--- a/packages/core/src/sync-realtime/index.test.ts
+++ b/packages/core/src/sync-realtime/index.test.ts
@@ -370,7 +370,7 @@ test("handleBlock() block event with log", async (context) => {
   expect(onEvent).toHaveBeenCalledTimes(1);
   expect(onEvent).toHaveBeenCalledWith({
     type: "block",
-    filters: expect.any(Object),
+    hasMatchedFilter: true,
     block: expect.any(Object),
     logs: expect.any(Object),
     factoryLogs: expect.any(Object),
@@ -453,7 +453,7 @@ test("handleBlock() block event with log factory", async (context) => {
   expect(onEvent).toHaveBeenCalledTimes(2);
   expect(onEvent).toHaveBeenCalledWith({
     type: "block",
-    filters: expect.any(Object),
+    hasMatchedFilter: true,
     block: expect.any(Object),
     logs: expect.any(Object),
     factoryLogs: expect.any(Object),
@@ -532,7 +532,7 @@ test("handleBlock() block event with block", async (context) => {
   expect(onEvent).toHaveBeenCalledTimes(1);
   expect(onEvent).toHaveBeenCalledWith({
     type: "block",
-    filters: expect.any(Object),
+    hasMatchedFilter: true,
     block: expect.any(Object),
     logs: expect.any(Object),
     factoryLogs: expect.any(Object),
@@ -606,7 +606,7 @@ test("handleBlock() block event with transaction", async (context) => {
   expect(onEvent).toHaveBeenCalledTimes(1);
   expect(onEvent).toHaveBeenCalledWith({
     type: "block",
-    filters: expect.any(Object),
+    hasMatchedFilter: true,
     block: expect.any(Object),
     logs: expect.any(Object),
     factoryLogs: expect.any(Object),
@@ -707,7 +707,7 @@ test("handleBlock() block event with transfer", async (context) => {
   expect(onEvent).toHaveBeenCalledTimes(1);
   expect(onEvent).toHaveBeenCalledWith({
     type: "block",
-    filters: expect.any(Object),
+    hasMatchedFilter: true,
     block: expect.any(Object),
     logs: expect.any(Object),
     factoryLogs: expect.any(Object),
@@ -852,7 +852,7 @@ test("handleBlock() block event with trace", async (context) => {
   expect(onEvent).toHaveBeenCalledTimes(2);
   expect(onEvent).toHaveBeenCalledWith({
     type: "block",
-    filters: expect.any(Object),
+    hasMatchedFilter: true,
     block: expect.any(Object),
     logs: expect.any(Object),
     factoryLogs: expect.any(Object),