Skip to content

Commit eeb4563

Browse files
authored
Merge pull request #203 from proto-kit/feature/processor-2
Feature/processor-2
2 parents cb1e23e + f2fdd2b commit eeb4563

31 files changed

+1258
-916
lines changed

package-lock.json

Lines changed: 295 additions & 902 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/api/src/graphql/GraphqlModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export abstract class SchemaGeneratingGraphqlModule<
3030
export abstract class ResolverFactoryGraphqlModule<
3131
Config = NoConfig,
3232
> extends GraphqlModule<Config> {
33-
public abstract resolvers(): NonEmptyArray<Function>;
33+
public abstract resolvers(): Promise<NonEmptyArray<Function>>;
3434
}
3535

3636
export function graphqlModule() {

packages/api/src/graphql/GraphqlSequencerModule.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ export class GraphqlSequencerModule<GraphQLModules extends GraphqlModulesRecord>
7171
const module = this.resolve(
7272
moduleName
7373
) as ResolverFactoryGraphqlModule<unknown>;
74-
this.graphqlServer.registerResolvers(module.resolvers());
74+
// eslint-disable-next-line no-await-in-loop
75+
this.graphqlServer.registerResolvers(await module.resolvers());
7576
} else {
7677
this.graphqlServer.registerModule(moduleClass);
7778

packages/common/src/config/ModuleContainer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,6 @@ export class ModuleContainer<
440440
throw errors.unableToDecorateModule(containedModuleName);
441441
}
442442
this.decorateModule(moduleName, containedModule);
443-
444443
containedModule.create(() => {
445444
const container = this.container.createChildContainer();
446445
container.reset();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
Warnings:
3+
4+
- Added the required column `events` to the `TransactionExecutionResult` table without a default value. This is not possible if the table is not empty.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "TransactionExecutionResult" ADD COLUMN "events" JSON NOT NULL;

packages/indexer/prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ model TransactionExecutionResult {
5353
protocolTransitions Json @db.Json
5454
status Boolean
5555
statusMessage String?
56+
events Json @db.Json
5657
5758
tx Transaction @relation(fields: [txHash], references: [hash])
5859
txHash String @id

packages/indexer/src/api/GeneratedResolverFactoryGraphqlModule.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import {
4444
applyResolversEnhanceMap,
4545
} from "./generated/type-graphql";
4646

47-
function cleanResolvers(resolvers: NonEmptyArray<Function>) {
47+
export function cleanResolvers(resolvers: NonEmptyArray<Function>) {
4848
return resolvers.map((resolver) => {
4949
const methods = Object.getOwnPropertyNames(resolver.prototype).map(
5050
(method) => method.toLowerCase()
@@ -85,10 +85,6 @@ export class GeneratedResolverFactoryGraphqlModule extends ResolverFactoryGraphq
8585
@inject("GraphqlServer") public graphqlServer: GraphqlServer
8686
) {
8787
super();
88-
89-
this.graphqlServer.setContext({
90-
prisma: this.initializePrismaClient(),
91-
});
9288
}
9389

9490
public async initializePrismaClient() {
@@ -102,7 +98,11 @@ export class GeneratedResolverFactoryGraphqlModule extends ResolverFactoryGraphq
10298
return prismaClient;
10399
}
104100

105-
public resolvers(): NonEmptyArray<Function> {
101+
public async resolvers(): Promise<NonEmptyArray<Function>> {
102+
this.graphqlServer.setContext({
103+
prisma: await this.initializePrismaClient(),
104+
});
105+
106106
// basic way to limit the number of results returned at the argument level
107107
const resolversEnchanceMap: ResolversEnhanceMap = {
108108
Block: {

packages/indexer/src/tasks/IndexBlockTask.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ export class IndexBlockTask
3636
await this.blockStorage.pushResult(input.result);
3737
} catch (error) {
3838
log.error("Failed to index block", input.block.height.toBigInt(), error);
39-
throw error;
39+
return;
4040
}
41+
4142
log.info(`Block ${input.block.height.toBigInt()} indexed sucessfully`);
4243
}
4344

packages/processor/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DATABASE_URL=postgresql://admin:password@localhost:5432/protokit?schema=public

packages/processor/.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../.eslintrc",
3+
"ignorePatterns": ["src/api/generated/**"]
4+
}

0 commit comments

Comments
 (0)