Skip to content
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

isolated chain ordering #1441

Draft
wants to merge 229 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
229 commits
Select commit Hold shift + click to select a range
972f036
api functions refactor
kyscott18 Dec 16, 2024
52986fb
start client
kyscott18 Dec 10, 2024
1936265
cleanup
kyscott18 Dec 10, 2024
a8758d3
improve client
kyscott18 Dec 11, 2024
1c32de7
types
kyscott18 Dec 13, 2024
6309706
postgres readonly database user
kyscott18 Dec 12, 2024
4807ea8
postgres search path
kyscott18 Dec 12, 2024
96cb514
some pglite
kyscott18 Dec 13, 2024
fd2f4c7
cleanup
kyscott18 Dec 13, 2024
eeca48f
examples
kyscott18 Dec 16, 2024
b3f6f0a
pnpm dedupe
kyscott18 Dec 17, 2024
b881974
bundle optimization
kyscott18 Dec 17, 2024
3e8013c
Merge branch 'v0.9' into kjs/db-role
kyscott18 Dec 18, 2024
a6cf9fd
cleanup
kyscott18 Dec 18, 2024
fd0d4db
more strict role
kyscott18 Dec 18, 2024
43accc7
pglite simplification
kyscott18 Dec 18, 2024
f4c0ae2
cleanup
kyscott18 Dec 18, 2024
e751916
fix tests
kyscott18 Dec 18, 2024
8819324
set drizzle schema fn
kyscott18 Dec 18, 2024
dd1f335
fix test
kyscott18 Dec 18, 2024
3ba0407
granular build
kyscott18 Dec 18, 2024
4934069
vite import
kyscott18 Dec 19, 2024
959ff6d
cleanup dev server
kyscott18 Dec 19, 2024
7cb4b94
fix start script
kyscott18 Dec 19, 2024
3d25521
improve errors
kyscott18 Dec 19, 2024
c5aa43b
update docs
kyscott18 Dec 19, 2024
175fac6
migration guide
kyscott18 Dec 19, 2024
40c0b22
Merge branch 'v0.9' into kjs/api-functions
kyscott18 Dec 19, 2024
1bba539
Merge branch 'kjs/api-functions' into kjs/client-db
kyscott18 Dec 19, 2024
1b48f7f
update client
kyscott18 Dec 19, 2024
19f79c6
use client in e2e tests
kyscott18 Dec 19, 2024
e31c86c
fix browser compatibility
kyscott18 Dec 19, 2024
dd313f1
stricter db types
kyscott18 Dec 19, 2024
1d0d66b
more strict db types
kyscott18 Dec 19, 2024
596c58d
fix ci
kyscott18 Dec 19, 2024
8482f93
docs
kyscott18 Dec 20, 2024
af071f9
nits
kyscott18 Dec 20, 2024
e000be0
limit query complexity
kyscott18 Dec 20, 2024
2d20ff6
fix e2e tests
kyscott18 Dec 20, 2024
6ed05f8
nits
kyscott18 Dec 20, 2024
30ec128
nits
kyscott18 Dec 20, 2024
7d57a61
nits
kyscott18 Dec 20, 2024
ba2b131
prepare namespace
kyscott18 Dec 20, 2024
5e5c98a
Merge pull request #1353 from ponder-sh/kjs/db-role
kyscott18 Dec 20, 2024
05dcb21
Merge branch 'v0.9' into kjs/api-functions
kyscott18 Dec 20, 2024
edd15e1
Merge pull request #1351 from ponder-sh/kjs/api-functions
kyscott18 Dec 20, 2024
5d3bb1d
Merge branch 'v0.9' into kjs/client-db
kyscott18 Dec 20, 2024
12d0e72
Merge pull request #1352 from ponder-sh/kjs/client-db
kyscott18 Dec 20, 2024
a165228
links
kyscott18 Dec 20, 2024
8edde32
client package
kyscott18 Dec 20, 2024
7bb1091
chore: prerelease
typedarray Dec 20, 2024
aa84bf5
update mg
kyscott18 Dec 20, 2024
377b02d
Merge branch 'v0.9' of https://github.com/0xOlias/ponder into v0.9
kyscott18 Dec 20, 2024
6ae709a
processing filter arrays in build added
khaidarkairbek Dec 23, 2024
a150566
filters build: args required, filters array, singular event
khaidarkairbek Dec 28, 2024
be7a78d
Merge branch 'main' into contracts-filter
khaidarkairbek Dec 29, 2024
dfc0564
tests fixed
khaidarkairbek Dec 29, 2024
8ff2f01
remove schema from cli options
kyscott18 Dec 31, 2024
14611db
minor refactoring
khaidarkairbek Dec 31, 2024
767bed9
refactor types location
kyscott18 Dec 31, 2024
c027cd3
internal directoryq
kyscott18 Jan 1, 2025
6e6d23c
database wrap
kyscott18 Jan 1, 2025
9f18b3a
cleanup
kyscott18 Jan 1, 2025
d4d2dad
source network
kyscott18 Jan 1, 2025
0edeef2
cleanup
kyscott18 Jan 1, 2025
ad4a41a
Merge branch 'v0.9' into contracts-filter
kyscott18 Jan 2, 2025
81019f5
remove filter from event names
kyscott18 Jan 2, 2025
5fc94bb
materialized status table
kyscott18 Jan 3, 2025
8cefecd
status export
kyscott18 Jan 3, 2025
dcada7d
fix shutdown behavior
kyscott18 Jan 3, 2025
499f140
start live queries
kyscott18 Jan 4, 2025
26c849a
escape database role
kyscott18 Jan 4, 2025
76d677a
fix
kyscott18 Jan 4, 2025
82d65b8
jsdoc
kyscott18 Jan 4, 2025
bb4ec2d
add status to client
kyscott18 Jan 4, 2025
88658f6
cleanup
kyscott18 Jan 4, 2025
ea51dd6
update types
kyscott18 Jan 5, 2025
0c35b0c
docs
kyscott18 Jan 5, 2025
1adf84d
Merge pull request #1373 from khaidarkairbek/contracts-filter
khaidarkairbek Jan 5, 2025
41c8a55
docs
kyscott18 Jan 5, 2025
379b7bb
Merge branch 'main' into v0.9
kyscott18 Jan 5, 2025
353d1e9
Merge branch 'main' into v0.9
kyscott18 Jan 5, 2025
77b2570
fix database cleanup and module argument types
kyscott18 Jan 5, 2025
f6b21bc
Merge branch 'v0.9' into kjs/internal
kyscott18 Jan 5, 2025
d7cdc74
fix merge
kyscott18 Jan 5, 2025
57a33ab
Merge pull request #1392 from ponder-sh/kjs/internal
kyscott18 Jan 5, 2025
222c635
Merge branch 'v0.9' into kjs/status
kyscott18 Jan 6, 2025
5dcd312
remove status from core
kyscott18 Jan 6, 2025
701dd0b
fix bad merge
kyscott18 Jan 6, 2025
8e257de
Merge pull request #1391 from ponder-sh/kjs/status
kyscott18 Jan 6, 2025
d7e0dd5
fix client example
kyscott18 Jan 6, 2025
56244e5
Merge branch 'v0.9' into kjs/live
kyscott18 Jan 6, 2025
bd591bc
use notifications on status table for live queries
kyscott18 Jan 8, 2025
2a7b8b7
live query
kyscott18 Jan 9, 2025
8a1175d
fix test
kyscott18 Jan 9, 2025
cd7544c
update run test
kyscott18 Jan 9, 2025
9a99deb
live query examples
kyscott18 Jan 9, 2025
214a12a
ping
kyscott18 Jan 9, 2025
3a075b1
cleanup
kyscott18 Jan 9, 2025
9001a85
docs
kyscott18 Jan 9, 2025
af25a96
batch query status
kyscott18 Jan 9, 2025
909d575
docs
kyscott18 Jan 9, 2025
0809696
update docs
kyscott18 Jan 9, 2025
dfe5c50
fix serve
kyscott18 Jan 9, 2025
30d6527
Merge branch 'main' into v0.9
kyscott18 Jan 9, 2025
9db4d1b
Merge branch 'v0.9' into kjs/live
kyscott18 Jan 9, 2025
2a55731
fix merge
kyscott18 Jan 9, 2025
f6ef3a6
remove driver from database type
kyscott18 Jan 9, 2025
b8d21e6
inject clients into api file
kyscott18 Jan 9, 2025
43cb1cd
chore: prerelease
typedarray Jan 9, 2025
bcf696d
wip docs
typedarray Jan 10, 2025
c94ae19
fix dev server
kyscott18 Jan 10, 2025
f6b7938
Merge branch 'kjs/live' of https://github.com/0xOlias/ponder into kjs…
kyscott18 Jan 10, 2025
260f7fa
fix plugin
kyscott18 Jan 10, 2025
e3c4372
`@ponder/react` (#1428)
kyscott18 Jan 10, 2025
3ee8edb
prerelease
typedarray Jan 10, 2025
1576aa8
offchain tables example
kyscott18 Jan 10, 2025
02c6bef
tsup config
kyscott18 Jan 10, 2025
3d0062a
pnpm dedupe
kyscott18 Jan 10, 2025
7c15a61
fix docs link
kyscott18 Jan 13, 2025
1913fac
Merge pull request #1429 from ponder-sh/kjs/api-client
kyscott18 Jan 13, 2025
097ae94
merge
kyscott18 Jan 13, 2025
d1c8651
cleanup
kyscott18 Jan 13, 2025
f79b1f8
export queryKey helper function
kyscott18 Jan 13, 2025
633cf48
.
kyscott18 Jan 13, 2025
ff0b188
public client docs
kyscott18 Jan 13, 2025
e6570e7
add client to examples
kyscott18 Jan 13, 2025
a0b1d04
Merge pull request #1431 from ponder-sh/kjs/offchain
kyscott18 Jan 13, 2025
2fb7c64
Merge branch 'main' into v0.9
kyscott18 Jan 13, 2025
b832c25
Merge branch 'v0.9' of https://github.com/0xOlias/ponder into v0.9
kyscott18 Jan 14, 2025
a963eaf
Merge branch 'v0.9' into kjs/live
kyscott18 Jan 14, 2025
549e395
Merge branch 'main' into v0.9
kyscott18 Jan 14, 2025
ad6afa5
Merge branch 'v0.9' into kjs/live
kyscott18 Jan 14, 2025
64e6637
initial commit
kyscott18 Jan 14, 2025
fa673b8
note
kyscott18 Jan 14, 2025
1cfb77d
Merge branch 'main' into v0.9
kyscott18 Jan 14, 2025
2160a45
Merge branch 'v0.9' into kjs/multichain
kyscott18 Jan 14, 2025
b467ad7
multichain
kyscott18 Jan 14, 2025
06bac0a
metrics
kyscott18 Jan 14, 2025
ea21048
use globalThis
typedarray Jan 15, 2025
34bcc9c
algorithm utils
kyscott18 Jan 15, 2025
bf9f5a3
cleanup
kyscott18 Jan 15, 2025
b6461f0
add mode to config
kyscott18 Jan 15, 2025
c923797
app router
typedarray Jan 15, 2025
65df14f
finalize checkpoint and generator tests
kyscott18 Jan 15, 2025
94bc19a
multichain for single network
kyscott18 Jan 15, 2025
77e5882
fix types
kyscott18 Jan 15, 2025
a04ee74
more tests
kyscott18 Jan 16, 2025
5b3f044
fix: packaging, RSC (#1445)
typedarray Jan 16, 2025
4be754f
prerelease
typedarray Jan 16, 2025
594fd28
start realtime testing
kyscott18 Jan 16, 2025
afb71a1
more sync testing
kyscott18 Jan 16, 2025
a62400c
update client and react libraries, fix status
kyscott18 Jan 16, 2025
5e60594
update example app
kyscott18 Jan 16, 2025
ba649ab
fix lint
kyscott18 Jan 16, 2025
bee9441
add temp file limti
kyscott18 Jan 17, 2025
cf82775
docs cleanup
kyscott18 Jan 17, 2025
829a277
Merge branch 'main' into v0.9
kyscott18 Jan 17, 2025
01fce86
Merge branch 'v0.9' into kjs/live
kyscott18 Jan 17, 2025
411c899
fix type error
kyscott18 Jan 17, 2025
c8e412a
Merge pull request #1408 from ponder-sh/kjs/live
kyscott18 Jan 17, 2025
f6ce6eb
chore: changeset
kyscott18 Jan 17, 2025
da9266f
fix graphql status
kyscott18 Jan 17, 2025
65d8cec
fix schema escaping
kyscott18 Jan 17, 2025
ff98f93
dont drop role if already exists, make sure database name exists
jaylmiller Jan 17, 2025
ee5e6d4
fix omnichain latency timer
kyscott18 Jan 17, 2025
2a2673b
comments
kyscott18 Jan 17, 2025
8cff706
prerelease
typedarray Jan 18, 2025
080a5bd
only set temp_file_limit if current user has superuser
jaylmiller Jan 18, 2025
3e613d0
run ddl/permissions code in transaction
jaylmiller Jan 18, 2025
8e32ec9
Merge pull request #1450 from ponder-sh/jay/v09-role-fix
jaylmiller Jan 18, 2025
2681802
relax hono check
typedarray Jan 18, 2025
8d68bf1
prerelease
typedarray Jan 18, 2025
732d83e
check for recursive query in client
kyscott18 Jan 20, 2025
9e524df
new app type
kyscott18 Jan 20, 2025
25caa4a
Merge branch 'main' into v0.9
typedarray Jan 20, 2025
f705c14
cleanup
kyscott18 Jan 20, 2025
7218045
cleanup
kyscott18 Jan 21, 2025
34c32a6
fix: schema dropped after role created
typedarray Jan 21, 2025
3ef2ced
prerelease
typedarray Jan 21, 2025
7955b9e
Merge branch 'v0.9' into kjs/multichain
kyscott18 Jan 21, 2025
c5826f8
fix type error
kyscott18 Jan 21, 2025
e0e2522
Merge branch 'v0.9' into kjs/multichain
kyscott18 Jan 21, 2025
7ec22b2
fix status bug
kyscott18 Jan 21, 2025
5c0242e
remove role
kyscott18 Jan 22, 2025
f5705ea
Merge branch 'v0.9' into kjs/multichain
kyscott18 Jan 22, 2025
c64d385
fix build constraint
kyscott18 Jan 22, 2025
d80d71a
fix postgres schema
kyscott18 Jan 22, 2025
61c2951
Merge branch 'v0.9' into kjs/multichain
kyscott18 Jan 22, 2025
bede0a1
client security
kyscott18 Jan 22, 2025
e4aa401
fix database
kyscott18 Jan 23, 2025
1b3a7f5
merge main
typedarray Jan 23, 2025
50693a2
start cmd
typedarray Jan 23, 2025
6362025
prerelease
typedarray Jan 23, 2025
71de3d7
exports ilike, notlike
typedarray Jan 23, 2025
be031b2
start validation
kyscott18 Jan 25, 2025
f4d8edf
validate
kyscott18 Jan 25, 2025
525253f
Merge pull request #1464 from ponder-sh/kjs/query-validation
kyscott18 Jan 27, 2025
6c60571
cleanup client
kyscott18 Jan 27, 2025
1f7af76
cleanup
kyscott18 Jan 27, 2025
5f315af
pg client settings
kyscott18 Jan 27, 2025
fcaf227
update docs
kyscott18 Jan 27, 2025
d6d5993
no subscribe when not enabled
kyscott18 Jan 27, 2025
1d3bcd7
fix dynamic import
kyscott18 Jan 27, 2025
b3bdc20
fix api functions imports
kyscott18 Jan 27, 2025
e23689e
fix validation
kyscott18 Jan 27, 2025
e7c542e
Merge branch 'main' into v0.9
kyscott18 Jan 27, 2025
3a5042f
Merge branch 'v0.9' into kjs/multichain
kyscott18 Jan 27, 2025
0bd2b13
merge multichain
kyscott18 Jan 28, 2025
20ab2d1
fix test type error
kyscott18 Jan 28, 2025
8bbbf95
remove console.log
kyscott18 Jan 28, 2025
bb5ac0e
Merge branch 'v0.9' into kjs/multichain
kyscott18 Jan 28, 2025
2249d5d
nits
kyscott18 Jan 28, 2025
659b0fd
comment
kyscott18 Jan 28, 2025
db76b1d
update docs
kyscott18 Jan 28, 2025
85cfe0f
refactor seconds metrics
kyscott18 Jan 28, 2025
26d8696
cleanup
kyscott18 Jan 28, 2025
5af59fb
Merge branch 'v0.9' into kjs/multichain
kyscott18 Jan 28, 2025
d52a454
historical sync logs
kyscott18 Jan 28, 2025
bb64601
event extract logs
kyscott18 Jan 28, 2025
735bd81
fix extract logs
kyscott18 Jan 28, 2025
dcf47b5
realtime event logs
kyscott18 Jan 29, 2025
76ada96
more logs
kyscott18 Jan 29, 2025
9d2210e
cleanup
kyscott18 Jan 29, 2025
1cd26b4
fix test type error
kyscott18 Jan 29, 2025
0888541
multichain reorg handling
kyscott18 Jan 30, 2025
79091fa
fix progress bar unit
kyscott18 Jan 31, 2025
40b6ce3
fix multichain reorg bug
kyscott18 Feb 2, 2025
82e02c0
more verbose logs
kyscott18 Feb 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "ponder-sh/ponder" }],
"commit": false,
"fixed": [["ponder", "create-ponder", "eslint-config-ponder"]],
"fixed": [
[
"ponder",
"create-ponder",
"eslint-config-ponder",
"@ponder/client",
"@ponder/react"
]
],
"ignore": [
"@ponder/common",
"ponder-examples-feature-accounts",
Expand Down
13 changes: 13 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"mode": "pre",
"tag": "next",
"initialVersions": {
"@ponder/client": "0.0.0",
"@ponder/common": "0.0.0",
"ponder": "0.8.7",
"create-ponder": "0.8.7",
"eslint-config-ponder": "0.8.7",
"@ponder/utils": "0.2.3"
},
"changesets": []
}
8 changes: 8 additions & 0 deletions .changeset/warm-cats-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"create-ponder": minor
"@ponder/client": minor
"@ponder/react": minor
"ponder": minor
---

Released `0.9`. Visit the [migration guide](https://ponder.sh/docs/migration-guide) for details.
15 changes: 3 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ jobs:
- name: Setup
uses: ./.github/actions/setup

- name: Codegen
run: cd packages/core/ && pnpm wagmi generate

- name: Typecheck
run: pnpm typecheck

- name: Test (types)
run: pnpm --filter "ponder" test:typecheck

- name: Lint
run: pnpm lint

Expand All @@ -46,6 +37,9 @@ jobs:
- name: Build
run: pnpm build

- name: Test (types)
run: pnpm --filter "ponder" test:typecheck

test:
name: Test [core]
runs-on: ubuntu-latest
Expand All @@ -66,9 +60,6 @@ jobs:
- name: Setup
uses: ./.github/actions/setup

- name: Codegen
run: cd packages/core/ && pnpm wagmi generate

- name: Test
run: pnpm --filter "ponder" test
env:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ jobs:
- name: Setup
uses: ./.github/actions/setup

- name: Codegen
run: cd packages/core/ && pnpm wagmi generate

- name: Test
run: pnpm --filter "ponder" test
env:
Expand Down
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"docs/",
"benchmarks/apps/subgraph-*",
"pnpm-lock.yaml",
"**/*.sol"
"**/*.sol",
"tsconfig.base.json"
]
},
"formatter": {
Expand Down
4 changes: 4 additions & 0 deletions docs/pages/docs/api-reference/database.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ style Z2 fill:#f00,color:#fff

The `_ponder_meta` table tracks the state of an instance running in a specific database schema. It stores the `build_id`, indexing checkpoint, and table names of the current instance, and uses a heartbeat locking mechanism to support the lifecycle logic described above.

### Status Table

The `_ponder_status` table tracks the indexing progress of each chain.

### Build ID and crash recovery

During the build step, each instance generates a content hash of the entire app (config, schema, and indexing function file contents). This is called the `build_id`.
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/docs/api-reference/ponder-cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Commands:
start [options] Start the production server
serve [options] Start the production HTTP server without the indexer
db list List all deployments
codegen Generate the schema.graphql file, then exit
codegen Generate the ponder-env.d.ts file, then exit
```

## dev
Expand Down Expand Up @@ -110,12 +110,12 @@ List all deployments
when changes are detected in `ponder.schema.ts`.
</Callout>

Generate the `schema.graphql` file.
Generate the `ponder-env.d.ts` file.

```bash
Usage: ponder codegen [options]

Generate the schema.graphql file, then exit
Generate the ponder-env.d.ts file, then exit

Options:
-h, --help display help for command
Expand Down
51 changes: 8 additions & 43 deletions docs/pages/docs/contracts-and-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -477,49 +477,10 @@ Tip: On Etherscan, there is a link to the current implementation contract on the

## Event filter

The `filter` option filters for events by signature and indexed argument values. This makes it possible to index events emitted by _any contract on the network_ that match the specified signature and arguments.

### By event name or signature

The `filter.event` option accepts an event name (or list of event names) present in the provided ABI.

```ts filename="ponder.config.ts" {14}
import { createConfig } from "ponder";
import { http } from "viem";

import { ERC20Abi } from "./abis/ERC20";

export default createConfig({
networks: {
mainnet: { chainId: 1, transport: http(process.env.PONDER_RPC_URL_1) },
},
contracts: {
ERC20: {
abi: ERC20Abi,
network: "mainnet",
filter: { event: "Transfer" },
// ^? "Transfer" | "Approval" | ("Transfer" | "Approval")[]
startBlock: 18500000,
endBlock: 18505000,
},
},
});
```

The indexing functions you write will run for all events matching the filter, regardless of which contract emitted them.

```ts filename="src/index.ts"
import { ponder } from "ponder:registry";

ponder.on("ERC20:Transfer", async ({ event }) => {
// This is the address of the contract that emitted the event.
// With this config, it could be any ERC20 contract on mainnet.
event.log.address;
// ^? string
});
```

### By indexed argument value
<Callout type="info">
Ponder will automatically filter out event signatures that don't have a
registered indexing function.
</Callout>

You can use the `filter.event` and `filter.args` options together to filter for events that have specific indexed argument values. Each indexed argument field accepts a single value or a list of values to match.

Expand Down Expand Up @@ -569,6 +530,10 @@ ponder.on("ERC20:Transfer", async ({ event }) => {
});
```

<Callout type="info">
Multiple filters can be specified by passing an array of filter objects.
</Callout>

## Call traces

The `includeCallTraces{:ts}` option specifies whether to enable call trace indexing for a contract. By default, call traces are **disabled**.
Expand Down
116 changes: 116 additions & 0 deletions docs/pages/docs/migration-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,122 @@ import { FileTree, Steps, Tabs, Callout } from "nextra/components";

# Migration guide

## 0.9

### API functions

This release makes Ponder's API layer less opinionated. Now, you just need to default export a Hono `App` object from the `src/api/index.ts` file, and Ponder will serve it.

<Callout type="warning">
The `src/api/index.ts` file is now required and no GraphQL endpoint is served
by default.
</Callout>

Copy the following code into `src/api/index.ts` to achieve the same functionality as `<=0.8`.

```ts filename="src/api/index.ts"
import { db } from "ponder:api";
import schema from "ponder:schema";
import { Hono } from "hono";
import { graphql } from "ponder";

const app = new Hono();

app.use("/", graphql({ db, schema }));
app.use("/graphql", graphql({ db, schema }));

export default app;
```

#### Removed `ponder.get()`, `post()`, `use()`

Now, simply use Hono's built-in routing system.

<div className="code-columns">

```ts filename="src/api/index.ts (<=0.8)"
import { ponder } from "ponder:registry";

ponder.get("/hello", (c) => {
return c.text("Hello, world!");
});
```

```ts filename="src/api/index.ts (0.9)"
import { Hono } from "hono";

const app = new Hono();

app.get("/hello", (c) => {
return c.text("Hello, world!");
});

export default app;
```

</div>

#### `import { db } from "ponder:api"`

The `c.db` object was removed from the Hono context. Now, use the `"ponder:api"` virtual module to access a readonly Drizzle database object.

```ts filename="src/api/index.ts" {1,10}
import { db } from "ponder:api";
import schema from "ponder:schema";
import { Hono } from "hono";

const app = new Hono();

app.get("/account/:address", async (c) => {
const address = c.req.param("address");

const account = await db
.select()
.from(schema.accounts)
.where(eq(schema.accounts.address, address))
.limit(1);

return c.json(account);
});

export default app;
```

#### `import { publicClients } from "ponder:api"`

[Viem Public Clients](https://viem.sh/docs/clients/public) for each network defined in `ponder.config.ts` are injected into `src/api/index.ts`.

```ts filename="src/api/index.ts" {1,11}
import { publicClients, db } from "ponder:api";
import schema from "ponder:schema";
import { Hono } from "hono";

const app = new Hono();

app.get("/account/:chainId/:address", async (c) => {
const chainId = c.req.param("chainId");
const address = c.req.param("address");

const balance = await publicClients[chainId].getBalance({ address });

const account = await db.query.accounts.findFirst({
where: eq(schema.accounts.address, address),
});

return c.json({ balance, account });
});

export default app;
```

### `@ponder/client` and `@ponder/react`

Two new packages for querying Ponder apps. [Read more](/docs/query/client).

### Event filters

The `contracts.filter` property now supports multiple filters, and requires argument values. [Read more](/docs/contracts-and-networks#event-filter).

## 0.8

<Callout type="warning">
Expand Down
3 changes: 2 additions & 1 deletion docs/pages/docs/query/_meta.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
"graphql": "GraphQL",
"api-functions": "API functions",
"client": "Client",
"graphql": "GraphQL",
"direct-sql": "Direct SQL",
};
Loading