Skip to content
Merged
2 changes: 1 addition & 1 deletion packages/simulator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"node": ">=22"
},
"scripts": {
"build": "tsc -p .",
"build": "tsc -p tsconfig.build.json",
"types": "tsc -p tsconfig.json --noEmit",
"test": "MIDNIGHT_BACKEND=dry vitest run",
"test:live": "MIDNIGHT_BACKEND=live vitest run",
Expand Down
15 changes: 10 additions & 5 deletions packages/simulator/src/factory/createSimulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,18 @@ export function createSimulator<
* @param options - Backend selection, witnesses, private state, live world.
* @returns The constructed simulator (subclass-aware via `this`).
Comment thread
0xisk marked this conversation as resolved.
Outdated
*/
static async create<T extends Simulator>(
static async create(
Comment thread
0xisk marked this conversation as resolved.
this: new (
deps: BackendDeps<P, L>,
) => T,
contractArgs: TArgs = [] as unknown as TArgs,
options: SimulatorOptions<P, W> = {},
): Promise<T> {
) => Simulator,
// Permissive so subclasses can override `create` with contract-specific
// params/returns without tripping TS's static-side `extends` check.
...args: unknown[]
): Promise<Simulator> {
Comment thread
0xisk marked this conversation as resolved.
const [
contractArgs = [] as unknown as TArgs,
options = {} as SimulatorOptions<P, W>,
] = args as [TArgs?, SimulatorOptions<P, W>?];
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
const deps = await prepareBackend(contractArgs, options);
return new this(deps);
}
Expand Down
5 changes: 4 additions & 1 deletion packages/simulator/test/integration/Witness.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const BYTES_OVERRIDE = new Uint8Array(32).fill(1);
const FIELD_OVERRIDE = 222n;
const UINT_OVERRIDE = 333n;

const overrideWitnesses = (): IWitnessWitnesses<WitnessPrivateState> => ({
const overrideWitnesses = (): IWitnessWitnesses<
Comment thread
0xisk marked this conversation as resolved.
Outdated
unknown,
WitnessPrivateState
> => ({
wit_secretBytes(ctx) {
return [ctx.privateState, BYTES_OVERRIDE];
},
Expand Down
20 changes: 20 additions & 0 deletions packages/simulator/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Emit-only config for the published package. Extends the nodenext base
// (NOT tsconfig.json, which is bundler/noEmit) so `src` is compiled and
// typechecked under the same ESM resolution consumers get. This is what
// enforces correct `.js` import extensions. `yarn build` runs this; the
// comprehensive typecheck lives in `tsconfig.json`.
"extends": "@tsconfig/node24/tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"declaration": true,
"skipLibCheck": true,
"sourceMap": true,
"rewriteRelativeImportExtensions": true,
"erasableSyntaxOnly": true,
"verbatimModuleSyntax": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
24 changes: 10 additions & 14 deletions packages/simulator/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
{
// Comprehensive typecheck. Uses bundler resolution to match how the
// tests actually resolve under vitest. Never emits: `tsconfig.build.json` owns
// emit and enforces nodenext/ESM correctness on the published `src`.
"extends": "@tsconfig/node24/tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"declaration": true,
"noEmit": true,
"declaration": false,
"module": "preserve",
"moduleResolution": "bundler",
"skipLibCheck": true,
"sourceMap": true,
"rewriteRelativeImportExtensions": true,
"erasableSyntaxOnly": true,
"verbatimModuleSyntax": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"dist",
"tests"
]
}
"include": ["src/**/*", "test/**/*"],
"exclude": ["node_modules", "dist"]
}
Loading