create-ponder 0.9.28 → 0.10.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/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/feature-api-functions/migrations/0000_equal_tarantula.sql +6 -0
- package/templates/feature-api-functions/migrations/0000_glamorous_fallen_one.sql +6 -0
- package/templates/feature-api-functions/migrations/meta/0000_snapshot.json +40 -0
- package/templates/feature-api-functions/migrations/meta/_journal.json +13 -0
- package/templates/feature-api-functions/ponder.offchain.ts +9 -0
- package/templates/feature-api-functions/src/index.ts +2 -2
- package/templates/feature-callTrace/_dot_env.local +5 -0
- package/templates/feature-callTrace/_dot_eslintrc.json +3 -0
- package/templates/feature-callTrace/_dot_gitignore +18 -0
- package/templates/feature-callTrace/package.json +26 -0
- package/templates/feature-callTrace/ponder-env.d.ts +27 -0
- package/templates/feature-callTrace/ponder.config.ts +22 -0
- package/templates/feature-callTrace/ponder.schema.ts +11 -0
- package/templates/feature-callTrace/src/index.ts +33 -0
- package/templates/feature-callTrace/tsconfig.json +26 -0
- package/templates/feature-factory/abis/ChildContractAbi.ts +62 -0
- package/templates/feature-factory/src/index.ts +24 -0
- package/templates/feature-filter/src/index.ts +1 -1
- package/templates/feature-proxy/src/index.ts +2 -2
- package/templates/project-friendtech/src/FriendtechSharesV1.ts +1 -1
- package/templates/project-uniswap-v3-flash/ponder.config.ts +1 -8
- package/templates/reference-erc1155/src/index.ts +2 -2
- 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/index.ts +2 -2
- package/templates/reference-erc20/src/indexing/index.ts +70 -0
- package/templates/reference-erc20/src/server/index.ts +20 -0
- package/templates/reference-erc4626/src/index.ts +4 -4
- package/templates/reference-erc721/src/index.ts +1 -1
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
});
|
|
@@ -31,7 +31,7 @@ ponder.on("ERC20:Transfer", async ({ event, context }) => {
|
|
|
31
31
|
|
|
32
32
|
// add row to "transfer_event".
|
|
33
33
|
await context.db.insert(transferEvent).values({
|
|
34
|
-
id: event.
|
|
34
|
+
id: event.id,
|
|
35
35
|
amount: event.args.amount,
|
|
36
36
|
timestamp: Number(event.block.timestamp),
|
|
37
37
|
from: event.args.from,
|
|
@@ -54,7 +54,7 @@ ponder.on("ERC20:Approval", async ({ event, context }) => {
|
|
|
54
54
|
|
|
55
55
|
// add row to "approval_event".
|
|
56
56
|
await context.db.insert(approvalEvent).values({
|
|
57
|
-
id: event.
|
|
57
|
+
id: event.id,
|
|
58
58
|
amount: event.args.amount,
|
|
59
59
|
timestamp: Number(event.block.timestamp),
|
|
60
60
|
owner: event.args.owner,
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|
|
@@ -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,22 @@
|
|
|
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
|
+
});
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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;
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
});
|
|
@@ -4,11 +4,11 @@ import schema from "ponder:schema";
|
|
|
4
4
|
ponder.on("AstariaRouter:Liquidation", async ({ event, context }) => {
|
|
5
5
|
await context.db
|
|
6
6
|
.insert(schema.liquidationEvent)
|
|
7
|
-
.values({ id: event.
|
|
7
|
+
.values({ id: event.id, liquidator: event.args.liquidator });
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
ponder.on("AstariaRouter:OwnershipTransferred", async ({ event, context }) => {
|
|
11
11
|
await context.db
|
|
12
12
|
.insert(schema.ownershipTransferEvent)
|
|
13
|
-
.values({ id: event.
|
|
13
|
+
.values({ id: event.id, newOwner: event.args.newOwner });
|
|
14
14
|
});
|
|
@@ -14,7 +14,7 @@ ponder.on("FriendtechSharesV1:Trade", async ({ event, context }) => {
|
|
|
14
14
|
: event.args.ethAmount - feeAmount;
|
|
15
15
|
|
|
16
16
|
const tradeEvent = await context.db.insert(schema.tradeEvent).values({
|
|
17
|
-
id: event.
|
|
17
|
+
id: event.id,
|
|
18
18
|
subject: event.args.subject,
|
|
19
19
|
trader: event.args.trader,
|
|
20
20
|
shareAmount: event.args.shareAmount,
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { createConfig, factory } from "ponder";
|
|
2
2
|
import { http, getAbiItem } from "viem";
|
|
3
|
-
|
|
4
3
|
import { UniswapV3FactoryAbi } from "./abis/UniswapV3FactoryAbi";
|
|
5
4
|
import { UniswapV3PoolAbi } from "./abis/UniswapV3PoolAbi";
|
|
6
5
|
|
|
7
6
|
export default createConfig({
|
|
8
7
|
networks: {
|
|
9
|
-
mainnet: {
|
|
10
|
-
chainId: 1,
|
|
11
|
-
transport: http(process.env.PONDER_RPC_URL_1),
|
|
12
|
-
},
|
|
8
|
+
mainnet: { chainId: 1, transport: http(process.env.PONDER_RPC_URL_1) },
|
|
13
9
|
},
|
|
14
10
|
contracts: {
|
|
15
11
|
UniswapV3Pool: {
|
|
@@ -21,9 +17,6 @@ export default createConfig({
|
|
|
21
17
|
parameter: "pool",
|
|
22
18
|
}),
|
|
23
19
|
startBlock: 12369621,
|
|
24
|
-
filter: {
|
|
25
|
-
event: "Flash",
|
|
26
|
-
},
|
|
27
20
|
},
|
|
28
21
|
},
|
|
29
22
|
});
|
|
@@ -38,7 +38,7 @@ ponder.on("ERC1155:TransferSingle", async ({ event, context }) => {
|
|
|
38
38
|
|
|
39
39
|
// Create a TransferEvent.
|
|
40
40
|
await context.db.insert(schema.transferEvent).values({
|
|
41
|
-
id: event.
|
|
41
|
+
id: event.id,
|
|
42
42
|
from: event.args.from,
|
|
43
43
|
to: event.args.to,
|
|
44
44
|
token: event.args.id,
|
|
@@ -83,7 +83,7 @@ ponder.on("ERC1155:TransferBatch", async ({ event, context }) => {
|
|
|
83
83
|
}));
|
|
84
84
|
|
|
85
85
|
await context.db.insert(schema.transferEvent).values({
|
|
86
|
-
id: event.
|
|
86
|
+
id: event.id,
|
|
87
87
|
from: event.args.from,
|
|
88
88
|
to: event.args.to,
|
|
89
89
|
token: id,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -23,7 +23,7 @@ ponder.on("ERC20:Transfer", async ({ event, context }) => {
|
|
|
23
23
|
|
|
24
24
|
// add row to "transfer_event".
|
|
25
25
|
await context.db.insert(transferEvent).values({
|
|
26
|
-
id: event.
|
|
26
|
+
id: event.id,
|
|
27
27
|
amount: event.args.amount,
|
|
28
28
|
timestamp: Number(event.block.timestamp),
|
|
29
29
|
from: event.args.from,
|
|
@@ -44,7 +44,7 @@ ponder.on("ERC20:Approval", async ({ event, context }) => {
|
|
|
44
44
|
|
|
45
45
|
// add row to "approval_event".
|
|
46
46
|
await context.db.insert(approvalEvent).values({
|
|
47
|
-
id: event.
|
|
47
|
+
id: event.id,
|
|
48
48
|
amount: event.args.amount,
|
|
49
49
|
timestamp: Number(event.block.timestamp),
|
|
50
50
|
owner: event.args.owner,
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
});
|
|
@@ -20,7 +20,7 @@ ponder.on("ERC4626:Transfer", async ({ event, context }) => {
|
|
|
20
20
|
|
|
21
21
|
// Create a TransferEvent.
|
|
22
22
|
await context.db.insert(schema.transferEvent).values({
|
|
23
|
-
id: event.
|
|
23
|
+
id: event.id,
|
|
24
24
|
from: event.args.from,
|
|
25
25
|
to: event.args.to,
|
|
26
26
|
amount: event.args.amount,
|
|
@@ -41,7 +41,7 @@ ponder.on("ERC4626:Approval", async ({ event, context }) => {
|
|
|
41
41
|
|
|
42
42
|
// Create an ApprovalEvent.
|
|
43
43
|
await context.db.insert(schema.approvalEvent).values({
|
|
44
|
-
id: event.
|
|
44
|
+
id: event.id,
|
|
45
45
|
owner: event.args.owner,
|
|
46
46
|
spender: event.args.spender,
|
|
47
47
|
amount: event.args.amount,
|
|
@@ -51,7 +51,7 @@ ponder.on("ERC4626:Approval", async ({ event, context }) => {
|
|
|
51
51
|
|
|
52
52
|
ponder.on("ERC4626:Deposit", async ({ event, context }) => {
|
|
53
53
|
await context.db.insert(schema.depositEvent).values({
|
|
54
|
-
id: event.
|
|
54
|
+
id: event.id,
|
|
55
55
|
sender: event.args.caller,
|
|
56
56
|
receiver: event.args.owner,
|
|
57
57
|
assets: event.args.assets,
|
|
@@ -61,7 +61,7 @@ ponder.on("ERC4626:Deposit", async ({ event, context }) => {
|
|
|
61
61
|
|
|
62
62
|
ponder.on("ERC4626:Withdraw", async ({ event, context }) => {
|
|
63
63
|
await context.db.insert(schema.withdrawalEvent).values({
|
|
64
|
-
id: event.
|
|
64
|
+
id: event.id,
|
|
65
65
|
sender: event.args.caller,
|
|
66
66
|
owner: event.args.owner,
|
|
67
67
|
receiver: event.args.receiver,
|
|
@@ -24,7 +24,7 @@ ponder.on("ERC721:Transfer", async ({ event, context }) => {
|
|
|
24
24
|
|
|
25
25
|
// Create a TransferEvent.
|
|
26
26
|
await context.db.insert(schema.transferEvent).values({
|
|
27
|
-
id: event.
|
|
27
|
+
id: event.id,
|
|
28
28
|
from: event.args.from,
|
|
29
29
|
to: event.args.to,
|
|
30
30
|
token: event.args.id,
|