Skip to content
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
2 changes: 1 addition & 1 deletion packages/simulator/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"dist",
"tests"
]
}
}
Loading