create-ponder 0.6.24 → 0.7.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 +11 -17
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/empty/ponder.schema.ts +4 -6
- package/templates/etherscan/ponder.schema.ts +4 -6
- package/templates/feature-api-functions/package.json +2 -0
- package/templates/feature-api-functions/ponder-env.d.ts +2 -3
- package/templates/feature-api-functions/ponder.schema.ts +35 -44
- package/templates/feature-api-functions/src/api/index.ts +10 -15
- package/templates/feature-api-functions/src/index.ts +46 -53
- package/templates/feature-blocks/ponder-env.d.ts +2 -3
- package/templates/feature-blocks/ponder.config.ts +1 -1
- package/templates/feature-blocks/ponder.schema.ts +4 -6
- package/templates/feature-blocks/src/index.ts +4 -5
- package/templates/feature-call-traces/ponder-env.d.ts +2 -3
- package/templates/feature-call-traces/ponder.schema.ts +7 -9
- package/templates/feature-call-traces/src/index.ts +12 -11
- package/templates/feature-factory/ponder-env.d.ts +2 -3
- package/templates/feature-factory/ponder.schema.ts +3 -5
- package/templates/feature-filter/ponder-env.d.ts +2 -3
- package/templates/feature-filter/ponder.schema.ts +5 -7
- package/templates/feature-filter/src/index.ts +4 -7
- package/templates/feature-multichain/ponder.schema.ts +4 -6
- package/templates/feature-multichain/src/index.ts +5 -11
- package/templates/feature-proxy/ponder-env.d.ts +2 -3
- package/templates/feature-proxy/ponder.schema.ts +12 -10
- package/templates/feature-proxy/src/index.ts +7 -16
- package/templates/feature-read-contract/ponder-env.d.ts +2 -3
- package/templates/feature-read-contract/ponder.schema.ts +9 -12
- package/templates/feature-read-contract/src/FileStore.ts +16 -20
- package/templates/project-friendtech/ponder-env.d.ts +2 -3
- package/templates/project-friendtech/ponder.schema.ts +43 -55
- package/templates/project-friendtech/src/FriendtechSharesV1.ts +56 -70
- package/templates/project-uniswap-v3-flash/ponder-env.d.ts +2 -3
- package/templates/project-uniswap-v3-flash/ponder.schema.ts +9 -10
- package/templates/project-uniswap-v3-flash/src/index.ts +25 -34
- package/templates/reference-erc1155/ponder-env.d.ts +2 -3
- package/templates/reference-erc1155/ponder.schema.ts +19 -23
- package/templates/reference-erc1155/src/index.ts +60 -76
- package/templates/reference-erc20/package.json +1 -0
- package/templates/reference-erc20/ponder-env.d.ts +2 -3
- package/templates/reference-erc20/ponder.schema.ts +35 -44
- package/templates/reference-erc20/src/index.ts +40 -57
- package/templates/reference-erc4626/ponder-env.d.ts +2 -3
- package/templates/reference-erc4626/ponder.schema.ts +43 -54
- package/templates/reference-erc4626/src/index.ts +41 -65
- package/templates/reference-erc721/ponder-env.d.ts +2 -3
- package/templates/reference-erc721/ponder.schema.ts +14 -25
- package/templates/reference-erc721/src/index.ts +21 -25
- package/templates/subgraph/ponder.schema.ts +4 -6
|
@@ -1,95 +1,71 @@
|
|
|
1
1
|
import { ponder } from "@/generated";
|
|
2
|
+
import * as schema from "../ponder.schema";
|
|
2
3
|
|
|
3
4
|
ponder.on("ERC4626:Transfer", async ({ event, context }) => {
|
|
4
|
-
const { Account, TransferEvent } = context.db;
|
|
5
|
-
|
|
6
5
|
// Create an Account for the sender, or update the balance if it already exists.
|
|
7
|
-
await
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
update: ({ current }) => ({
|
|
14
|
-
balance: current.balance - event.args.amount,
|
|
15
|
-
}),
|
|
16
|
-
});
|
|
6
|
+
await context.db
|
|
7
|
+
.insert(schema.account)
|
|
8
|
+
.values({ address: event.args.from, balance: 0n })
|
|
9
|
+
.onConflictDoUpdate((row) => ({
|
|
10
|
+
balance: row.balance - event.args.amount,
|
|
11
|
+
}));
|
|
17
12
|
|
|
18
13
|
// Create an Account for the recipient, or update the balance if it already exists.
|
|
19
|
-
await
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
update: ({ current }) => ({
|
|
26
|
-
balance: current.balance + event.args.amount,
|
|
27
|
-
}),
|
|
28
|
-
});
|
|
14
|
+
await context.db
|
|
15
|
+
.insert(schema.account)
|
|
16
|
+
.values({ address: event.args.to, balance: event.args.amount })
|
|
17
|
+
.onConflictDoUpdate((row) => ({
|
|
18
|
+
balance: row.balance + event.args.amount,
|
|
19
|
+
}));
|
|
29
20
|
|
|
30
21
|
// Create a TransferEvent.
|
|
31
|
-
await
|
|
22
|
+
await context.db.insert(schema.transferEvent).values({
|
|
32
23
|
id: event.log.id,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
timestamp: Number(event.block.timestamp),
|
|
38
|
-
},
|
|
24
|
+
from: event.args.from,
|
|
25
|
+
to: event.args.to,
|
|
26
|
+
amount: event.args.amount,
|
|
27
|
+
timestamp: Number(event.block.timestamp),
|
|
39
28
|
});
|
|
40
29
|
});
|
|
41
30
|
|
|
42
31
|
ponder.on("ERC4626:Approval", async ({ event, context }) => {
|
|
43
|
-
const { Allowance, ApprovalEvent } = context.db;
|
|
44
|
-
|
|
45
|
-
const allowanceId = `${event.args.owner}-${event.args.spender}`;
|
|
46
|
-
|
|
47
32
|
// Create or update the Allowance.
|
|
48
|
-
await
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
amount: event.args.amount,
|
|
54
|
-
},
|
|
55
|
-
update: {
|
|
33
|
+
await context.db
|
|
34
|
+
.insert(schema.allowance)
|
|
35
|
+
.values({
|
|
36
|
+
owner: event.args.owner,
|
|
37
|
+
spender: event.args.spender,
|
|
56
38
|
amount: event.args.amount,
|
|
57
|
-
}
|
|
58
|
-
|
|
39
|
+
})
|
|
40
|
+
.onConflictDoUpdate({ amount: event.args.amount });
|
|
59
41
|
|
|
60
42
|
// Create an ApprovalEvent.
|
|
61
|
-
await
|
|
43
|
+
await context.db.insert(schema.approvalEvent).values({
|
|
62
44
|
id: event.log.id,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
timestamp: Number(event.block.timestamp),
|
|
68
|
-
},
|
|
45
|
+
owner: event.args.owner,
|
|
46
|
+
spender: event.args.spender,
|
|
47
|
+
amount: event.args.amount,
|
|
48
|
+
timestamp: Number(event.block.timestamp),
|
|
69
49
|
});
|
|
70
50
|
});
|
|
71
51
|
|
|
72
52
|
ponder.on("ERC4626:Deposit", async ({ event, context }) => {
|
|
73
|
-
await context.db.
|
|
53
|
+
await context.db.insert(schema.depositEvent).values({
|
|
74
54
|
id: event.log.id,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
shares: event.args.shares,
|
|
80
|
-
},
|
|
55
|
+
sender: event.args.caller,
|
|
56
|
+
receiver: event.args.owner,
|
|
57
|
+
assets: event.args.assets,
|
|
58
|
+
shares: event.args.shares,
|
|
81
59
|
});
|
|
82
60
|
});
|
|
83
61
|
|
|
84
62
|
ponder.on("ERC4626:Withdraw", async ({ event, context }) => {
|
|
85
|
-
await context.db.
|
|
63
|
+
await context.db.insert(schema.withdrawalEvent).values({
|
|
86
64
|
id: event.log.id,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
shares: event.args.shares,
|
|
93
|
-
},
|
|
65
|
+
sender: event.args.caller,
|
|
66
|
+
owner: event.args.owner,
|
|
67
|
+
receiver: event.args.receiver,
|
|
68
|
+
assets: event.args.assets,
|
|
69
|
+
shares: event.args.shares,
|
|
94
70
|
});
|
|
95
71
|
});
|
|
@@ -7,7 +7,7 @@ declare module "@/generated" {
|
|
|
7
7
|
import type { Virtual } from "@ponder/core";
|
|
8
8
|
|
|
9
9
|
type config = typeof import("./ponder.config.ts").default;
|
|
10
|
-
type schema = typeof import("./ponder.schema.ts")
|
|
10
|
+
type schema = typeof import("./ponder.schema.ts");
|
|
11
11
|
|
|
12
12
|
export const ponder: Virtual.Registry<config, schema>;
|
|
13
13
|
|
|
@@ -21,8 +21,7 @@ declare module "@/generated" {
|
|
|
21
21
|
schema,
|
|
22
22
|
name
|
|
23
23
|
>;
|
|
24
|
-
export type ApiContext = Virtual.
|
|
24
|
+
export type ApiContext = Virtual.ApiContext<schema>;
|
|
25
25
|
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
|
|
26
26
|
Virtual.IndexingFunctionArgs<config, schema, name>;
|
|
27
|
-
export type Schema = Virtual.Schema<schema>;
|
|
28
27
|
}
|
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { onchainTable } from "@ponder/core";
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
tokens: p.many("Token.ownerId"),
|
|
7
|
-
|
|
8
|
-
transferFromEvents: p.many("TransferEvent.fromId"),
|
|
9
|
-
transferToEvents: p.many("TransferEvent.toId"),
|
|
10
|
-
}),
|
|
11
|
-
Token: p.createTable({
|
|
12
|
-
id: p.bigint(),
|
|
13
|
-
ownerId: p.hex().references("Account.id"),
|
|
3
|
+
export const account = onchainTable("account", (t) => ({
|
|
4
|
+
address: t.hex().primaryKey(),
|
|
5
|
+
}));
|
|
14
6
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
id: p.string(),
|
|
20
|
-
timestamp: p.int(),
|
|
21
|
-
fromId: p.hex().references("Account.id"),
|
|
22
|
-
toId: p.hex().references("Account.id"),
|
|
23
|
-
tokenId: p.bigint().references("Token.id"),
|
|
7
|
+
export const token = onchainTable("token", (t) => ({
|
|
8
|
+
id: t.bigint().primaryKey(),
|
|
9
|
+
owner: t.hex().notNull(),
|
|
10
|
+
}));
|
|
24
11
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
export const transferEvent = onchainTable("transfer_event", (t) => ({
|
|
13
|
+
id: t.text().primaryKey(),
|
|
14
|
+
timestamp: t.integer().notNull(),
|
|
15
|
+
from: t.hex().notNull(),
|
|
16
|
+
to: t.hex().notNull(),
|
|
17
|
+
token: t.bigint().notNull(),
|
|
29
18
|
}));
|
|
@@ -1,37 +1,33 @@
|
|
|
1
1
|
import { ponder } from "@/generated";
|
|
2
|
+
import * as schema from "../ponder.schema";
|
|
2
3
|
|
|
3
4
|
ponder.on("ERC721:Transfer", async ({ event, context }) => {
|
|
4
|
-
const { Account, Token, TransferEvent } = context.db;
|
|
5
|
-
|
|
6
5
|
// Create an Account for the sender, or update the balance if it already exists.
|
|
7
|
-
await
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
await context.db
|
|
7
|
+
.insert(schema.account)
|
|
8
|
+
.values({ address: event.args.from })
|
|
9
|
+
.onConflictDoNothing();
|
|
11
10
|
// Create an Account for the recipient, or update the balance if it already exists.
|
|
12
|
-
await
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
await context.db
|
|
12
|
+
.insert(schema.account)
|
|
13
|
+
.values({ address: event.args.to })
|
|
14
|
+
.onConflictDoNothing();
|
|
15
15
|
|
|
16
16
|
// Create or update a Token.
|
|
17
|
-
await
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
});
|
|
17
|
+
await context.db
|
|
18
|
+
.insert(schema.token)
|
|
19
|
+
.values({
|
|
20
|
+
id: event.args.id,
|
|
21
|
+
owner: event.args.to,
|
|
22
|
+
})
|
|
23
|
+
.onConflictDoUpdate({ owner: event.args.to });
|
|
26
24
|
|
|
27
25
|
// Create a TransferEvent.
|
|
28
|
-
await
|
|
26
|
+
await context.db.insert(schema.transferEvent).values({
|
|
29
27
|
id: event.log.id,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
timestamp: Number(event.block.timestamp),
|
|
35
|
-
},
|
|
28
|
+
from: event.args.from,
|
|
29
|
+
to: event.args.to,
|
|
30
|
+
token: event.args.id,
|
|
31
|
+
timestamp: Number(event.block.timestamp),
|
|
36
32
|
});
|
|
37
33
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { onchainTable } from "@ponder/core";
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
name: p.string().optional(),
|
|
7
|
-
}),
|
|
3
|
+
export const example = onchainTable("example", (t) => ({
|
|
4
|
+
id: t.text().primaryKey(),
|
|
5
|
+
name: t.text(),
|
|
8
6
|
}));
|