create-ponder 0.5.0-next.2 → 0.5.0
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 +2 -2
- package/dist/index.js +6 -1
- package/package.json +1 -1
- package/templates/empty/package.json +1 -0
- package/templates/empty/ponder-env.d.ts +1 -0
- package/templates/empty/src/api/index.ts +5 -0
- package/templates/etherscan/package.json +1 -0
- package/templates/etherscan/ponder-env.d.ts +1 -0
- package/templates/feature-api-functions/abis/erc20ABI.ts +147 -0
- package/templates/{feature-callTrace → feature-api-functions}/package.json +2 -1
- package/templates/{feature-callTrace → feature-api-functions}/ponder-env.d.ts +2 -1
- package/templates/feature-api-functions/ponder.config.ts +21 -0
- package/templates/feature-api-functions/ponder.schema.ts +50 -0
- package/templates/feature-api-functions/src/api/index.ts +47 -0
- package/templates/feature-blocks/package.json +1 -0
- package/templates/feature-blocks/ponder-env.d.ts +1 -0
- package/templates/feature-call-traces/package.json +1 -0
- package/templates/feature-call-traces/ponder-env.d.ts +1 -0
- package/templates/feature-factory/package.json +1 -0
- package/templates/feature-factory/ponder-env.d.ts +1 -0
- package/templates/feature-filter/package.json +1 -0
- package/templates/feature-filter/ponder-env.d.ts +1 -0
- package/templates/feature-multichain/package.json +1 -0
- package/templates/feature-multichain/ponder-env.d.ts +1 -0
- package/templates/feature-proxy/package.json +1 -0
- package/templates/feature-proxy/ponder-env.d.ts +1 -0
- package/templates/feature-read-contract/package.json +1 -0
- package/templates/feature-read-contract/ponder-env.d.ts +1 -0
- package/templates/project-friendtech/package.json +1 -0
- package/templates/project-friendtech/ponder-env.d.ts +1 -0
- package/templates/project-uniswap-v3-flash/package.json +1 -0
- package/templates/project-uniswap-v3-flash/ponder-env.d.ts +1 -0
- package/templates/reference-erc1155/package.json +1 -0
- package/templates/reference-erc1155/ponder-env.d.ts +1 -0
- package/templates/reference-erc20/package.json +1 -1
- package/templates/reference-erc20/ponder-env.d.ts +1 -20
- package/templates/reference-erc4626/package.json +1 -0
- package/templates/reference-erc4626/ponder-env.d.ts +1 -0
- package/templates/reference-erc721/package.json +1 -0
- package/templates/reference-erc721/ponder-env.d.ts +1 -0
- package/templates/subgraph/package.json +1 -0
- package/templates/subgraph/ponder-env.d.ts +1 -0
- 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/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/api/index.ts +0 -26
- package/templates/reference-erc20/src/server/index.ts +0 -20
- /package/templates/{feature-callTrace → feature-api-functions}/_dot_env.local +0 -0
- /package/templates/{feature-callTrace → feature-api-functions}/_dot_eslintrc.json +0 -0
- /package/templates/{feature-callTrace → feature-api-functions}/_dot_gitignore +0 -0
- /package/templates/{reference-erc20/src/indexing → feature-api-functions/src}/index.ts +0 -0
- /package/templates/{feature-callTrace → feature-api-functions}/tsconfig.json +0 -0
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ Join [Ponder's telegram chat](https://t.me/ponder_sh) for support, feedback, and
|
|
|
33
33
|
|
|
34
34
|
### 1. Run `create-ponder`
|
|
35
35
|
|
|
36
|
-
You will be asked for a project name, and if you are using a [template](https://ponder.sh/api-reference/create-ponder#templates) (recommended). Then, the CLI will create a project directory, install dependencies, and initialize a git repository.
|
|
36
|
+
You will be asked for a project name, and if you are using a [template](https://ponder.sh/docs/api-reference/create-ponder#templates) (recommended). Then, the CLI will create a project directory, install dependencies, and initialize a git repository.
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
39
|
npm init ponder@latest
|
|
@@ -128,7 +128,7 @@ ponder.on("BaseRegistrar:NameRegistered", async ({ event, context }) => {
|
|
|
128
128
|
});
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
-
See the [create & update records](https://ponder.sh/docs/
|
|
131
|
+
See the [create & update records](https://ponder.sh/docs/indexing/create-update-records) docs for a detailed guide on writing indexing functions.
|
|
132
132
|
|
|
133
133
|
### 6. Query the GraphQL API
|
|
134
134
|
|
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.5.0
|
|
19
|
+
version: "0.5.0",
|
|
20
20
|
type: "module",
|
|
21
21
|
description: "A CLI tool to create Ponder apps",
|
|
22
22
|
license: "MIT",
|
|
@@ -626,6 +626,11 @@ var templates = [
|
|
|
626
626
|
title: "Feature - Custom event filter",
|
|
627
627
|
description: "A Ponder app using an event filter"
|
|
628
628
|
},
|
|
629
|
+
{
|
|
630
|
+
id: "feature-api-functions",
|
|
631
|
+
title: "Feature - Custom api functions",
|
|
632
|
+
description: "A Ponder app using a custom api functions"
|
|
633
|
+
},
|
|
629
634
|
{
|
|
630
635
|
id: "feature-blocks",
|
|
631
636
|
title: "Feature - Block filter",
|
package/package.json
CHANGED
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
export const erc20ABI = [
|
|
2
|
+
{
|
|
3
|
+
stateMutability: "view",
|
|
4
|
+
type: "function",
|
|
5
|
+
inputs: [],
|
|
6
|
+
name: "DOMAIN_SEPARATOR",
|
|
7
|
+
outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
stateMutability: "view",
|
|
11
|
+
type: "function",
|
|
12
|
+
inputs: [
|
|
13
|
+
{ name: "", internalType: "address", type: "address" },
|
|
14
|
+
{ name: "", internalType: "address", type: "address" },
|
|
15
|
+
],
|
|
16
|
+
name: "allowance",
|
|
17
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
stateMutability: "nonpayable",
|
|
21
|
+
type: "function",
|
|
22
|
+
inputs: [
|
|
23
|
+
{ name: "spender", internalType: "address", type: "address" },
|
|
24
|
+
{ name: "amount", internalType: "uint256", type: "uint256" },
|
|
25
|
+
],
|
|
26
|
+
name: "approve",
|
|
27
|
+
outputs: [{ name: "", internalType: "bool", type: "bool" }],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
stateMutability: "view",
|
|
31
|
+
type: "function",
|
|
32
|
+
inputs: [{ name: "", internalType: "address", type: "address" }],
|
|
33
|
+
name: "balanceOf",
|
|
34
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
stateMutability: "view",
|
|
38
|
+
type: "function",
|
|
39
|
+
inputs: [],
|
|
40
|
+
name: "decimals",
|
|
41
|
+
outputs: [{ name: "", internalType: "uint8", type: "uint8" }],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
stateMutability: "view",
|
|
45
|
+
type: "function",
|
|
46
|
+
inputs: [],
|
|
47
|
+
name: "name",
|
|
48
|
+
outputs: [{ name: "", internalType: "string", type: "string" }],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
stateMutability: "view",
|
|
52
|
+
type: "function",
|
|
53
|
+
inputs: [{ name: "", internalType: "address", type: "address" }],
|
|
54
|
+
name: "nonces",
|
|
55
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
stateMutability: "nonpayable",
|
|
59
|
+
type: "function",
|
|
60
|
+
inputs: [
|
|
61
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
62
|
+
{ name: "spender", internalType: "address", type: "address" },
|
|
63
|
+
{ name: "value", internalType: "uint256", type: "uint256" },
|
|
64
|
+
{ name: "deadline", internalType: "uint256", type: "uint256" },
|
|
65
|
+
{ name: "v", internalType: "uint8", type: "uint8" },
|
|
66
|
+
{ name: "r", internalType: "bytes32", type: "bytes32" },
|
|
67
|
+
{ name: "s", internalType: "bytes32", type: "bytes32" },
|
|
68
|
+
],
|
|
69
|
+
name: "permit",
|
|
70
|
+
outputs: [],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
stateMutability: "view",
|
|
74
|
+
type: "function",
|
|
75
|
+
inputs: [],
|
|
76
|
+
name: "symbol",
|
|
77
|
+
outputs: [{ name: "", internalType: "string", type: "string" }],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
stateMutability: "view",
|
|
81
|
+
type: "function",
|
|
82
|
+
inputs: [],
|
|
83
|
+
name: "totalSupply",
|
|
84
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
stateMutability: "nonpayable",
|
|
88
|
+
type: "function",
|
|
89
|
+
inputs: [
|
|
90
|
+
{ name: "to", internalType: "address", type: "address" },
|
|
91
|
+
{ name: "amount", internalType: "uint256", type: "uint256" },
|
|
92
|
+
],
|
|
93
|
+
name: "transfer",
|
|
94
|
+
outputs: [{ name: "", internalType: "bool", type: "bool" }],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
stateMutability: "nonpayable",
|
|
98
|
+
type: "function",
|
|
99
|
+
inputs: [
|
|
100
|
+
{ name: "from", internalType: "address", type: "address" },
|
|
101
|
+
{ name: "to", internalType: "address", type: "address" },
|
|
102
|
+
{ name: "amount", internalType: "uint256", type: "uint256" },
|
|
103
|
+
],
|
|
104
|
+
name: "transferFrom",
|
|
105
|
+
outputs: [{ name: "", internalType: "bool", type: "bool" }],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: "event",
|
|
109
|
+
anonymous: false,
|
|
110
|
+
inputs: [
|
|
111
|
+
{
|
|
112
|
+
name: "owner",
|
|
113
|
+
internalType: "address",
|
|
114
|
+
type: "address",
|
|
115
|
+
indexed: true,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "spender",
|
|
119
|
+
internalType: "address",
|
|
120
|
+
type: "address",
|
|
121
|
+
indexed: true,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "amount",
|
|
125
|
+
internalType: "uint256",
|
|
126
|
+
type: "uint256",
|
|
127
|
+
indexed: false,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
name: "Approval",
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
type: "event",
|
|
134
|
+
anonymous: false,
|
|
135
|
+
inputs: [
|
|
136
|
+
{ name: "from", internalType: "address", type: "address", indexed: true },
|
|
137
|
+
{ name: "to", internalType: "address", type: "address", indexed: true },
|
|
138
|
+
{
|
|
139
|
+
name: "amount",
|
|
140
|
+
internalType: "uint256",
|
|
141
|
+
type: "uint256",
|
|
142
|
+
indexed: false,
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
name: "Transfer",
|
|
146
|
+
},
|
|
147
|
+
] as const;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "ponder-examples-feature-
|
|
2
|
+
"name": "ponder-examples-feature-api-functions",
|
|
3
3
|
"private": true,
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@ponder/core": "workspace:*",
|
|
15
|
+
"hono": "^4.5.0",
|
|
15
16
|
"viem": "^1.19.9"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file enables type checking and editor autocomplete for this Ponder project.
|
|
2
2
|
// After upgrading, you may find that changes have been made to this file.
|
|
3
3
|
// If this happens, please commit the changes. Do not manually edit this file.
|
|
4
|
-
// See https://ponder.sh/docs/
|
|
4
|
+
// See https://ponder.sh/docs/getting-started/installation#typescript for more information.
|
|
5
5
|
|
|
6
6
|
declare module "@/generated" {
|
|
7
7
|
import type { Virtual } from "@ponder/core";
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createConfig } from "@ponder/core";
|
|
2
|
+
import { http } from "viem";
|
|
3
|
+
import { erc20ABI } from "./abis/erc20ABI";
|
|
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
|
+
ERC20: {
|
|
14
|
+
network: "mainnet",
|
|
15
|
+
abi: erc20ABI,
|
|
16
|
+
address: "0x32353A6C91143bfd6C7d363B546e62a9A2489A20",
|
|
17
|
+
startBlock: 13142655,
|
|
18
|
+
endBlock: 13150000,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createSchema } from "@ponder/core";
|
|
2
|
+
|
|
3
|
+
export default createSchema((p) => ({
|
|
4
|
+
Account: p.createTable({
|
|
5
|
+
id: p.hex(),
|
|
6
|
+
balance: p.bigint(),
|
|
7
|
+
isOwner: p.boolean(),
|
|
8
|
+
|
|
9
|
+
allowances: p.many("Allowance.ownerId"),
|
|
10
|
+
approvalOwnerEvents: p.many("ApprovalEvent.ownerId"),
|
|
11
|
+
approvalSpenderEvents: p.many("ApprovalEvent.spenderId"),
|
|
12
|
+
transferFromEvents: p.many("TransferEvent.fromId"),
|
|
13
|
+
transferToEvents: p.many("TransferEvent.toId"),
|
|
14
|
+
}),
|
|
15
|
+
Allowance: p.createTable({
|
|
16
|
+
id: p.string(),
|
|
17
|
+
amount: p.bigint(),
|
|
18
|
+
|
|
19
|
+
ownerId: p.hex().references("Account.id"),
|
|
20
|
+
spenderId: p.hex().references("Account.id"),
|
|
21
|
+
|
|
22
|
+
owner: p.one("ownerId"),
|
|
23
|
+
spender: p.one("spenderId"),
|
|
24
|
+
}),
|
|
25
|
+
TransferEvent: p.createTable(
|
|
26
|
+
{
|
|
27
|
+
id: p.string(),
|
|
28
|
+
amount: p.bigint(),
|
|
29
|
+
timestamp: p.int(),
|
|
30
|
+
|
|
31
|
+
fromId: p.hex().references("Account.id"),
|
|
32
|
+
toId: p.hex().references("Account.id"),
|
|
33
|
+
|
|
34
|
+
from: p.one("fromId"),
|
|
35
|
+
to: p.one("toId"),
|
|
36
|
+
},
|
|
37
|
+
{ fromIdIndex: p.index("fromId") },
|
|
38
|
+
),
|
|
39
|
+
ApprovalEvent: p.createTable({
|
|
40
|
+
id: p.string(),
|
|
41
|
+
amount: p.bigint(),
|
|
42
|
+
timestamp: p.int(),
|
|
43
|
+
|
|
44
|
+
ownerId: p.hex().references("Account.id"),
|
|
45
|
+
spenderId: p.hex().references("Account.id"),
|
|
46
|
+
|
|
47
|
+
owner: p.one("ownerId"),
|
|
48
|
+
spender: p.one("spenderId"),
|
|
49
|
+
}),
|
|
50
|
+
}));
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ponder } from "@/generated";
|
|
2
|
+
import { count, desc, eq, graphql, or, replaceBigInts } from "@ponder/core";
|
|
3
|
+
import { formatEther, getAddress } from "viem";
|
|
4
|
+
|
|
5
|
+
ponder.use("/graphql", graphql());
|
|
6
|
+
|
|
7
|
+
ponder.get("/count", async (c) => {
|
|
8
|
+
const result = await c.db
|
|
9
|
+
.select({ count: count() })
|
|
10
|
+
.from(c.tables.TransferEvent);
|
|
11
|
+
|
|
12
|
+
if (result.length === 0) return c.text("0");
|
|
13
|
+
return c.text(String(result[0]!.count));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
ponder.get("/count/:address", async (c) => {
|
|
17
|
+
const account = getAddress(c.req.param("address"));
|
|
18
|
+
const { TransferEvent } = c.tables;
|
|
19
|
+
|
|
20
|
+
const result = await c.db
|
|
21
|
+
.select({ count: count() })
|
|
22
|
+
.from(c.tables.TransferEvent)
|
|
23
|
+
.where(
|
|
24
|
+
or(eq(TransferEvent.fromId, account), eq(TransferEvent.toId, account)),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
if (result.length === 0) return c.text("0");
|
|
28
|
+
return c.text(String(result[0]!.count));
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
ponder.get("/whale-transfers", async (c) => {
|
|
32
|
+
const { TransferEvent, Account } = c.tables;
|
|
33
|
+
|
|
34
|
+
// Top 10 transfers from whale accounts
|
|
35
|
+
const result = await c.db
|
|
36
|
+
.select({
|
|
37
|
+
amount: TransferEvent.amount,
|
|
38
|
+
senderBalance: Account.balance,
|
|
39
|
+
})
|
|
40
|
+
.from(TransferEvent)
|
|
41
|
+
.innerJoin(Account, eq(TransferEvent.fromId, Account.id))
|
|
42
|
+
.orderBy(desc(Account.balance))
|
|
43
|
+
.limit(10);
|
|
44
|
+
|
|
45
|
+
if (result.length === 0) return c.text("Not found", 500);
|
|
46
|
+
return c.json(replaceBigInts(result, (b) => formatEther(b)));
|
|
47
|
+
});
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -21,27 +21,8 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
declare module "ponder:db" {
|
|
30
|
-
import type { ConvertToDrizzleTable } from "@ponder/core";
|
|
31
|
-
|
|
32
|
-
type schema = typeof import("./ponder.schema.ts").default;
|
|
33
|
-
|
|
34
|
-
const drizzleTables: {
|
|
35
|
-
[tableName in keyof schema]: ConvertToDrizzleTable<
|
|
36
|
-
tableName,
|
|
37
|
-
schema[tableName]["table"],
|
|
38
|
-
schema
|
|
39
|
-
>;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export = drizzleTables;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
declare module "ponder:db" {
|
|
46
|
-
export * from "@ponder/core/drizzle";
|
|
47
|
-
}
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -21,6 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
+
export type ApiContext = Virtual.Drizzle<schema>;
|
|
24
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
25
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
26
27
|
export type Schema = Virtual.Schema<schema>;
|
|
@@ -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
|
-
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Allowance, asc, desc, sql } from "ponder:db";
|
|
2
|
-
import { ponder } from "@/generated";
|
|
3
|
-
import { graphql, replaceBigInts } from "@ponder/core";
|
|
4
|
-
|
|
5
|
-
// write file
|
|
6
|
-
ponder.use("/graphql", graphql());
|
|
7
|
-
|
|
8
|
-
ponder.get("/allowance", async (c) => {
|
|
9
|
-
const db = c.get("db");
|
|
10
|
-
|
|
11
|
-
const result = await db
|
|
12
|
-
.select({
|
|
13
|
-
owner: Allowance.ownerId,
|
|
14
|
-
count: sql<number>`cast(count(${Allowance.id}) as int)`,
|
|
15
|
-
balance: sql<number>`cast(sum(${Allowance.amount}) as numeric(78,0))`,
|
|
16
|
-
})
|
|
17
|
-
.from(Allowance)
|
|
18
|
-
.groupBy(Allowance.ownerId)
|
|
19
|
-
.orderBy(desc(sql`count`))
|
|
20
|
-
.limit(2);
|
|
21
|
-
|
|
22
|
-
// Hono JSON doesn't support BigInts
|
|
23
|
-
const safeResult = replaceBigInts(result, (b) => b.toString());
|
|
24
|
-
|
|
25
|
-
return c.json(safeResult);
|
|
26
|
-
});
|
|
@@ -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
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|