Skip to content

Commit 6f33978

Browse files
committed
feat: subgraph client requests
- [x] Add code generation for graphql types - [x] Add boilerplate for project stats queries - [x] Add SUBGRAPH_URL env
1 parent 93fc585 commit 6f33978

13 files changed

Lines changed: 6056 additions & 52 deletions

File tree

.github/workflows/gas-benchmarks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ jobs:
2929
- name: Test
3030
run: pnpm run test
3131
working-directory: gas-benchmarks
32+
env:
33+
SUBGRAPH_URL: ${{ secrets.SUBGRAPH_URL }}
3234

3335
- name: Benchmark
3436
run: pnpm run benchmark
3537
working-directory: gas-benchmarks
3638
env:
3739
ETH_RPC_URL: ${{ secrets.ETH_RPC_URL }}
3840
SCROLL_RPC_URL: ${{ secrets.SCROLL_RPC_URL }}
41+
SUBGRAPH_URL: ${{ secrets.SUBGRAPH_URL }}
3942
MIN_SAMPLES: ${{ vars.MIN_SAMPLES }}
4043
MONERO_FAIL_NODES_API_URL: ${{ vars.MONERO_FAIL_NODES_API_URL }}

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist
33
build
44
.cache
55
*.log
6+
generated

gas-benchmarks/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ SCROLL_RPC_URL=https://scroll.gateway.tenderly.co
44

55
MONERO_FAIL_NODES_API_URL=https://monero.fail/nodes.json
66

7+
SUBGRAPH_URL=
8+
79
MIN_SAMPLES=10

gas-benchmarks/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/generated

gas-benchmarks/codegen.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { config } from "dotenv";
2+
import path from "node:path";
3+
4+
import type { CodegenConfig } from "@graphql-codegen/cli";
5+
6+
config();
7+
8+
if (!process.env.SUBGRAPH_URL) {
9+
throw new Error("SUBGRAPH_URL is not set");
10+
}
11+
12+
const codegenConfig: CodegenConfig = {
13+
overwrite: true,
14+
schema: [process.env.SUBGRAPH_URL, path.resolve(".", "scalars.graphql")],
15+
ignoreNoDocuments: true,
16+
documents: ["src/**/*.ts"],
17+
emitLegacyCommonJSImports: false,
18+
generates: {
19+
"src/generated/": {
20+
preset: "client-preset",
21+
config: {
22+
useTypeImports: true,
23+
},
24+
},
25+
},
26+
};
27+
28+
export default codegenConfig;

gas-benchmarks/package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
"repository": "https://github.com/privacy-ethereum/private-transfers-benchmarks",
66
"type": "module",
77
"scripts": {
8+
"prebenchmark": "pnpm run codegen",
89
"benchmark": "tsx src/index.ts",
9-
"test": "vitest run"
10+
"pretest": "pnpm run codegen",
11+
"test": "vitest run",
12+
"codegen": "graphql-codegen-esm --config codegen.ts"
1013
},
1114
"keywords": [
1215
"private-transfers",
@@ -15,19 +18,28 @@
1518
],
1619
"author": "PSE",
1720
"license": "MIT",
18-
"packageManager": "pnpm@10.29.3",
21+
"packageManager": "pnpm@10.33.0",
1922
"engines": {
2023
"node": "24",
2124
"pnpm": "10"
2225
},
2326
"devDependencies": {
27+
"@graphql-codegen/cli": "6.3.1",
28+
"@graphql-codegen/client-preset": "5.3.0",
29+
"@graphql-codegen/introspection": "5.0.2",
30+
"@graphql-codegen/typed-document-node": "^6.1.8",
31+
"@graphql-codegen/typescript": "^5.0.10",
32+
"@graphql-codegen/typescript-operations": "^5.1.0",
2433
"@types/node": "^25.2.3",
2534
"tsx": "^4.21.0",
2635
"typescript": "^5.9.3",
2736
"vitest": "^4.0.18"
2837
},
2938
"dependencies": {
39+
"@graphql-typed-document-node/core": "^3.2.0",
3040
"dotenv": "^17.2.4",
41+
"graphql": "^16.13.2",
42+
"graphql-request": "^7.4.0",
3143
"lowdb": "^7.0.1",
3244
"viem": "^2.45.3"
3345
}

0 commit comments

Comments
 (0)