create-ponder 0.4.3 → 0.4.5
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 +51 -41
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[![CI status][ci-badge]][ci-url]
|
|
4
4
|
[![Version][version-badge]][version-url]
|
|
5
|
-
|
|
6
5
|
[![Telegram chat][tg-badge]][tg-url]
|
|
7
6
|
[![License][license-badge]][license-url]
|
|
8
7
|
|
|
@@ -62,41 +61,47 @@ Ponder fetches event logs for the contracts added to `ponder.config.ts`, and pas
|
|
|
62
61
|
|
|
63
62
|
```ts
|
|
64
63
|
// ponder.config.ts
|
|
65
|
-
import { http } from "viem";
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
import { createConfig } from "@ponder/core";
|
|
66
|
+
import { http } from "viem";
|
|
67
|
+
|
|
68
|
+
import { BaseRegistrarAbi } from "./abis/BaseRegistrar";
|
|
69
|
+
|
|
70
|
+
export default createConfig({
|
|
71
|
+
networks: {
|
|
72
|
+
mainnet: {
|
|
71
73
|
chainId: 1,
|
|
72
|
-
transport: http("https://eth-mainnet.g.alchemy.com/v2/...")
|
|
74
|
+
transport: http("https://eth-mainnet.g.alchemy.com/v2/...")
|
|
73
75
|
},
|
|
74
|
-
|
|
75
|
-
contracts:
|
|
76
|
-
{
|
|
77
|
-
|
|
76
|
+
},
|
|
77
|
+
contracts: {
|
|
78
|
+
BaseRegistrar: {
|
|
79
|
+
abi: BaseRegistrarAbi,
|
|
78
80
|
network: "mainnet",
|
|
79
|
-
abi: "./abis/BaseRegistrar.json",
|
|
80
81
|
address: "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85",
|
|
81
82
|
startBlock: 9380410,
|
|
82
83
|
},
|
|
83
|
-
|
|
84
|
-
};
|
|
84
|
+
},
|
|
85
|
+
});
|
|
85
86
|
```
|
|
86
87
|
|
|
87
88
|
### 4. Define your schema
|
|
88
89
|
|
|
89
|
-
The `schema.
|
|
90
|
+
The `ponder.schema.ts` file contains the database schema, and defines the shape data that the GraphQL API serves.
|
|
90
91
|
|
|
91
92
|
```ts
|
|
92
|
-
// schema.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
// ponder.schema.ts
|
|
94
|
+
|
|
95
|
+
import { createSchema } from "@ponder/core";
|
|
96
|
+
|
|
97
|
+
export default createSchema((p) => ({
|
|
98
|
+
EnsName: p.createTable({
|
|
99
|
+
id: p.string(),
|
|
100
|
+
name: p.string(),
|
|
101
|
+
owner: p.string(),
|
|
102
|
+
registeredAt: p.int(),
|
|
103
|
+
}),
|
|
104
|
+
}));
|
|
100
105
|
```
|
|
101
106
|
|
|
102
107
|
### 5. Write indexing functions
|
|
@@ -123,36 +128,40 @@ ponder.on("BaseRegistrar:NameRegistered", async ({ event, context }) => {
|
|
|
123
128
|
});
|
|
124
129
|
```
|
|
125
130
|
|
|
126
|
-
See the [create & update
|
|
131
|
+
See the [create & update records](https://ponder.sh/docs/guides/create-update-records) docs for a detailed guide on writing indexing functions.
|
|
127
132
|
|
|
128
133
|
### 6. Query the GraphQL API
|
|
129
134
|
|
|
130
|
-
Ponder automatically generates a frontend-ready GraphQL API based on your
|
|
135
|
+
Ponder automatically generates a frontend-ready GraphQL API based on your `ponder.schema.ts` file. The API serves data that you inserted in your indexing functions.
|
|
131
136
|
|
|
132
137
|
```ts
|
|
133
138
|
{
|
|
134
|
-
ensNames(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
ensNames(limit: 2) {
|
|
140
|
+
items {
|
|
141
|
+
name
|
|
142
|
+
owner
|
|
143
|
+
registeredAt
|
|
144
|
+
}
|
|
138
145
|
}
|
|
139
146
|
}
|
|
140
147
|
```
|
|
141
148
|
|
|
142
149
|
```json
|
|
143
150
|
{
|
|
144
|
-
"ensNames":
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
151
|
+
"ensNames": {
|
|
152
|
+
"items": [
|
|
153
|
+
{
|
|
154
|
+
"name": "vitalik.eth",
|
|
155
|
+
"owner": "0x0904Dac3347eA47d208F3Fd67402D039a3b99859",
|
|
156
|
+
"registeredAt": 1580345271
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"name": "joe.eth",
|
|
160
|
+
"owner": "0x6109DD117AA5486605FC85e040ab00163a75c662",
|
|
161
|
+
"registeredAt": 1580754710
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
}
|
|
156
165
|
}
|
|
157
166
|
```
|
|
158
167
|
|
|
@@ -165,6 +174,7 @@ If you're interested in contributing to Ponder, please read the [contribution gu
|
|
|
165
174
|
## Packages
|
|
166
175
|
|
|
167
176
|
- `@ponder/core`
|
|
177
|
+
- `@ponder/utils`
|
|
168
178
|
- `create-ponder`
|
|
169
179
|
- `eslint-config-ponder`
|
|
170
180
|
|
package/dist/index.js
CHANGED