Skip to content

Commit f490791

Browse files
committed
Merge branch 'feature/configurable_block_size' into fix/mempool-context-clear
# Conflicts: # packages/sequencer/src/mempool/private/PrivateMempool.ts
2 parents 0046b32 + 0366e68 commit f490791

File tree

107 files changed

+6214
-1841
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+6214
-1841
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ Thumbs.db
4040
lerna-debug.log
4141

4242
docs/save
43-
packages/research
43+
packages/research
44+
packages/indexer/src/api/generated

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18.17

jest.config.cjs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,33 @@
55

66
module.exports = {
77
// because we run tests from within ./packages/<package_name>/
8-
rootDir: './../../',
8+
rootDir: "./../../",
99
moduleDirectories: ["node_modules", "packages"],
10-
extensionsToTreatAsEsm: ['.ts'],
10+
extensionsToTreatAsEsm: [".ts"],
1111
moduleNameMapper: {
12-
'o1js/dist/(.*)': '<rootDir>/node_modules/o1js/dist/$1',
13-
'../../../node_modules/o1js/dist/(.*)': '<rootDir>/node_modules/o1js/dist/$1',
14-
'../../../../node_modules/o1js/dist/(.*)': '<rootDir>/node_modules/o1js/dist/$1',
15-
'^(\\.{1,2}/.*)\\.js$': '$1',
12+
"o1js/dist/(.*)": "<rootDir>/node_modules/o1js/dist/$1",
13+
"../../../node_modules/o1js/dist/(.*)":
14+
"<rootDir>/node_modules/o1js/dist/$1",
15+
"../../../../node_modules/o1js/dist/(.*)":
16+
"<rootDir>/node_modules/o1js/dist/$1",
17+
"^(\\.{1,2}/.*)\\.js$": "$1",
1618
},
19+
1720
transform: {
1821
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
1922
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
20-
'^.+\\.tsx?$': [
21-
'ts-jest',
23+
"^.+\\.ts?$": [
24+
"ts-jest",
25+
{
26+
useESM: true,
27+
tsconfig: "./test/tsconfig.json",
28+
},
29+
],
30+
"^.+\\.tsx?$": [
31+
"ts-jest",
2232
{
2333
useESM: true,
24-
tsconfig: './test/tsconfig.json'
34+
tsconfig: "./test/tsconfig.json",
2535
},
2636
],
2737
},

package-lock.json

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

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint:staged": "eslint",
1313
"test": "npx lerna run test -- --passWithNoTests",
1414
"test:ci": "npx lerna run test -- --passWithNoTests --forceExit",
15-
"test:integration": "npx lerna run integration -- --passWithNoTests --forceExit",
15+
"test:integration": "npx lerna run test:integration -- --passWithNoTests --forceExit",
1616
"test:watch": "npx lerna run test:watch",
1717
"migrate": "npx lerna run prisma-migrate",
1818
"prisma-generate": "npx lerna run prisma-generate",
@@ -58,5 +58,8 @@
5858
"*.ts": [
5959
"npm run lint:staged"
6060
]
61+
},
62+
"dependencies": {
63+
"react-json-view-lite": "^1.4.0"
6164
}
6265
}

packages/api/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
"@graphql-tools/stitch": "^9.0.3",
2121
"@types/humanize-duration": "^3.27.2",
2222
"class-validator": "^0.14.0",
23-
"graphql": "16.6.0",
23+
"graphql": "^16.9.0",
2424
"graphql-scalars": "^1.22.4",
2525
"graphql-yoga": "^5.0.0",
2626
"humanize-duration": "^3.30.0",
2727
"koa": "^2.14.2",
2828
"lodash": "^4.17.21",
2929
"reflect-metadata": "^0.1.13",
30-
"type-graphql": "2.0.0-beta.1"
30+
"type-graphql": "2.0.0-rc.2"
3131
},
3232
"peerDependencies": {
3333
"@proto-kit/common": "*",

packages/api/src/graphql/GraphqlModule.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ConfigurableModule, NoConfig, TypedClass } from "@proto-kit/common";
22
import { GraphQLSchema } from "graphql/type";
33
import { injectable, Lifecycle, scoped } from "tsyringe";
4-
import { Resolver } from "type-graphql";
4+
import { NonEmptyArray, Resolver } from "type-graphql";
55

66
const graphqlModuleMetadataKey = "graphqlModule";
77

@@ -27,6 +27,12 @@ export abstract class SchemaGeneratingGraphqlModule<
2727
public abstract generateSchema(): GraphQLSchema;
2828
}
2929

30+
export abstract class ResolverFactoryGraphqlModule<
31+
Config = NoConfig,
32+
> extends GraphqlModule<Config> {
33+
public abstract resolvers(): Promise<NonEmptyArray<Function>>;
34+
}
35+
3036
export function graphqlModule() {
3137
return (
3238
/**

packages/api/src/graphql/GraphqlSequencerModule.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import {
1212
} from "@proto-kit/common";
1313

1414
import { GraphqlServer } from "./GraphqlServer";
15-
import { GraphqlModule, SchemaGeneratingGraphqlModule } from "./GraphqlModule";
15+
import {
16+
GraphqlModule,
17+
ResolverFactoryGraphqlModule,
18+
SchemaGeneratingGraphqlModule,
19+
} from "./GraphqlModule";
1620

1721
export type GraphqlModulesRecord = ModulesRecord<
1822
TypedClass<GraphqlModule<unknown>>
@@ -55,22 +59,38 @@ export class GraphqlSequencerModule<GraphQLModules extends GraphqlModulesRecord>
5559
// eslint-disable-next-line guard-for-in
5660
for (const moduleName in this.definition.modules) {
5761
const moduleClass = this.definition.modules[moduleName];
58-
this.graphqlServer.registerModule(moduleClass);
5962

6063
if (
6164
Object.prototype.isPrototypeOf.call(
62-
SchemaGeneratingGraphqlModule,
65+
ResolverFactoryGraphqlModule,
6366
moduleClass
6467
)
6568
) {
66-
log.debug(`Registering manual schema for ${moduleName}`);
69+
log.debug(`Registering resolvers factory from ${moduleName}`);
6770
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
6871
const module = this.resolve(
6972
moduleName
70-
) as SchemaGeneratingGraphqlModule<unknown>;
71-
this.graphqlServer.registerSchema(module.generateSchema());
73+
) as ResolverFactoryGraphqlModule<unknown>;
74+
// eslint-disable-next-line no-await-in-loop
75+
this.graphqlServer.registerResolvers(await module.resolvers());
76+
} else {
77+
this.graphqlServer.registerModule(moduleClass);
78+
79+
if (
80+
Object.prototype.isPrototypeOf.call(
81+
SchemaGeneratingGraphqlModule,
82+
moduleClass
83+
)
84+
) {
85+
log.debug(`Registering manual schema for ${moduleName}`);
86+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
87+
const module = this.resolve(
88+
moduleName
89+
) as SchemaGeneratingGraphqlModule<unknown>;
90+
this.graphqlServer.registerSchema(module.generateSchema());
91+
}
7292
}
7393
}
74-
void this.graphqlServer.startServer();
94+
await this.graphqlServer.startServer();
7595
}
7696
}

packages/api/src/graphql/GraphqlServer.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ export class GraphqlServer extends SequencerModule<GraphqlServerOptions> {
3232

3333
private readonly schemas: GraphQLSchema[] = [];
3434

35+
private resolvers: NonEmptyArray<Function> | undefined;
36+
3537
private dependencyContainer?: DependencyContainer;
3638

3739
private server?: Server;
3840

41+
private context: {} = {};
42+
3943
public setContainer(container: DependencyContainer) {
4044
this.dependencyContainer = container;
4145
}
@@ -56,6 +60,18 @@ export class GraphqlServer extends SequencerModule<GraphqlServerOptions> {
5660
this.schemas.push(schema);
5761
}
5862

63+
public registerResolvers(resolvers: NonEmptyArray<Function>) {
64+
if (this.resolvers === undefined) {
65+
this.resolvers = resolvers;
66+
} else {
67+
this.resolvers = [...this.resolvers, ...resolvers];
68+
}
69+
}
70+
71+
public setContext(context: {}) {
72+
this.context = context;
73+
}
74+
5975
public async start() {
6076
noop();
6177
}
@@ -64,16 +80,17 @@ export class GraphqlServer extends SequencerModule<GraphqlServerOptions> {
6480
const { dependencyContainer, modules } = this;
6581
this.assertDependencyContainerSet(dependencyContainer);
6682

83+
const resolvers = [...modules, ...(this.resolvers || [])];
84+
6785
assertArrayIsNotEmpty(
68-
modules,
86+
resolvers,
6987
"At least one module has to be provided to GraphqlServer"
7088
);
7189

7290
// Building schema
7391
const resolverSchema = buildSchemaSync({
74-
resolvers: modules,
92+
resolvers,
7593

76-
// resolvers: [MempoolResolver as Function],
7794
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
7895
container: { get: (cls) => dependencyContainer.resolve(cls) },
7996

@@ -101,6 +118,7 @@ export class GraphqlServer extends SequencerModule<GraphqlServerOptions> {
101118
const yoga = createYoga<Koa.ParameterizedContext>({
102119
schema,
103120
graphiql: this.config.graphiql,
121+
context: this.context,
104122
});
105123

106124
// Bind GraphQL Yoga to `/graphql` endpoint

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();

0 commit comments

Comments
 (0)