Skip to content

Commit 9c182f3

Browse files
add ponder
1 parent f081022 commit 9c182f3

File tree

13 files changed

+2204
-79
lines changed

13 files changed

+2204
-79
lines changed

package-lock.json

Lines changed: 186 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@
3333
"hardhat:lint-staged": "yarn workspace @se-2/hardhat lint-staged",
3434
"hardhat:test": "yarn workspace @se-2/hardhat test",
3535
"hardhat:verify": "yarn workspace @se-2/hardhat verify",
36+
"ponder:dev": "yarn workspace @se-2/indexer dev",
37+
"ponder:start": "yarn workspace @se-2/indexer start",
38+
"ponder:db": "yarn workspace @se-2/indexer db",
39+
"ponder:codegen": "yarn workspace @se-2/indexer codegen",
40+
"ponder:lint": "yarn workspace @se-2/indexer lint",
3641
"postinstall": "husky install",
3742
"ipfs": "yarn workspace @se-2/nextjs ipfs",
38-
"lint": "yarn next:lint && yarn hardhat:lint",
43+
"lint": "yarn next:lint && yarn hardhat:lint && yarn ponder:lint",
3944
"next:build": "yarn workspace @se-2/nextjs build",
4045
"next:check-types": "yarn workspace @se-2/nextjs check-types",
4146
"next:format": "yarn workspace @se-2/nextjs format",

packages/indexer/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "ponder"
3+
}

packages/indexer/.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Debug
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
.pnpm-debug.log*
9+
10+
# Misc
11+
.DS_Store
12+
13+
# Env files
14+
.env*.local
15+
16+
# Ponder
17+
/generated/
18+
/.ponder/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const ExampleContractAbi = [] as const;

packages/indexer/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "@se-2/indexer",
3+
"version": "0.0.1",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"dev": "ponder dev",
8+
"start": "ponder start",
9+
"db": "ponder db",
10+
"codegen": "ponder codegen",
11+
"lint": "eslint .",
12+
"typecheck": "tsc"
13+
},
14+
"dependencies": {
15+
"hono": "^4.5.0",
16+
"ponder": "^0.13.12",
17+
"viem": "^2.21.3"
18+
},
19+
"devDependencies": {
20+
"@types/node": "^20.9.0",
21+
"eslint": "^8.53.0",
22+
"eslint-config-ponder": "^0.13.12",
23+
"typescript": "^5.2.2"
24+
},
25+
"engines": {
26+
"node": ">=18.14"
27+
}
28+
}

packages/indexer/ponder-env.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference types="ponder/virtual" />
2+
3+
declare module "ponder:internal" {
4+
const config: typeof import("./ponder.config.ts");
5+
const schema: typeof import("./ponder.schema.ts");
6+
}
7+
8+
declare module "ponder:schema" {
9+
export * from "./ponder.schema.ts";
10+
}
11+
12+
// This file enables type checking and editor autocomplete for this Ponder project.
13+
// After upgrading, you may find that changes have been made to this file.
14+
// If this happens, please commit the changes. Do not manually edit this file.
15+
// See https://ponder.sh/docs/requirements#typescript for more information.

packages/indexer/ponder.config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { createConfig } from "ponder";
2+
3+
import { ExampleContractAbi } from "./abis/ExampleContractAbi";
4+
5+
export default createConfig({
6+
chains: {
7+
mainnet: {
8+
id: 1,
9+
rpc: process.env.PONDER_RPC_URL_1!,
10+
},
11+
},
12+
contracts: {
13+
ExampleContract: {
14+
chain: "mainnet",
15+
abi: ExampleContractAbi,
16+
address: "0x0000000000000000000000000000000000000000",
17+
startBlock: 1234567,
18+
},
19+
},
20+
});

packages/indexer/ponder.schema.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { onchainTable } from "ponder";
2+
3+
export const example = onchainTable("example", (t) => ({
4+
id: t.text().primaryKey(),
5+
name: t.text(),
6+
}));

packages/indexer/src/api/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { db } from "ponder:api";
2+
import schema from "ponder:schema";
3+
import { Hono } from "hono";
4+
import { client, graphql } from "ponder";
5+
6+
const app = new Hono();
7+
8+
app.use("/sql/*", client({ db, schema }));
9+
10+
app.use("/", graphql({ db, schema }));
11+
app.use("/graphql", graphql({ db, schema }));
12+
13+
export default app;

0 commit comments

Comments
 (0)