create-ponder 0.10.0 → 0.10.2
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/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/feature-api-functions/migrations/0000_equal_tarantula.sql +0 -6
- package/templates/feature-api-functions/migrations/0000_glamorous_fallen_one.sql +0 -6
- package/templates/feature-api-functions/migrations/meta/0000_snapshot.json +0 -40
- package/templates/feature-api-functions/migrations/meta/_journal.json +0 -13
- package/templates/feature-api-functions/ponder.offchain.ts +0 -9
- package/templates/feature-callTrace/_dot_env.local +0 -5
- package/templates/feature-callTrace/_dot_eslintrc.json +0 -3
- package/templates/feature-callTrace/_dot_gitignore +0 -18
- package/templates/feature-callTrace/package.json +0 -26
- package/templates/feature-callTrace/ponder-env.d.ts +0 -27
- package/templates/feature-callTrace/ponder.config.ts +0 -22
- package/templates/feature-callTrace/ponder.schema.ts +0 -11
- package/templates/feature-callTrace/src/index.ts +0 -33
- package/templates/feature-callTrace/tsconfig.json +0 -26
- package/templates/feature-factory/abis/ChildContractAbi.ts +0 -62
- package/templates/feature-factory/src/index.ts +0 -24
- package/templates/reference-erc20/sqlite/ponder.db +0 -0
- package/templates/reference-erc20/sqlite/ponder_cache.db +0 -0
- package/templates/reference-erc20/sqlite/ponder_sync.db +0 -0
- package/templates/reference-erc20/src/indexing/index.ts +0 -70
- package/templates/reference-erc20/src/server/index.ts +0 -20
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "6011cb22-cfd9-474d-a02b-ba6addfea155",
|
|
3
|
-
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
|
-
"version": "7",
|
|
5
|
-
"dialect": "postgresql",
|
|
6
|
-
"tables": {
|
|
7
|
-
"offchain.metadata": {
|
|
8
|
-
"name": "metadata",
|
|
9
|
-
"schema": "offchain",
|
|
10
|
-
"columns": {
|
|
11
|
-
"id": {
|
|
12
|
-
"name": "id",
|
|
13
|
-
"type": "serial",
|
|
14
|
-
"primaryKey": true,
|
|
15
|
-
"notNull": true
|
|
16
|
-
},
|
|
17
|
-
"account": {
|
|
18
|
-
"name": "account",
|
|
19
|
-
"type": "text",
|
|
20
|
-
"primaryKey": false,
|
|
21
|
-
"notNull": true
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"indexes": {},
|
|
25
|
-
"foreignKeys": {},
|
|
26
|
-
"compositePrimaryKeys": {},
|
|
27
|
-
"uniqueConstraints": {}
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"enums": {},
|
|
31
|
-
"schemas": {
|
|
32
|
-
"offchain": "offchain"
|
|
33
|
-
},
|
|
34
|
-
"sequences": {},
|
|
35
|
-
"_meta": {
|
|
36
|
-
"columns": {},
|
|
37
|
-
"schemas": {},
|
|
38
|
-
"tables": {}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ponderHex } from "@ponder/core";
|
|
2
|
-
import { pgSchema, serial } from "drizzle-orm/pg-core";
|
|
3
|
-
|
|
4
|
-
export const offchainSchema = pgSchema("offchain");
|
|
5
|
-
|
|
6
|
-
export const metadata = offchainSchema.table("metadata", {
|
|
7
|
-
id: serial("id").primaryKey(),
|
|
8
|
-
account: ponderHex("account").notNull(),
|
|
9
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ponder-examples-feature-callTrace",
|
|
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
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
includeFunctionCalls: true,
|
|
19
|
-
maxBlockRange: 25,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export const ChildContractAbi = [
|
|
2
|
-
{
|
|
3
|
-
inputs: [
|
|
4
|
-
{ internalType: "string", name: "_name", type: "string" },
|
|
5
|
-
{ internalType: "uint256", name: "_initialValue", type: "uint256" },
|
|
6
|
-
],
|
|
7
|
-
stateMutability: "nonpayable",
|
|
8
|
-
type: "constructor",
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
anonymous: false,
|
|
12
|
-
inputs: [
|
|
13
|
-
{
|
|
14
|
-
indexed: true,
|
|
15
|
-
internalType: "address",
|
|
16
|
-
name: "child",
|
|
17
|
-
type: "address",
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
indexed: true,
|
|
21
|
-
internalType: "address",
|
|
22
|
-
name: "updater",
|
|
23
|
-
type: "address",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
indexed: false,
|
|
27
|
-
internalType: "uint256",
|
|
28
|
-
name: "oldValue",
|
|
29
|
-
type: "uint256",
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
indexed: false,
|
|
33
|
-
internalType: "uint256",
|
|
34
|
-
name: "newValue",
|
|
35
|
-
type: "uint256",
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
name: "ValueUpdated",
|
|
39
|
-
type: "event",
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
inputs: [],
|
|
43
|
-
name: "factory",
|
|
44
|
-
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
45
|
-
stateMutability: "view",
|
|
46
|
-
type: "function",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
inputs: [{ internalType: "uint256", name: "_newValue", type: "uint256" }],
|
|
50
|
-
name: "setValue",
|
|
51
|
-
outputs: [],
|
|
52
|
-
stateMutability: "nonpayable",
|
|
53
|
-
type: "function",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
inputs: [],
|
|
57
|
-
name: "value",
|
|
58
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
59
|
-
stateMutability: "view",
|
|
60
|
-
type: "function",
|
|
61
|
-
},
|
|
62
|
-
] as const;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ponder } from "ponder:registry";
|
|
2
|
-
import { childContract } from "../ponder.schema";
|
|
3
|
-
|
|
4
|
-
ponder.on("LlamaCore:ActionCreated", async ({ event }) => {
|
|
5
|
-
console.log(
|
|
6
|
-
`Handling ActionCreated event from LlamaCore @ ${event.log.address}`,
|
|
7
|
-
);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
ponder.on("LlamaPolicy:Initialized", async ({ event }) => {
|
|
11
|
-
console.log(
|
|
12
|
-
`Handling Initialized event from LlamaPolicy @ ${event.log.address}`,
|
|
13
|
-
);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
ponder.on("ChildContract:ValueUpdated", async ({ event, context }) => {
|
|
17
|
-
const { child, updater, oldValue, newValue } = event.args;
|
|
18
|
-
context.db.insert(childContract).values({
|
|
19
|
-
id: child,
|
|
20
|
-
});
|
|
21
|
-
console.log(
|
|
22
|
-
`Handling ValueUpdated event from ChildContract @ ${event.log.address}`,
|
|
23
|
-
);
|
|
24
|
-
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { ponder } from "@/generated";
|
|
2
|
-
|
|
3
|
-
ponder.on("ERC20:Transfer", async ({ event, context }) => {
|
|
4
|
-
const { Account, TransferEvent } = context.db;
|
|
5
|
-
|
|
6
|
-
// Create an Account for the sender, or update the balance if it already exists.
|
|
7
|
-
await Account.upsert({
|
|
8
|
-
id: event.args.from,
|
|
9
|
-
create: {
|
|
10
|
-
balance: BigInt(0),
|
|
11
|
-
isOwner: false,
|
|
12
|
-
},
|
|
13
|
-
update: ({ current }) => ({
|
|
14
|
-
balance: current.balance - event.args.amount,
|
|
15
|
-
}),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
// Create an Account for the recipient, or update the balance if it already exists.
|
|
19
|
-
await Account.upsert({
|
|
20
|
-
id: event.args.to,
|
|
21
|
-
create: {
|
|
22
|
-
balance: event.args.amount,
|
|
23
|
-
isOwner: false,
|
|
24
|
-
},
|
|
25
|
-
update: ({ current }) => ({
|
|
26
|
-
balance: current.balance + event.args.amount,
|
|
27
|
-
}),
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Create a TransferEvent.
|
|
31
|
-
await TransferEvent.create({
|
|
32
|
-
id: event.log.id,
|
|
33
|
-
data: {
|
|
34
|
-
fromId: event.args.from,
|
|
35
|
-
toId: event.args.to,
|
|
36
|
-
amount: event.args.amount,
|
|
37
|
-
timestamp: Number(event.block.timestamp),
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
ponder.on("ERC20:Approval", async ({ event, context }) => {
|
|
43
|
-
const { Allowance, ApprovalEvent } = context.db;
|
|
44
|
-
|
|
45
|
-
const allowanceId = `${event.args.owner}-${event.args.spender}`;
|
|
46
|
-
|
|
47
|
-
// Create or update the Allowance.
|
|
48
|
-
await Allowance.upsert({
|
|
49
|
-
id: allowanceId,
|
|
50
|
-
create: {
|
|
51
|
-
ownerId: event.args.owner,
|
|
52
|
-
spenderId: event.args.spender,
|
|
53
|
-
amount: event.args.amount,
|
|
54
|
-
},
|
|
55
|
-
update: {
|
|
56
|
-
amount: event.args.amount,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Create an ApprovalEvent.
|
|
61
|
-
await ApprovalEvent.create({
|
|
62
|
-
id: event.log.id,
|
|
63
|
-
data: {
|
|
64
|
-
ownerId: event.args.owner,
|
|
65
|
-
spenderId: event.args.spender,
|
|
66
|
-
amount: event.args.amount,
|
|
67
|
-
timestamp: Number(event.block.timestamp),
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ponder } from "@/generated";
|
|
2
|
-
import { graphql } from "@ponder/core";
|
|
3
|
-
|
|
4
|
-
ponder.use("/graphql", graphql());
|
|
5
|
-
|
|
6
|
-
ponder.get("/router", async (c) => {
|
|
7
|
-
const db = c.get("db");
|
|
8
|
-
|
|
9
|
-
// await db.query(`UPDATE "Account" SET "isOwner" = 1`);
|
|
10
|
-
|
|
11
|
-
const account = await db.query<{ balance: bigint }>(
|
|
12
|
-
`SELECT * FROM "Account" LIMIT 1`,
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
if (account.rows.length === 0) {
|
|
16
|
-
return c.text("Not Found!");
|
|
17
|
-
} else {
|
|
18
|
-
return c.text(`Balance: ${account.rows[0]!.balance.toString()}`);
|
|
19
|
-
}
|
|
20
|
-
});
|