Skip to content

Commit

Permalink
feat: export CompiledCircuit from codegened TS (#3589)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Nov 27, 2023
1 parent 2ca9b05 commit e06c675
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tooling/noir_codegen/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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};
Expand Down

0 comments on commit e06c675

Please sign in to comment.