create-ponder 0.4.24 → 0.4.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,7 +26,7 @@ Join [Ponder's telegram chat](https://t.me/ponder_sh) for support, feedback, and
26
26
  ✅ &nbsp;Index events from multiple chains in the same app<br/>
27
27
  ✅ &nbsp;Reconciles chain reorganization<br/>
28
28
  ✅ &nbsp;Factory contracts<br/>
29
- 🏗️ &nbsp;Process transactions calls (in addition to logs)<br/>
29
+ &nbsp;Process transactions calls (in addition to logs)<br/>
30
30
  🏗️ &nbsp;Run effects (e.g. send an API request) in indexing code<br/>
31
31
 
32
32
  ## Quickstart
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import { default as prompts } from "prompts";
16
16
  // package.json
17
17
  var package_default = {
18
18
  name: "create-ponder",
19
- version: "0.4.24",
19
+ version: "0.4.26",
20
20
  type: "module",
21
21
  description: "A CLI tool to create Ponder apps",
22
22
  license: "MIT",
@@ -635,6 +635,11 @@ var templates = [
635
635
  title: "Feature - Block filter",
636
636
  description: "A Ponder app using a block filter"
637
637
  },
638
+ {
639
+ id: "feature-call-traces",
640
+ title: "Feature - Call traces",
641
+ description: "A Ponder app using a call traces"
642
+ },
638
643
  {
639
644
  id: "feature-multichain",
640
645
  title: "Feature - Multichain contract",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ponder",
3
- "version": "0.4.24",
3
+ "version": "0.4.26",
4
4
  "type": "module",
5
5
  "description": "A CLI tool to create Ponder apps",
6
6
  "license": "MIT",
@@ -0,0 +1,5 @@
1
+ # Mainnet RPC URL used for fetching blockchain data. Alchemy is recommended.
2
+ PONDER_RPC_URL_1=
3
+
4
+ # (Optional) Postgres database URL. If not provided, SQLite will be used.
5
+ DATABASE_URL=
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "ponder"
3
+ }
@@ -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/
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "ponder-examples-feature-call-traces",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "ponder dev",
7
+ "start": "ponder start",
8
+ "codegen": "ponder codegen",
9
+ "serve": "ponder serve",
10
+ "lint": "eslint .",
11
+ "typecheck": "tsc"
12
+ },
13
+ "dependencies": {
14
+ "@ponder/core": "workspace:*",
15
+ "viem": "^1.19.9"
16
+ },
17
+ "devDependencies": {
18
+ "@types/node": "^20.10.0",
19
+ "eslint": "^8.54.0",
20
+ "eslint-config-ponder": "workspace:*",
21
+ "typescript": "^5.3.2"
22
+ },
23
+ "engines": {
24
+ "node": ">=18.14"
25
+ }
26
+ }
@@ -0,0 +1,27 @@
1
+ // This file enables type checking and editor autocomplete for this Ponder project.
2
+ // After upgrading, you may find that changes have been made to this file.
3
+ // If this happens, please commit the changes. Do not manually edit this file.
4
+ // See https://ponder.sh/docs/guides/typescript for more information.
5
+
6
+ declare module "@/generated" {
7
+ import type { Virtual } from "@ponder/core";
8
+
9
+ type config = typeof import("./ponder.config.ts").default;
10
+ type schema = typeof import("./ponder.schema.ts").default;
11
+
12
+ export const ponder: Virtual.Registry<config, schema>;
13
+
14
+ export type EventNames = Virtual.EventNames<config>;
15
+ export type Event<name extends EventNames = EventNames> = Virtual.Event<
16
+ config,
17
+ name
18
+ >;
19
+ export type Context<name extends EventNames = EventNames> = Virtual.Context<
20
+ config,
21
+ schema,
22
+ name
23
+ >;
24
+ export type IndexingFunctionArgs<name extends EventNames = EventNames> =
25
+ Virtual.IndexingFunctionArgs<config, schema, name>;
26
+ export type Schema = Virtual.Schema<schema>;
27
+ }
@@ -0,0 +1,21 @@
1
+ import { createConfig } from "@ponder/core";
2
+ import { http, Abi, multicall3Abi } from "viem";
3
+ import { mainnet } from "viem/chains";
4
+
5
+ export default createConfig({
6
+ networks: {
7
+ mainnet: {
8
+ chainId: 1,
9
+ transport: http(process.env.PONDER_RPC_URL_1),
10
+ },
11
+ },
12
+ contracts: {
13
+ multicall3: {
14
+ network: "mainnet",
15
+ abi: multicall3Abi,
16
+ address: mainnet.contracts.multicall3.address,
17
+ startBlock: 19_800_000,
18
+ includeCallTraces: true,
19
+ },
20
+ },
21
+ });
@@ -0,0 +1,11 @@
1
+ import { createSchema } from "@ponder/core";
2
+
3
+ export default createSchema((p) => ({
4
+ multicalls: p.createTable({
5
+ id: p.hex(),
6
+ gasUsed: p.bigint(),
7
+ bytes: p.int(),
8
+ successfulCalls: p.int(),
9
+ failedCalls: p.int(),
10
+ }),
11
+ }));
@@ -0,0 +1,33 @@
1
+ import { ponder } from "@/generated";
2
+
3
+ ponder.on("multicall3.aggregate3()", async ({ event, context }) => {
4
+ await context.db.multicalls.upsert({
5
+ id: event.trace.from,
6
+ create: {
7
+ gasUsed: event.trace.gasUsed,
8
+ bytes: event.args[0].reduce<number>(
9
+ (acc, cur) => acc + Math.ceil((cur.callData.length - 2) / 8),
10
+ 0,
11
+ ),
12
+ successfulCalls: event.result.filter(({ success }) => success === true)
13
+ .length,
14
+ failedCalls: event.result.filter(({ success }) => success === false)
15
+ .length,
16
+ },
17
+ update: ({ current }) => ({
18
+ gasUsed: current.gasUsed + event.trace.gasUsed,
19
+ bytes:
20
+ current.bytes +
21
+ event.args[0].reduce<number>(
22
+ (acc, cur) => acc + Math.ceil((cur.callData.length - 2) / 8),
23
+ 0,
24
+ ),
25
+ successfulCalls:
26
+ current.successfulCalls +
27
+ event.result.filter(({ success }) => success === true).length,
28
+ failedCalls:
29
+ current.failedCalls +
30
+ event.result.filter(({ success }) => success === false).length,
31
+ }),
32
+ });
33
+ });
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Type checking
4
+ "strict": true,
5
+ "noUncheckedIndexedAccess": true,
6
+
7
+ // Interop constraints
8
+ "verbatimModuleSyntax": false,
9
+ "esModuleInterop": true,
10
+ "isolatedModules": true,
11
+ "allowSyntheticDefaultImports": true,
12
+ "resolveJsonModule": true,
13
+
14
+ // Language and environment
15
+ "moduleResolution": "bundler",
16
+ "module": "ESNext",
17
+ "noEmit": true,
18
+ "lib": ["ES2022"],
19
+ "target": "ES2022",
20
+
21
+ // Skip type checking for node modules
22
+ "skipLibCheck": true
23
+ },
24
+ "include": ["./**/*.ts"],
25
+ "exclude": ["node_modules"]
26
+ }