Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate codegen #413

Merged
merged 8 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"packageManager": "[email protected]",
"pnpm": {
"patchedDependencies": {
"graphql@15.8.0": "patches/graphql@15.8.0.patch"
"graphql@16.8.1": "patches/graphql@16.8.1.patch"
}
}
}
3 changes: 2 additions & 1 deletion packages/core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ dist/
.ponder/
generated/
.env.local
**/*.node
**/*.node
ponder-env.d.ts
10 changes: 2 additions & 8 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,16 @@
"async-mutex": "^0.4.0",
"better-sqlite3": "^8.7.0",
"cac": "^6.7.14",
"chokidar": "^3.5.3",
"conf": "^10.2.0",
"cors": "^2.8.5",
"data-uri-to-buffer": "3.0.1",
"detect-package-manager": "^2.0.1",
"dotenv": "^16.0.1",
"emittery": "^0.13.1",
"esbuild": "^0.15.2",
"ethereum-bloom-filters": "^1.0.10",
"express": "^4.18.1",
"glob": "^8.1.0",
"graphql": "^15.3.0",
"graphql": "^16.8.1",
"graphql-http": "^1.22.0",
"http-terminator": "^3.2.0",
"ink": "^3.2.0",
Expand All @@ -59,12 +57,10 @@
"pg": "^8.9.0",
"picocolors": "^1.0.0",
"pino": "^8.14.1",
"prettier": "^2.6.2",
"prom-client": "^14.2.0",
"react": "17",
"retry": "^0.13.1",
"stacktrace-parser": "^0.1.10",
"tsc-alias": "^1.8.2",
"viem": "^1.2.6",
"vite": "^4.5.0",
"vite-node": "^0.34.6"
Expand All @@ -73,20 +69,18 @@
"@types/babel__code-frame": "^7.0.3",
"@types/better-sqlite3": "^7.6.0",
"@types/cors": "^2.8.12",
"@types/detect-port": "^1.3.2",
"@types/express": "^4.17.13",
"@types/glob": "^8.0.0",
"@types/module-alias": "^2.0.1",
"@types/node": "^18.7.8",
"@types/pg": "^8.6.6",
"@types/react": "^18.0.25",
"@types/retry": "^0.12.2",
"@types/supertest": "^2.0.12",
"@viem/anvil": "^0.0.6",
"concurrently": "^8.2.0",
"module-alias": "^2.2.2",
"rimraf": "^5.0.1",
"supertest": "^6.3.3",
"tsc-alias": "^1.8.2",
"typescript": "^5.1.3",
"vitest": "^0.34.6"
}
Expand Down
12 changes: 4 additions & 8 deletions packages/core/src/Ponder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ export class Ponder {
common: this.common,
indexingStore: this.indexingStore,
});
this.codegenService = new CodegenService({
common: this.common,
sources: this.sources,
});
this.codegenService = new CodegenService({ common: this.common });
this.uiService = new UiService({
common: this.common,
sources: this.sources,
Expand All @@ -186,8 +183,8 @@ export class Ponder {
// using the initial config, register service dependencies.
this.registerServiceDependencies();

// TODO: Remove once we have the new PonderApp magic.
this.codegenService.generateAppFile();
// Regenerate the `ponder-env.d.ts` file in case it was deleted.
this.codegenService.generateDeclarationFile();

// One-time setup for some services.
await this.syncStore.migrateUp();
Expand Down Expand Up @@ -242,7 +239,7 @@ export class Ponder {
}

async codegen() {
this.codegenService.generateAppFile();
this.codegenService.generateDeclarationFile();

const result = await this.buildService.loadSchema();
if (result) {
Expand Down Expand Up @@ -297,7 +294,6 @@ export class Ponder {
this.buildService.on("newSchema", async ({ schema, graphqlSchema }) => {
this.common.errors.hasUserError = false;

this.codegenService.generateAppFile({ schema });
this.codegenService.generateGraphqlSchemaFile({ graphqlSchema });

this.serverService.reload({ graphqlSchema });
Expand Down
8 changes: 0 additions & 8 deletions packages/core/src/_test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import SqliteDatabase from "better-sqlite3";
import moduleAlias from "module-alias";
import path from "node:path";
import { Pool } from "pg";
import { type TestContext, beforeEach } from "vitest";

Expand All @@ -21,12 +19,6 @@ import { TelemetryService } from "@/telemetry/service";
import { FORK_BLOCK_NUMBER, vitalik } from "./constants";
import { poolId, testClient } from "./utils";

/**
* Set up a package alias so we can reference `@ponder/core` by name in test files.
*/
const ponderCoreDir = path.resolve(__dirname, "../../");
moduleAlias.addAlias("@ponder/core", ponderCoreDir);

/**
* Inject an isolated sync store into the test context.
*
Expand Down
36 changes: 0 additions & 36 deletions packages/core/src/build/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,42 +42,6 @@ export type RawIndexingFunctions = {
};
};

// @ponder/core creates an instance of this class called `ponder`
export class PonderApp<
IndexingFunctions = Record<string, LogEventIndexingFunction>
> {
private indexingFunctions: RawIndexingFunctions = { eventSources: {} };
private errors: Error[] = [];

on<EventName extends Extract<keyof IndexingFunctions, string>>(
name: EventName,
indexingFunction: IndexingFunctions[EventName]
) {
if (name === "setup") {
this.indexingFunctions._meta_ ||= {};
this.indexingFunctions._meta_.setup =
indexingFunction as SetupEventIndexingFunction;
return;
}

const [eventSourceName, eventName] = name.split(":");
if (!eventSourceName || !eventName) {
this.errors.push(new Error(`Invalid event name: ${name}`));
return;
}

this.indexingFunctions.eventSources[eventSourceName] ||= {};
if (this.indexingFunctions.eventSources[eventSourceName][eventName]) {
this.errors.push(
new Error(`Cannot add multiple indexing functions for event: ${name}`)
);
return;
}
this.indexingFunctions.eventSources[eventSourceName][eventName] =
indexingFunction as LogEventIndexingFunction;
}
}

export type IndexingFunctions = {
_meta_: {
setup?: {
Expand Down
46 changes: 0 additions & 46 deletions packages/core/src/codegen/entity.ts

This file was deleted.

44 changes: 0 additions & 44 deletions packages/core/src/codegen/event.ts

This file was deleted.

25 changes: 0 additions & 25 deletions packages/core/src/codegen/prettier.ts

This file was deleted.

33 changes: 0 additions & 33 deletions packages/core/src/codegen/service.test.ts

This file was deleted.

Loading
Loading