Skip to content

Commit e06c675

Browse files
authored
feat: export CompiledCircuit from codegened TS (#3589)
1 parent 2ca9b05 commit e06c675

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tooling/noir_codegen/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const codegenPrelude = `/* Autogenerated file, do not edit! */
88
99
/* eslint-disable */
1010
11-
import { Noir, InputMap } from "@noir-lang/noir_js"
11+
import { Noir, InputMap, CompiledCircuit } from "@noir-lang/noir_js"
1212
`;
1313

1414
const codegenFunction = (
@@ -19,8 +19,11 @@ const codegenFunction = (
1919
const args = function_signature.inputs.map(([name]) => `${name}`).join(', ');
2020
const args_with_types = function_signature.inputs.map(([name, type]) => `${name}: ${type}`).join(', ');
2121

22-
return `export async function ${name}(${args_with_types}): Promise<${function_signature.returnValue}> {
23-
const program = new Noir(${JSON.stringify(compiled_program)});
22+
return `
23+
export const ${name}_circuit: CompiledCircuit = ${JSON.stringify(compiled_program)};
24+
25+
export async function ${name}(${args_with_types}): Promise<${function_signature.returnValue}> {
26+
const program = new Noir(${name}_circuit);
2427
const args: InputMap = { ${args} };
2528
const { returnValue } = await program.execute(args);
2629
return returnValue as ${function_signature.returnValue};

0 commit comments

Comments
 (0)