From 66ba44a7ac326dbd3f7e8ba6787a9c06e2fc822d Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 27 Nov 2023 11:41:00 +0000 Subject: [PATCH] feat: export `CompiledCircuit` from codegened TS --- tooling/noir_codegen/src/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tooling/noir_codegen/src/index.ts b/tooling/noir_codegen/src/index.ts index 53ea99c2eb2..8d45b76bd7d 100644 --- a/tooling/noir_codegen/src/index.ts +++ b/tooling/noir_codegen/src/index.ts @@ -8,7 +8,7 @@ const codegenPrelude = `/* Autogenerated file, do not edit! */ /* eslint-disable */ -import { Noir, InputMap } from "@noir-lang/noir_js" +import { Noir, InputMap, CompiledCircuit } from "@noir-lang/noir_js" `; const codegenFunction = ( @@ -19,8 +19,11 @@ const codegenFunction = ( const args = function_signature.inputs.map(([name]) => `${name}`).join(', '); const args_with_types = function_signature.inputs.map(([name, type]) => `${name}: ${type}`).join(', '); - return `export async function ${name}(${args_with_types}): Promise<${function_signature.returnValue}> { - const program = new Noir(${JSON.stringify(compiled_program)}); + return ` +export const ${name}_circuit: CompiledCircuit = ${JSON.stringify(compiled_program)}; + +export async function ${name}(${args_with_types}): Promise<${function_signature.returnValue}> { + const program = new Noir(${name}_circuit); const args: InputMap = { ${args} }; const { returnValue } = await program.execute(args); return returnValue as ${function_signature.returnValue};